// JavaScript Document

var strTitulo;
var scrX;
var scrY;

function obtenerScrX()
{
ancho = screen.width;
switch(ancho)
	{
	case 1024:
	  ancho = 990;
//	  ancho = 990;
	  break;    
	case 1280:
	  ancho = 1200;
//    ancho = 1200;	  
	  break;
	default:
	  ancho = 990;
	}
return ancho;
}

function obtenerScrY()
{
alto = screen.height;
switch(alto)
	{
		case 768:
		  alto = 540;
//		  alto = 540;		  
		  break;    
		case 1024:
		  alto = 750;
//		  alto = 750;		  		  
		  break;
		default:
		  alto = 540;
	}
return alto;
}


function obtenerAnio()
{
vBusqueda = window.location.search;
vBusqueda = vBusqueda.substring(vBusqueda.length-4,vBusqueda.length);
return vBusqueda;
}

function recargarMenu(IDMenu)
{
	vDIVMenu = window.parent.document.getElementById('navigationBar');
	vDIVMenu.focus();
	OcultarMostrarMenu(IDMenu);
}


function Fecha(FormatoFecha)
{
meses = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
data = new Date();
index = data.getMonth();
diasemana=new Array("Lunes","Martes","Miércoles","Jueves","Viernes","Sábado","Domingo");
indexday =  data.getDay();
if (indexday == 0)
indexday = 7;
any = data.getYear();
if (any < 1900)
	any = 1900 + any;
if (FormatoFecha=="larga") return diasemana[indexday-1]+ ", " + ' '+data.getDate()+ " de " + meses[index] + " de " + any;
if (FormatoFecha=="mediana") return data.getDate()+ " de " + meses[index] + " de " + any;
if (FormatoFecha=="corta")
	{
		anio = String(any);
		anio = anio.substring(2,4);
		dia = String(data.getDate());
		if (dia.length==1) dia="0" + dia;
		mes = String(index)		
		if (mes.length==1) mes="0" + mes;
		return dia + "/" + mes + "/" + anio;
	}
}


function ponerTitulo(cadena)
{
zonaDeTitulo = window.parent.document.getElementById('strTit');
zonaDeTitulo.innerText  = "[" + cadena + "]"; /* para IE */
zonaDeTitulo.textContent  = "[" + cadena + "]"; /* para Firefox */
}


function limpiarEstilosMenu()
{
	winParent = window.parent.parent.document;	
	var MenuVar=winParent.getElementsByTagName("A");
	for (var i = 0; i < MenuVar.length; i++)
	{ 		
			estiloExistente = MenuVar[i].style.backround;
			estiloExistente = MenuVar[i].getAttribute("style");
			/*alert(estiloExistente);*/
			estiloMenuSeleccionado = "#F2F0EE url('css/pix/punto_s.gif') no-repeat 1px 4px";
			if(estiloExistente==estiloMenuSeleccionado)
			{
			MenuVar[i].style.backround="#444444 url('css/pix/punto_s.gif') no-repeat 1px 15px";
			}
	}	
}



function ocultarTodosMenus()
{
	winParent = window.parent.parent.document;	
	var MenuVar=winParent.getElementsByTagName("ul");
	for (var i = 0; i < MenuVar.length; i++)
	{ 		
		if (MenuVar[i].id != "")
		{
		winParent.getElementById(MenuVar[i].id).style.display="none";
		winParent.getElementById(MenuVar[i].id).style.visibility="hidden";
		winParent.getElementById(MenuVar[i].id).style.height="0px";
		}
	}	
}

function mostrarMenu(IDMenu)
{
	var vIDMenu = IDMenu;
	winParent = window.parent.parent.document;	
	vMenu=winParent.getElementById(vIDMenu); 
	vMenu.style.visibility="visible";
	vMenu.style.display="block";
	vMenu.style.height="100%";

}

function OcultarMostrarMenu(IDMenu)
{
	var nivel
	vIDMenu = IDMenu;

	pos1=vIDMenu.substring(0,1);
	pos2=vIDMenu.substring(1,2);
	pos3=vIDMenu.substring(2,3);
	pos4=vIDMenu.substring(3,4);
	if ((pos2=="0") && (pos3=="0") && (pos4 =="0")) {nivel=1};
	if ((pos2 !=="0") && (pos3 =="0") && (pos4 =="0")) {nivel=2};
	if ((pos2 !=="0") && (pos3 !=="0") && (pos4 =="0")) {nivel=3};	
	if ((pos2 !=="0") && (pos3 !=="0") && (pos4 !=="0")) {nivel=4};	
	
	
	winParent = window.parent.parent.document;
	menu=winParent.getElementById(vIDMenu); 

	if (menu.style.visibility==null){
		visibilidad = "visible"
      }
	else
	 {
	 	visibilidad = menu.style.visibility		
	 };
	
	ocultarTodosMenus();
	limpiarEstilosMenu();

switch(nivel)
{
	case 1:
		if (visibilidad=="visible")
		{			
			/*No hace nada*/
		}
		else
		{
			mostrarMenu(vIDMenu);							
		}
		/*Aplicamos el Estilo del menu activo*/
		if (menu.nodeName !== 'A')
		{
			/* El menú tiene submenus. debemos buscar el anterior elemento del tag <A>, 	*/
			/* que es a quien se debe definir el estilo "de seleccionado"					*/
			menuPadre = menu.parentNode;
			tagsTipoA = menuPadre.getElementsByTagName('A');
			for (var i=0;i<tagsTipoA.length;i++)
			  { 
			  if (tagsTipoA[i].id == "")
			  	{					
						vID= tagsTipoA[i].href.substring(tagsTipoA[i].href.length - 9,tagsTipoA[i].href.length);
						if (vID==vIDMenu)
						{
/*							tagsTipoA[i].style.background="#F2F0EE url('css/pix/punto_s.gif') no-repeat 1px 4px";*/
						}						
			  	}
			  }
		}
		else
		{
			menu=winParent.getElementById(vIDMenu);
/*			menu.style.background="#F2F0EE url('css/pix/punto_s.gif') no-repeat 1px 4px";*/
		}
		break    
	case 2:
		if (visibilidad=="visible")
		{
			mostrarMenu(pos1 + "00000000");
		}
		else
		{
			mostrarMenu(pos1 + "00000000");
			mostrarMenu(pos1 + pos2 + "0000000");
		}
		/*Aplicamos el Estilo del menu activo */
		if (menu.nodeName !== 'A')
		{
			/* El menú tiene submenus. debemos buscar el anterior elemento del tag <A>, 	*/
			/* que es a quien se debe definir el estilo "de seleccionado"					*/
			menuPadre = menu.parentNode;
			tagsTipoA = menuPadre.getElementsByTagName('A');
			for (var i=0;i<tagsTipoA.length;i++)
			  { 
			  if (tagsTipoA[i].id == "")
			  	{					
						vID= tagsTipoA[i].href.substring(tagsTipoA[i].href.length - 9,tagsTipoA[i].href.length);
						if (vID==vIDMenu)
						{
/*							tagsTipoA[i].style.background="#F2F0EE url('css/pix/sub1_s.gif')  no-repeat 2px 3px";*/
						}						
			  	}
			  }

		}
		else
		{
			menu=winParent.getElementById(vIDMenu);
/*			menu.style.background="#F2F0EE url('css/pix/sub_s.gif') no-repeat 2px 3px";*/
		}		
		break
	case 3:
		if (visibilidad=="visible")
		{
			mostrarMenu(pos1 + "00000000");
			mostrarMenu(pos1 + pos2 + "0000000");			
		}
		else
		{
			mostrarMenu(pos1 + "00000000");
			mostrarMenu(pos1 + pos2 + "0000000");
			mostrarMenu(pos1 + pos2 + pos3 + "000000");				
		}
		/*Aplicamos el Estilo del menu activo*/
		if (menu.nodeName !== 'A')
		{

			/* El menú tiene submenus. debemos buscar el anterior elemento del tag <A>, 	*/
			/* que es a quien se debe definir el estilo "de seleccionado"					*/
			menuPadre = menu.parentNode;
			tagsTipoA = menuPadre.getElementsByTagName('A');
			for (var i=0;i<tagsTipoA.length;i++)
			  { 
			 	 if (tagsTipoA[i].id == "")
			  	{					
						vID= tagsTipoA[i].href.substring(tagsTipoA[i].href.length - 9,tagsTipoA[i].href.length);
						if (vID==vIDMenu)
						{
/*							tagsTipoA[i].style.background="#F2F0EE url('css/pix/sub2_s.gif') no-repeat 12px 3px";*/
						}						
			  	}
			  }


		}
		else
		{
			menu=winParent.getElementById(vIDMenu);
			/*menu.style.background="#F2F0EE url('css/pix/sub2_s.gif') no-repeat 12px 3px";*/
		}				
		break
	default:
		mostrarMenu(pos1 + "00000000");
		mostrarMenu(pos1 + pos2 + "0000000");
		mostrarMenu(pos1 + pos2 + pos3 + "000000");					
		mostrarMenu(pos1 + pos2 + pos3 + pos4 + "00000");
		/*Aplicamos el Estilo del menu activo*/
		if (menu.nodeName !== 'A')
		{

			/* El menú tiene submenus. debemos buscar el anterior elemento del tag <A>, 	*/
			/* que es a quien se debe definir el estilo "de seleccionado"					*/
			menuPadre = menu.parentNode;
			tagsTipoA = menuPadre.getElementsByTagName('A');
			for (var i=0;i<tagsTipoA.length;i++)
			  { 
			 	 if (tagsTipoA[i].id == "")
			  	{					
						vID= tagsTipoA[i].href.substring(tagsTipoA[i].href.length - 9,tagsTipoA[i].href.length);
						if (vID==vIDMenu)
						{
/*							tagsTipoA[i].style.background="#F2F0EE url('css/pix/sub3_s.gif') no-repeat  22px 3px";*/
						}						
			  	}
			  }


		}
		else
		{
			menu=winParent.getElementById(vIDMenu);
/*			menu.style.background="#F2F0EE url('css/pix/sub3_s.gif') no-repeat  22px 3px"						*/
		}						
					
} /*Final del SWITCH*/

}


function AddDataCookie(variable, dato, miliseg_vida)
{
	if ( miliseg_vida ) {
		var fecha = new Date();
		fecha.setTime(fecha.getTime() + miliseg_vida);
		document.cookie = (variable + '=' + escape(dato) + ';expires=' + fecha.toGMTString());
	}
	else
	{
		document.cookie = variable + '=' + escape(dato);
	}
} 

function GetDataCookie(variable)
{
	var pos_ini, pos_fin, pos, mycook = document.cookie;
	if (!mycook) return "";
	pos = mycook.indexOf(variable);
	if ( pos == -1 ) return "";
	pos_ini = mycook.indexOf("=", pos);
	if ( pos_ini != (pos + variable.length) ) return "";
	pos_fin = mycook.indexOf(";", pos_ini) - 1;
	if (pos_fin == -2) pos_fin = mycook.length - 1;
	return unescape( mycook.substr(pos_ini+1,(pos_fin-pos_ini)) );
}

function DeleteVarCookie(variable)
{
	var fecha_cad = new Date();
	fecha_cad.setTime(fecha_cad.getTime() - 1000);
	document.cookie = variable + "=NULL;expires=" +
	fecha_cad.toGMTString();
}

function ObtenerParametro( name ){
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp ( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null )
		return"";
	else
		return results[1];
}



function RestaurarImg() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function PrecargarImg() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=PrecargarImg.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function EncontrarObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=EncontrarObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function CambiarImg() {
  var i,j=0,x,a=CambiarImg.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=EncontrarObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->