<!--

function verificar(){
var theForm = document.forms[0];
var siguiente = true;
var falta="Faltan los datos referente a: "+'\n';

//primero verificar el correo principal
x=document.getElementById('E-mail_principal');
if ( EmailBlanco(x)== false ) {return false;}


for (i=0; i<theForm.elements.length; i++)
{
    if (theForm.elements[i].className == "oblig") 
    {
       switch(theForm.elements[i].type) 
       {
         case "text":
            if (theForm.elements[i].value == ""  ) 
            {
              falta += (theForm.elements[i].id)+'\n';
              siguiente=false;
            }
            break;
         case "textarea" :
            if (theForm.elements[i].value == "" ) 
            {
              falta += theForm.elements[i].id +'\n';
              siguiente=false;
            }
           break;
         case "radio" :
           nombreradio = theForm.elements[i].name;
           siguiente = false;
           nomradio= theForm.elements[i].id;
           while (nombreradio == theForm.elements[i].name)
           { 
              if (theForm.elements[i].checked == true ) {siguiente = true; } 
              i++;
           } 
           i--;
           if (siguiente == false) 
           { 
              falta += theForm.elements[i].id +'\n';
              siguiente=false;
           }
           break;
         case "checkbox" :
           if (theForm.elements[i].checked == false ) 
           {
              falta += theForm.elements[i].id +'\n';
              siguiente=false;
           }
           break;
         case "select-one" :
            if (theForm.elements[i].value == "xx" ) 
            {
              falta += theForm.elements[i].id +'\n';
              siguiente=false;
            }
            break;
       }
    }
}

if (siguiente==false)
{ alert (falta); }
else
{ 
 //mensaje general con todos los datos
  var mensaje = "Se ruega verificar los datos ingresados\n - Si está de acuerdo apoye sobre ACEPTAR o ENTER\n - Si desea modificarlos apoye sobre CANCELAR o ESC\n";
  for(i=0; i<theForm.elements.length-1; i++)
  {
     if (theForm.elements[i].value==undefined)
       { mensaje += '\n'+theForm.elements[i].id+'\n'; }
     else
       {
         if (theForm.elements[i].type != "radio" || theForm.elements[i].checked == true) 
            { mensaje += theForm.elements[i].id+": "+theForm.elements[i].value+'\n'; } 
       }
   }
   siguiente=confirm(mensaje);
}

return (siguiente);
}



function checkEmail(emField){ //reference to email field passed as argument

var fieldValue = emField.value // store field's entire value in variable

//if field is not empty
if(fieldValue != ""){ 
  var atSymbol = 0
  //loop through field value string
  for(var a = 0; a < fieldValue.length; a++){ 
    //look for @ symbol and for each @ found, increment atSymbol variable by 1
    if(fieldValue.charAt(a) == "@"){atSymbol++}
  }
  // if more than 1 @ symbol exists
  if(atSymbol > 1){ 
    // then cancel and don't submit form
    alert("El correo no es válido") 
    return false
  }
  // if 1 @ symbol was found, and it is not the 1st character in string
  if(atSymbol == 1 && fieldValue.charAt(0) != "@"){ 
    //look for period at 2nd character after @ symbol 
    var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) 
    // "." immediately following 1st "." ? 
    var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false 
    //if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
    if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
    // then cancel and don't submit form
    alert("El correo no es válido") 
    return false
  }
}
// no @ symbol exists or it is in position 0 (the first character of the field)
else{ 
  // then cancel and don't submit form
  alert("El correo no es válido")
  return false 
}
}
// if field is empty
else{ 
// then cancel and don't submit form
alert("El correo no es válido")
return false 
}

//all tests passed, submit form
return true
}



//VERIFICAR EMAIL SIN QUE SEA NECESARIO QUE ESTE LLENA LA CASILLA
function EmailBlanco(field){ 
var fieldValue = field.value; 
var salir = true;
var atSymbol = 0;

  for(var a = 0; a < fieldValue.length; a++){ 
    if(fieldValue.charAt(a) == "@"){atSymbol++}
  }
  // if more than 1 @ symbol exists
  if(atSymbol > 1){salir = false;} 
  if(atSymbol == 1 && fieldValue.charAt(0) != "@"){ 
     var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2); 
     var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false; 
     if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)==".")
        {salir = false;}
  }
  else { 
    // no @ symbol exists or it is in position 0
    salir = false; 
  }

  if (fieldValue=="") { salir=true  }

if (salir==false) {  
    alert("el correo "+fieldValue+" no es válido "); 
    field.value="";
    field.focus();
    field.select();
    return false;
   }
else  
   { return true; }
}



// -->


