// JavaScript Document

/* FUNCIONES PARA LAS COOKIES */
function getCookieVal (offset){
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;

	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (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 SetCookie (name, value){
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

/*
GetCookie("visit");

expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
SetCookie("visit", visit, expdate, "/", null, false);
*/


/* FUNCIONES PARA LISTA DESPLEGABLES */
var rapTime;
function verLista(){
	clearTimeout(rapTime);
	document.getElementById('lista').style.visibility='visible';
}
function quitaLista(){
	rapTime=setTimeout('fueraLista();',400);
	//document.getElementById('lista').style.visibility='hidden';
}
function fueraLista()
{
	topLista=dameTop(document.getElementById('lista'));
	YMaxLista=topLista+70; //posicion y max en la lista top
	leftLista=dameLeft(document.getElementById('lista'));
	XMaxLista=leftLista+176; //posicion x max en la lista left
	//alert("la Y Max:"+YMaxLista+"\n la X Max:"+XMaxLista);
	//alert("la Y :"+posicY+"\n la X :"+posicX);
	if (posicY>YMaxLista || posicX>XMaxLista || posicY<topLista || posicX<leftLista)
		document.getElementById('lista').style.visibility='hidden';
	else
		rapTime=setTimeout('fueraLista();',400);

}

/* FUNCIONES PARA EL IFRAME DEL CALENDARIO */
function centrarCapa(laCapa,miAncho,miAlto,posiTop,posiLeft){
	elancho=screen.availWidth;
	elalto=screen.availHeight;
	if(posiLeft==0){
		l=(elancho/2)-(parseInt(miAncho/2)); //Pos. izquierda
		l=l-15;
		posiLeft=l;
	}
	if (posiTop==0){
		t=(elalto/2)-(parseInt(miAlto/2)); //Pos. superior
		t=t-100; //Quito por la barra del navegador
		//aņadir scroll
		t=t+document.body.scrollTop;
		posiTop=t;
	}
	laCapa.style.left=posiLeft+"px";
	laCapa.style.top=posiTop+"px";
}

/* Funcion AjaxXocolait */
function palIframe(capita,ancho,alto,posiTop,posiLeft,url){
	capita.style.height=alto+"px";
	capita.style.width=ancho+"px";
	if (posiTop==0 || posiLeft==0){
		centrarCapa(capita,ancho,alto,posiTop,posiLeft);
	}else{
		capita.style.top=posiTop+"px";
		capita.style.left=posiLeft+"px";
	}
	capita.src=url;
	capita.style.visibility="visible";
}

function encogeCapa(esa){
	esa.style.width="1px";
	esa.style.height="1px";
}








function abreCalendar(esaFecha,elObj,idioma){
	lafecha=eval("document.buscador."+esaFecha+".value");
	laurl="calendario.asp?lang="+idioma+"&elForm=buscador&valor="+esaFecha+"&"+esaFecha+"="+lafecha;
	ptop=posicY+16; //dameTop(elObj);
	pleft=posicX-20; //dameLeft(elObj)+20;
	palIframe(document.getElementById('verCalendario'),220,120,ptop,pleft,laurl);
}

function fechaWeb(lafecha){
	Fdia=lafecha.getDate();
	if (Fdia<10)
		Fdia="0"+Fdia;
	Fmes=lafecha.getMonth()+1;
	if (Fmes<10)
		Fmes="0"+Fmes;
	Fany=lafecha.getFullYear();
	return Fdia+"/"+Fmes+"/"+Fany;
}

function sumaDias(laFecha,losDias){
	//la fecha viene en formato dd/mm/aaaa
	fdia=laFecha.substring(0,2);
	fmes=parseInt(laFecha.substring(3,5),10)-1;
	fany=laFecha.substring(6,10);
	midia=new Date(fany,fmes,fdia);

	milisegundos=parseInt(losDias*24*60*60*1000);
	tiempo=midia.getTime();
	total=midia.setTime(parseInt(tiempo+milisegundos));
	
	//retorno en el mismo formato
	return fechaWeb(midia);
}

-->

