/**
 * @author joaquin
 */
	function SetCookie(cookieName,cookieValue,nDays) {
		var today = new Date();
		var expire = new Date();
		if (nDays==null || nDays==0) nDays=1;
		expire.setTime(today.getTime() + 3600000*24*nDays);
		document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString()+"; path=/";
	}
	
	function ReadCookie(cookieName) {
		var theCookie=""+document.cookie;
		var ind=theCookie.indexOf(cookieName);
		if (ind==-1 || cookieName=="") return ""; 
		var ind1=theCookie.indexOf(';',ind);
		if (ind1==-1) ind1=theCookie.length; 
		return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
	}
	
Catfish = new function() {
	this.showContent = function() {
		$('#catfish_c').show('slow',Catfish.autoHide);
	}
	this.wwwroot = "/";
	
	this.hide = function() {
		$('#catfish').slideUp('slow')
		return false;
	}

	this.autoHide = function() {
		setTimeout("Catfish.hide()", 10000);
	}
	this.bye = function() {
			SetCookie("showCatfish", "nope", 30);
			return this.hide();
	}
	
	this.dontShow = function() {
		return ReadCookie("showCatfish") == "nope";
	}
	
	this.getSRC = function() {
		return webroot;
	}
	this.init = function() { 
		if (Catfish.dontShow()) {
			return;
		}
		this.wwwroot = Catfish.getSRC();
		var cf = document.createElement("div");
		cf.id = "catfish";
		cf.setAttribute("style", "display:none");
		html = "<div style='display:none' id='catfish_c'>";
		html+= "<img src='"+this.wwwroot+"img/alerta.gif' alt='Programación abierta' />";
		html+= "<h2>¡Revise nuestra ";
		html+= "<a href='"+this.wwwroot+"calendario' title='Programación de cursos'>programación de cursos</a>!";
		html+= "</h2>";
		html+= "<p><a onclick='return Catfish.hide();' href='#'>cerrar</a> | "; 
		html+= "<a onclick='return Catfish.bye();' href='#'>no volver a mostrar</a></p>";
		html+= "</div>";
		
		cf.innerHTML = html ;
		document.body.appendChild(cf);
		$(cf).slideDown('slow',Catfish.showContent);
	}
}
$(document).ready(Catfish.init);