function frmReservaAlquilar(){
	var fechaIni, fechaFin;
	xform=document.forms["frmReserva"];	
	if( document.getElementById( "uID" ).value=="" ){
		alert("debe seleccionar un producto");
		document.getElementById( "uID" ).focus();			
		return;		
	}		 
	//xform["fechaEntrega"].value		=xform["anoSalida"].value+"-"+xform["mesSalida"].value+"-"+xform["diaSalida"].value+" "+xform["horaSalida"].value+":00:00";
	xform["fechaEntrega"].value		=xform["mesSalida"].value+"-"+xform["diaSalida"].value+" "+xform["horaSalida"].value+":00:00";	
//	xform["fechaDevolucion"].value	=xform["anoVuelta"].value+"-"+xform["mesVuelta"].value+"-"+xform["diaVuelta"].value+" "+xform["horaVuelta"].value+":00:00";
	xform["fechaDevolucion"].value	=xform["mesVuelta"].value+"-"+xform["diaVuelta"].value+" "+xform["horaVuelta"].value+":00:00";
	fechaIni = xform["mesSalida"].value+xform["diaSalida"].value+xform["horaSalida"].value+"0000";
	fechaFin = xform["mesVuelta"].value+xform["diaVuelta"].value+xform["horaVuelta"].value+"0000";
	/*
	if( Number(fechaFin)<=Number(fechaIni) ){
		alert("Verifique la fecha de entrega,  debe ser mayor a la fecha de llevar el vehículo");
		document.getElementById( "horaVuelta" ).focus();			
		return;			
	} */
	xform["doAction"].value="alquilar";
	xform.submit();
}

function frmReservaSubmit( param ){
	
	
	xform=document.frmReserva;
//	alert( document.getElementById( "apellidos" ).value );
	if( document.getElementById( "apellidos" ).value=="" ){
		alert("Apellidos son requeridos");
		document.getElementById( "apellidos" ).focus();
		return;		
	}
	
	if( document.getElementById( "nombres" ).value=="" ){
		alert("Nombres son requeridos");
		document.getElementById( "nombres" ).focus();		
		return;		
	}	
	/*
	if( document.getElementById( "telefono" ).value=="" ){
		alert("Teléfono es requerido");
		document.getElementById( "telefono" ).focus();			
		return;		
	}	
	
	if( document.getElementById( "celular" ).value=="" ){
		alert("Celular es requerido");
		document.getElementById( "celular" ).focus();			
		return;		
	}*/
	/*
	if( document.getElementById( "celular" ).value=="" ){
		alert("Celular es requerido");
		document.getElementById( "celular" ).focus();			
		return;		
	}	*/
	
	if( document.getElementById( "email" ).value=="" ){		
		alert("E-mail es requerido");
		document.getElementById( "email" ).focus();		
		return;		
	}else{
		if( !emailCheck( document.getElementById( "email" ).value ) ){
			return;				
		}
	}		
	/*
	if( document.getElementById( "empresa" ).value=="" ){
		alert("Empresa es requerido");
		document.getElementById( "empresa" ).focus();			
		return;		
	}	*/	
	
	if( document.getElementById( "ruc" ).value=="" ){
		/*
		alert("RUC es requerido");
		document.getElementById( "ruc" ).focus();			
		return;		
		*/
	}else{
		///var ruc = document.getElementById( "ruc" ).value;
		if( isNaN( document.getElementById( "ruc" ).value ) ){
			alert("ruc se requiere solo números");			 
			document.getElementById( "ruc" ).focus();  			
			return;				
		}
		if( document.getElementById( "ruc" ).value.length != 11 ){
			alert("ruc requiere 11 números");			 
			document.getElementById( "ruc" ).focus();			
			return;				 
		}
	}				
	
	if(xform["uID"].value==""){
		alert("debe seleccionar un producto");
		return;
	}
	
	if( param!=1 ){
		document.getElementById( "CoberturaIDS" ).value = buildChkItemsCobertura(xform);	
	}
	
	if( param==1 ){
		xform["doAction"].value="reservar";
	}else{
		xform["doAction"].value="continuar";
	}

	xform.submit();
}

function frmReset(xform, valor ){
	if( valor == 1 ){
		xform["doAction"].value="recargar";		
		xform.submit();
	}else{
		xform.reset();		
	}
}

function cambiarAuto( objForm ){
	if( document.getElementById( "uIDAuto" ).value=="" ){
		alert("debe seleccionar un producto");
		document.getElementById( "uIDAuto" ).focus();	
		document.getElementById( "uIDAuto" ).value=document.getElementById( "uID" ).value;
		return;		
	}else{
		document.getElementById( "uID" ).value=document.getElementById( "uIDAuto" ).value;
	}	
	if( document.getElementById( "idPromocion" )!=null ){
		document.getElementById( "idPromocion" ).value=0;
	}	
	objForm["doAction"].value="alquilar";
	objForm.submit();	
}

function cambiarPromocion( objForm ){
	objForm["doAction"].value="alquilar";
	objForm.submit();	
}


function masProducto(){
	document.getElementById( "masProductos" ).style.display="";
}

function imprimir(num) {
document.getElementById(num).className="ver";
print();
document.getElementById(num).className="nover";
}

function buildChkItemsCobertura(xform)
{
	var chkItems="";
	if(typeof(xform.CoberturaID)!="object"){
       	return;
	}
	
	if(xform.CoberturaID.checked){
       	chkItems=xform.CoberturaID.value;
	}else{
		for(i=0;i<(xform.CoberturaID).length;i++){
			if(xform.CoberturaID[i].checked)
			{
				if (chkItems==""){
					chkItems=xform.CoberturaID[i].value;
				}else{
					chkItems+=","+xform.CoberturaID[i].value;
				}
			}
		}
	}		
	return chkItems;
}

function emailCheck(emailStr) {

	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {
		
		alert("El correo electrónico es incorrecto. Por favor ingréselo correctamente");
		
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		
		alert("El nombre de usuario contiene caracteres inválidos.");
				
		return false;
		}
	}

	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		
		alert("El nombre de dominio contiene caracteres inválidos.");
						
		return false;
		}
	}

	if (user.match(userPat)==null) {
		
		alert("El nombre de usuario no parece ser válido");
							
		return false;
	}

	var IPArray=domain.match(ipDomainPat);

	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
		
			alert("dirección IP es inválido!");
										
			return false;
			}
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		
		alert("El nombre de dominio no parece ser válido.");
												
		return false;
		}
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 &&
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
		
	alert("la direccion de email debe terminar con un dominio correcto o con dos letras del pais");
													
	return false;
	}

	if (len<2) {
		
	alert("Dirección no tiene un Hostname!");
														
	return false;
	}

	return true;
}