// JavaScript Document
function emailCheck (emailStr) {
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) {
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    // user is not valid
     return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	      return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	return false
}

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   return false
}

// If we've gotten this far, everything's valid!
return true;
}
/*
function validar(){
  if(document.cotizacion.lstMake.options[0].selected){
    alert("Seleccione una Marca");
	document.cotizacion.lstMake.focus();
	return false;
  }
   Comentado JC
  if(document.cotizacion.lstModel.options[0].selected){
    alert("Seleccione Clase ");
	document.cotizacion.lstModel.focus();
	return false;
  }
  if(document.cotizacion.lstOptions.options[0].selected){
    alert("Seleccione Estilo");
	document.cotizacion.lstOptions.focus();
	return false;
  }
  
  
  
  if(document.cotizacion.lstColors.options[0].selected){
    alert("Seleccione un Modelo");
	document.cotizacion.lstColors.focus();
	return false;
  }
  if(document.cotizacion.lstVersion.options[0].selected){
    alert("Seleccione una Versión");
	document.cotizacion.lstVersion.focus();
	return false;
  }

  if(document.cotizacion.sucursal.options[0].selected){
    alert("Seleccione la Sucursal");
	document.cotizacion.sucursal.focus();
	return false;
  }

  if(document.cotizacion.apellidos.value==""){
	    alert("Ingrese sus Apellidos");
		document.cotizacion.apellidos.focus();
		return false;
  }

  if(document.cotizacion.nombres.value==""){
     alert("Ingrese sus Nombres");
	 document.cotizacion.nombres.focus();
	 return false;
  }
 if (document.cotizacion.tipo_cliente[1].checked){
    if (document.cotizacion.empresa.value==""){
		 alert("Ingrese Nombre de la empresa si es persona juridica");
		 document.cotizacion.empresa.focus();
		 return false;
	}
 }
 
 
   if(document.cotizacion.telefono.value==""){   	   
    alert("Ingresa Número de Teléfono");
    document.cotizacion.area.focus();
	return false;
  }


  if(document.cotizacion.email.value==""){
	 alert("Ingrese su Correo Electrónico");
	 document.cotizacion.email.focus();
	 return false;
  }

  if(!emailCheck(document.cotizacion.email.value)){
     alert("Dirección de email Incorrecta!");
	 document.cotizacion.email.focus();
	 return false;
  }	 


  if(document.cotizacion.pais.options[0].selected){
    alert("Seleccione Pais de Residencia");
	document.cotizacion.pais.focus();
	return false;
  }

  if(!(document.cotizacion.tipo_cliente[0].checked || document.cotizacion.tipo_cliente[1].checked)){
		 alert("Especificar tipo de Cliente");
	     document.cotizacion.tipo_cliente[0].focus();
		 return false;	
	 }

return true;
}*/
