/////////////////////////////////////////////////////////////
//
// Author Scott Herbert (www.scott-herbert.com)
//
// Version History 
// 1 (19-June-2011) Inital release on to Google code.
//
//
//


function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}


function displayNotification()
{

// this sets the page background to semi-transparent black should work with all browsers
var message = "<div id='cookiewarning' ><div style='z-index:999; position:absolute; width:155%;height:160%;background: rgb(0, 0, 0) transparent;background: rgba(0, 0, 0, 0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: \"progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)\"'>";

// center vert
message = message + "<div style='margin:19%;padding:10px;width:25%;height:25%;background:black;color:white'>";

// this is the message displayed to the user.
message = message + "<br><br>Cookie Compliance<br><br><p>For this site to work correctly we need to store a cookie on your computer. Since the 25th of May 2011 the law about cookies on websites changed. We have to get your permission first.</p> <p>A cookie is a small file of letters and numbers. These cookies allow us to distinguish you from other users which helps us to provide you with a good experience when you browse our website and also allows us to improve our site. Our website uses the following cookies: (1) a cookie which retains your approval of cookies, (2) a session cookie to keep you logged in, (3) third party cookies sent from Google ads.</p><p>If you click 'I agree', below, we will store cookies and you'll notice no difference. If you click on 'I don't agree' then this site won't work. You'll get re-direct to the ICO web site where you can search and read up on this change in law.</p>";
	
	
// Displays the I agree/disagree buttons.
// Feel free to change the address of the I disagree redirection to either a non-cookie site or a Google or the ICO web site 
message = message + "<INPUT TYPE='button' VALUE='I Agree' onClick='JavaScript:setCookie(\"jsCookieCheck\",null,365);' /> <INPUT TYPE='button' VALUE=\"I don't agree\" onClick='JavaScript:window.location = \"http://www.ico.gov.uk/\"' />";

	
// and this closes everything off.
message = message + "</div></div></div>";


document.writeln(message);


}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;

// set cookiewarning to hidden.
var cw = document.getElementById("cookiewarning");
cw.innerHTML = "";
}

function checkCookie()
{

var cookieName="jsCookieCheck";
var cookieChk=getCookie(cookieName);
if (cookieChk!=null && cookieChk!="")
  {
  // the jsCookieCheck cookie exists so we can assume the person has read the notification
  // within the last year
  
  setCookie(cookieName,cookieChk,365);	// set the cookie to expire in a year.
  }
else 
  {
  // No cookie exists, so display the lightbox effect notification.
  displayNotification();	
  }
}

checkCookie();


