// JavaScript Document
  function setBrowserType(){ 
    var aBrowFull = new Array("opera", "msie", "netscape", "gecko", "mozilla"); 
    var aBrowVers = new Array("opera", "msie", "netscape", "rv",    "mozilla"   ); 
    var aBrowAbrv = new Array("op",    "ie",   "ns",       "mo",    "ns"   ); 
    var sInfo = navigator.userAgent.toLowerCase();; 

    sBrowser = ""; 
    for (var i = 0; i < aBrowFull.length; i++){ 
     if ((sBrowser == "") && (sInfo.indexOf(aBrowFull[i]) != -1)){ 
      sBrowser = aBrowAbrv[i]; 
      sVersion = String(parseFloat(sInfo.substr(sInfo.indexOf(aBrowVers[i]) + aBrowVers[i].length + 1))); 
     } 
    } 
	return sBrowser;
   } 
var navega = setBrowserType();
if(navega!="ie"){
//document.write("<link rel='icon' href='favicon.png' type='image/png'>")
//document.getElementById("encues1").style.height=150;
var tam_hei = 100;
document.write("<link rel='stylesheet' type='text/css' href='css/site.css' />")
}else{
//document.write("<link rel='shortcut icon' href='favicon.ico' type='image/x-icon'>");
//document.getElementById("encues1").style.height=181;
var tam_hei = 181;
document.write("<link rel='stylesheet' type='text/css' href='css/site2.css' />")
}





function MM_swapImgRestore() { //v3.0
  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 MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.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 MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}



///////////////////////////PESTAŅAS//////////////////////////////////////////////////////
	
	/*if(document.experimento.grupo.value==false){
	document.experimento.grupo.value = 1;
	document.experimento.seccion.value = "";
	}*/
	var menuactual="";
	var menuactual2="";
	var textoactual="";
	var paginaactual="";
	

		function Link_Lateral_Over(id_link){
			//alert(id_link);
			if(document.getElementById("link_" + id_link))
			{
				if(id_link==1)
				{
					document.getElementById("link_" + id_link).style.color = "#00429B";
				}
				if(id_link==2)
				{
					document.getElementById("link_" + id_link).style.color = "#999999";
				}
				
			}
						
        }

		
		function Link_Lateral_Normal(id_link){
			//alert(id_link);
			if(document.getElementById("link_" + id_link))
			{
				if(id_link==1)
				{
					document.getElementById("link_" + id_link).style.color = "#00224E";
				}
				if(id_link==2)
				{
					document.getElementById("link_" + id_link).style.color = "#666666";
				}
				
			}
			
        }
		
		function VerMas_Over(id_link){
			
			if(document.getElementById("VerMas_" + id_link) != "")
			{
				document.getElementById("VerMas_" + id_link).style.color = "#22323B";	
			}
			
		}
		
		function VerMas_Normal(id_link){
			
			if(document.getElementById("VerMas_" + id_link) != "")
			{
				document.getElementById("VerMas_" + id_link).style.color = "#55656F";	
			}
			
		}
		
		
		function cambiarContenido(texto){
			textoactual = texto;
			document.getElementById("txt_" + texto).style.display = "block";
  
        }
		function quitarContenido(texto){
			if(document.getElementById("txt_" + textoactual) != '')
			{
				document.getElementById("txt_" + textoactual).style.display = "none";
			}
			
  
        }
		
		
		function amenu(cual,seccion){
		   
		  
			if(seccion!="false"){
			document.experimento.grupo.value=cual;
			document.experimento.seccion.value=seccion;
			}
			
			//if (menuactual=='')menuactual=1;
				if(menuactual!='')
				{	
					document.getElementById("sm_" + menuactual).style.display="none";
				}
					menuactual=cual;
				  
				  if(document.getElementById("sm_" + cual)){
					document.getElementById("sm_" + cual).style.display="block";
				  }
			//return grupoactual;  
			//}
	    }
	   

		function sec_interna(cual){
		   	//alert(cual);					
			if(cual!="")
			{
				//alert(cual);
				
					if(cual=="1")
					{
						this.document.getElementById("sec_h" + cual).className = "pestanaseleccionada";
												
					}
					if(cual=="2")
					{
						this.document.getElementById("sec_h" + cual).className = "pestanaseleccionada2";
					}
					if(cual=="3")
					{
						this.document.getElementById("sec_h" + cual).className = "pestanaseleccionada3";
					}
			}
			
	   }
	   
	   function limpia_boton(cual){
	   	
			if(this.document.getElementById("sec_h" + cual)!="")
			{
				this.document.getElementById("sec_h" + cual).className = " ";
			}
	   
	   }
	   
	   
	   
	   function direccion(){
		var grupo = "";
		var sec = "";
		var sp = "";
		
		 if(document.experimento.grupo.value!="")
		 {
			 
			 grupo = document.experimento.grupo.value;
			 //alert(grupo);
		 }
		 
		 	sec = 216;
			sp = 292;			
		 /*
		 if (grupo==3){
		 	sec = 216;
			sp = 292;
		 }*/
		 
	    document.location.href='p_contenido.asp?gact='+grupo+'&sec='+sec+'&sp='+sp;
	   }
	   
	   function GrupoActual(seccion)
	   {
		 var sp = "";
	   	 if(document.experimento.grupo.value!="")
		 {
		 	 grupo = document.experimento.grupo.value;
		 }
		 else
		 {
			 grupo = 1;
		 }
		 if(seccion==294){
		 	grupo = 3;
			sp = "&sp=291";
		 }
		 if(sp == ""){
		 	sp = "&sp=0";
		 }
		 document.location.href='p_contenido.asp?gact='+grupo+'&sec='+seccion+sp;
	   }
	  
	  var imagenactual1="";
	  var imagenactual2="";
	  var imagenactual3="";
	  var imagenactual4="";
	  var imagenactual5="";
	  var imagenactual6="";
	  var imagenactual7="";
	  var imagenactual8="";
	  var imagenactual9="";

	  var i=0;
	   
	   function imagen(cual,padre){
		  	  //alert(padre);
			  document.getElementById("imagenes" + padre).style.display="block";
			   for(i=1; i<=9; i++){
				 if(padre==i){document.getElementById("img_padre" + padre).style.display="none";
					if(padre==1){ 
						if(imagenactual1)document.getElementById("img_" + imagenactual1).style.display="none";
						 imagenactual1 = cual;
						  
					}
					if(padre==2){ 
						 if(imagenactual2)document.getElementById("img_" + imagenactual2).style.display="none";
						 imagenactual2 = cual;
						 
					}
					if(padre==3){ 
						 if(imagenactual3)document.getElementById("img_" + imagenactual3).style.display="none";
						 imagenactual3 = cual;
						 
					}
					if(padre==4){ 
						 if(imagenactual4)document.getElementById("img_" + imagenactual4).style.display="none";
						 imagenactual4 = cual;
						 
					}
					if(padre==5){ 
						 if(imagenactual5)document.getElementById("img_" + imagenactual5).style.display="none";
						 imagenactual5 = cual;
						 
					}
					if(padre==6){ 
						 if(imagenactual6)document.getElementById("img_" + imagenactual6).style.display="none";
						 imagenactual6 = cual;
						 
					}
					if(padre==7){ 
						 if(imagenactual7)document.getElementById("img_" + imagenactual7).style.display="none";
						 imagenactual7 = cual;
						 
					}
					if(padre==8){ 
						 if(imagenactual8)document.getElementById("img_" + imagenactual8).style.display="none";
						 imagenactual8 = cual;
						 
					}
					if(padre==9){ 
						 if(imagenactual9)document.getElementById("img_" + imagenactual9).style.display="none";
						 imagenactual9 = cual;
						 
					}
					document.getElementById("img_" + cual).style.display="block";
				 }
			  
				 
				 
			   }
	   }
	 
	   
	   
	   function padre(esta){
		   if(esta!=""){
			
	   		document.getElementById("imagenes" + esta).style.display="none";
			document.getElementById("img_padre" + esta).style.display="block";
			
		   }
		   
		
	   }
		
		function cambioPestana(idPestana, visible)
		{
		
		if (visible)
		{
		   if (idPestana == 1){
			
			this.document.getElementById('fondo_contenido').className = "fondo_personas";
			this.document.getElementById('pest'+idPestana).style.display = "block";
			this.document.getElementById('tit'+idPestana).className = "pestanaseleccionada";
			
		   
		   }else if (idPestana == 2){
			
			this.document.getElementById('fondo_contenido').className = "fondo_empresas";
			this.document.getElementById('pest'+idPestana).style.display = "block";
			this.document.getElementById('tit'+idPestana).className = "pestanaseleccionada2";
			
		
		   }else if (idPestana == 3){
			
			this.document.getElementById('fondo_contenido').className = "fondo_nuestro_banco";
			this.document.getElementById('pest'+idPestana).style.display = "block";
			this.document.getElementById('tit'+idPestana).className = "pestanaseleccionada3";
			
			
			}
		
		}
		else
		{
		this.document.getElementById('pest'+idPestana).style.display = "none";
		this.document.getElementById('tit'+idPestana).className = "";
		}
		}
		
		function actualizarPestanas(idPest)
		{
		cambioPestana(idPest, true);
		
		var lstTags = this.document.getElementsByTagName("div");
		for(i=0;i<lstTags.length;i++)
		{
		
		var nomPestAux = lstTags[i].id;
		
		if (nomPestAux.substring(0, 4) == "pest" && nomPestAux != "pest"+idPest)
		{
		
		var idPestAux = nomPestAux.substring(4, nomPestAux.length);
		
		cambioPestana(idPestAux, false);
		}
		}
		}

///////////////////////FIN PESTAŅAS////////////////////////////////////////////////


 
 function marquesinas(){
  //var grupo = amenu();
	//alert(document.experimento.grupo.value);
 if (document.experimento.grupo.value=="1")
	{
	 //alert(document.experimento.grupo.value);	
	 document.getElementById("sm_1").style.visibility="visible";
	 document.getElementById("sm_2").style.display="none";
	 document.getElementById("sm_3").style.display="none";
	 document.getElementById("sm_2").style.height="100%";
	 document.getElementById("sm_3").style.height="100%";
	 document.getElementById("sm_2").style.visibility="visible";
	 document.getElementById("sm_3").style.visibility="visible";
	 document.getElementById("sm_1").style.position="";
	 document.getElementById("sm_2").style.position="";
	 document.getElementById("sm_3").style.position="";
	}
 if (document.experimento.grupo.value=="2")
    {
	 //alert(document.experimento.grupo.value);
	 document.getElementById("sm_2").style.visibility="visible";
	 document.getElementById("sm_1").style.display="none";
	 document.getElementById("sm_3").style.display="none";
	 document.getElementById("sm_1").style.height="100%";
	 document.getElementById("sm_3").style.height="100%";
	 document.getElementById("sm_1").style.visibility="visible";
	 document.getElementById("sm_3").style.visibility="visible";
	 document.getElementById("sm_1").style.position="";
	 document.getElementById("sm_2").style.position="";
	 document.getElementById("sm_3").style.position="";
	}
 if (document.experimento.grupo.value=="3")
    {
	 document.getElementById("sm_3").style.visibility="visible";	
	 document.getElementById("sm_1").style.display="none";
	 document.getElementById("sm_2").style.display="none";
	 document.getElementById("sm_1").style.height="100%";
	 document.getElementById("sm_2").style.height="100%";
	 document.getElementById("sm_1").style.visibility="visible";
	 document.getElementById("sm_2").style.visibility="visible";
	 document.getElementById("sm_1").style.position="";
	 document.getElementById("sm_2").style.position="";
	 document.getElementById("sm_3").style.position="";
	}
 }



//////////////////////////////////CALENDARIO//////////////////////////////////////////////


function nuevoAjax()
{ 
    var xmlhttp=false;
    try
    {
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(E)
        {
            if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
        }
    }
    return xmlhttp; 
}
function cargarMes(mes, anio, div, fut, co, pas, co2) {
   
	var destino = document.getElementById(div);    
       
	   var ajax=nuevoAjax();
	   //if (fut == "" && co == "" && pas == "" && cop == ""){
       // ajax.open("GET", "includes/calendario.asp?MES="+mes+"&ANIO="+anio, true);
	  // }
	   //else{
	   	ajax.open("GET", "includes/calendario.asp?MES="+mes+"&ANIO="+anio+"&fut="+fut+"&co="+co+"&pas="+pas+"&co2="+co2, true);
	  // }
        ajax.onreadystatechange=function() 
        { 
            if (ajax.readyState==1)
            {
                // Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				 destino.innerHTML=""
                destino.innerHTML="<div style=\"text-align:center; width:169px; height:200px; vertical-align:middle\"><br><br><br><br><img src=\"images/home/5-0.gif\" border=\"0\" /></div>";
            }
            if (ajax.readyState==4)
            {
				
               destino.innerHTML=ajax.responseText;
            } 
        }
        ajax.send(null);
}  


/////////////////////////////////////FIN CALENDARIO//////////////////////////////////////////////


////////////////////////////////////RELOJ/////////////////////////////////////////////////


function dar_hora(){
		fecha = new Date();
		fecha_1=fecha.getDate();
		fecha_2=fecha.getMonth();
		hora_s=fecha.getHours();
		dia_s = fecha.getDay();
		dias_nombres = Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
		dia = dias_nombres[dia_s];
		am_pm="am.";
			if(hora_s>11&&hora_s>=12){
				if(hora_s!=12)
				{	
					hora_s=hora_s-12;
				
				}
				am_pm="pm.";
					if(hora_s>23)
					{
					  am_pm = "am."								
					}
			}
			minutos_s= fecha.getMinutes();
			if(minutos_s<10){
				minutos_s="0"+minutos_s;
			}
			setTimeout(dar_hora,1000);
			if(document.getElementById("hora")){
				document.getElementById("hora").innerHTML=hora_s+":"+minutos_s+" "+am_pm;
			}
			
		}

//////////////////////////////////FIN RELOJ////////////////////////////////////////////////


function AbrirVentana(esta)
{
	if (esta!="Seleccione")
	{
  		window.open("i_herramientas2.asp?her="+esta,"herramienta","scrollbars=yes,width=300,height=300");
  	}
}

function addtofavorites(url, description)
{
	if (window.sidebar) //Mozilla Firefox
   	{
		//alert("YES FF");
   		window.sidebar.addPanel(description, url,"");
   	}
   	else if( window.external)
	{
		//IE Favorite
		//alert("YES IE");
		window.external.AddFavorite( url, description);
	}
   	else
   	{
   		return ;
   	}
}

function mostrar_ocultar_div (nombre_div, total_div)
{
	ruta_imagen = new Image;
	ruta_imagen2 = new Image;
	ruta_imagen.src = "images/home/flecha_rigth.gif";
	ruta_imagen2.src = "images/home/flecha_down.gif";
	
	document.getElementById(nombre_div).style.display = "block";
	document.images['imagen_'+nombre_div].src = ruta_imagen2.src;
	
		for (var a=0;a<total_div;a++)
		{
			if (nombre_div != a)
			{
				document.getElementById(a).style.display = "none";
				document.images['imagen_'+a].src = ruta_imagen.src;
			}
		}
}

function show_divg (nombre_div,total_div)
{
	for (var a=0;a<=(total_div);a++)
	{
		document.getElementById(a).style.display = "none";
	}

	if (document.getElementById(nombre_div))
	document.getElementById(nombre_div).style.display = "block";
}

function Levantar_Ventana(ID) {
	//alert("Levantar ventana 2");
	window.open('p_vista.asp?sec='+ID+'&gact=1','','scrollbars=yes,width=890,height=650,resizable=1,menubar=0,toolbar=0');
	//window.open('p_vista.asp?sec='+ID+'&gact=1','Condiciones Generales','scrollbars=yes,width=890,height=650');
	//window.open('p_vista.asp?sec='+ID+'&gact=1', '', 'width=220,height=200,scrollbars=yes');
}

function paginar(cual){
	if (paginaactual == "")
	{
		paginaactual = 1;
	}
	if(paginaactual != "")
	{
		document.getElementById("c_" + paginaactual).style.display = "none";
	}
	paginaactual = cual;
	if(document.getElementById("c_" + cual))
	{
		document.getElementById("c_" + cual).style.display = "block";
	}
}

function edicion_actual(seccion, grupo, edicion,sp)
{
	if(edicion != "")
	{
		if (seccion == "377")
		{
			document.location.href='p_contenido.asp?gact='+grupo+'&sec='+seccion+'&sp='+sp+'&edi_act='+edicion;
		}
		else if (seccion == "378")
		{
			document.location.href='p_contenido.asp?gact='+grupo+'&sec='+seccion+'&sp='+sp+'&enl_hum='+edicion;
		}
		else if (seccion == "297")
		{
			document.location.href='p_contenido.asp?gact='+grupo+'&sec='+seccion+'&sp='+sp+'&enl_hum='+edicion;
		}
	}
}

function abrirpopup (direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba)
{
	var opciones = "fullscreen=" + pantallacompleta +
                 ",toolbar=" + herramientas +
                 ",location=" + direcciones +
                 ",status=" + estado +
                 ",menubar=" + barramenu +
                 ",scrollbars=" + barrascroll +
                 ",resizable=" + cambiatamano +
                 ",width=" + ancho +
                 ",height=" + alto +
                 ",left=" + izquierda +
                 ",top=" + arriba;
	
	var ventana = window.open(direccion, "Editorial", opciones); 
}

function imprimir()
{
	window.print();
}

function currencyFormat(fld, milSep, decSep, e)
{
	var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
                if (whichCode == 13) return true; // Enter
                if (whichCode == 8) return true;//return
                if (whichCode == 0) return true;//suprimir, flechas direccion
    key = String.fromCharCode(whichCode); // Get key value from key code
                if (strCheck.indexOf(key) == -1) return false; // Not a valid key
    len = fld.value.length;
    for(i = 0; i < len; i++)
     if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
    aux = '';
    for(; i < len; i++)
     if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) fld.value = '';
    if (len == 1) fld.value = '0'+ decSep + '0' + aux;
    if (len == 2) fld.value = '0'+ decSep + aux;
    if (len > 2) {
     aux2 = '';
     for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
       aux2 += milSep;
       j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
     }
     fld.value = ''; 
     len2 = aux2.length; 
     for (i = len2 - 1; i >= 0; i--)
      fld.value += aux2.charAt(i);
     fld.value += decSep + aux.substr(len - 2, len);
    }
    return false;
}


//Parametro 1: nombre_banner -> Nombre de la imagen o del banner
//Parametro 2: externo -> 1) Si es Externo, 2) No
//Parametro 2: link_externo -> Tiene el link
function cambiar_banner (nombre_banner, externo, link_externo)
{ 
	if (nombre_banner != "")
	{
			if (externo)
			{
				ruta_banner = "<a href='+link_externo+'><img src='../uploads/"+ nombre_banner +"' width='243' height='95' border='0'/></a>"
			}
			else
			{
				ruta_banner = "<img src='../uploads/"+ nombre_banner +"' width='243' height='95' border='0'/>"
			}
		
		if(document.getElementById("smhijasarriba")){
			document.getElementById("smhijasarriba").style.display = "block";			
			document.getElementById("smhijasarriba").innerHTML = ruta_banner;
		}
		
		if(document.getElementById("smdemasbanners")){
			document.getElementById("smdemasbanners").style.display = "none";
		}
	}
	else
	{
		if(document.getElementById("smhijasarriba")){
			document.getElementById("smhijasarriba").style.display = "none";
		}
		if(document.getElementById("smdemasbanners")){
			document.getElementById("smdemasbanners").style.display = "block";
		}
	}
}

function dateComapreTo(yy1, mm1, dd1) {

var f1 =  new Date(yy1, mm1, dd1);
fecha = new Date();
var fecha_dia=fecha.getDate();
var fecha_mes=fecha.getMonth()+1;
var fecha_anio=fecha.getYear();

 var BName = navigator.appName;

 if(BName == "Netscape"){
         var Year = fecha_anio + 1900;
 }else{
 	var Year = fecha_anio;
 }

var f2 =  new Date(Year, fecha_mes, fecha_dia);

return f1.getTime() - f2.getTime();

}

