/****************************************************************************
'* Generico.js  Enero 2007 - Madrid - España								*
'* Funciones comunes Javaescript                                       		*
'* Autor:	Jesús Moreno Sanz	( 626257650 )		Para "Viajes Vidal"		*
'****************************************************************************/


/**************************************************
* Nombre:		LimpiaCampos                      *
* Descripción:	Limpia los campos del Formulario  *
* Paginas:                                        *
*	-	Formulario.asp                            *
***************************************************/
function LimpiaCampos()
{
	document.FormularioConsulta.reset();
}

/**************************************************
* Nombre:		SoloNum.                          *
* Descripcion:	Solo permite insertar numeros     *
* Paginas:                                        *
*	-	Formulario.asp                            *
***************************************************/
function SoloNum()
{ 
	var key=window.event.keyCode;//codigo de tecla. 
	if (key < 48 || key > 57)//si no es numero  
	{
		window.event.keyCode=0;//anula la entrada de texto. 
	}
} 

/**************************************************
* Nombre:		ValidarForm                       *
* Descripcion:	Valida los campos del formulario  *
* Paginas:                                        *
*	-	Formulario.asp                            *
***************************************************/
function ValidarForm()
{
	var bolError = false;
	var n;
	var strMensajeValidacion = "Por favor, complete los siguientes campos obligatorios:\n\n";
	var strMensajeValidacion2 = "Por favor, complete los siguientes campos obligatorios:\n\n";
	var strCampo1=strCampo2=strCampo3=strCampo4=strCampo5=strCampo6="";

	if (document.FormularioConsulta.NombreApellidos.value=="")	strCampo1="- Nombre y Apellidos de la persona que genera la consulta.\n";
	if (document.FormularioConsulta.Dni.value=="") strCampo2="- El Dni.\n";
	if (document.FormularioConsulta.Telefono.value=="") strCampo3="- El Teléfono de contacto\n";
	if (document.FormularioConsulta.Email.value=="") strCampo4="- Email de contacto\n";

	for(n=1;n<=4;n++) if (eval("strCampo"+n+"!=''")) {bolError=true;break;}

	if (bolError)
		alert(strMensajeValidacion + strCampo1 + strCampo2 + strCampo3 + strCampo4 );
	else 
	{

		if ((document.FormularioConsulta.Dni.value.indexOf('-',0)==-1)|| (document.FormularioConsulta.Dni.value.length<10) ) strCampo5="- El Dni debe tener el siguiente formato (xxxxxxxx-X).\n";
		if ((document.FormularioConsulta.Email.value.indexOf('@',0)==-1)||(document.FormularioConsulta.Email.value.indexOf('.',0)==-1)) strCampo6="- El Email no es correccto Ejemp:pedro@hotmil.com.\n";

		for(n=5;n<=6;n++) if (eval("strCampo"+n+"!=''")) {bolError=true;break;}
		if (bolError)
			alert(strMensajeValidacion2 + strCampo5 + strCampo6 );
			if (strCampo5) document.FormularioConsulta.Dni.focus();
			else if (strCampo6)	document.FormularioConsulta.Email.focus();
		else 
		{
			var numero;
			var let;
			numero = document.FormularioConsulta.Dni.value.substring(0,8);
			let =   document.FormularioConsulta.Dni.value.substring(9,10);
			numero = numero % 23;
			letra='TRWAGMYFPDXBNJZSQVHLCKET';
			letra=letra.substring(numero,numero+1);
			if (letra!=let.toUpperCase())
			{ 
				alert ("El numero de Dni introducido no es valido.Pruebe con otr por favor.");
			}
			else
			{
				document.FormularioConsulta.envio.value='si';
				//document.FormularioConsulta.action ="formulario.asp?env=si";
				document.FormularioConsulta.submit();
			}
		}
	}
	return false;
	//event.returnValue = 0;
}
/**************************************************
* Nombre:		Back							  *
* Descripcion:	Monta Background segun resolucion *
* Paginas:                                        *
*	-	Index.html		                          *
***************************************************/
function Back()
{
	var y = Math.floor(screen.height); 
	var x = Math.floor(screen.width); 
	if(x==1024 && y==768)
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_4.jpg';
	}
	else if(x==1280 && y==600)
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_3.jpg';
	}
	else if(x==1280 && y==720)
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_2.jpg';
	}
	else if(x==1280 && y==768)
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_2.jpg';
	}
	else if(x==1280 && y==800)
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_1.jpg';
	}
	else if (x<=1280 && x>=1024)
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_1.jpg';
	}
	else
	{
		document.body.background='Imagenes/BackGround/SanEstebandeGormaz_4.jpg';
	}
}

/**************************************************
* Nombre:		doPopup							  *
* Descripcion:	Monta el PopUp					  *
* Paginas:                                        *
*	-	Index.html		                          *
***************************************************/
function doPopup() 
{
	url = "Paginas/Home.asp";
	width = 890;
	height = 620;
	delay = 1;
	timer = setTimeout("Start(url, width, height)", delay*1000);
}
closetime = 0;

/**************************************************
* Nombre:		Start							  *
* Descripcion:	Lanza el PopUp					  *
* Paginas:                                        *
*	-	Index.html		                          *
***************************************************/
function Start(url, width, height) {
	var y = Math.floor(screen.height); 
	var x = Math.floor(screen.width); 
	windowprops = "width=" + width + ",height=" + height ;
	if (y<=600 || x<=800 )
	{
		alert("Debería cambiar la configuración de su pantalla a una mayor \npara ver correctamente la página 'Viajes Vidal'.");
		preview = window.open(url, "preview", "width=790,height=570,top=0,left=0,scrollbars=yes","windowprops");
	}
	else
	{
		x=(x-width)/2;
		y=((y-height)/2)-20;
		preview = window.open(url, "preview", "width=890,height=620,top="+y+",left="+x+"","windowprops");
	}
	if (closetime) setTimeout("preview.close();", closetime*1000);
 }
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
		var mostrando;

		function Iluminar(f_intNumero)
			{
			//Establece un color de fondo y cambia el cursor
			var strFuente;
			strFuente=eval("nmr"+f_intNumero);
			if (f_intNumero!=mostrando)	strFuente.style.color="#FF6600";
			strFuente.style.cursor='hand';
			} 
		
		function Apagar(f_intNumero)
			{
			//Establece un color de fondo y restaura el cursor predeterminado
			var strFuente;
			strFuente=eval("nmr"+f_intNumero);
			strFuente.style.cursor='default';
			if (f_intNumero!=mostrando) strFuente.style.color="yellow";
			}
		function Pestanna(f_intNumero)
			{
				mostrando=f_intNumero;
				eval("unId"+mostrando+".style.top='1px';");
				eval("nmr"+mostrando+".style.color='white';");
//				eval("pstIzq"+mostrando+".src='../imagenes/pestañas/pestaña_left_select.gif';");
				document.getElementById("pstIzq"+mostrando).src='../imagenes/pestañas/pestana_left_select.gif';
				document.getElementById("pstDrch"+mostrando).src='../imagenes/pestañas/pestana_right_select.gif';
				//document.getElementById("nmr"+mostrando).style.background-image='url(../imagenes/pestañas/pestaña_center_select.gif)';
//				alert(document.getElementById("nmr"+mostrando).style.background)
//				eval("nmr"+mostrando+".style.background.url='../imagenes/pestañas/pestaña_right_select.jpg';");
//				eval("pstDrch"+mostrando+".style.background='none';");
				//eval("unId"+mostrando+"_1.style.visibility = 'hidden';");
			//JND color
				switch(f_intNumero)
				{
					case 1:	//Petición de Servicios
						strColor = '#698DC2';
						break;
					case 2:	//Petición de Inco/Baja
						strColor = '#AF9CC3';
						break;						
					case 4:	//Histórico
						strColor = '#F9E747';
						break;					
					case 5:	//Incidencia
						strColor = '#22A57A';
						break;	
					case 6:	//Aprobaciones
						strColor = '#F48F8C';
						break;		
					case 7:	//Delegaciones
						strColor = '#D9337B';
						break;																		
					case 8:
						strColor = '#32A2C9';
						break;					
				}
			//	eval("nmr"+mostrando+".style.background=strColor;");
				eval("nmr"+mostrando+".style.background='url(../imagenes/pestañas/pestana_center_select.gif)';");
			}


		function Abrir(f_strURLPagina)
			{
				document.forms[0].action=f_strURLPagina;
				document.forms[0].submit();
			}
