function addLoader(f) {
	if (f!=undefined) {
	if (window.onload) {
		var z=window.onload	
		window.onload=function () {f();z()}
	} else {
		window.onload=f
	}}
}
function addUnLoader(f) {
	if (window.onunload) {
		var z=window.onunload	
		window.onunload=function () {z();f()}
	} else {
		window.onunload=f
	}
}

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);
	}
}


var oObjMng=new Array()
function postLoad() {
	for (var i=0;i<oObjMng.length;i++) {
		if (oObjMng[i].postInit) {oObjMng[i].postInit()}
	}
}
function postUnload() {
	for (var i=0;i<oObjMng.length;i++) {
		if (oObjMng[i].unload) {oObjMng[i].unload()}
	}
}
addLoader(postLoad)
addUnLoader(postUnload)

function loadMiniNews(id,n) {
	oObjMng[oObjMng.length]=new fsScrollV(oObjMng.length,id,n)
}
function goNotizia(id) {
	if (cPage!="news") {
		document.location="news.asp?id="+id
	} else {
		showNews(id)
	}
}
var newsID=""
function showNews(id) {
	if (newsID!=id) {
		if(newsID!="") {sc($("n"+newsID),"hide");sc($("m"+newsID),"","corrente");}
		newsID=id
		sc($("n"+newsID),"","hide");sc($("m"+newsID),"corrente")
	}
}
fsScrollV=function(idx,id,n) {
	this.obj=$(id)
	this.omgIdx=idx
	this.timer=null
	this.ctop=0
	this.cHeight=0
	this.nBox=n
	this.timeRun=10
	this.timeStop=5000
	var vo=$t(this.obj,"*")
	if (vo.length>1) {
		this.cHeight=vo[0].clientHeight	
	}
}
fsScrollV.prototype.postInit=function() {
	if (this.cHeight!=0) {
		this.timer=	setTimeout("oObjMng["+this.omgIdx+"].run()",this.timeStop)
	}
}
fsScrollV.prototype.unload=function() {clearTimeout(this.timer)}
fsScrollV.prototype.run=function() {
	this.ctop--
	if (this.ctop==(-this.nBox*this.cHeight)) {this.ctop=0}
	this.obj.style.top=this.ctop+"px"
	if ((this.ctop%this.cHeight)==0) {
		this.timer=	setTimeout("oObjMng["+this.omgIdx+"].run()",this.timeStop)
	} else {
		this.timer=	setTimeout("oObjMng["+this.omgIdx+"].run()",this.timeRun)
	}
}


function sc(o,ncn,ocn) {
	if (o) {
		if (ocn!=undefined) {
			if(ocn!="") {
				var re=new RegExp("\\b"+ocn+"\\b","gi")
				var i=o.className.search(re)
				if (i!=-1) {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}
		}
	}
}

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 {
				if (ve[4]=="X") {
					callback(true, Req,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
		}
    }
}

