
function addLoader(f) {
	if (window.onload) {
		var z=window.onload	
		window.onload=function () {z();f()}
	} else {
		window.onload=f
	}
}
function addUnLoader(f) {
	if (window.onunload) {
		var z=window.onunload	
		window.onunload=function () {z();f()}
	} else {
		window.onunload=f
	}
}

function pretty(v,d0) {
	var d=(d0==undefined)?2:d0
	if (d==2) {
		var v0=(Math.round(v*100)/100)+.0001
	} else {
		var v0=Math.round(v*1)
	}
	var vv=(v0+"").split(".")
	var d=""
	var m=""
	var c=""
	//if(vv.length==2) {d=","+(vv[1]+"00").substr(0,2)}
	if(vv.length==2) {d=","+(vv[1]+"00").substr(0,2)}
	if (vv[0].length>3) {
		c="."+vv[0].substr(vv[0].length-3,3)
		m=vv[0].substr(0,vv[0].length-3)
		return pretty(m,0)+c+d
	} else {
		return vv[0]+d
	}
}


function getSafExx(s) {
	return  s.replace(/&#(\d{1,4});/gi,function (a,b,c,d) {return String.fromCharCode(b)})
}

function $(id) {return document.getElementById(id)}
function $t(o,id) {return o.getElementsByTagName(id)}
function $b(id) {return document.createElement(id)}
function $ct(t) {return document.createTextNode(t)}
function $ae(o,eName,f) {
	if(window.addEventListener){ // Mozilla, Netscape, Firefox
		o.addEventListener(eName, f, false);
	} else { // IE
		o.attachEvent('on'+eName, f);
	}
}
function $clone(id) {
	var o=$(id)
	var c=null
	if (o) {
		var c=o.cloneNode(true)
		c.style.display=""
	}
	return c
}
function setEditValueV(ids,vs) {
	for(var i=0;i<ids.length;i++) {
		setEditValue(ids[i],(i<vs.length)?vs[i]:"")
	}
}
function setErrValue(id,value) {
	var o=$("e"+id)
	if (o) {o.innerHTML=value}
}
function setEditValue(id,value) {
	var o=$(id)
	if (o) {
		if (o.tagName=="TD"||o.tagName=="DIV"||o.tagName=="SPAN") {
			o.innerHTML=value
		} else {
			if(o.type=="checkbox") {
				o.checked=(value!="")
			} else {
				o.value=value
			}
		}
		setErrValue(id,"")
	}
}

function getEscValueV(ids) {
	var r=""
	for(var i=0;i<ids.length;i++) {
		r+=getEscValue(ids[i],(i==0)?"":"&")
	}
	return r
}

function getEscValue(id,p) {
	var o=$(id)
	var rval=p+id+"="
	if(o&&o.tagName=="INPUT"&&o.type=="radio") {o=null}
	if (o) {
		if(o.type=="checkbox") {
			rval=p+id+"="+escape(o.checked?o.value:"")
		} else {
			rval=p+id+"="+escape(o.value)
		}
	} else {
		var vo=document.getElementsByName(id)
		if (vo.length!=0) {
			for(var i=0;i<vo.length;i++) {
				if (vo[i].tagName=="INPUT") {
					if (vo[i].type=="radio") {
						if (vo[i].checked) {rval=p+id+"="+escape(vo[i].value)}
					}
				}
			}
			rval=p+id+"="
		}
	}
	return rval.replace("+","%2B")
}

function getFldValue(id) {
	var o=$(id)
	if (o) {
		return (o.type=="checkbox")?(o.checked?o.value:""):(o.value)
	} else {
		return ""
	}
}
function abilitaV(vv,modo) {
	for(var i=0;i<vv.length;i++) {abilita(vv[i],modo)}
}
function abilita(id,modo) {
	var o=$(id)
	if (o) {o.disabled=!modo}
}

function sc(o,ncn,ocn) {
	if (o) {
		if (ocn!=undefined) {
			if(ocn!="") {
				var re=new RegExp("\\b"+ocn+"\\b","gi")
				o.className=o.className.replace(re,"")
			}
		}
		if (ncn!="") {
			var re=new RegExp("\\b"+ncn+"\\b","gi")
			var i=o.className.search(re)
			if (i==-1) {o.className=o.className.replace(/\s*$/,'')+" "+ncn}
		}
		//alert(o.className)
	}
}


var vxc=new Array()
var vxr=false

function callAction(ve) {
	vxc.push(ve)
///	wl("callA")
	if (!vxr) {callX()}
}

function callX() {
	if (vxc.length==0) {return}
	vxr=true
	ve=vxc.pop()
	var isXML=false
	var isIE=false
//	wl("callX")
	var callback=ve[1]
	
	isXML=(window.XMLHttpRequest?true:false)
	isIE=(window.ActiveXObject?true:false)
	if (isIE) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP")
			isIE=(req?true:false)
		} catch (e) {
       		isIE = false;
		}
	}
	if (isIE) {isXML=true}
	if (isXML) {
		if (isIE) {
			var Req = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		    var Req = new XMLHttpRequest();
		}
		if (ve[0]=="P") {
			Req.onreadystatechange = mycallback
		    Req.open("POST", ve[2], true)
			Req.setRequestHeader('Accept','jsxfalcosoft')
			Req.setRequestHeader('Content-Type','charset=iso-8859-1')
			Req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			Req.send(ve[3]);
		} else {
			Req.onreadystatechange = mycallback
		    Req.open("GET", ve[2]+"?"+ve[3], true);
			Req.setRequestHeader('Accept','jsxfalcosoft')
			Req.setRequestHeader('Content-Type','charset=iso-8859-1')
			Req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    		Req.send(null);
		}
	} else {
		document.location=ve[2]+"?"+ve[3]
	}
	function mycallback() {
        if (Req.readyState != 4) return;
        if (Req.status == 200) {
			if (ve[4]=="T") {
				callback(true, Req.responseText,ve[2],ve[3])
			} else {
				callback(true, Req.responseXML,ve[2],ve[3])
			}
        } else {
			callback(false, Req.status + ": " + Req.statusText,ve[2],ve[3])
		}
		if(vxc.length!=0) {
			callX()
		} else {
			vxr=false
		}
    }
}




