function valida_horas(edit){
      if(event.keyCode<48 || event.keyCode>57){
        event.returnValue=false;
      }
      if(edit.value.length==2 || edit.value.length==6	){
        edit.value+=":";}
}
function esnumero(campo){ return (!(isNaN( campo )));}
//----------------------------------------------------------------------
function esnulo(campo){ return (campo == null||campo=="");}
//----------------------------------------------------------------------
function ValidaNro(cc){
	if ( esnulo(cc.value) ){
	  alert('Debes de Ingresar un N&#176; V&#225;lido')
	  cc.focus(); 
	  return true;	  	
	}
	if ( !esnumero(cc.value) ){
	  alert('El N&#250;mero Ingresado no es v&#225;lido')
	  cc.focus();
	  return true;	  
	}
return false;	
}
//----------------------------------------------------------------------
function Validarcampovacio(ls_campovacio)
{
    for ( ls_indicex = 0; ls_indicex < ls_campovacio.length; ls_indicex++ ) {
        if ( ls_campovacio.charAt(ls_indicex) != " " ) {
          return true
        }
    }
    return false
}
//----------------------------------------------------------------------
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
//----------------------------------------------------------------------
function isValidDate (myDate,sep) {
// Valida la Fecha Ingresada
// mydate : Fecha Ingresada
// Sep    : Separador '/','-'
    var hoy = new Date();    
    
    if (myDate.length == 10) {
        
        if (myDate.substring(2,3) == sep && myDate.substring(5,6) == sep) {
            var date  = myDate.substring(0,2);
            var month = myDate.substring(3,5);
            var year  = myDate.substring(6,10);
            var test = new Date(year,month-1,date);
            //if ( parseInt(year) > parseInt(hoy.getYear()) ){
            //if ( test > hoy ){
              //alert("El a&#241;o no puede mayor al actual");
              //return false;
            //}

            if (year == y2k(test.getYear()) && (month-1 == test.getMonth()) && (date == test.getDate())) {
                reason = '';
                //alert("perfecto");
                return true;
            }
            else {
                //alert("valid format but an invalid date");
                return false;
            }
        }
        else {
            //alert("invalid spearators");
            return false;
        }
    }
    else {
        //alert("invalid length");
        return false;
    }
}

//-----------------------------------------------------------------------
function f_obtener_fechaactual(){
// Fecha Actual del Sistema

  now = new Date();
  dia = now.getDay()
  if (dia==0){dia="Domingo"};
  if (dia==1){dia="Lunes"};
  if (dia==2){dia="Martes"};
  if (dia==3){dia="Miercoles"};
  if (dia==4){dia="Jueves"};
  if (dia==5){dia="Viernes"};
  if (dia==6){dia="Sabado"};

  
  fecha = now.getDate();
  mes = now.getMonth();
  
  if (mes==0){mes="Enero"};
  if (mes==1){mes="Febrero"};
  if (mes==2){mes="Marzo"};
  if (mes==3){mes="Abril"};
  if (mes==4){mes="Mayo"};
  if (mes==5){mes="Junio"};
  if (mes==6){mes="Julio"};
  if (mes==7){mes="Agosto"};
  if (mes==8){mes="Septiembre"};
  if (mes==9){mes="Octubre"};
  if (mes==10){mes="Noviembre"};
  if (mes==11){mes="Diciembre"};
 
  annio = now.getYear();
  document.write(dia + " " + fecha + " de " + mes + " del " + annio)
}
//----------------------------------------------------------------------
function Cerrar(){ 
  window.close()
}

//----------------------------------------------------------------------
function validarCaracterFecha(){
	  		var objeto = validarCaracterFecha.arguments[0];
  	  	var wKey = window.event.keyCode;
 	  		valor = objeto.value;
	 	  	var nAnt = 0;
   			n = valor.length;
	   		if (n > 0){
		    		for(var i=0; i< n ; i++){
			    		if(nAnt < n){
				    		if(n==2 && i==1) objeto.value = valor+"/";
					    	if(n==5 && i==3) objeto.value = valor+"/";
						    //if(n==4 && i==1) objeto.value = valor+"/";
  						  //if(n==7 && i==1) objeto.value = valor+"/";
	  		      }
		  		  }
			    }
			    nAnt = n;
    }	
    
//----------------------------------------------------------------------    
function SeleccionarCampo(campo, valor){
  for(var i = 0; i < document.forms[0].elements.length; i++){
    if (document.forms[0].elements[i].name==campo){
      for(var j=0; j< document.forms[0].elements[i].length; j++){      
        if (document.forms[0].elements[i].options[j].value==valor){
          document.forms[0].elements[i].options[j].selected=true;
        }
      }
    }    
  }
}

//----------------------------------------------------------------------
function isEmail(e) {   
    ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
    for(i=0; i < e.length ;i++){
        if(ok.indexOf(e.charAt(i))<0){ 
            return (false);
        }	
    } 
    re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
    re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if (!e.match(re) && e.match(re_two)) {
        return (-1);
    }
}
function vacio(q) {
        for ( i = 0; i < q.length; i++ ) {
                if ( q.charAt(i) != " " ) {
                        return true
                }
        }
        return false
}

function valida(F) {
        
        if( vacio(F.value) == false ) {                
                return false
        } else {
                //cambiar la linea siguiente por return true para que ejecute la accion del formulario
                return true
        }
        
}

