//...................................................................................................................
//CAMBIA EL EFECTO QUE SE PRODUCE AL CLICAR LAS DIVERSAS OPCIONES DE MENÚ TENIENDO EN CUENTA SI ESTA DESPLEGADO O NO
function cambiarFuncionBtn (iden,submenu){	
	msubmenu = iden-1;
	if ((id_menu[msubmenu]=="") || (id_menu[msubmenu]==2)){id_menu[msubmenu] = 1;}	
	else {id_menu[msubmenu] = 2;}
	switch(id_menu[msubmenu]){
		case 1: new Effect.SlideDown(submenu); 
				  break;
		case 2: new Effect.SlideUp(submenu); 
				  break;
	}	
}
//...................................................................................................................
//CAMBIA LA CLASE REFERENTE A LAS OPCIONES DE MENÚ CON LA ACCIÓN DEL RATÓN
function estadoMenu(origen){
	var actual = $(origen).className;
	if (actual == "opcion_menu"){$(origen).className = "opcion_menuSelec";}
	else{$(origen).className = "opcion_menu";}
}

//...................................................................................................................
//CAMBIA LA CLASE REFERENTE A LAS OPCIONES DE SUBMENÚ CON LA ACCIÓN DEL RATÓN
function estadoSubmenu(origen){
	var actual = $(origen).className;
	if (actual == "opcion_submenu"){$(origen).className = "opcion_submenuSelec";}
	else{$(origen).className = "opcion_submenu";}
}
//...................................................................................................................
//CARGA LA PÁGINA QUE SE LE INDICA CAMBIANDO LA VARIABLE QUE HACE REFERÉNCIA AL IDIOMA DENTRO DE LAS SECCIONES
function cambiarIdiomaSecciones(pagina, codIdioma, padreMenu, hijoMenu){
	/*if ((padreMenu!="")&&(hijoMenu!="")) {*/
		$('form1').action = "pagina.php";
		$('cambiarIdioma').value = codIdioma;
		$('codPadreMenu').value = padreMenu;
		$('liteOpcionMenu').value = hijoMenu;
		$('urlPagina').value = pagina;
		$('form1').submit();
	/*}
	else window.location.href= pagina + "?idioma=" + codIdioma;
	*/
}
//...................................................................................................................
//CARGA DE NUEVO LA PÁGINA PRINCIPAL
function regresarHome(pagina){
	window.location.href= pagina;
}
//...................................................................................................................
//CARGA LA SECCIÓN QUE TOQUE TENIENDO EN CUENTA LA OPCIÓN SELECCIONADA PARA MANTENERLA SELECCIONADA
function cambiarSeccion(pagina, codLiteral, codPadre){
	$('form1').action = "pagina.php";
	$('urlPagina').value = pagina;
	$('liteOpcionMenu').value = codLiteral;
	$('codPadreMenu').value = codPadre;
	$('form1').submit();
}
//...................................................................................................................
//CARGA LA IMAGEN GRANDE EN UNA CAPA Y LA POSICIONA
	function cargarImagenGrande(iden){
		ancho = eval("img_g_"+iden+".width")+2;
		alto = eval("img_g_"+iden+".height")+21;
		$('max').src=eval("img_g_"+iden+".src");
		ImgDim = $('contenedor_img_G').getDimensions();
		$('barrarCerrar').style.width = (ancho)-2+'px';
		$('contenedor_img_G').setStyle({
		  width: ancho+'px',
		  height: alto+'px',
		  marginTop: (alto/2)*-1+'px',
		  marginLeft: (ancho/2)*-1+'px',
		  left:'50%',
		  top:'50%',
		  zIndex:200,
		  fontSize:'0px'
		});

		$('desactivar').style.zIndex = 199;
		$('contenedor_img_G').appear();
		
		$('desactivar').style.display = "block";
	}
//...................................................................................................................
//PREPARA LOS INPUS Y LOS TEXTAREAS PARA QUE CUANDO TENGAN EL FOCO SE LES CAMBIE LA CLASE
	function prepararInputs(){
		$$("input", "textarea").each(function(objInput){
			if (objInput.type=='text' &&  objInput.type=='textarea') {
				$(objInput).observe("focus",function(evnt){ this.addClassName("textoFromAct"); });
				$(objInput).observe("blur",function(evnt){ this.removeClassName("textoFromAct"); });
			}
		});
	}
//...................................................................................................................
//MUESTRA EL CALENDARIO
	function showCale(que) {
		queCale = que;
		$("calendar-container").style.display = 'inline';
		$("calendar-container").style.left = $('MouseX').value + "px";
		$("calendar-container").style.top = $('MouseY').value + "px";
	}
//...................................................................................................................
//VALIDA QUE UN CAMPO ES NUMÉRICO
	function validarNumerico(campo,valor){
	    var conver = parseInt(valor);
     	if (isNaN(conver)){
			$(campo).focus();
			return false;
		}else{
			return true;
		}
	}
//...................................................................................................................
//VALIDACIÓN DE DIRECCIÓN DE CORREO ELECTRÓNICO
	function validarCorreo(correo){
		var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
		if (correo.length == 0 ){
			$('mail').focus();
			return false;
		}
		if (filter.test(correo)){
			return true
		}else{
			$('mail').focus();
			return false;
		}
	}
//...................................................................................................................		
//OBTENER DATOS DE LA PANTALLA
	function getWindowData(){
		var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
		if (typeof window.innerWidth != 'undefined'){
			widthViewport= window.innerWidth-17;
			heightViewport= window.innerHeight-17;
		}else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
			widthViewport=document.documentElement.clientWidth;
			heightViewport=document.documentElement.clientHeight;
		}else{
			widthViewport= document.getElementsByTagName('body')[0].clientWidth;
			heightViewport=document.getElementsByTagName('body')[0].clientHeight;
		}
		xScroll=self.pageXOffset || (document.documentElement.scrollLeft+document.body.scrollLeft);
		yScroll=self.pageYOffset || (document.documentElement.scrollTop+document.body.scrollTop);
		widthTotal=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth,widthViewport);
		heightTotal=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,heightViewport);
		return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
	}
/*
validacion mail_expreg
*/
function validaMail(txt){
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
        return b.test(txt)
}

function verCondiciones(){
	var URL = "declaracion_privacidad.php";
	var parametros = "toolbar=no, left=200, top=200, scrollbars=yes, resizeable=no, width=650, height=280";
	window.open(URL,"",parametros);
}

function irAPagina(urlPagina){
	$("form1").action = "pagina.php";
	$("urlPagina").value = urlPagina;
	$("form1").submit();
}

function dameDiasDeDiferencia(fecha1, fecha2){
	//Calculo de dias de diferencia entre dos fechas
	//Debemos asegurarnos de que las variables que le pasemos ya estén convertidas a tipo Date
	var milisegDia = 1000 * 60 * 60 * 24;
	var milisegDiferencia = fecha1.getTime() - fecha2.getTime();
	var diasDiferencia = Math.ceil(milisegDiferencia/milisegDia);
	return diasDiferencia;
}