/*
Manejo de errores de JScript
*/

//window.onerror = GoErrorTrap;


function GoErrorTrap (msg,url,line) {

	document.all.oErrorLog.innerHTML="<b>Un error ha ocurrido.</b><p>";
	document.all.oErrorLog.innerHTML+="Error: " + msg + "<br>";
	document.all.oErrorLog.innerHTML+="Linea: " + line + "<br>";
	document.all.oErrorLog.innerHTML+="URL: " + url + "<br>";

    return true;

}

function htmlDebugInfo(oContainer) {

	var htmlDebug = ""

	htmlDebug = htmlDebug + "window.screen.availHeight                     		= " + window.screen.availHeight                       + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.appCodeName          		= " + window.clientInformation.appCodeName            + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.appMinorVersion      		= " + window.clientInformation.appMinorVersion        + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.appName              		= " + window.clientInformation.appName                + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.browserLanguage      		= " + window.clientInformation.browserLanguage        + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.appVersion           		= " + window.clientInformation.appVersion             + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.cookieEnabled        		= " + window.clientInformation.cookieEnabled          + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.cpuClass             		= " + window.clientInformation.cpuClass               + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.onLine               		= " + window.clientInformation.onLine                 + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.platform             		= " + window.clientInformation.platform               + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.systemLanguage       		= " + window.clientInformation.systemLanguage         + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.userAgent            		= " + window.clientInformation.userAgent              + "<br>";
	htmlDebug = htmlDebug + "window.clientInformation.userLanguage         		= " + window.clientInformation.userLanguage           + "<br>";

	htmlDebug = htmlDebug + "window.screen.availHeight                     		= " + window.screen.availHeight                       + "<br>";
	htmlDebug = htmlDebug + "window.screen.availWidth                      		= " + window.screen.availWidth                        + "<br>";
	htmlDebug = htmlDebug + "window.screen.bufferDepth                     		= " + window.screen.bufferDepth                       + "<br>";
	htmlDebug = htmlDebug + "window.screen.colorDepth                      		= " + window.screen.colorDepth                        + "<br>";
	htmlDebug = htmlDebug + "window.screen.fontSmoothingEnab               		= " + window.screen.fontSmoothingEnab                 + "<br>";
	htmlDebug = htmlDebug + "window.screen.height                          		= " + window.screen.height                            + "<br>";
	htmlDebug = htmlDebug + "window.screen.updateInterval                  		= " + window.screen.updateInterval                    + "<br>";
	htmlDebug = htmlDebug + "window.screen.width                           		= " + window.screen.width                             + "<br>";

	htmlDebug = htmlDebug + "window.screenLeft                             		= " + window.screenLeft                               + "<br>";
	htmlDebug = htmlDebug + "window.screenTop                              		= " + window.screenTop                                + "<br>";

	return htmlDebug;
}


/*************
expande y colapsa
*************/
function expandIt(whichEl){
    whichEl.style.display = (whichEl.style.display == "none" ) ? "" : "none";
}


/*************
help system vars
*************/

var dragapproved=false
var z,x,y

function move(){
	if (event.button==1&&dragapproved){
		z.style.pixelLeft=temp1+event.clientX-x
		z.style.pixelTop=temp2+event.clientY-y
		document.all.helpbackground.style.pixelLeft=temp1+event.clientX-x
		document.all.helpbackground.style.pixelTop=temp2+event.clientY-y
		document.all.helptitle.style.pixelLeft=temp1+event.clientX-x
		document.all.helptitle.style.pixelTop=temp2+event.clientY-y
		document.all.helptext.style.pixelLeft=temp1+event.clientX-x
		document.all.helptext.style.pixelTop=temp2+event.clientY-y
		document.all.helpdiv.style.pixelLeft=temp1+event.clientX-x
		document.all.helpdiv.style.pixelTop=temp2+event.clientY-y

		return false;
	}
}

function drags(){
	if (!document.all)
		return
	if (event.srcElement.className=="drag" || event.srcElement.className=="helptitle" || event.srcElement.className=="helptext"){
		dragapproved=true
		z=event.srcElement
		temp1=z.style.pixelLeft
		temp2=z.style.pixelTop
		x=event.clientX
		y=event.clientY
		document.onmousemove=move
	}
}

function showHelp() {
	document.all.helpbackground.style.display='';
	document.all.helpdiv.style.display='';
	document.all.helptitle.style.display='';
}
function closeHelp(){
	document.all.helpbackground.style.display='none';
	document.all.helpdiv.style.display='none';
	document.all.helptitle.style.display='none';
}

document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")

/*************
fin system help
*************/

function mVolver()
{
  window.history.back();
}

function ReadOnly(o) {

	o.blur();
	return;

}

function CheckReturn(form) {
	if (event.keyCode == 13){
		if (form.onsubmit) {
			if (eval (form.onsubmit+"anonymous(form);")) {
				form.submit();
			}
		} else {
			form.submit();
		}
	}
}

		function KillOnSubmit(form) {
			form.onsubmit = "return true";
			return true;
		}

	function SetGoSubmit(form,value) {
		form.GOSUBMIT.value = value;
		return true;
	}


		function CheckNumeros(form,lCycle,element,nextelement) {

			if ((form) && (!lCycle)) {
				if (event.keyCode == 13){
					if (form.onsubmit) {
						if (eval (form.onsubmit+"anonymous(form);")) {
							form.submit();
						}
					} else {
						form.submit();
					}
				}
			}

			//alert(event.keyCode);
			if (event.keyCode < 48 || event.keyCode > 57){
				event.returnValue = false;
			}

			if (lCycle) {

			 if (isNumber(event.keyCode)){
			 versionBrowser=clientBrwVersion()
             resta=(versionBrowser.indexOf("4.")!=-1?0:0)
               if (element.size-resta == element.value.length){
                   form(nextelement).select()
                   form(nextelement).focus()} }
				         }


		}

		function CheckAlfa(form,lCycle,element,nextelement) {
			//alert(event.keyCode);
			if ((form) && (!lCycle)) {
				if (event.keyCode == 13){
					if (form.onsubmit) {
						if (eval (form.onsubmit+"anonymous(form);")) {
							form.submit();
						}
					} else {
						form.submit();
					}
				} else {
					event.returnValue = true;
				}
			}
			if ( (event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode >= 97 && event.keyCode <= 122 ) || event.keyCode == 32  ) {
				/*
				if (lCycle) {
					if (element.size-1 == element.value.length) {
						//form(nextelement).blur();
						form(nextelement).select();
						form(nextelement).focus();
					}
				}
				*/
				event.returnValue = true;
			} else {
				event.returnValue = false;
			}

		}

function desdehastaimporte(strMsg) {

	if (document.all.form1.edesdeimporte.value + document.all.form1.ddesdeimporte.value < document.all.form1.ehastaimporte.value + document.all.form1.dhastaimporte.value) {
		return true;
	} else {
		return true;
	}


}

function clientBrwName()
{
 var elementosPrimarios=new Array(2);
 var retornoFinal=new Array(1);
 var nomBrow=new Array(1);
  strNavegador=navigator.appVersion;
  elementosPrimarios=strNavegador.split(";");
  nomBrow=elementosPrimarios[1].split(" ");
 return nomBrow[1];
}

function clientBrwVersion()
{
 var elementosPrimarios=new Array(2);
 var retornoFinal=new Array(1);
 var verBrow=new Array(1);
  strNavegador=navigator.appVersion;
  elementosPrimarios=strNavegador.split(";");
  verBrow=elementosPrimarios[1].split("E");
 return verBrow[1];
}

function isNumber(intKeyPress){
 return (intKeyPress>95 && intKeyPress<106);
}

function isAlpha(intKeyPress){
return ((intKeyPress >= 65 && intKeyPress <= 90) || (intKeyPress>= 97 && intKeyPress <= 122 ));
}

function hideSelect(form,strId) {
	var iddummy="dummyselect" + strId;
	var iddummycontrol="dummycontrol" + strId;
	var idselect= strId;
	var idselectcontrol = "control" + strId;
	var obj = form(idselect);
	form(iddummy).value=obj.options[obj.selectedIndex].text;
	document.all(iddummycontrol).style.display='';
	//obj.options(obj.selectedIndex).selected = true;
	document.all(idselectcontrol).style.display='none';
	document.all(iddummy).style.display='';
	window.event.cancelBubble = true;
	return true;
}

function changeSelect(form,strId) {
	var iddummy="dummyselect" + strId;
	var idselect= strId;
	var obj = form(idselect);
	form(iddummy).value=obj.options[obj.selectedIndex].text;
	obj.options(obj.selectedIndex).selected = true ;
	obj.blur();
	return true;
}

function showSelect(form,strId) {
	var iPointer;
	var iddummy="dummyselect" + strId;
	var iddummycontrol="dummycontrol" + strId;
	var idselect= strId;
	var idselectcontrol = "control" + strId;
	var obj = form(idselect);

	document.all(iddummy).style.display='none';
	document.all(iddummycontrol).style.display='none';
	document.all(idselectcontrol).style.display='';

	obj.focus();
	iPointer = obj.selectedIndex;
	obj.click();
	obj.selectedIndex = iPointer;
	window.event.cancelBubble = true;

}

function gotoUrl(strTargetPage){
  window.location=strTargetPage;}

function goBack() {
	var inputs = document.all.tags("INPUT");
	var value="";
	for (i=0; i<inputs.length; i++){
    	if (inputs(i).getAttribute("volver") != null ) {
			value = inputs(i).value
			i = inputs.length + 1;
    	}
	}
	if (value!="") {
		SetGoSubmit(document.all.form1,value);
		KillOnSubmit(document.all.form1);
		document.all.form1.submit();
	}
	return true;
}

function querySt(ji) 
{
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) 
	{
		ft = gy[i].split("=");
		if (ft[0] == ji) 
		{
			if (ft[1] == "Sellado")
			{
				return ft[1];
			}else{
				return "Base de Cálculo";
			}
		}else{
			return "Base de Cálculo";
		}
	}
}
