var SYMBOL_DATE_NUM = 47;							//Para el '/'
var SYMBOL_DATE_NUM_CONV = 45;						//Para el '-'

var SYMBOL_DATE = "/";								//Puede ser '-' o '/'
var SYMBOL_DATE_CONV = "-";							//Para uso de la BD Oracle solamente
var SYMBOL_DATE_NUMOUT = SYMBOL_DATE_NUM_CONV;		//Para el algoritmo de validación de fecha


/* CENTRADO DE LOS FORMULARIOS*/

//<script>
function centrar() {
    iz=(screen.width-document.body.clientWidth) / 2;
    de=(screen.height-document.body.clientHeight) / 2;
    moveTo(iz,de);
}
//</script>

function cerrar() {
var ventana = window.self;
ventana.opener = window.self;
ventana.close();
}

function contactenos(pagina)
{
   window.open (pagina,'titulo','scrollbars=no,status=no,resizable=no,toolbars=0,location=0,directories=0,menubar=0,width=610,height=350');
}

function reservas(pagina)
{
   window.open (pagina,'titulo','scrollbars=no,status=no,resizable=no,toolbars=0,location=0,directories=0,menubar=0,width=625,height=582');
}


function flipImage(url)
{
    if (window.event.srcElement.tagName == "IMG" ) {
        window.event.srcElement.src = url;
    }
}

function noClick()
{
   var a;
   if(event.type == 'mousedown' && event.button == 2)
   {
     alert("Elaborado en los talleres de Mundo IT S.A.C.");
   }
}

        function fn_AYUD_GEN_FECHA(opcion) {
                switch (opcion)
                {
                        case 1 : {
                                                fecha=document.wfrmPropuestaServicio.txtFecInicio;
                                                break;
                                         }
                        case 2 : {
                                                fecha=document.wfrmPropuestaServicio.txtFecFin;
                                                break;
                                         }
                        case 3 : {
                                                fecha=document.wfrmRegVoluntarios.txtFechaNac;
                                                break;
                                         }
                        case 4 : {
                                                fecha=document.wfrmTerminoReferencia.txtFecha;
                                                break;
                                         }
                        case 5 : {
                                                fecha=document.wfrmProfReq.txtFecIni;
                                                break;
                                         }
                        case 6 : {
                                                fecha=document.wfrmProfReq.txtFecFin;
                                                break;
                                         }
                        case 9 : {
                                                fecha=document.listado.txt_fec_inicio;
                                                break;
                                         }
                        case 10 : {
                                                fecha=document.listado.txt_fec_fin;
                                                break;
                                         }
                        case 11 : {
                                                fecha=document.listado.txt_fec_inicio1;
                                                break;
                                         }
                        case 12 : {
                                                fecha=document.listado.txt_fec_fin1;
                                                break;
                                         }
                        case 13 : {
                                                fecha=document.llenado.txt_fec_inicio;
                                                break;
                                         }
                        case 14 : {
                                                fecha=document.llenado.txt_fec_fin;
                                                break;
                                         }
                        case 15 : {
                                        fecha=document.llenado.txt_fecinicioest;
                           break;
                        }
                        case 16 : {
                                        fecha=document.llenado.txt_fecfinest;
                           break;
                        }
                        case 17 : {
                                        fecha=document.listado.txt_fecinicio
                           break;
                        }
                        case 18 : {
                                        fecha=document.listado.txt_fecfin;
                           break;
                        }
                        case 19 : {
                                        fecha=document.listado.txt_fec_creaini;
                           break;
                        }
                        case 20 : {
                                        fecha=document.listado.txt_fec_creafin;
                           break;
                        }
                }

                var myWindow=window.open('calendario.htm','windowref','location=no,width=250,height=295,scrollbars=no,top=140,left=250');
                myWindow.location.href = 'calendario.htm';
                if (!myWindow.opener)
                        myWindow.opener=self;

        }

        function fn_AYUD_GEN_MES_Y_ANO(opcion) {
                switch (opcion)
                {
                        case 2 : {
                                                fecha=document.listado.txt_fec_publicacion;
                                                break;
                                         }
                                                 case 4 : {
                                                fecha=document.llenado.txt_fecinicioest;
                                                break;
                                                                                                 }                                 
                        case 5 : {
                                                fecha=document.llenado.txt_fecfinest;
                                                break;
                                         }
                                                case 6 : {
                                                fecha=document.listado.txt_fec_retiro1;
                                                break;
                                         }
                                                case 7 : {
                                                fecha=document.listado.txt_fecinicio;
                                                break;
                                                                                                 }                                 
                        case 8 : {
                                                fecha=document.listado.txt_fecfin;
                                                break;
                                         }
                                                
                                                                                 
                }

                var myWindow=window.open('mya_picker.htm','windowref','location=no,width=160,height=10,scrollbars=no,top=140,left=250');
                myWindow.location.href = 'mya_picker.htm';
                if (!myWindow.opener)
                        myWindow.opener=self;

        }


        function aceptaEntero(evt){
        // NOTA: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
                var key = evt.keyCode;
                if (!(key <= 13 || (key >= 48 && key <= 57))) {
                        window.event.keyCode="";
                }
        }

        function aceptaFlotante(evt,obj){
        // NOTA: Backspace = 8, Enter = 13, '0' = 48, '9' = 57, '.' = 46
                var key = evt.keyCode;
                var cad = obj.value;
                if (!(key <= 13 || (key >= 48 && key <= 57) || key == 46)) {
                        window.event.keyCode="";
                }
                if ((cad.indexOf('.')>0) && (key == 46)) {
                        window.event.keyCode="";
                }
        }

        function aceptaCadena(evt){
        // NOTA: Backspace = 8, Enter = 13, 'A' = 65, 'Z' = 90 , 'a' = 97 , 'z' = 122 , '.' = 46 , '-' = 45
        //       '_' = 95 , '(' = 40, ')' = 41, '0' = 48, '9' = 57 , SPACE = 32
                var key = evt.keyCode;
                if (!(key <= 13 || (key == 32) || (key >= 47 && key <= 57) || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || key == 46 || key == 45 || key == 95 || key == 40 || key == 41  || key == 241 || key == 109 || key == 130 || (key >= 160 && key <=163) || key == 225 || key == 233 || key == 237 || key == 243 || key == 250 || key == 44 || key == 46 || key == 43 || key == 58 || key == 209  )) {
                        window.event.keyCode="";
                }
        }

        function aceptaCadenaNoEnter(evt){
        // NOTA: Backspace = 8, Enter = 13, 'A' = 65, 'Z' = 90 , 'a' = 97 , 'z' = 122 , '.' = 46 , '-' = 45
        //       '_' = 95 , '(' = 40, ')' = 41, '0' = 48, '9' = 57 , SPACE = 32
                var key = evt.keyCode;
                if (!(key < 13 || (key == 32) || (key >= 48 && key <= 57) || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || key == 46 || key == 45 || key == 95 || key == 40 || key == 41  || key == 241 || key == 109 || key == 130 || (key >= 160 && key <=163) || key == 225 || key == 233 || key == 237 || key == 243 || key == 250 || key == 44 || key == 46 || key == 43 || key == 58 || key == 209 )) {
                        window.event.keyCode="";
                }
        }

        function aceptaMail(evt){
        // NOTA: Backspace = 8, Enter = 13, 'A' = 65, 'Z' = 90 , 'a' = 97 , 'z' = 122 , '.' = 46 , '-' = 45
        //       '_' = 95 , '(' = 40, ')' = 41, '0' = 48, '9' = 57 , SPACE = 32
                var key = evt.keyCode;
                if (!(key <= 13 || (key >= 48 && key <= 57) || key == 64 || (key >= 97 && key <= 122) ||  key == 95 || key == 46)) {
                        window.event.keyCode="";
                }
        }

    function noEscritura(evt){
                window.event.keyCode="";
        }

    function aceptaCodigo(evt){
        // NOTA: Backspace = 8, Enter = 13, 'A' = 65, 'Z' = 90 , 'a' = 97 , 'z' = 122 , '0' = 48, '9' = 57
                var key = evt.keyCode;
                if (!(key <= 13 || (key >= 48 && key <= 57) || (key >= 65 && key <= 90) || (key >= 97 && key <= 122))) {
                        window.event.keyCode="";
        }
    }
    function validaEmail(email)
        {
                var re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
                if (!re.test(email)) {
                        return false;
                }
                return true;
        }
		
	function habilita()
	{	
		
		document.frm.dom.disabled = false;
		document.frm.des.disabled = false;

	}
	function deshabilita()
	{ 
		
		document.frm.dom.disabled = true;
		document.frm.des.disabled = true;
	
	}
	
		var tot,res1=0,res2=0,res3=0;
		var resultado;
		
		function mostr(combo,indice,num)
			{								
				var valor = combo.options[indice].value;
				
				 if (document.frm.seleccion[0].checked) {
				 	
					if (num==1){
						if (valor==0)
							res1=25;
						if (valor==1)
							res1=40;
						if (valor==2)
							res1=70;
						if (valor==3)	
							res1=0;											
					}
					
					if (num==2){
						if (valor==0)
							res2=10;
						if (valor==1)
							res2=35;		
						if (valor==2)
							res2=0;						
					}
					
					if (num==3){
						if (valor==0)
							res3=130;
						if (valor==1)
							res3=180;
						if (valor==2)
							res3=350;			
						if (valor==3)
							res3=0;
					}					
					
					tot=res1+res2+res3;
					resultado="$ " + tot;
					
					document.frm.valhos.value="$ " +res1;
					document.frm.valdom.value="$ " +res2;
					document.frm.valdes.value="$ " +res3;
				 }
				 else{
				 	
					if (valor==0)
						resultado="$ 140";
					if (valor==1)
						resultado="$ 210";
					if (valor==2)
						resultado="$ 390";			
					if (valor==3)
				 		resultado="$ 0";		
						
					document.frm.valhos.value=resultado;
						
				 }
				
				
				document.frm.answer.value=resultado;
			}							
	
	
	
	var remplaza = /\+/gi; 
	var url = window.location.href;
	
	url = unescape(url);
	url = url.replace(remplaza, " ");
	
	
	function obtener_valor(variable) 
	{ 
	var variable_may = variable;
	var variable_pos = url.indexOf(variable_may);
	
	if (variable_pos != -1) 
	{
	var pos_separador = url.indexOf("&", variable_pos);
	
	if (pos_separador != -1) 
	{
	return url.substring(variable_pos + variable_may.length + 1, pos_separador);
	} else
	{
	return url.substring(variable_pos + variable_may.length + 1, url.length);
	}
	} else 
	{
	return "";
	}
	}

	function combovalor(){

		var va=obtener_valor('val');
		var ve=obtener_valor('vd');
		var vi=obtener_valor('pc');
		var dom=obtener_valor('domain');
		
		if (dom==null)
			document.frm.txtdominio.value="";
		else
			document.frm.txtdominio.value=dom;
		
		if (va != null){
			if (va==25){
				document.frm.hos.selectedIndex=1;
				res1=25;
				document.frm.valhos.value="$ 25";
				document.frm.answer.value="$ 25";
			}
			
			if (va==40){
				document.frm.hos.selectedIndex=2;
				res1=40;
				document.frm.valhos.value="$ 40";
				document.frm.answer.value="$ 40";
			}
			
			if (va==70){
				document.frm.hos.selectedIndex=3;
				res1=70;
				document.frm.valhos.value="$ 70";
				document.frm.answer.value="$ 70";
			}
		}
		
		if (ve != null){
			if (ve==130){
				document.frm.des.selectedIndex=1;
				res3=130;
				document.frm.valdes.value="$ 130";
				document.frm.answer.value="$ 130";
			}
			
			if (ve==180){
				document.frm.des.selectedIndex=2;
				res3=180;
				document.frm.valdes.value="$ 180";
				document.frm.answer.value="$ 180";
			}
			
			if (ve==350){
				document.frm.des.selectedIndex=3;
				res3=350;
				document.frm.valdes.value="$ 350";
				document.frm.answer.value="$ 350";
			}
		}
		
		if (vi != null){
			if (vi==140){
				document.frm.hos.selectedIndex=1;
				document.frm.des.selectedIndex=1;	
				document.frm.valhos.value="$ 25";				
				document.frm.valdes.value="$ 130";
				document.frm.answer.value="$ 140";
			}
			
			if (vi==210){
				document.frm.hos.selectedIndex=2;
				document.frm.des.selectedIndex=2;	
				document.frm.valhos.value="$ 40";				
				document.frm.valdes.value="$ 180";
				document.frm.answer.value="$ 210";
			}
			
			if (vi==390){
				document.frm.hos.selectedIndex=3;			
				document.frm.des.selectedIndex=3;	
				document.frm.valhos.value="$ 70";				
				document.frm.valdes.value="$ 350";
				document.frm.answer.value="$ 390";
			}
			
			//document.frm.dom.selectedIndex=1;
			//res2=10;
			//document.frm.valdom.value="$ 10";
			//document.frm.answer.value="$ 10";
			document.frm.seleccion[0].checked=true;
		}
	
}


function verifica(formu) {
	
	var vermail=ValidarEmail(formu.txtMail.value);

	if ((formu.txtNombre.value == "") || (formu.txtNombre.value== null)) {
	alert("Debe ingresar nombre de Contacto"); 
	formu.txtNombre.focus();
	return false;
	}
	else
	if ((formu.txtDireccion.value == "") || (formu.txtDireccion.value== null)) {
	alert("Debe ingresar Dirección, lugar de residencia."); 
	formu.txtDireccion.focus();
	return false;
	}
	else 
	if ((formu.txtTelefono.value == "") || (formu.txtTelefono.value== null)) {
	alert("Debe ingresar número de Teléfono"); 
	formu.txtTelefono.focus();
	return false;
	}	
	else
	if ((formu.txtMail.value == "") || (formu.txtMail.value== null) || (vermail==false)) {
	alert("Dirección E-mail no valida o no ingresada"); 
	formu.txtMail.focus();
	return false;
	}	
	else
	if ((formu.Tour.value == 0)) {
	alert("Debe elegir el Tour de su preferencia."); 
	formu.ubi.focus();
	return false;
	}	
    else 
	return true;	
	
}

function verificaterminos(formu) {
	
	if (formu.acepto.checked  == false)  {
	alert("You must read terms and conditions  of this service, then check it."); 
	return false;
	}
	else 
	return true;	
}



function probar()
	{ 
		var val=verifica(prueba);
		if (val == true){
			document.prueba.action='http://www.mundoit.com.pe/pruebahost.php'
			document.prueba.submit();
		}
		
	}

function enviar()
	{ 
		var valida=verifica(frm);
		if (valida == true) {
		var terminos=verificaterminos(frm);
		if ((valida == true) && (terminos == true)) {
			valores()
			document.frm.action='envia_reserva.php'
			document.frm.submit();
		}
		}
	}


function enviar_peru()
	{ 
		var valida=verifica(frm);
		if (valida == true) {
		var terminos=verificaterminos(frm);
		if ((valida == true) && (terminos == true)) {
			valores_peru()
			document.frm.action='envia_reserva_peru.php'
			document.frm.submit();
		}
		}
	}

function valores(){
	var a=document.frm.Tour.value;
	var b=document.frm.Adul.value;
	var c=document.frm.Menor.value;
    document.frm.txtTour.value=a;
    document.frm.txtAdul.value=b;
    document.frm.txtMenor.value=c;
}

function valores_peru(){
	var a=document.frm.Tour.value;
	var b=document.frm.Adul.value;
	var c=document.frm.Menor.value;
	var e=document.frm.destino.value;
	
    document.frm.txtTour.value=a;
    document.frm.txtAdul.value=b;
    document.frm.txtMenor.value=c;
    document.frm.txtDest.value=e;
	
}


function ValidarEmail(email){
    var cadena = "Direccion de correo no valida: " + email;     

    if( email.indexOf('@',0) <= 0  || email.indexOf(';',0) != -1
     || email.indexOf(' ',0) != -1 || email.indexOf('/',0) != -1
     || email.indexOf(';',0) != -1 || email.indexOf('<',0) != -1
     || email.indexOf('>',0) != -1 || email.indexOf('*',0) != -1
     || email.indexOf('|',0) != -1 || email.indexOf('`',0) != -1
     || email.indexOf('&',0) != -1 || email.indexOf('$',0) != -1
     || email.indexOf('!',0) != -1 || email.indexOf('"',0) != -1
     || email.indexOf(':',0) != -1 )
       { return false; }
    else return true;
    }


