// JavaScript Document

// JavaScript Document
function divide_string()
{
var where_is_mytool="home/mytool/mytool.cgi";
var mytool_array=where_is_mytool.split("/");
alert(mytool_array[0]+" "+mytool_array[1]+" "+mytool_array[2]);
}

function cotizar(Obj,i){
var z = new Array(); 
var max1;
if(max1<1) { alert('Select an option ')  }
Obj.id = Obj.options[Obj.selectedIndex].value;

x()
}



//ChangeItem('cuarto',frm.cuartos.options[frm.cuartos.selectedIndex].value)
function ChangeItem(objExpand,obj) {
var casillas = 20;  

    for(i=1; i <=obj ; i++){
 		document.getElementById([objExpand + i]).style.display = ""; 
    }
	a=parseInt(obj) +1;  		
	for(var i=a;i<=casillas;i++){
	var t=i-1;
	eval('document.frm.adultos'+ i +'.value='+ 0) ;	
	//eval('document.frm.adultos'+ i +'.id='+0) ;		
	var ar = eval('document.frm.txtvalor' + t );	
	ar.value=0;
		if (ie4) {document.all[objExpand + i].style.visibility = "hidden";}
        if (ns4) {document.layers[objExpand + i].visibility = "hide";}
        if (ns6 || msie) {document.getElementById([objExpand + i]).style.display = "none";} 
	
	
	}

puente()
}

///   Calculo De los Pasajeros Total Adultos , Total Seniors ,Total  Adolecentes Total  Juniors//
function puente(){
	x()
}
	

function x(){
var total = 0;
var a ;
var arreglo = new Array();
var valores = new Array();
var casillas = 20;
arreglo[0] = 'adultos';		
		var total=0;
				
				for(var f=1;f<=casillas;f++){
				ar = eval('document.frm.' + arreglo[0] + f) ;	
				valores=ar.value.split("-");
				total  = total + eval(valores[0]);
				//txt = eval('document.frm.txt' + arreglo[0] ) ;
				//txt.value = total;				
				}				
document.frm.txtpasajero.value = total ;


}


function verificacion() {

	if (document.frm.txtpasajero.value==0){
	return alert('Number of guests \ must be more than 0')
	}else{
		document.frm.action="paso5.php";		
		document.frm.submit();
	}	


}

function numerico(){
   if (Length(document.frmcontacto.txtcountry.value)==0){ 
	  alert('Enter your country')
	  enfoque(document.frmcontacto.txtcountry)   
	  return false; }		
   if (isNaN(document.frmcontacto.txtcountry.value)) 
   	  { 
      alert('Please enter only numbers in Country') 
	  enfoque(document.frmcontacto.txtcountry)
      return false; 
      } 


   if (Length(document.frmcontacto.txtcity.value)==0) {
	  alert('Enter your City Code');
	  enfoque(document.frmcontacto.txtcity)   		
	  return false; }
   if (isNaN(document.frmcontacto.txtcity.value)) 
   	  { 
      alert('Please enter only numbers in City') 
	  enfoque(document.frmcontacto.txtcity)
      return false; 
      } 


	if (Length(document.frmcontacto.txttelefono.value)==0){
	alert('Enter your Telephone number') 
	enfoque(document.frmcontacto.txttelefono)
	return false;
	}
	var strString = document.frmcontacto.txttelefono.value;
   
   var strValidChars = "0123456789-";
   var strChar;
   var blnResult = true;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
		 enfoque(document.frmcontacto.txttelefono)
		 alert('Please enter a valid number')
	    return false;
         }
      }
//validacion  ask

	if (Length(document.frmcontacto.txtask.value)==0){
	alert('Enter your comentary') 
	enfoque(document.frmcontacto.txtask)
	return false;
	}
 
 
 	if (Length(document.frmcontacto.txtfecha.value)==0){
	alert('Enter date') 
	enfoque(document.frmcontacto.txtfecha)
	return false;
	}
 
 	if (Length(document.frmcontacto.txthora.value)==0){
	alert('Enter hour') 
	enfoque(document.frmcontacto.txthora)
	return false;
	}
 
	return true;
 	document.frmcontacto.action= "save_contacto.php";
	document.frmcontacto.submit();
}

/*ENVIAR CONTACTO*/
function enviar_contacto(){
 	document.frmcontacto.action= "save_contacto.php";
	document.frmcontacto.submit();
}



function Length(txtobj){
return txtobj.length

}

function enfoque(obj){
obj.select()
obj.focus(); 
return true
}


	

	function checkTheKey()
	{
	if(event.keyCode==13){
	UsuarioR('validacion_usuario.php');
	return true ;
	}
	return false ;
	}





	function UsuarioR(param1){
	if (checkemail(document.usuario.txtemail.value)== false)
	{
		document.usuario.txtemail.focus()
		document.usuario.txtemail.select()
		return;
	}
	if 	(JStrim(document.usuario.txtclave.value) == 0)
	{
		alert("Please enter your password.")
		document.usuario.txtclave.focus()
		document.usuario.txtclave.select()
		return;
	}
		document.usuario.action =  param1
		document.usuario.submit()
	}	

////-------------------------validacion de cadena ----------------------

//Simula el Trim de VB


	function JSmid(cad,I,Cantidad){			//Simula el Mid de VB
		if (Cantidad == null){
			I = I - 1;
			cad = cad.substring(I,(I + cad.length));
			}
		else{
			I = I - 1;
			cad = cad.substring(I,(I + Cantidad));
			}
		return cad;
		}

	function JSlen(cad){					//Simula el Len de VB
		return cad.length;
		}

	function JStrim(cad){					//Simula el Trim de VB
		Inicio="";
		y = "";
		Final = "";
		x = "";
		for (x=1; x<=JSlen(cad); x=x+1)	{
			if (JSmid(cad,x,1) != " "){
				y = x;
				x = JSlen(cad);
				}
			}
		Inicio = y;
		for (x=JSlen(cad); x>=1; x=x-1){
			if (JSmid(cad,x,1) != " "){
				y = x;
				x = 1;
				}
			}
		Final = y;
		CantidadCaracteres = (Final - Inicio) + 1;
		return JSmid(cad,Inicio,CantidadCaracteres);
		}

	  	var testresults
		function checkemail(value)
		{
			var str = value
			var filter=/^.+@.+\..{2,3}$/

			if (filter.test(str))
				testresults=true
			else
			{
				alert("Please enter a valid e-mail...")
				testresults=false
			}
			return (testresults)
		}
		
		
		
		function cargar(){
		window.usuario.txtemail.focus()
		}
		
		
		

	function clave(value)
		{
			var str = value
			var filter=/^.+@.+\..{2,3}$/

			if (filter.test(str))
				testresults=true
			else
			{
				alert("Do not accept specials caracters ")
				testresults=false
			}
			return (testresults)
		}
				

function hola(parametro){
alert(parametro)
}


var newwindow;
function poptastic_consultor(url)
{
newwindow=window.open(url,'name','height=250,width=450,left=150,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}


var newwindow;
function window_terminos(url)
{
newwindow=window.open(url,'name','height=280,width=450,left=150,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

var newwindow;
function poptastic(url)
{
newwindow=window.open(url,'name','height=250,width=380,left=600,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}