var meses=new Array("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre");
var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");

var dias=new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
var weekdays=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

/*
if(document.all)
{document.write("<style>.margen{display:block;padding-left:20px;padding-right:20px}</style>")} 
else
{document.write("<style>.margen{display:block;margin-left:20px;margin-right:20px}</style>")}
*/

//***************
function popup(q)
{window.open(q,"popup","top=20, left=20, width=648, height=480, resizable=yes,scrollbars=yes, status=no")}

//***************
function fechaverbal()
{
var aho=new Date();
var hoy=new Date(aho.getFullYear(),aho.getMonth(),aho.getDate());
return dias[hoy.getDay()]+", "+hoy.getDate()+" de "+meses[hoy.getMonth()]+" de "+hoy.getFullYear();
}

//***************
function verbaldate()
{
var aho=new Date();
var hoy=new Date(aho.getFullYear(),aho.getMonth(),aho.getDate());
return weekdays[hoy.getDay()]+", "+months[hoy.getMonth()]+" "+hoy.getDate()+", "+hoy.getFullYear();
}


//***************
function fechaverbalmysql(str)
{return str.substr(8,2)+" de "+meses[parseInt(str.substr(5,2))-1]+" de "+str.substr(0,4);}

//***************
function fechaverbalmssql(str)
{return str.substr(6,2)+" de "+meses[parseInt(str.substr(4,2))-1]+" de "+str.substr(0,4);}


//***************
function columnaAbrir()
{
	top.document.getElementById("col_abrir").src="img/columna_cerrar.gif";
	top.document.getElementById("subnavegadorid").style.display="";
}

//***************
function ajustarAncho()
{
	ancho=parseInt(top.subnavegador.document.getElementById("subnav_tabla").offsetWidth);
	top.document.getElementById("subnavegadorid").style.width=ancho;
}

//***************
function columnaCerrar()
{
	top.document.getElementById("col_abrir").src="img/columna_abrir.gif";
	top.document.getElementById("subnavegadorid").style.display="none";
}

//***************
function columnaConmuta()
{
estado=top.document.getElementById("subnavegadorid").style.display;

if(estado=="none") 
	{//abrimos
	columnaAbrir();
	}
	else 
	{//cerramos
	columnaCerrar();
	}
}

var columnaAccion;

//***************
function columnaEncoge()
{
columnaPara();
ancho=parseInt(top.document.getElementById("subnavegadorid").offsetWidth);
if(ancho>40) ancho-=10;
top.document.getElementById("subnavegadorid").style.width=ancho;
top.subnavegador.document.getElementById("subnav_tabla").style.width=ancho;
columnaAccion=setTimeout("columnaEncoge()",50);
}

//***************
function columnaExpande()
{
columnaPara();
ancho=parseInt(top.document.getElementById("subnavegadorid").offsetWidth);
if(ancho<400) ancho+=10;
top.document.getElementById("subnavegadorid").style.width=ancho;
top.subnavegador.document.getElementById("subnav_tabla").style.width=ancho;
columnaAccion=setTimeout("columnaExpande()",50);
}

//***************
function columnaPara()
{clearTimeout(columnaAccion);}

//***************
function completaColumna()
{
document.write('');
q=document.getElementById("interiorcolumna").innerHTML.toLowerCase();
q=q.replace(/^[\n\r\t\s]|[\n\r\t\s]$/gim, '');
q=q.replace("<script>poscolumna()</script>", '');
if(q!="") {columnaConmuta();}
}

//***************
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

//***************
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//***************
function eraseCookie(name) {
	createCookie(name,"",-1);
}

//***************
function checkFramework(item)
{//alert("checkFramework:"+item);
//comprueba que no se trate de un frame aislado
if(top==self || top.name!="framework")
	{
	//carga la totalidad del framework indicándole a través de una cookie como debe hacerlo
//alert("redirigiendo");
	createCookie("navegacion", item);
	top.location.href="framework.hps";
	}
//si no se trata de un frame aislado significa que está integrado con lo que
else if(top.activo==null || item!=top.activo.name) top.VCHSalta(item);
}

//***************
function navegacionSecundaria()
{
var hayobjeto=readCookie("navegacion");
//alert("leyendo cookie:"+hayobjeto);
eraseCookie("navegacion");
if(hayobjeto!=null) top.VCHSalta(hayobjeto);
}

//***************
function reescalaIframes()
{
alto=(document.all?parseInt(top.document.body.clientHeight):parseInt(top.innerHeight))-120;
//alert(alto);
top.document.getElementById("cuerpoframe").style.height=alto;
top.document.getElementById("subnavegadorframe").style.height=alto;
}

//***************
function cuerpoCargaExterna(url)
{
top.activo=null;
top.columnaCerrar();
top.VCHMenuDraw();
top.cuerpo.location.href=url;
}

//***************
function googlesearch()
{
document.f.q.value=document.f.busqueda.value;//+" site:www.hunosa.es";
if(document.f.q.value=="") {alert("introduzca un término de búsqueda"); return false;}
//alert("NOTA: este buscador sólo funciona con la versión de la página subida a internet.\n\nNOTA: sería interesante comprobar http://google.com/coop/cse/");
top.activo=null;
top.VCHMenuDraw();
top.columnaCerrar();
return true;
}

//***************
function saltaidioma(q)
{
try {
	pagina=top.cuerpo.location.pathname;
	}
	catch(err)
	{
	top.location.href="../"+q+"/framework.hps";
	}
componentes=pagina.split("/");
pagina=componentes[componentes.length-1];
salto="../"+q+"/"+pagina;
//esta cerdada la tengo que hacer por culpa del explorer, que no entiende el top.location.replace
top.name="";
top.frames["cuerpo"].location.replace(salto);
}