/***************************/
function validar_login(){
	var di = ifrm_login.document.frm;
	var d  = document.frm;
	if(d.usuario.value == ''){
		alert("Debe ingresar un usuario!");
		d.usuario.focus();	
		return false;
	} else if ( d.clave.value == ''){
		alert("Debe ingresar una clave!");
		d.clave.focus();
		return false;
	} else {			
		d.action = "iframe/login.php";
		d.target = "ifrm_login";
		d.submit();
		return true;
	}
}
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) {
    var ok=false; document.MM_returnValue = false;
    with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
       ok=(plugins && plugins[plgIn]);
    } else if (appVersion.indexOf('3.1')==-1) {
       if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
       else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
       else ok=autoGo; }
	   //alert(ok);
    if (!ok) {
		//alert("1");
		//alert(theURL);
		theURL=altURL; 
		theURL="player/install_flash_player.exe";
		window.location=theURL;
	}
	//if (theURL) {
		//alert("2");
		//alert(theURL);
		//window.location=theURL;
	//}
}
/***************************/
<!-- Esconde esto de navegadores antiguos
//  if (window != window.top)
//	 top.location.href = location.href;
// -->

<!--
/*
var message="";
function clickIE(){if (document.all){(message);return false;}}
function clickNS(e){if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else	{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
*/
// -->
function verespera(bver){
if (bver==1){
//swait.style.font = 'Tahoma';
swait.style.fontWeight = 'bold';
swait.style.fontSize = '16';
swait.style.fontStyle = 'Italic';
swait.style.fontFamily = "'Tahoma', 'Arial', 'Times New Roman'";
swait.innerHTML = 'Cargando: espere por favor....';
swait.style.visibility = 'visible';}else{swait.style.visibility = 'hidden';}}
function keyvalid(){
var ieKey=event.keyCode;
if ((ieKey >=48) && (ieKey<=57)){return;}// 0 - 9
if ((ieKey >=65) && (ieKey<=90)){return;}// A - Z
// a - z  - ñ - ó - ú
if ( ( (ieKey >=97) && (ieKey<=122) ) || (ieKey==241) || (ieKey==243) || (ieKey==250) ){return;}
// ' - ,
if ( (event.shiftKey) || (event.ctrlKey ) || (event.altKey) || (ieKey==39) || (ieKey==44) )
   {event.returnValue = false;return;}
if (ieKey!=13){return;}else{lostfocus();}
return;}
function keyfull(){
if (event.ctrlKey==true || event.altKey==true || event.shiftKey==true || event.keyCode==9 || event.keyCode==16 || event.keyCode==17 || event.keyCode==18 || event.keyCode==20 ){return;}
var field = document.activeElement
if (field.type!='text'){return;}
if (field.value.length>=field.maxLength){lostfocus();}
else{event.returnValue=true;return;}
return;}
function lostfocus(){
var field= document.activeElement
var f=document.forms;
var i=0;j=0;next=0,found=false;
var fsub;
for(i=0;i<f.length;i++){
	fsub=f(i);next=0;
	for(j=0;j<fsub.length;j++){if(field.name==fsub.item(j).name){next=j+1;found=true;break;}}
	while(found){
		if( fsub.item(next).readOnly==false && fsub.item(next).disabled==false &&  (fsub.item(next).type=='text' || fsub.item(next).type=='password') )
			{fsub.item(next).focus();break;}
		else{if(next<fsub.length-1) next=next+1;else break;}
	}
}
event.returnValue = false;
return;}
//document.onkeypress=keyvalid;
//document.onkeyup=keyfull;



function replaceChars(entry, out, add) {
temp = "" + entry; // temporary holder
	while (temp.indexOf(out)>-1) {		
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
	}
return temp;}

function traedatos(st,scod,nsp,id,ih,il,iv,ie,sf){
var s = '/multicard/general/funciones/verifserver.asp?sQry='+nsp;
if (scod.indexOf("|")>-1){scod = replaceChars(scod,'|',',');s = s + "&sPrm='" + st + "'," + scod;}
else{s = s + "&sPrm='" + st + "','" + scod + "'";}
s = s + "&sFrom="+id;
s = s + "&sTo="+ih;
s = s + '&iValidar='+iv;
s = s + '&iExec='+ie;
s = s + '&nFunct='+sf;
s = s + '&sClear='+il;
NewWindow(s , st + nsp + 'wndvct');}


function buscardatos(sc, c, d, t, i, r){
var cod=c;des=d;
var s = "/multicard/general/funciones/buscar.asp?iLC="+document.getElementById(cod).getAttribute("maxLength");
s = s + "&iLD="+ document.getElementById(des).getAttribute("maxLength");
s = s + "&sLbC=Cód.";
s = s + "&sLbD="+ t ;
s = s + "&sSp="+sc ;
s = s + "&sRef="+document.location.href;
s = s + "&iD=" + i;
s = s + '&nR='+r;
NewWindow2 (s, "slvhb28");}




function guarda( spag, ssql, sfile ){
spag = spag + '?ss=' + ssql;
var wAncho=280;
var wAlto =30;
var winl  = (screen.width - wAncho) / 2;
var wint  = (screen.height - wAlto) / 2;  
winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=no,resizable=no,menubar=no,directories=no,border=no';
abre=window.open(spag, 'guardador', winprops);
abre.document.execCommand('SaveAs',1, sfile);
abre.close();}
function camposvacios(sobj){
bvacio = true;
for (var i = 0; i < sobj.value.length; i++)
{if ( sobj.value.substr(i, 1) != ' ' ){ bvacio = false; }}
if(!bvacio){ alert('¡ Faltan datos por ingresar !'); sobj.focus();}
return bvacio;}
function vacio(sobj){
bvacio = true;
for (var i = 0; i < sobj.value.length; i++)
{if ( sobj.value.substr(i, 1) != ' ' ){ bvacio = false; }}
return bvacio;}
function esperar(){document.body.style.cursor = "wait";}
function normal(){document.body.style.cursor = "default";}
function CheckText(strTexto){
	if (!validchar(strTexto)){return false;}
	var itec= window.event.keyCode
	if (  ( itec == 27 )
		 || ( itec == 32 )
		 || ( itec == 193 )
		 || ( itec == 201 )
		 || ( itec == 205 )
		 || ( itec == 209 )
		 || ( itec == 211 )
		 || ( itec == 218 )
		 || ( itec == 225 )
		 || ( itec == 233 )
		 || ( itec == 237 )
		 || ( itec == 241 )
		 || ( itec == 243 )
		 || ( itec == 250 )

	  )	
	{return true;}
	if ( itec != 13 ){	
		if(    ( ( itec < 65 ) || ( itec > 90  ) )
				&& ( ( itec < 97 ) || ( itec > 122 ) )
			 )
			 {alert("¡ Debe Ingresar sólo Letras !");return false;}
		}
return true};
function cualitem(obj){
var i;var r; var bchek = false;
for (i = 0; i < obj.length; i++)
if (obj[i].checked == true){ r=i;bchek = true};  
if ( bchek == false ){ r = -1 ;}
return r}
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/";
var vDateType = 3; // Global value for type of date format
//  1 = mm/dd/yyyy
//  2 = yyyy/dd/mm  (Unable to do date check at this time)
//  3 = dd/mm/yyyy
var vYearType = 4;
var vYearLength = 2;
var err = 0;
if(navigator.appName == "Netscape") {
	if (navigator.appVersion < "5")
	{isNav4 = true;isNav5 = false;}
	else
	if (navigator.appVersion > "4")
	{isNav4 = false;isNav5 = true;}	}
else {isIE4 = true;}
function rd(iInt,iDec){
var nTemp= ''
var nRound = ''
for (var i=0;i < iDec;i++){nRound = nRound + '0';}
nRound = '1' + nRound;
return Math.round( nRound * iInt ) / nRound
//return Math.round(100*x)/100
}
function imprimewin(){
	if (parseInt(navigator.appVersion) >= 4)
	{esperar();window.print();window.close();}}
function IfCero(ObjNum){
if ((ObjNum.length == 0) || (ObjNum.value == ''))
	return 0;
else
	return ObjNum.value;
}
function FecSQl(ObjFec){
if (ObjFec.length == 0){return null;}
var iMonth =  ObjFec.value.substr(3,2);
var iDay = ObjFec.value.substr(0,2);
var iYear = ObjFec.value.substr(6,4);
//var sFechaPrm = iMonth+strSeperator+iDay+strSeperator+iYear;
var sFechaPrm = iDay+strSeperator+iMonth+strSeperator+iYear;
sFechaPrm = "'" + sFechaPrm + "'"
return sFechaPrm;}
function NewWindow(mypage, myname){
  var wAncho=280;
  var wAlto =30;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = (screen.height - wAlto) / 2;  
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=no,resizable=no,menubar=no,directories=no,border=no';
  win = window.open(mypage, myname, winprops);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
return win;}
function NewWindow2(mypage, myname){  
  var wAncho=screen.width - 50;
  var wAlto =screen.height - 200;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = (screen.height - wAlto) / 2;  
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=yes,resizable=yes,menubar=no';
  win = window.open( mypage, myname, winprops,true);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
  return win;}
function NewWindowImp(mypage, myname){
  var wAncho=250;
  var wAlto =350;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = (screen.height - wAlto) / 2;
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=no,resizable=no,menubar=no';  
  win = window.open( mypage, myname, winprops,true);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
return win;}
function NewWindowImpPago(mypage, myname){  
  var wAncho=270;
  var wAlto =320;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = (screen.height - wAlto) / 2;  
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=no,resizable=no,menubar=no';  
  win = window.open( mypage, myname, winprops,true);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
  return win;}
function NewImprime(mypage, myname, myancho, myalto){  
  var wAncho=myancho;
  var wAlto =myalto;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = (screen.height - wAlto) / 2;
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=yes,resizable=yes,menubar=no,dependent=yes';
  win = window.open( mypage, myname, winprops, true);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
  return win;}
function NewImprimeScroll(mypage, myname, myancho, myalto){  
  var wAncho=myancho;
  var wAlto =myalto;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = (screen.height - wAlto) / 2;  
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=yes,resizable=yes,menubar=no';     
  win = window.open( mypage, myname, winprops,true);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
  return win;}
function NewExcel(mypage, myname, myancho, myalto){  
  var wAncho=myancho;
  var wAlto =myalto;
  var winl  = (screen.width - wAncho) / 2;
  var wint  = ((screen.height - wAlto) / 2 ) - 10;  
  winprops  = 'height='+wAlto+',width='+wAncho+',top='+wint+',left='+winl+',toolbar=no,scrollbars=yes,resizable=yes,menubar=yes';
  winprops = 'top='+wint+',left='+winl+',height='+wAlto+',width='+wAncho+',menubar=yes,resizable=yes';
  win = window.open( mypage, myname, winprops,true);
  if (parseInt(navigator.appVersion) >= 4)
  {win.window.focus();}
  return win;}
function FormatNumber(snum, idec){
var icount, limite
var ineg = 1
if (snum.value <0){ snum.value = snum.value * -1; ineg = -1}
limite = snum.value.length
//if ( snum.value < 0 ){ limite = limite - 1};
if ( limite == 0 ){return '';}
var ipunto = 0
var snewnumber = '';
for(icount = limite - 1 ; icount > -1; icount--){
	snewnumber = snum.value.substr(icount, 1) + snewnumber	
	ipunto++
	if ( idec > 0 ){if ( ipunto == idec ){snewnumber = ',' + snewnumber; ipunto = 0; idec = 0;}}
	else{if ( ipunto == 3 ){snewnumber = '.' + snewnumber;ipunto = 0;}}
}
if ( snewnumber.substr(0, 1) == '.' ){snewnumber = snewnumber.substr(1, snewnumber.length)}
if (ineg == -1){ snewnumber = '-' + snewnumber}
return snewnumber;}
function FormatNumberVar(snum, idec){
var icount, limite
limite = snum.value.length
alert('limite'  + limite)
if ( limite == 0 ){return '';}
var ipunto = 0
var snewnumber = '';
for(icount = limite - 1 ; icount > -1; icount--){
	snewnumber = snum.substr(icount, 1) + snewnumber	
	ipunto++
	if ( idec > 0 ){if ( ipunto == idec ){snewnumber = ',' + snewnumber;ipunto = 0;idec = 0;}		}
	else{if ( ipunto == 3 ){snewnumber = '.' + snewnumber;ipunto = 0;}}
}
if ( snewnumber.substr(0, 1) == '.' )
{snewnumber = snewnumber.substr(1, snewnumber.length)}
return snewnumber;}
function CheckDV( dvr ){
  dv = dvr + "";
  if ( dv != '0' && dv != '1' && dv != '2' && dv != '3' && dv != '4' && dv != '5' && dv != '6' && dv != '7' && dv != '8' && dv != '9' && dv != 'k'  && dv != 'K')
  {alert("¡ Debe Ingresar un Dígito Verificador Válido !");return false;}
  return true;}
function CheckRut( crut, cdig ){
largo = crut.length;
if ( largo == 0  ){alert("¡ Debe Ingresar el Rut !");return false;}
rut=crut
dv=cdig 
if ( !CheckDV(cdig ) ){return false;}
if ( rut == null || dv == null ){return false;}	
var dvr = '0';
suma = 0;
mul  = 2;
for (i= rut.length -1 ; i >= 0; i--){
	suma = suma + rut.charAt(i) * mul;
	if (mul == 7)
		mul = 2;
	else
		mul++;
}
res = suma % 11;
if (res==1)
	dvr = 'K';
else if (res==0)
	dvr = '0';
else{dvi = 11-res;dvr = dvi + "";}
dvr 	= dvr.toUpperCase();
dv 	= dv.toUpperCase();
if ( dvr != dv ){alert("¡ El Rut es Incorrecto !");return false;}
return true;}
function validchar(iKey){
if ((window.event.keyCode  == 44) || (window.event.keyCode  == 39)){return false;}
return true;}
function CheckNumeros(StrNum, iNumDec){
	if (!validchar(StrNum)){return false;}
	var smsg = "¡ El Formato NO es Correcto, \n Debe ser por ejemplo : 25730 !";
	if (iNumDec > 0){smsg = "¡ El Formato NO es Correcto, \n Debe ser por ejemplo : 25730.12 !";}
	var digits="0123456789.";
	var temp;
	var nsep = 0;
	var ndec = 0;
	var itec= window.event.keyCode;
	if ( itec == 27 ){return true;}
	if ( itec == 46 ){nsep++;ndec=1;}
	if ( itec != 13 ){
		if (( itec < 48 ) || ( itec > 57 ) ){
			if ((iNumDec > 0)){if ( itec != 46 ){alert("¡ Debe ingresar un Número!");return false;}}
			else{alert("¡ Debe ingresar un Número Entero !");return false;}
		}
	}
	if ((StrNum=="") && (StrNum.length > 0)){alert("¡ Debe ingresar un Número!");return false;}
	for (var i=0;i<StrNum.length;i++){
		temp=StrNum.substring(i,i+1);
		if (temp == '.'){nsep++;ndec=i+1;}
		if (digits.indexOf(temp)==-1)
			{alert("¡ Debe Ingresar Números !");return false;}
     	}
     	if (ndec > 0){
     		if (StrNum.indexOf(".") >= 0 ){   			
     			temp =  StrNum.substring(StrNum.indexOf("."),StrNum.length);
     			if (temp.length > iNumDec){return false;}
     		}
	}
	if (nsep>1){alert(smsg);return false;}		     	
 return true;}
function CheckHora(StrNum){
	if (!validchar(StrNum))	{return false;}
	var digits="0123456789:"
	var temp
	temp=StrNum.substring(0,1);
	if (digits.indexOf(temp)==-1){alert("¡Debe Ingresar Caracteres Validos!");return false;}
	if ((StrNum=="") && (StrNum.length > 0)){alert("¡ Debe ingresar Hora Correcta!");return false;}
	for (var i=0;i<StrNum.length;i++){
		temp=StrNum.substring(i,i+1)
		if (digits.indexOf(temp)==-1){alert("¡Ha ingresado caracteres inválidos!");return false;}
     	}
 return true;}
function CheckEnteros22(StrNum){
	var digits="0123456789"
	var temp
	temp=StrNum.substring(0,1);	
	if (digits.indexOf(temp)==-1){alert("¡ Ha ingresado caracteres inválidos !");return false;}
	if ((StrNum=="") && (StrNum.length > 0)){alert("¡ Debe ingresar un Número !");return false;}
	for (var i=0;i<StrNum.length;i++){
		temp=StrNum.substring(i,i+1)
		if (digits.indexOf(temp)==-1){alert("¡ Debe Ingresar Números !");return false;}
     	}
 return true;}
function dateValid(objName){
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = objName;
if (strDate.length < 1)
{return true;}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
	if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
		strDateArray = strDate.split(strSeparatorArray[intElementNr]);
		if (strDateArray.length != 3){err = 1;return false;}
		else {
			strDay = strDateArray[0];
			strMonth = strDateArray[1];
			strYear = strDateArray[2];}
		booFound = true;
	   }
}
if (booFound == false){
	if (strDate.length>5){
		strDay = strDate.substr(0, 2);
		strMonth = strDate.substr(2, 2);
		strYear = strDate.substr(4);}
}
if (strYear.length == 2)
{strYear = '20' + strYear;}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
if (isNaN(intday)){err = 2;return false;}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
	for (i = 0;i<12;i++) {
		if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
			intMonth = i+1;
			strMonth = strMonthArray[i];
			i = 12;}
	}
	if (isNaN(intMonth)){err = 3;return false;}
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)){err = 4;return false;}
if (intMonth>12 || intMonth<1){err = 5;return false;}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {err = 6;return false;}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {err = 7;return false;}
if (intMonth == 2){
	if (intday < 1) {err = 8;return false;}
	if (LeapYear(intYear) == true){
		if (intday > 29){err = 9;return false;}}
else {if (intday > 28) {err = 10;return false;}}
}
return true;}
function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
vDateType = dateType;
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck
// True  = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
if (vDateValue == "~") {
	alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
	vDateName.value = "";
	vDateName.focus();
	return true;}
var whichCode = (window.Event) ? e.which : e.keyCode;
if ( event.altKey || event.ctrlkey  || event.ShiftKey || whichCode==18 || whichCode==20){ return false; }
if ( (whichCode >= 32) && (whichCode <= 40 ) ) { return false; }
if ( (whichCode >= 16) && (whichCode <= 17 ) ) { return false; }
if ( (whichCode >= 45) && (whichCode <= 46 ) ) { return false; }
if ( whichCode == 27) {return false;}
// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4)
	{if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
	return true;}
var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
if (alphaCheck.indexOf(vDateValue) >= 1){
	if (isNav4) {
		vDateName.value = "";
		vDateName.focus();
		vDateName.select();
		return false;}
	else {
		vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));		
		return false;}
}
if (whichCode == 8){return false;}
else {	var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
	if (strCheck.indexOf(whichCode) != -1) {
		if (isNav4) {
			if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
				alert("Fecha No Válida Vuelva a Infresarla");
				vDateName.value = "";
				vDateName.focus();
				vDateName.select();
				return false;}
			if (vDateValue.length == 6 && dateCheck){
				var mDay = vDateName.value.substr(2,2);
				var mMonth = vDateName.value.substr(0,2);
				var mYear = vDateName.value.substr(4,4);
				if (mYear.length == 2 && vYearType == 4){
					var mToday = new Date();				
					var checkYear = mToday.getFullYear() + 30;
					var mCheckYear = '20' + mYear;
					if (mCheckYear >= checkYear)
						mYear = '19' + mYear;
					else
						mYear = '20' + mYear;
					}
					var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
					if (!dateValid(vDateValueCheck)) {
						alert("Fecha No Válida Vuelva a Ingesarla");
						vDateName.value = "";
						vDateName.focus();
						vDateName.select();
						return false;}
				return true;}
			else {
				if (vDateValue.length >= 8  && dateCheck) {
					if (vDateType == 1) // mmddyyyy
					{	var mDay = vDateName.value.substr(2,2);
						var mMonth = vDateName.value.substr(0,2);
						var mYear = vDateName.value.substr(4,4)
						vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
						}
						if (vDateType == 2) // yyyymmdd
						{
						var mYear = vDateName.value.substr(0,4)
						var mMonth = vDateName.value.substr(4,2);
						var mDay = vDateName.value.substr(6,2);
						vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
						}
						if (vDateType == 3) { // ddmmyyyy
							var mMonth = vDateName.value.substr(2,2);
							var mDay = vDateName.value.substr(0,2);
							var mYear = vDateName.value.substr(4,4)
							vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
						}
						var vDateTypeTemp = vDateType;
						vDateType = 1;
						var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
						if (!dateValid(vDateValueCheck)) {
							alert("Fecha No Válida Vuelva a Ingesarla");
							vDateType = vDateTypeTemp;
							vDateName.value = "";
							vDateName.focus();
							vDateName.select();
							return false;
						}
					vDateType = vDateTypeTemp;
					return true;}
				else {
					if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
						alert("Fecha No Válida Vuelva a Ingesarla");
						vDateName.value = "";
						vDateName.focus();
						vDateName.select();
						return false;}}
			}
		}
	else {	// Non isNav Check
		if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
			alert("Fecha No Válida Vuelva a Ingesarla");
			vDateName.value = "";
			vDateName.focus();
			return true;
		}
		// Reformat date to format that can be validated. mm/dd/yyyy
		if (vDateValue.length >= 8 && dateCheck) {
			if (vDateType == 1) { // mm/dd/yyyy
				var mMonth = vDateName.value.substr(0,2);
				var mDay = vDateName.value.substr(3,2);
				var mYear = vDateName.value.substr(6,4)}
			if (vDateType == 2) { // yyyy/mm/dd
				var mYear = vDateName.value.substr(0,4)
				var mMonth = vDateName.value.substr(5,2);
				var mDay = vDateName.value.substr(8,2);}
			if (vDateType == 3) { // dd/mm/yyyy
				var mDay = vDateName.value.substr(0,2);
				var mMonth = vDateName.value.substr(3,2);
				var mYear = vDateName.value.substr(6,4)}
			if (vYearLength == 4) {
				if (mYear.length < 4) {
					alert("Fecha No Válida Vuelva a Ingesarla");
					vDateName.value = "";
					vDateName.focus();
					return true; }
			}			
			var vDateTypeTemp = vDateType;
			vDateType = 1;			
			var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
			if (mYear.length == 2 && vYearType == 4 && dateCheck) {				
				var mToday = new Date();				
				var checkYear = mToday.getFullYear() + 30;
				var mCheckYear = '20' + mYear;
				if (mCheckYear >= checkYear)
					mYear = '19' + mYear;
				else
					mYear = '20' + mYear;
					
				vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
				if (vDateTypeTemp == 1) // mm/dd/yyyy
					vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
				if (vDateTypeTemp == 3) // dd/mm/yyyy
					vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
			}
			if (!dateValid(vDateValueCheck)) {
				alert("Fecha No Válida Vuelva a Ingesarla");
				vDateType = vDateTypeTemp;
				vDateName.value = "";
				vDateName.focus();
				return true;}
			vDateType = vDateTypeTemp;
			return true;}
		else {	if (vDateType == 1) {
				if (vDateValue.length == 2)
				{vDateName.value = vDateValue+strSeperator;}
				if (vDateValue.length == 5)
				{vDateName.value = vDateValue+strSeperator;}
			}
			if (vDateType == 2) {
				if (vDateValue.length == 4)
				{vDateName.value = vDateValue+strSeperator;}
				if (vDateValue.length == 7)
				{vDateName.value = vDateValue+strSeperator;}
			} 
			if (vDateType == 3) {
				if (vDateValue.length == 2)
				{vDateName.value = vDateValue+strSeperator;}
				if (vDateValue.length == 5)
				{vDateName.value = vDateValue+strSeperator;}
			}
			return true;}
	}	
	if (vDateValue.length == 10&& dateCheck){
		if (!dateValid(vDateName)){
			alert("Fecha No Válida Vuelva a Ingesarla");
			vDateName.focus();
			vDateName.select();}
	}
	return false;}
else {	if (isNav4){
		vDateName.value = "";
		vDateName.focus();
		vDateName.select();
		return false;}
	else{	if (whichCode != 13)
		{vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));}
		return false;}}
}
if (!ValidaFecha(vDateName.value) ){return false;}
}
function ValidaFecha(FecDato){
if (FecDato.length != 10){err=1;return false;}
if (FecDato.substr(2,1)!="/" &&  FecDato.substr(5,1)!="/"){err=2;return false;}
dia=FecDato.substr(0,2);
mes=FecDato.substr(3,2);
ano=FecDato.substr(6,4);
if (mes>12 || mes<1){err=3;return false;}
if ((mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12) && (dia > 31 || dia < 1)){err = 4;return false;}
if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && (dia > 30 || dia < 1)){err = 5;return false;}
if (mes == 2){
	if (dia < 1){err = 6;return false;}
	if (LeapYear(ano) == true){if (dia > 29){err = 7;return false;}}
	else{if (dia > 28){err = 8;return false;}}}
return true;}
function LeapYear(intYear){
	if (intYear % 100 == 0)
		{if (intYear % 400 == 0){return true;}}
	else{	if ((intYear % 4) == 0){return true;}}
return false;}

/* Compara Fechas */
//Formato de la fecha
// 1 = DD/MM/YYYY 
// 2 = MM/DD/YYYY   
// 3 = YYYY/MM/DD
// 4 = YYYY/DD/MM
var formato = 1;

//**********************************************************************************************
//   invierta una fecha dada retornando en formato YYYYMMDD
//  dFecIni = Fecha a invertir
//   nTipFormat = Formato en que biene la fecha
//             1 = DD/MM/YYYY 
//             2 = MM/DD/YYYY   
//             3 = YYYY/MM/DD
//             4 = YYYY/DD/MM

function invFecha(nTipFormat,dFecIni){
   var dFecIni = dFecIni.replace(/-/g,"/");               // reemplaza el - por /   
   
   // primera division fecha
   var nPosUno  = ponCero(dFecIni.substr(0,dFecIni.indexOf("/")));
   // 2º divicion fecha
   var nPosDos  = ponCero(dFecIni.substr(parseInt(dFecIni.indexOf("/")) + 1,parseInt(dFecIni.lastIndexOf("/")) - parseInt(dFecIni.indexOf("/")) - 1));
   // 3º divicion fecha
   var nPosTres = ponCero(dFecIni.substr(parseInt(dFecIni.lastIndexOf("/")) + 1));

   switch(nTipFormat){
      case 1 :   //   DD/MM/YYYY
         dReturnFecha = nPosTres + "" + nPosDos + "" + nPosUno;
         break;

      case 2 :   //   MM/DD/YYYY
         dReturnFecha = nPosTres + "" + nPosUno + "" +nPosDos;
         break;

      case 3 :   //   YYYY/MM/DD
         dReturnFecha = nPosUno + "" + nPosDos + "" +nPosTres;
         break;
   
      case 4 :   //   YYYY/DD/MM
         dReturnFecha = nPosUno + "" + nPosTres + "" +nPosDos;
         break;
   }
   
   return dReturnFecha;   // retorna la fecha    
}

// Agrega un cero delante del strPon cuando tenga solo un caracter
function ponCero(strPon){
   if(parseInt(strPon.length) < 2)
      strPon = "0" + strPon;
   return strPon;
}

//*******************************************************************************
// valida que la fecha dFecMenor es menor o igual a  dFecMayor
// los parametros dFecMenor, dFecMayor son fecha con divisores validos "-" o "/"
// el parametro dFormat es el tipo de formato en que viene la fecha 
//             1 = DD/MM/YYYY 
//             2 = MM/DD/YYYY   
//             3 = YYYY/MM/DD
//             4 = YYYY/DD/MM

function comparaFecha(dFormat,dFecMenor, dFecMayor){
   dFecMenor = invFecha(dFormat,dFecMenor);
   dFecMayor = invFecha(dFormat,dFecMayor);

   if(dFecMenor > dFecMayor)
      return false;
   else
      return true;
}

function validaFechaMenor( formulario, fMenor, fMayor ){
   if(comparaFecha( formato,fMenor,fMayor) == true) {
	  return true; 
   } else {
	  alert("Fecha Desde Debe Ser Menor!");
	  return false;
   }
}

/*				  */
/***************************/
