// JavaScript Document

function validar(form){
	 if (form.nombre.value == "")
  { alert("Debe ingresar su nombre y apellido"); 
  form.nombre.focus(); 
  return false; 
  }
   if (form.nombre.value.length < 4) {
    alert("El nombre y apellido debe tener al menos 4 letras");
    form.nombre.focus();
    return false;
  }
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ   " + "abcdefghijklmnopqrstuvwxyz    ";
  var checkStr = form.nombre.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("El nombre y apellido debe tener solo letras"); 
    form.nombre.focus(); 
    return false; 
  }
  if (form.tel.value == "")
	  { alert("Debe ingresar un teléfono"); 
	  form.tel.focus(); 
	  return false; 
  }
  if (form.email.value == "(su correo)" || form.email.value == ""){ 
	  alert("Debe ingresar su dirección de Correo Electrónico");
	  form.email.focus();
	  return false;
	  }
	  else{
	  var Email = form.email.value;
	  var Formato = /^([\w-_\.])+@([\w-]+\.)+([a-z]){2,4}$/;
	  var Comparacion = Formato.test(Email);
	  if(Comparacion == false){
	  alert("Debe ingresar una dirección de Correo Electrónico válida");
	  form.email.focus();
	  return false;
	  }
  }
  if (form.tipo.value == "elija el tipo de fiesta")
	  { alert("Debe elegir el tipo de fiesta"); 
	  form.tipo.focus(); 
	  return false; 
  }
  if (form.fecha.value == "")
	  { alert("Debe ingresar la fecha del evento"); 
	  form.fecha.focus(); 
	  return false; 
  }
  if (form.lugar.value == "")
	  { alert("Debe ingresar el lugar del evento"); 
	  form.lugar.focus(); 
	  return false; 
  }
  if (form.cantidad.value == "")
	  { alert("Debe ingresar la cantidad de invitados"); 
	  form.cantidad.focus(); 
	  return false; 
  }  

  form.submit();
}


   nivel1Actual='';
   nivel2Actual='';
   nivel3Actual='';
   function activaMenuL1(opcion){
       if (nivel1Actual!=''){
	       actual=document.getElementById(nivel1Actual);
		   actual.className='level1_op';
	       nuevo=document.getElementById(opcion);
		   nuevo.className='selected';
		   nivel1Actual=opcion;
	   }else{
	       nuevo=document.getElementById(opcion);
		   nuevo.className='selected';
		   nivel1Actual=opcion;	       
	   }
	   apagaMenuL2(nivel2Actual);
	   
   }
      function activaMenuL2(opcion){
       if (nivel2Actual!=''){
	       actual=document.getElementById(nivel2Actual);
		   actual.className='level2_op';
	       nuevo=document.getElementById(opcion);
		   nuevo.className='selected_l2';
		   nivel2Actual=opcion;
	   }else{
	       nuevo=document.getElementById(opcion);
		   nuevo.className='selected_l2';
		   nivel2Actual=opcion;	       
	   }
   }
      function apagaMenuL2(opcion){
       if (nivel2Actual!=''){
	       actual=document.getElementById(nivel2Actual);
		   actual.className='level2_op';
       }
   }   
   
   function activaMenuL3(opcion){
       if (nivel3Actual!=''){
	       nivel3Actual.className='level3_op';
	   }
       opcion.className='selected_l3'
	   nivel3Actual=opcion;
	   
   }

