/* ---- IMAGEN DE INTERCAMBIO ---- */
// javascript document
function changeCellImage(idcell, imgName) {
	document.getElementById(idcell).style.background = "url(" + imgName + ") no-repeat";
}




/* ---- SIDEBAR ---- */
/*
var idNames = new Array('temporada','actualidad','miweb','tcyvos','entodoslados');
var theRules = {
	'#temporada h3' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('temporada-body');
				Element.removeClassName(this, 'invisible');
				setCookie(this.parentNode.id, '', 365);
			} else {
				new Effect.BlindUp('temporada-body');
				Element.addClassName(this, 'invisible');
				setCookie(this.parentNode.id, 'invisible', 365);
			}
		}		
	},
	'#actualidad h3' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('actualidad-body');
				Element.removeClassName(this, 'invisible');
				setCookie(this.parentNode.id, '', 365);
			} else {
				new Effect.BlindUp('actualidad-body');
				Element.addClassName(this, 'invisible');
				setCookie(this.parentNode.id, 'invisible', 365);
			}
		}		
	},
	'#miweb h3' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('miweb-body');
				Element.removeClassName(this, 'invisible');
				setCookie(this.parentNode.id, '', 365);
			} else {
				new Effect.BlindUp('miweb-body');
				Element.addClassName(this, 'invisible');
				setCookie(this.parentNode.id, 'invisible', 365);
			}
		}		
	},
	'#tcyvos h3' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('tcyvos-body');
				Element.removeClassName(this, 'invisible');
				setCookie(this.parentNode.id, '', 365);
			} else {
				new Effect.BlindUp('tcyvos-body');
				Element.addClassName(this, 'invisible');
				setCookie(this.parentNode.id, 'invisible', 365);
			}
		}		
	},
	'#entodoslados h3' : function(el){
		el.onclick = function(){
			if (Element.hasClassName(this, 'invisible')) {
				new Effect.BlindDown('entodoslados-body');
				Element.removeClassName(this, 'invisible');
				setCookie(this.parentNode.id, '', 365);
			} else {
				new Effect.BlindUp('entodoslados-body');
				Element.addClassName(this, 'invisible');
				setCookie(this.parentNode.id, 'invisible', 365);
			}
		}		
	}
};
Behaviour.register(theRules);
Behaviour.addLoadEvent(do_onload);
*/

function do_onload() {
	
	removeImageLinkBorders();
	
	// Id names of all the "boxes"
	boxIds = $('temporada','actualidad','miweb','tcyvos','entodoslados');
	
	for (i = 0; i < boxIds.length; i++) {
		if (boxIds[i]) {
			cookieValue = readCookie(boxIds[i].id);
			if (cookieValue == 'invisible') {
				var h3 = boxIds[i].getElementsByTagName('h3');
				Element.addClassName(h3[0], 'invisible');
				var kids = boxIds[i].childNodes;
				for (j = 1; j < kids.length; j++) {
					if (kids[j].id) {
						Element.hide(kids[j]);
					}
				}
			}
		}		
	}	
}

function setCookie(name,value,days) {
 if (days) {
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = ";expires="+date.toGMTString();
 } else {
   expires = "";
 }
 document.cookie = name+"="+value+expires+";path=/";
}


function readCookie(name) {
 var needle = name + "=";
 var cookieArray = document.cookie.split(';');
 for(var i=0;i < cookieArray.length;i++) {
   var pair = cookieArray[i];
   while (pair.charAt(0)==' ') {
     pair = pair.substring(1, pair.length);
   }
   if (pair.indexOf(needle) == 0) {
     return pair.substring(needle.length, pair.length);
   }
 }
 return null;
}

function removeImageLinkBorders() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName('a');
	for (var i=0; i<anchors.length; i++) {
   		anchor = anchors[i];
		var images = anchor.getElementsByTagName('img');
		if (images[0] != null) {
			anchor.className = "image";
		}
 	}
	return;
}

