/*
 * @author Yohny
 * @licence free to use
 */
                 
var schema;  //global color scheme keeper
var poz = document.cookie.indexOf("schema"); //searching cookie for previous saved scheme

if(poz==-1)  //not found - set default scheme (=1)
  schema = 1;
else         //found - use that scheme
  schema = document.cookie.charAt(poz+7) * 1;     //*1  transform to number

/**
 * sets scheme selected by user into a cookie
 *
 * @param c index of scheme to set
 */
function set_scheme(c) 
{
  var datum = new Date(); 
  datum.setTime(datum.getTime()+(10*24*60*60*1000));    //counting expiration time for 10 days (in milisec)
	document.cookie="schema="+c+"; expires="+datum.toUTCString()+"; path=/";  //save scheme to cookie
  for (j=1;j<=3;j++)  //looping all schemes (there are 3 possible color schemes)
  {
    var ico = document.getElementById("img"+j);
    if (j!=c)   //if its not desired scheme disable it (its stylesheet)
    { 
      document.styleSheets[j].disabled=true; //disabling stylesheet
      ico.src="/img/sch"+j+".png";         //and setting small scheme icon
    }
    else //otherwise enable scheme
    {
      document.styleSheets[j].disabled=false; //enable color scheme stylesheet
      ico.src="/img/sch"+j+"_big.png";      //and change its icon to bigger one
    }
  } 
}

