
///////////////////////////////////////////////////////////////////
// HACE UN RANDOM Y ESTABLECE EL FONDO
///////////////////////////////////////////////////////////////////

var randnum;

var cssList = new Array(
         'buzz01.css',
         'buzz02.css',
         'buzz03.css',
         'buzz04.css',
		 'buzz05.css',
		 'buzz06.css');


function SetInitCookie(name,value,expireDate) {
	var theCookie = name + "=";
	theCookie = theCookie + escape(value);
	document.cookie = theCookie+";path=/;expires="+expireDate;
}

function SetACookie(name,value) {
	var theCookie = name + "=";
	theCookie = theCookie + escape(value);
	document.cookie = theCookie;
}

function GetCookieVal(offset) {
   var endstr = document.cookie.indexOf (";",offset);
   if (endstr == -1) { endstr = document.cookie.length; }
   return unescape(document.cookie.substring(offset,endstr));
}

function GetACookie(name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while(i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i,j) == arg) {
         return GetCookieVal(j);
      }
      i = document.cookie.indexOf(" ", i) + 1;
      if(i == 0) break;
   }
   return null;
}


function GetCSSAleatoria() {
   cookieEnabled=(document.cookie.indexOf("bg_Buzz")!=-1)? true:false;
   if(cookieEnabled) {    
   return GetACookie('bg_Buzz');
   }
   else {      
      randnum = Math.floor(cssList.length * Math.random());
      SetACookie('bg_Buzz',cssList[randnum]);	
      return cssList[randnum];
   }
}

function cambiaFondo(cami) {
   document.getElementById('cssBgBuzz').setAttribute('href',cami+GetCSSAleatoria());
}

cambiaFondo('/code/');


