// JavaScript Document
function overme(o,modo) {
	var d=$("overup")
	if (d) {
		if (modo) {
			d.style.backgroundImage="url(css/home/"+o.className+"_txt.png)"
		} else {
			d.style.backgroundImage="none"
		}
	}
}
function overbot(o,modo) {
	sc($("normale_txt"),(modo)?"hide":"",(modo)?"":"hide")
	sc($(o.className+"_txt"),(modo)?"":"hide",(modo)?"hide":"")
}

function faderfoto(id,p,vi) {
	oObjMng[oObjMng.length]=new cls_animazione_d(oObjMng.length,id,p,vi)
}

function cls_animazione_d(obIndx,holder,inBase,inSrc,inStop,idInt,idExt,inMultiLoop) {
	this.obIndex=obIndx
	this.cimg=0
	this.holder=holder
	this.objHolder=null
	this.base=inBase
	this.ext=".jpg"
	this.maximg=inSrc.length
	this.runTime=30
	this.stopTime=(inStop==undefined)?2000:inStop
	this.opa=1
	this.verso=1
	this.multiloop=(inMultiLoop==undefined)?true:inMultiLoop
	this.pr=10
	this.images=new Array()
	this.vcimg=inSrc
	this.clock=0
	this.wkswObj=0
	this.idIntName=(idInt==undefined)?(holder+"2"):idInt
	this.idExtName=(idExt==undefined)?(holder+"1"):idExt
	this.oInt=$(this.idIntName)
	this.oExt=$(this.idExtName)
	
	this.maximg=this.vcimg.length-1
	
	if (this.maximg>=0) {
		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.postInit=function postInit() {
		if (this.maximg>=0) {
			var o=$(this.holder)
			if (o) {
				if (!this.oExt) {
					this.oExt=$b("div")
					this.oExt.id=this.idExtName
					this.oExt.className=o.className
					o.appendChild(this.oExt)
				}
				if (!this.oInt) {
					this.oInt=$b("div")
					this.oInt.id=this.idIntName
					this.oInt.className=o.className
					this.oExt.appendChild(this.oInt)
				}
				this.objHolder=o
				this.oExt.style.backgroundImage="url("+this.base+this.vcimg[1]+this.ext+")"
				this.oInt.style.backgroundImage="url("+this.base+this.vcimg[0]+this.ext+")"
				this.opa=98
				this.wkswObj=1
				this.verso=1
				if (this.maximg>0) {
					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}
			if (webKitVersion==0) {
				this.clock=setTimeout("oObjMng["+this.obIndex+"].run()",nt)
			} else {
				this.clock=setTimeout("oObjMng["+this.obIndex+"].wkrun()",nt)
			}
		} else {
			this.pr+=10
			this.clock=setTimeout("oObjMng["+this.obIndex+"].prerun()",10)
		}
	}
	this.wkrun=function wkrun() {
		this.clock=setTimeout("oObjMng["+this.obIndex+"].wkswap()",this.runTime*10)
	}
	this.wkswap=function wkswap() {
		this.wkswObj=(this.wkswObj==0)?1:0
		this.oInt.style.opacity=this.wkswObj
		
		if (this.wkswObj==0) {
			this.cimg=(this.cimg<this.maximg)?(this.cimg+1):0
			this.oExt.style.backgroundImage="url("+this.images[this.cimg].src+")"
			this.clock=setTimeout("oObjMng["+this.obIndex+"].wkrun()",this.stopTime*5)
		} else {
			this.cimg=(this.cimg<this.maximg)?(this.cimg+1):0
			this.oInt.style.backgroundImage="url("+this.images[this.cimg].src+")"
			this.clock=setTimeout("oObjMng["+this.obIndex+"].wkrun()",this.stopTime*5)
		}
		
	}
	this.run=function run() {
		this.opa=this.opa+this.verso	
		if (this.opa<1) {this.opa=1}
		this.oInt.style.opacity=(this.opa/100);this.oInt.style.filter="alpha(opacity="+this.opa+")"
		
		if (this.opa==1) {
			this.verso=1
			this.cimg=(this.cimg<this.maximg)?(this.cimg+1):0
			this.oInt.style.backgroundImage="url("+this.images[this.cimg].src+")"
			
			this.clock=setTimeout("oObjMng["+this.obIndex+"].run()",this.stopTime)
		} else {
			if (this.opa==99) {
				this.verso=-1
				this.cimg=(this.cimg<this.maximg)?(this.cimg+1):0
				this.oExt.style.backgroundImage="url("+this.images[this.cimg].src+")"
				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
	}
}
