


function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function alertSizeWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

function estaCursor(idObjeto, x, y)
{
	var altoInicial = findPosY(document.getElementById(idObjeto)); //document.getElementById(objeto).offsetTop;
	var altoFinal = altoInicial + document.getElementById(idObjeto).offsetHeight;
	var largoInicial = findPosX(document.getElementById(idObjeto)); //document.getElementById(objeto).offsetLeft;
	var largoFinal = largoInicial + document.getElementById(idObjeto).offsetWidth;
	
	if ( altoInicial <= y && altoFinal >= y && largoInicial <= x && largoFinal >= x)
	{
		return true;
	}
	
	return false;
	
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getCursorPosX()
{
	var posx = 0;
	var e = window.event;
	if (e.pageX )
	{
		posx = e.pageX;
	}
	else if (e.clientX)
	{
		posx = e.clientX + document.body.scrollLeft;
	}
	
	return posx;		
}

function getCursorPosY()
{
	var posy = 0;
	var e = window.event;
	if (e.pageY)
	{
		posy = e.pageY;
	}
	else if (e.clientY)
	{
		posy = e.clientY + document.body.scrollTop;
	}
	
	return posy;			
}

function quitarPunteroMenu(elemento)
{
	elemento.style.cursor="default";
	fondoSinResaltado(overAnterior);
}


function fondoResaltado(id)
{
	// Quitamos el resaltado si la variable es distinta de vacio y mantenemos en caso de que el menu este abierto
	if ( overAnterior != "") 
	{
		fondoSinResaltado(overAnterior);
	}
	document.getElementById(id).className = "MenuCapaSi";
	
	overAnterior = id;
}

function fondoSinResaltado(id)
{
	try { document.getElementById(id).className = "MenuCapa"; }
	catch ( er ) {}
}


function irUrl(url) 
{ 
	document.location.href=url; 
}

function ajustar()
{
	// Coge lo que exista dentro de la capa SubMenu
/*	var txtDivSubMenu = document.getElementById("CapaSubMenu").innerHTML;
		
	if(txtDivSubMenu == "")
	{*/
		// Página sin SubMenu
		document.getElementById("Contenido").style.width = document.getElementById("CapaSuperior").offsetWidth - 200 + "px";
		document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
		document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
/*	}
	else
	{
		try 
		{
			// pagina con SubMenu
			var maximo = document.getElementById("CapaSubMenu").offsetHeight;
			if ( maxHeightTercerNivel() > maximo ) { maximo = maxHeightTercerNivel(); }
			document.getElementById("Contenido").style.top = document.getElementById("CapaSubMenu").offsetTop + maximo;
			document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
			document.getElementById("Contenido").style.width = alertSizeWidth() - 220;	
		}
		catch ( er ) { }
	}
	*/
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";
}

function ajustar_vacio()
{
	document.getElementById("Contenido").style.width = document.getElementById("CapaSuperior").offsetWidth - 10 + "px";
	document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
	document.getElementById("Contenido").style.left = "10px";
    document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";

//	document.getElementById("Contenido").style.width = "320px";
//	document.getElementById("Contenido").style.top = "220px";
//	document.getElementById("Contenido").style.left = "320px";
//	document.getElementById("Contenido").style.height = "210px";

}
function ajustar_vacio_noraiz()
{
	document.getElementById("Contenido").style.width = document.getElementById("CapaSuperior").offsetWidth - 10 + "px";
	//document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
	document.getElementById("Contenido").style.left = "10px";
    document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";

//	document.getElementById("Contenido").style.width = "320px";
//	document.getElementById("Contenido").style.top = "220px";
//	document.getElementById("Contenido").style.left = "320px";
//	document.getElementById("Contenido").style.height = "210px";

}
function ajustar50_contenido()
{
	document.getElementById("Contenido").style.width = document.getElementById("CapaSuperior").offsetWidth - 200 + "px";
	document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
	document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";
}

function ajustar_indice()
{
	try 
	{
		var maximo = document.getElementById("CapaSubMenu").offsetHeight;
		try { 
			if ( maxHeightTercerNivel() > maximo ) 
			{ 
				maximo = maxHeightTercerNivel(); 
			}
		} catch (ex) {
			if ( 0 > maximo ) 
			{ 
				maximo = 0; 
			}
		}
		
		document.getElementById("Contenido").style.top = document.getElementById("CapaSubMenu").offsetTop + maximo;
		document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
		document.getElementById("Contenido").style.visibility = "visible";
		document.getElementById("Contenido").style.width = alertSizeWidth() - 220;	
		document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";
	}
	catch ( er ) {
	}
}

function ajustar_cuadrocontrol()
{
	document.getElementById("Contenido").style.width = "100%";
	document.getElementById("Contenido").style.left = "0px";
	document.getElementById("Contenido").style.top = document.getElementById("Titulos").offsetTop + document.getElementById("Titulos").offsetHeight;
	document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";
}

function ajustar_unidades()
{
	document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
	document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
	document.getElementById("Contenido").style.visibility = "visible";
}

function ajustar_unidades_indice()
{

	var maximo = document.getElementById("CapaSubmenu").offsetHeight;
	if ( maxHeightTercerNivel() > maximo ) { maximo = maxHeightTercerNivel();  }
	document.getElementById("Contenido").style.top = document.getElementById("CapaSubmenu").offsetTop + maximo;
	document.getElementById("Contenido").style.height = alertSize() - 220 - maximo + "px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.getElementById("Contenido").style.visibility = "visible";
	document.getElementById("Contenido").style.width = alertSizeWidth() - 220;
}


function ajustarInfantil()
{
	document.getElementById("Contenido").style.width = document.getElementById("CapaSuperior").offsetWidth - 200 + "px";
	document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
	document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-infantil.gif)";
}

function ajustar50()
{
	document.getElementById("Contenido").style.width = "320px";
	document.getElementById("Contenido").style.top = "220px";
	document.getElementById("Contenido").style.left = "320px";
	document.getElementById("Contenido").style.height = "210px";
	document.getElementById("Contenido").style.visibility = "visible";
	document.body.style.backgroundImage = "url('')";
}

function ajustar_portada()
{
	try {
		document.getElementById("Contenido").style.top = document.getElementById("CapaMenu").offsetTop;
		document.getElementById("Contenido").style.height = alertSize() - 130 + "px";
		document.getElementById("Contenido").style.visibility = "visible";
		
		document.getElementById("DatosAgenda").style.width = "200px";
		document.getElementById("DatosAgenda").style.left = alertSizeWidth() - 219;
		document.getElementById("DatosAgenda").style.height = alertSize()/2 -45;
/*
		//document.getElementById("ContenidoNovedades").style.top = -15;
		document.getElementById("ContenidoNovedades").style.left = alertSizeWidth() - 219;
		document.getElementById("ContenidoNovedades").style.color = "black";
		document.getElementById("ContenidoNovedades").style.height = ((alertSize() - 220) / 3 - 3)+"px";
		document.getElementById("ContenidoNovedades").style.height = document.getElementById("ContenidoNovedades").offsetHeight - 45 + 50;
		*/
		//document.getElementById("capaNovedades").style.height = ( alertSize() - 180) / 3  + "px";
		
		document.getElementById("capaNoticias").style.height = (alertSize() - 180) / 2 - 75 + "px";
		
		document.getElementById("ContenidoListaNoticias").style.height =  alertSize()/2 - 75 +  "px";
		document.getElementById("ContenidoListaNoticias").style.width = 200;
		document.getElementById("ContenidoListaNoticias").style.left = alertSizeWidth() - 219;
		document.getElementById("capaAgenda").style.top = document.getElementById("ContenidoListaNoticias").offsetHeight + document.getElementById("capaNoticias").offsetTop +5 + "px";
		//document.getElementById("capaAgenda").style.height = document.getElementById("FondoAgenda").offsetHeight -25;
		
		/*
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
		document.getElementById("capaNovedades").style.top = document.getElementById("DatosAgenda").offsetHeight + document.getElementById("capaAgenda").offsetTop + 2 + "px";
		
		}
		else
		{
		document.getElementById("ContenidoNovedades").style.top = document.getElementById("DatosAgenda").offsetHeight + document.getElementById("capaAgenda").offsetTop + 2 + "px";
		}
*/
		document.getElementById("Contenido").style.width = alertSizeWidth() - 429;
		
	//	document.getElementById("capaNovedades").style.visibility = "visible";
		document.getElementById("capaNoticias").style.visibility = "visible";	
		document.getElementById("capaAgenda").style.visibility = "visible";		
	}	
	catch(ex) {}
	
	document.body.style.backgroundImage = "url(/CmsHUVR/system/modules/plantilla_huvr/resources/fondo-logo.gif)";
} 

function Visualizar(oItems,x)
{
if ((oItems.style.display =="") || (oItems.style.display == 'none'))
{
oItems.style.display = "block";
}
else
{
oItems.style.display = "none"; 
}
}   
