
/*==============================================================================
    JavaScript Document
    Written to create session cookie for users agreeing to the terms and 
    conditions,if cookies are disabled users will have to confirm upon 
    page load. This is inlcuded into each header.file.
==============================================================================*/


if (IntellectSessionCookie()){
           //alert ("Session coookies are enabled");
           if (getCookieValue("termsagreed")== false){
           //alert ("Show terms and Set the cookie or redirect")
            var answer = confirm("The material as it appears on this website is generic and will not necessarily fit the requirement of the user without amendment or modification. \n\nTo the fullest extent permitted by law, Intellect will not be liable by reason of breach of contract, negligence or otherwise for any loss or damage (whether direct, indirect or consequential) occasioned to any person acting or omitting to act or refraining from acting upon the information provided by this website whatsoever. Nothing in this paragraph will be deemed to exclude or limit Intellect's liability for death or personal injury caused by negligence or for fraud or fraudulent misrepresentation.\n\nClick OK to accept or Cancel to return to the Intellect web site.")
               if (!answer){
               window.location="http://www.intellectuk.org/"
               }
               else{
                writeSessionCookie("termsagreed","true") ;
               }
           }
} else{
          //alert ("Session coookies are NOT enabled redirect to landing page");
          //window.location="http://www.intellecthr.org/docs/intellect/n004.html"
          var answer = confirm("You do not have cookies enabled, this message will be displayed on each page.\n\nThe material as it appears on this website is generic and will not necessarily fit the requirement of the user without amendment or modification. \n\nTo the fullest extent permitted by law, Intellect will not be liable by reason of breach of contract, negligence or otherwise for any loss or damage (whether direct, indirect or consequential) occasioned to any person acting or omitting to act or refraining from acting upon the information provided by this website whatsoever. Nothing in this paragraph will be deemed to exclude or limit Intellect's liability for death or personal injury caused by negligence or for fraud or fraudulent misrepresentation.\n\nClick OK to accept or Cancel to return to the Intellect web site.")
          if (!answer){
          window.location="http://www.intellectuk.org/"
          }
}  
                
/*==============================================================================
  http://www.javascriptkit.com/javatutors/cookie2.shtml
==============================================================================*/

function writeSessionCookie (cookieName, cookieValue) {
  if (IntellectSessionCookie()) {
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
    return true;
  }
  else return false;
}

function getCookieValue (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return false;
}

function IntellectSessionCookie () {
  document.cookie ="IntellectSessionCookie=Enabled";
  if (getCookieValue ("IntellectSessionCookie")=="Enabled")
    return true 
  else
    return false;
}
/*============================================================================*/
