// JavaScript Document



// Function for bookmarks
function bookmark(){
  var MyURL = document.location.href;
  var MyTITLE = document.title;
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(MyURL,MyTITLE);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(MyTITLE,MyURL,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}


// Function for pop up window
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

// Cookie utility - see http://www.quirksmode.org/js/cookies.html
function readCookie(name) {
    var nameEQ = name + "=";
    if (document.cookie && document.cookie != '') {
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
    }
    return null;
}


// Function to check for existence of valid "accept Ts&Cs cookie" and redirect
// to the disclaimer page if the cookie is not set. Clients with JavaScript switched
// off (e.g. A search crawler) will NOT be redirected and will see the original page.
function checkAcceptanceCookie() {
    var cookie = readCookie('UserAgreed');
    if (cookie) {
        // Cookie set, need to check expiry date
        //alert("Cookie: " + cookie);
    } else {
        // Cookie not set, redirect to disclaimer (todo, append current url)
        newurl = "/disclaimer.aspx?URL=" + window.location.pathname + window.location.search;
        //alert("Cookie not set: Redirect to " + newurl + "," + window.location.href);
        window.location = newurl;
    }
    return null;
}




