﻿// JScript File

document.onkeydown=function (evt) {return (evt ? evt.which : event.keyCode) != 13;}

function valida_fecha(valor) { 

    if (valor!="") { 
    var fecha2= valor 

    var pos1b=fecha2.indexOf("/",0) 
    var pos2b=fecha2.indexOf("/",4) 

    if (pos1b==-1 || pos2b==-1){ 
        alert('Debe introducir una fecha del tipo dd/mm/aaaa') 
        //document.getElementById("txtDate").value="";
        //document.getElementById("txtDate").focus();
        return false;
    }else{ 
        dia2=parseInt(fecha2.substr(0,pos1b)) 
        mes2=parseInt(fecha2.substr(pos1b+1,pos2b-pos1b)) 
        anno2=parseInt(fecha2.substr(pos2b+1)) 
    if (mes2>=13 || dia2>=32 || anno2<=999 || isNaN(mes2) || isNaN(dia2) || isNaN(anno2)) { 
        alert('Debe introducir una fecha del tipo dd/mm/aaaa') 
        //document.getElementById("txtDate").value="";
        //document.getElementById("txtDate").focus();
        return false;
    } 
}
 return true; 
}
}
 function fecha(){
	if (valida_fecha(document.getElementById("FechaNac").value)==false){
    document.getElementById("FechaNac").value="";
    document.getElementById("FechaNac").focus();
	}
	}

function blanquear(Control){

document.getElementById(Control).value = "";
}
	
//function valEmail(document.getElementById('TxtEmail').value){
//re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
//if(!re.exec(valor)){
//alert('NO');}
//else{
//alert('Si');
//}
//}

 /********************************************************/
// Temporizador  Para mantener activa la sesion en la orden de compra.
/********************************************************/


var timerID = 0;
var tStart  = null;
function UpdateTimer() {

   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();

   tDate.setTime(tDiff);


    if (tDate.getSeconds()>2) { 
         //alert("Activo");
         clsAdmin.VerificarSesion(Session_CallBack);
         tDate.valueOf 
        Stop();                    
    }


   timerID = setTimeout("UpdateTimer()", 5000);
}

function Start() {
   tStart   = new Date();
   timerID  = setTimeout("UpdateTimer()", 5000);
   //alert("Inicio");
}

function Stop() {

   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function Reset() {
   tStart = null;
}

function Session_CallBack(response){
    var valor = response.value
        return;
        //alert(valor);  
} 

