function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

function valida() {
var bgMal = "#e6f3ff";
var bgBien = "#FFFFFF";
if (document.RESERVAS.Tipo.selectedIndex == 0 )
        {    alert("Por favor, seleccione Presupuesto o Reserva")
		    document.RESERVAS.Tipo.focus();
			setColor(document.RESERVAS.Tipo, bgMal)
			return ;
        }
else {
    setColor(document.RESERVAS.Tipo, bgBien);
}
if (document.RESERVAS.Base.selectedIndex == 0 )
        {    alert("Por favor, seleccione una flotilla o una base charter")
		    document.RESERVAS.Base.focus();
			setColor(document.RESERVAS.Base, bgMal)
			return ;
        }
else {
    setColor(document.RESERVAS.Base, bgBien);
}
if (document.RESERVAS.Barco.value == "" || document.RESERVAS.Barco.value == null)
      {		fError(document.RESERVAS.Barco,"Por favor, un barco o su Refª") 
			document.RESERVAS.Barco.select();
			document.RESERVAS.Barco.focus();
			setColor(document.RESERVAS.Barco, bgMal)
			return ;
}
 else {
    setColor(document.RESERVAS.Barco, bgBien);
}
if (document.RESERVAS.Nombre.value == "" || document.RESERVAS.Nombre.value == null)
      {		fError(document.RESERVAS.Nombre,"Por favor, escriba su NOMBRE") 
			document.RESERVAS.Nombre.select();
			document.RESERVAS.Nombre.focus();
			setColor(document.RESERVAS.Nombre, bgMal)
			return ;
} else {
    setColor(document.RESERVAS.Nombre, bgBien);
}
if (document.RESERVAS.Telefono.value == "" || document.RESERVAS.Telefono.value == null)
      {		fError(document.RESERVAS.Telefono,"Por favor, escriba un telefono de contacto") 
			document.RESERVAS.Telefono.select();
			document.RESERVAS.Telefono.focus();
			setColor(document.RESERVAS.Telefono, bgMal)
			return ;
} else {
    setColor(document.RESERVAS.Telefono, bgBien);
}
if (document.RESERVAS.email.value == null || document.RESERVAS.email.value == "") 
		{  
			setColor(document.RESERVAS.email, bgMal)
			document.RESERVAS.email.select()
			document.RESERVAS.email.focus()
			window.alert ("Debe rellenar obligatoriamente el campo EMAIL")
			return 
		}
		else		
		{ 	if (document.RESERVAS.email.value.indexOf ("@",0) == -1) 
				{   setColor(document.RESERVAS.email, bgMal)
				   document.RESERVAS.email.focus()
				   document.RESERVAS.email.focus()
				   window.alert ("Debe rellenar correctamente el campo EMAIL")
				  return
			}
		}

document.RESERVAS.action="http://www.canalmar.com/bases/reservas/reservasn2.asp";
document.RESERVAS.submit();

}
function fError(elem, text) 
{

   window.alert(text)
   elem.select()
   elem.focus()
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}


