
//window.onerror = myOnError;
function myOnError(msg, url, lno) {
	return true; }
// boton derecho
document.oncontextmenu = function(){return false}
// control de objetos
String.prototype.mensaje = function()
	{	mensaje.innerText = this;
		LayerMensaje.style.visibility="visible"
	window.setTimeout("LayerMensaje.style.visibility='hidden'",3000);	}
String.prototype.trim = function()
	{ return this.replace(/(^\s*)|(\s*$)/g, ""); 	}
String.prototype.left = function(d1)
	{ return this.substring(this.length-d1,this.length); 	}
String.prototype.right = function(d1)
	{ return this.substring(0,d1); 	}
String.prototype.isempty = function()
	{ if(this.trim()=="") return true; else return false; 	}
String.prototype.isnumber = function()
	{ arr = "";
	if(!this.isempty()) arr=this.split(".");
	for(ind1=0;ind1<arr.length;ind1++)
	for(ind2=0;ind2<arr[ind1].length;ind2++)
	if(arr[ind1].charCodeAt(ind2)<48 || arr[ind1].charCodeAt(ind2)>57)
	return false; 	return true; }
String.prototype.rutdvr = function()
	{ var rut = ""; var s = 0; var l_dv; 
	if(this.isempty()) return "";
	rrut = this.split(".");
	for(and1=0;and1<rrut.length;and1++) rut+=rrut[and1];
	for (i=2; i< 8; i++) { s = s + ( rut % 10 ) * i; rut = (rut - ( rut % 10 )) / 10; }
	s = s + ( rut % 10 ) * 2; rut = (rut - ( rut % 10 )) / 10;
	s = s + ( rut % 10 ) * 3; rut = (rut - ( rut % 10 )) / 10; 	s = 11 - ( s % 11 );
	if ( s == 10 ) l_dv = "K"; 	else if ( s == 11 ) l_dv = "0"; else l_dv = new String(s) ; 
	return( l_dv ); 	}
String.prototype.isrut = function()
	{var rut ;
	if(this.isempty()==false) { rut = this.split("-");
	if(rut[0].rutdvr()==rut[1]) return true; else return false; } 	}
String.prototype.frut = function()
	{if(this.isrut()) { rrut = this.split("-")
	return rrut[0].miles() + "-" + rrut[1]; }
	return "";	}
String.prototype.febYear = function()
	{if (this % 100 == 0) if (this % 400 == 0) return true;
	else if ((this % 4) == 0) return true;
	return false;	}
String.prototype.isdate = function()
	{ if(this.isempty()) return "";
	var adias = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	fecha = this.split("/");
	if(fecha.length!=3) return "";
	if(fecha[2]<1900)return "";
	if(fecha[2]>2070)return "";
	if(fecha[2].febYear()) adias[1] = 29;
	if(fecha[1]>12)return "";
	if(fecha[0] > adias[(parseInt(fecha[1])-1)]) return "";
	fecha = fecha[0] + "/" + fecha[1] + "/" + fecha[2]
	return fecha.trim() ;	}
String.prototype.getdate = function(Ptype)
	{ d = new Date();
    var dia = new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
    var mes = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")	
	switch(Ptype)
		{
		case 100: 
			return dia[d.getDay()] +", "+d.getDate()+" de "+ mes[d.getMonth()] ;	
			break;
		default :
			return d.getDay() +"/"+ d.getMonth() +"/"+ d.getYear();
			break;			
		}
	}
String.prototype.DecRound = function(dec)
	{
	  Valor = this;
	  ndecimales = Math.pow(10,dec);
	  Valor = Valor * ndecimales;
	  Valor = Math.round(Valor);
	  Valor = Valor /ndecimales
	  return Valor;
	}

Array.prototype.nSplice = function(pArr)
	{
	arrTmp = new Array()
	for(iArr=0;iArr<this.length;iArr++)
		if(pArr!=iArr)
			arrTmp[arrTmp.length] = this[iArr]
	return arrTmp;
	}


function formaDT() { event.srcElement.value = event.srcElement.value.isdate();	}
document.onkeypress = forma;
//  "9" "9," "A9" "DT" "FN"
function forma()
	{
	param = event.srcElement.forma;
	obj = event.srcElement;
	ev = event.keyCode;
	if(param=="9")		{
		var car = "0123456789"
		if( car.indexOf(String.fromCharCode(ev))==-1) event.keyCode="";
		}
	if(param=="9,")		{
		var car = "0123456789,"
		if( car.indexOf(String.fromCharCode(ev))==-1) event.keyCode="";
		}
	if(param=="FN")		{
		var car = "0123456789-()"
		if( car.indexOf(String.fromCharCode(ev))==-1) event.keyCode="";
		}
	if(param=="A9")
		{
		obj = event.srcElement;
		var cadena1 = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890 /.&";
		var cadena2 = "abcdefghijklmnñopqrstuvwxyz";
		var cadena3 = "áéíóú";
		var retcad3 = new Array(65,69,73,79,85);
		if(cadena1.indexOf(String.fromCharCode(event.keyCode))!=-1){event.keyCode=event.keyCode; return;}
		if(cadena2.indexOf(String.fromCharCode(event.keyCode))!=-1){event.keyCode=(event.keyCode-32); return;}
		if(cadena3.indexOf(String.fromCharCode(event.keyCode))!=-1)
				{event.keyCode=retcad3[cadena3.indexOf(String.fromCharCode(event.keyCode))];return}
		if(String.fromCharCode(event.keyCode)=="'"){event.keyCode=180; return;}
		event.keyCode="";
		}	
	if(param=="DT")
		{
	var valin = event.keyCode;
	var obj = event.srcElement; 
	obj.onblur = formaDT ;
	if(!String.fromCharCode(valin).isnumber()) return event.keyCode = "";	
	if(obj.value.trim().length > 9) return event.keyCode = "";
	obj.value += String.fromCharCode(valin)
	event.keyCode = "";
	if(obj.value.trim().length==3)
		if(obj.value.indexOf("/")==-1) 
			obj.value = obj.value.substring(0,2) +"/"+ String.fromCharCode(valin)
	if(obj.value.trim().length==6)
		if(obj.value.substring(5,6)!="/")
			obj.value = obj.value.substring(0,5) +"/"+ String.fromCharCode(valin)
	if(obj.value.trim().length==2 || obj.value.trim().length==5) {			
		obj.value += "/"; }
	if(obj.value.trim().length==10)
		if(!obj.value.trim().isdate())
			obj.value = "";
	return ;
		}
}
function Mc_read()
	{
	this.path="";
	this.ext="asp";
	this.Global = window.RstGlobal;
	}{
	var p = Mc_read.prototype
	p.build = Mc_build;
	p.load = Mc_datos;
	}
function Mc_datos(proc,dat)
{ 
if(typeof(this.Global)=="undefined") this.Global = "setGlobalSession"
return RS_datos(this.path,this.ext,proc,dat,this.Global);	
}
function sessiontimeout(){this.out}
function Mc_build()	{
	_stc  = ' <script language=vbscript> \n ';
	_stc += ' function RS_datos(path,ext,proc,dat,par) \n ';
	_stc += '   dim  xmldoc \n';
	_stc += ' 	set xmldoc=CreateObject("Msxml.DOMDocument") \n ';
	_stc += '	xmldoc.async=False \n ' ;
	_stc += '	xmldoc.validateOnParse = False \n ' ;
	_stc += ' //msgbox path&"."&ext&"?proc="&proc&"&tex="&dat&"&par="&par \n ';
	_stc += '	if xmldoc.load(path&"."&ext&"?proc="&proc&"&tex="&dat&"&par="&par) then \n';
	_stc += '	    RS_datos = Mc_cargadatos(xmldoc.xml) \n ';
	_stc += '   else \n ' ;
	_stc += '       xmldoc.load(path&"."&ext&"?proc="&proc&"&tex="&dat&"&par="&par )  \n ' ;
	_stc += '	    RS_datos = Mc_cargadatos(xmldoc.xml) \n ';
	_stc += '   end if \n ';
	_stc += ' end function \n ';
	_stc += ' </'+'script> \n'; 	
	//alert('entro 2');
	document.write( _stc); }

function Mc_cargadatos(param) { 
	if(param.isempty()) return "-1";
	param = param.split("^"); 
	var_ret = "String.fromCharCode("+param[1]+")"; 
	var_ret = eval(var_ret); 
	while(true) { 
		if(var_ret.indexOf("~")==-1)break; 
		var_ret = var_ret.replace("~"," ") 	}  
	if(var_ret.indexOf("TimeOut§")!=-1) 
		{ document.location.href='/'; return -1;}
	if(var_ret.indexOf("ErrSESS¥")!=-1)
		{Mc_readGlobal();return -1	}
	if(var_ret.indexOf("¥")!=-1) return -1; 	
	else return var_ret;	
	} 

//alert('entro');
var Mct_Err = new Mc_read();
Mct_Err.build();

Mct_Err.path="/js/mclibrary";
window.RstGlobal = Mct_Err.load('Global', "" );

log = Mct_Err.load('SendLog', location.href );
//alert(log)








