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);
	}
}

function mappaLoad() {
	if (GBrowserIsCompatible()) {
    	var map = new GMap2(document.getElementById("map"));
		var latlng=new GLatLng(43.582155,13.337134)
        map.setCenter(latlng, 12);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		var marker=new GMarker(latlng)
		GEvent.addListener(marker,"click", function() {
        var myHtml = '<img src="imgs/miamappa.gif" style="float:left;margin-left:3px"/><b style="color:#44a22a">Mia Golf Club </b><br/><b style="color:#009ee0">Camerata Picena </b><br/><a href="http://maps.google.com/maps?f=d&amp;hl=it&amp;geocode=10475551903980381518,43.582062,13.337113&amp;saddr=&amp;daddr=MiaGolfClub+%4043.582062,13.337113&amp;sll=43.582062,13.337113&amp;sspn=0.009839,0.016093&amp;ie=UTF8&amp;t=h&amp;z=14">Visualizza</a> il percorso raggiuncerci';
        map.openInfoWindowHtml(latlng, myHtml);
      });
		map.addOverlay(marker)
	}
}
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()}
	}
}
function checkIE6() {
	var ie6=navigator.appVersion.indexOf("MSIE 6.0")
	if (ie6!=-1) {sc(document.body,"ie6")}
	
}
addLoader(checkIE6)
addLoader(postLoad)
addUnLoader(postUnload)


/*function animahome(a,b,c) {
	oObjMng[oObjMng.length]=new cls_animazione(oObjMng.length,a,b,c)
}*/
function animahome() {
	oObjMng[oObjMng.length]=new cls_animazione(oObjMng.length,"topslide/index.html",[1,2,3,4,5,6,7,8,9,10],5000)
}
function cls_animazione(obIndx,inBase,inSrc,inStop,idExt,idInt) {
	this.obIndex=obIndx
	this.cimg=0
	this.base=inBase
	this.ext=".jpg"
	this.maximg=inSrc.length
	this.runTime=50
	this.stopTime=(inStop==undefined)?2000:inStop
	this.opa=100
	this.multiloop=true
	this.pr=10
	this.images=new Array()
	this.vcimg=inSrc
	this.oInt=null
	this.oExt=null
	this.clock=0
	this.idIntName=(idInt==undefined)?"anima1":idInt
	this.idExtName=(idExt==undefined)?"anima":idExt
	this.postInit=function postInit() {
		this.maximg=this.vcimg.length-1
		for (var i=0;i<=this.maximg;i++) {
			var ci=new Image()
			ci.src=this.base+this.vcimg[i]+this.ext
			this.images[i]=ci
		}
		this.oInt=$(this.idIntName)
		if (this.oInt) {this.oInt.style.backgroundImage="url("+this.base+this.vcimg[0]+this.ext+")"}
		this.oExt=$(this.idExtName)
		if (this.oExt) {this.oExt.style.backgroundImage="url("+this.base+this.vcimg[1]+this.ext+")"}
		if (this.oExt&&this.oInt) {this.vcimg=null;this.clock=setTimeout("oObjMng["+this.obIndex+"].prerun()",10)}
	}
	this.prerun=function prerun() {
		var ok=true
		for(var i=0;i<this.images.length;i++) {
			if (!this.images[i].complete) {ok=false}
		}
		if(ok) {
			var nt=this.stopTime-this.pr
			if (nt<10) {nt=10}
			this.clock=setTimeout("oObjMng["+this.obIndex+"].run()",nt)
		} else {
			this.pr+=10
			this.clock=setTimeout("oObjMng["+this.obIndex+"].prerun()",10)
		}
	}
	this.run=function run() {
		this.opa--
		
		this.oInt.style.opacity=(this.opa/100);this.oInt.style.filter="alpha(opacity="+this.opa+")"
		
		if (this.opa==1) {
			if (this.multiloop) {
				this.cimg=(this.cimg<this.maximg)?(this.cimg+1):0
				var nstagione=(this.cimg<this.maximg)?(this.cimg+1):0
				
				this.oInt.style.backgroundImage="url("+this.images[this.cimg].src+")"
				this.opa=99
				this.oInt.style.opacity=(this.opa/100)
				this.oInt.style.filter="alpha(opacity="+this.opa+")"
				this.oExt.style.backgroundImage="url("+this.images[nstagione].src+")"
				
				this.clock=setTimeout("oObjMng["+this.obIndex+"].run()",this.stopTime)
			} else {
				if (this.cimg<this.maximg) {
					this.cimg++
					this.oInt.style.backgroundImage="url("+this.images[this.cimg].src+")"
					this.opa=99
					this.oInt.style.opacity=(this.opa/100)
					this.oInt.style.filter="alpha(opacity="+this.opa+")"
					this.oExt.style.backgroundImage="url("+this.images[this.cimg].src+")"
					if (this.cimg<this.maximg) {this.clock=setTimeout("oObjMng["+this.obIndex+"].run()",this.stopTime)}
				}
			}
		} else {
			this.clock=setTimeout("oObjMng["+this.obIndex+"].run()",this.runTime)
		}	
	}
	this.unload=function unload() {
		clearTimeout(this.clock)
		this.oInt=null
		this.oExt=null
		this.images=null
	}
}


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
		}
    }
}
