<!--// Validar pagina de actualización
function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(typeof haystack[i] == 'object') {
            if(arrayCompare(haystack[i], needle)) return true;
        } else {
            if(haystack[i] == needle) return true;
        }
    }
    return false;
}

<!--// Validar pagina de actualización
function validar_actualizacion_datos(theForm) {
	var miembro_sistema = theForm.miembro_sistema.value;
	if(miembro_sistema == 1){
		
		if (theForm.primerNombre.value == "-1") {
			 alert("Ingrese el primer nombre");
			 theForm.primerNombre.focus();
			 return (false);
		}
		if (theForm.primerApellido.value == "-1") {
			 alert("Ingrese el primer apellido");
			 theForm.primerNombre.focus();
			 return (false);
		}
		if (theForm.sexoId.value == "-1") {
			 alert("Seleccion el sexo");
			 theForm.sexoId.focus();
			 return (false);
		}
		if (theForm.dia.value == "-1") {
			 alert("Seleccione el dia de su nacimiento");
		 theForm.dia.focus();
		 return (false);
		}
		if (theForm.mes.value == "-1") {
			 alert("Seleccione el mes de su nacimiento");
		 theForm.mes.focus();
		 return (false);
		}
		if (theForm.anio.value == "-1") {
			 alert("Seleccione el anio de su nacimiento");
		 theForm.anio.focus();
		 return (false);
		}
		if (theForm.nacionalidad.value == "-1") {
			alert("Seleccione su nacionalidad");
			theForm.nacionalidad.focus();
			return (false);
		}
		if (theForm.direccionCompleta.value == "") {
			alert("Ingrese la direccion completa");
			theForm.direccionCompleta.focus();
			return (false);
		}
		if (theForm.localidad.value < 1) {
			alert("Debe seleccionar su localidad");
			theForm.localidad.focus();
			return (false);
		}
		if (theForm.telefono.value == "") {
			alert("Ingrese el numero de telefono");
			theForm.telefono.focus();
			return (false);
		}
		if (theForm.correoElectronico.value == "") {
			alert("Ingrese el correo electronico");
			theForm.correoElectronico.focus();
			return (false);
		}
		if(!ValidarEmail(theForm.correoElectronico)) {
			alert("Correo electronico invalido");
			theForm.correoElectronico.focus();
			return(false);
		}
		if (theForm.codigo.value == "") {
			alert("Ingrese el codigo (Carné/Cuenta)");
			theForm.codigo.focus();
			return (false);
		}
	}
	<!-- // Ahora validamos las nuevas entradas
	var myVars=new Array("usuarioId","primerNombre","primerApellido","segundoNombre","segundoApellido",
						 "sexoId","dia","mes","anio",
						 "nacionalidad","direccionCompleta","localidad","telefono","correoElectronico",
						 "codigo", "miembro_sistema", "adeId", "modificar", "actualizaId", "estudianteId");
	var sId,arreglo;
	for(var i = 0; i < theForm.elements.length; i++){
		if(!inArray(theForm.elements[i].name, myVars) && theForm.elements[i].type != 'fieldset'){
			sId = theForm.elements[i].id;
			arreglo = sId.split('-');
			if(arreglo[0] ==1){
				if(arreglo[1] == "Texto" || arreglo[1] == "TextoGrande")
					if(theForm.elements[i].value ==""){
						alert("Todos los datos con * son obligatorios");
						theForm.elements[i].focus();
						return(false);
							
					}
				if(arreglo[1] == "Numero")
					if(theForm.elements[i].value =="-1"){
						alert("Debe seleccionar todos los select con * son obligatorios");
						theForm.elements[i].focus();
						return(false);
							
					}
				if(arreglo[1] == "Localidad")
					if(theForm.elements[i].value < 1){
						alert("Debe elegir la localidad correspondiente");
						theForm.elements[i].focus();
						return(false);
							
					}
				if(arreglo[1] == "Fecha")
					if(!checkdate(theForm.elements[i]))
						return false;
			}
			}
		}
	if(confirm('¿Esta seguro que desea modificar los datos?')){
		submitform(theForm,'personal/grabar_actualizacion_datos.php','process_ajax2',validatetask);
		}
}
//Validando fecha
function checkdate(input){
var validformat=/^\d{4}-\d{2}-\d{2}$/ //Basic check for format validity
var returnval=false
if (!validformat.test(input.value))
alert("Recuerde el formato debe ser AAAA-MM-DD. Porfavor corrija.")
else{ //Detailed check for valid date ranges
var monthfield=input.value.split("-")[1]
var dayfield=input.value.split("-")[2]
var yearfield=input.value.split("-")[0]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Fecha invalida. Por favor corrija.")
else
returnval=true
}
if (returnval==false) input.select()
return returnval
}
<!--// Validar las contadores
function ampliar_pantalla(amp){
	if(amp){
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';
	}else{
		document.getElementById('light').style.display='none';
		document.getElementById('fade').style.display='none';	
	}
}
<!--// Validar las contadores
function isDate(mm,dd,yyyy) {
   var d = new Date(mm + "/" + dd + "/" + yyyy);
   return d.getMonth() + 1 == mm && d.getDate() == dd && d.getFullYear() == yyyy;
}
function MayorQueHoy(mm,dd,yyyy) {
   var hoy = new Date();
   hoy.setDate(hoy.getDate());
   var d = new Date(mm + "/" + dd + "/" + yyyy);
   return(hoy < d);
}
function MayorEntreDos(mm,dd,yyyy, mm2,dd2,yyyy2) {
   var menor = new Date(mm + "/" + dd + "/" + yyyy);
   var mayor = new Date(mm2 + "/" + dd2 + "/" + yyyy2);
   return(menor < mayor);
}
function textCounter(field,maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
	mayornumber = maxlimit + 1;
    alert( 'Usted puede Ingresar unicamente ' + mayornumber + ' Caracteres');
    return false;
  }
 
}
<!--// Validar Email
function validarNumero(item){
	if(item.value.match(/^-?\d+(\.\d+)?$/)){
		return false;
	}
	else{
		return true;	
	}
}
function  ValidarEmail(item)
{
    var checkOK = "0123456789-.@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
    var checkStr = item.value;
    var allValid = true;
    var decPoints = 0;
    var posarroba = 0;
    var cantarroba=0;
    var allNum = "";
	
	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(ch == "@"){
		   allNum += "@";
		   posarroba = i;
		   cantarroba ++;
		}
		else if(ch == ".")
		{
			allNum += ".";
			decPoints++;
        }		
		else
		{
			allNum += ch;
		}
	}
	if(cantarroba > 1){
		allValid = false;
	}
	if(cantarroba <1){
		allValid = false;
	}
		
	if(posarroba == 0){
	    allValid = false;
	}
	if(decPoints < 1){
		allValid = false;
	}
	return (allValid);
}
function allSelect()
{
List = document.forms[0].elements["destinatarios[]"];
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
function seleccionar_todo_select(nombre)
{
List = document.forms[0].elements[nombre];
for (i=0;i<List.length;i++)
{
	List.options[i].selected = true;
}
}
function poptastic(url, name)
{
    name=window.open(url, name,'height=725,width=760');
	if (window.focus) {name.focus()}
}
function nueva_ventana(url, name, ancho, alto, para)
{
	para= typeof(para) != 'undefined' ? String(para) : "";
    var argumentos = "height="+String(alto)+",width="+String(ancho)+para;
	name=window.open(url, name, argumentos);
	if (window.focus) {name.focus()}
}
function poppresentacion(url, name)
{
    name=window.open(url, name,'height=325,width=575');
	if (window.focus) {name.focus()}
}
