<!--//
//Cookie script
//Generic Get and Set Values
function getCookie(c_value)
{
  if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_value + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_value.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_value,value,expiredays)
{
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_value+ "=" +value+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+';path=/;');
}

//holiday check
if(check_date() != false)
{
  holiday = check_date(); //get the holiday from check_date return
  setCookie('holiday',holiday,365);
}
else //not a holiday
{
  holiday = "false";
  setCookie('holiday',holiday,365);
}

color=getCookie('color');
mood=getCookie('mood');
holiday=getCookie('holiday');

if(color != null && color != "")
{
  if(document.all)
  {
    changeClassValue('.center', 'background-color', color);
/*
    var cookieStyleSheet = document.createStyleSheet("cookie style sheet", "screen");
    cookieStyleSheet.addRule("#center", "background-color:"+color+";");
*/
  }
  else if(document.getElementById)
  {
    changeClassValue('.center', 'background-color', color);
/*
    this.styleSheet = document.createElement('style');
    this.styleSheet.type = 'text/css';
    var oHead = document.getElementsByTagName('head')[0];
    // If there is no head tag on the page
    if (!oHead) {
     oHead = document.documentElement;
    }
    if (oHead) {
     oHead.appendChild(this.styleSheet);
    }
    this.styleSheet.appendChild(document.createTextNode('#center {background-color:'+ color +';}'));
*/
  }
}
//**************
//
//  Update the code below
//
//***************
else // set to defaults
{
  color = '#9cc13e'; //default Joppa green
  if(document.all)
  {
    changeClassValue('.center', 'background-color', color);
/*
    var cookieStyleSheet = document.createStyleSheet("cookie style sheet", "screen");
    if(cookieStyleSheet.addRule){
      cookieStyleSheet.addRule('#center', '{background-color:'+color+';}');
      //stylesheet.addRule(selector, rule)
    }
    else if(cookieStyleSheet.insertRule) {
      cookieStyleSheet.insertRule("#center {background-color:"+color+";}", 0);
      //stylesheet.insertRule(selector + ' { ' + rule + ' }', stylesheet.cssRules.length);
    }
*/
  }
  else if(document.getElementById)
  {
    changeClassValue('.center', 'background-color', color);
/*
    this.styleSheet = document.createElement('style');
    this.styleSheet.type = 'text/css';
    var oHead = document.getElementsByTagName('head')[0];
    // If there is no head tag on the page
    if (!oHead) {
     oHead = document.documentElement;
    }
    if (oHead) {
     oHead.appendChild(this.styleSheet);
    }
    this.styleSheet.appendChild(document.createTextNode('#center {background-color:'+ color +';}'));
*/
  }
}
// Moods
if(mood != null && mood != "")
{
  sheetId = "ss"+ mood;
  holidaysheet = "ssholiday";

  if(document.all)
  {
   document.getElementById(sheetId).disabled = false;
  }
  else if(document.getElementById)
  {
   document.getElementById(sheetId).disabled = false;
  }

  //Holiday overrides
  if(holiday != false)
  {
  	if(document.all)
    {
      document.getElementById(holidaysheet).disabled = false;
      document.getElementById(holidaysheet).href = "css/"+holiday+".css";
    }
    else if(document.getElementById)
    {
      document.getElementById(holidaysheet).disabled = false;
      document.getElementById(holidaysheet).href = "css/"+holiday+".css";
    }
  }
  else
  {
  	if(document.all)
    {
      document.getElementById(holidaysheet).disabled = true;
    }
    else if(document.getElementById)
    {
      document.getElementById(holidaysheet).disabled = true;
    }
  }
}
else //if(mood == null && mood == "")
{
  sheetId = "ssjoppa"; // default to joppa mood
  holidaysheet = "ssholiday";

  if(document.all)
  {
   document.getElementById(sheetId).disabled = false;
  }
  else if(document.getElementById)
  {
   document.getElementById(sheetId).disabled = false;
  }

  //Holiday overrides
  if(holiday != false)
  {
  	if(document.all)
    {
      document.getElementById(holidaysheet).disabled = false;
      document.getElementById(holidaysheet).href = "css/"+holiday+".css";
    }
    else if(document.getElementById)
    {
      document.getElementById(holidaysheet).disabled = false;
      document.getElementById(holidaysheet).href = "css/"+holiday+".css";
    }
  }
  else
  {
  	if(document.all)
    {
      document.getElementById(holidaysheet).disabled = true;
    }
    else if(document.getElementById)
    {
      document.getElementById(holidaysheet).disabled = true;
    }
  }
}
//-->