function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString() + "; path=/messiaen/");
}

function deleteCookie (cookie_name)
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


function setText(){
	if (document.cookie.length>0)
  {
bgcolours=getCookie('bgcolours');
  }
  else
  {
	bgcolours = 'yes';
  }
elem = document.getElementById("bg");
elem.style.background = '#6F0C17';
if (bgcolours == 'no') {
document.getElementById('bgswitch').innerHTML = '<a href="javascript:changeText()" class="footerlink" onmouseover="window.status=\'Enable background colour changing\';return true;" onmouseout="window.status=\' \';">Enable Background</a>'; 
value = 1;
}
else {
document.getElementById('bgswitch').innerHTML = '<a href="javascript:changeText()" class="footerlink" onmouseover="window.status=\'Disable background colour changing\';return true;" onmouseout="window.status=\' \';">Disable Background</a>';
value = 0;
}
return true;
}

function changeText(){
if (value == 0) {
	document.getElementById('bgswitch').innerHTML = '<a href="javascript:changeText()" class="footerlink" onmouseover="window.status=\'Enable background colour changing\';return true;" onmouseout="window.status=\' \';">Enable Background</a>';
	//deleteCookie('bgcolours');
	setCookie('bgcolours','no',7);
	value = 1;
}
else {
	document.getElementById('bgswitch').innerHTML = '<a href="javascript:changeText()" class="footerlink" onmouseover="window.status=\'Disable background colour changing\';return true;" onmouseout="window.status=\' \';">Disable Background</a>';	
	//deleteCookie('bgcolours');
	setCookie('bgcolours','yes',7);
	value = 0;
}
}

function tempDisable(){
	if (value == 0) {
	document.getElementById('bgswitch').innerHTML = '<a href="javascript:changeText()" class="footerlink" onmouseover="window.status=\'Enable background colour changing\';return true;" onmouseout="window.status=\' \';">Enable Background</a>';
	setCookie('bgcolours','no',7);
}
}

function reEnable(){
	if (value == 0) {
	document.getElementById('bgswitch').innerHTML = '<a href="javascript:changeText()" class="footerlink" onmouseover="window.status=\'Disable background colour changing\';return true;" onmouseout="window.status=\' \';">Disable Background</a>';	
	setCookie('bgcolours','yes',7);
	value = 0;
}
}
