//<!--
/*=========================================================
	3-DHTML Photo Gallery

	by William Verdolini - jesi (italy) - 11/2002
	mail: w.verdolini@html.it

=========================================================*/

d = document
PGOp = window.opera?1:0
PGOp5 = (navigator.userAgent.toLowerCase().indexOf("opera 5")>-1)?1:0

function PG(arrayPGphotos,InitPGphoto,
		WIcone,HWRatio,dimFoto,Zoom,
		xPos,yPos,raggio,inclinazione,number,
		Func,otherArgs) {
	this.Img = []
	this.Lk = []
	this.didSpan = []
	this.x = []
	this.y2d = []
	this.y3d = []
	this.ang = []
	this.dim = []
	this.Immagini = []
	this.ImmBig = []
	this.did = []
	for(i=0; i<arrayPGphotos.length; i++) {
		this.Immagini[i] = arrayPGphotos[i].Ico
		this.did[i] = arrayPGphotos[i].txt	
		this.ImmBig[i] = arrayPGphotos[i].pho
	}
	this.DM = WIcone
	this.HWR = HWRatio
	this.DMF = dimFoto
	this.Z = Zoom/100
	this.xPG = xPos
	this.yPG = yPos
	this.r = raggio
	this.AZ = Math.cos((inclinazione/180)*Math.PI)
	this.AZrad = (inclinazione/180)*Math.PI
	this.AS = 1
	this.or = 1
	this.n = number || 1
	this.F = Func
	this.othArg = otherArgs
	this.ImZi = InitPGphoto ? 1 : 0
	var StrHTMLImm = ""
	StrHTMLImm += "<div align='center' id='LivPG"+this.n+"' style='position:absolute;left:"+(this.xPG)+"px;top:"+(this.yPG)+"px;'>"
	for(i=0; i<this.Immagini.length; i++) {
		StrHTMLImm +="<a onfocus='this.blur()' href='javascript:"
		StrHTMLImm += (this.F)?this.F+"("+i+""+(this.othArg?','+this.othArg+'['+i+']':'')+")'":"//'"
		StrHTMLImm +="><img style='position: absolute;width:"+this.DM+";' border='0' id='Imm"+this.n+"_"+i+"'  src='"+this.Immagini[i].src+"'>"
		StrHTMLImm +="</a>"
	}
	StrHTMLImm += "<img name='ImmPG"+this.n+"' style='position:absolute;left:"+((-this.DMF+this.DM)/2)+";top:"+(-(this.DMF/2))+"; width:"+this.DMF+";height:"+(this.DMF*this.HWR)+";z-index:0'  src='"+(InitPGphoto?InitPGphoto.Ico.src:this.NoImagePath)+"'>"
	StrHTMLImm += "<span class='didascalia"+this.n+"' id='PGdid"+this.n+"' style='position:absolute;width:"+(InitPGphoto?this.DMF:'0')+";left:"+((-this.DMF+this.DM)/2)+";top:"+(this.DMF*this.HWR)+";"+((InitPGphoto && InitPGphoto.txt)?'':'visibility:hidden;')+"z-index:0;'>"+(InitPGphoto?InitPGphoto.txt:'')+"</span>"
	for(i=0; i<this.Immagini.length; i++) {
		if(this.did[i])
			StrHTMLImm += "<span class='didascalia"+this.n+"' id='PGdid"+this.n+"_"+i+"' style='position:absolute;width:"+this.DMF+";left:"+((-this.DMF+this.DM)/2)+";top:"+(this.DMF*this.HWR)+";z-index:0;"+(PGOp?'visibility:hidden;':'display:none;')+"'>"+this.did[i]+"</span>"
	}
	StrHTMLImm += "<span class='didascalia"+this.n+"' id='PGldg"+this.n+"' style='position:absolute;width:"+this.DMF+";left:"+((-this.DMF+this.DM)/2)+";top:"+(this.DMF*this.HWR)+";z-index:0;"+(PGOp?'visibility:hidden;':'display:none;')+"'>"+this.LoadingMsg+"</span>"
	StrHTMLImm += "</div>"
	d.write(StrHTMLImm)
	this.AngRad = 0
	this.init()
}
function PGinit() {
	this.PGLevel=d.all?d.all["LivPG"+this.n]:d.getElementById?d.getElementById("LivPG"+this.n):null
	this.PGImm=d.images["ImmPG"+this.n]
	this.PGdid=d.all?d.all["PGdid"+this.n]:d.getElementById?d.getElementById("PGdid"+this.n):null
	this.PGldg=d.all?d.all["PGldg"+this.n]:d.getElementById?d.getElementById("PGldg"+this.n):null
	for (i=0;i<this.Immagini.length;i++) {
		this.Img[i]=d.all?d.all["Imm"+this.n+"_"+i]:d.getElementById?d.getElementById("Imm"+this.n+"_"+i):null;
		this.didSpan[i]=d.all?(d.all["PGdid"+this.n+"_"+i]||null):d.getElementById?d.getElementById("PGdid"+this.n+"_"+i):null;
		this.Img[i].ref = this
		this.ang[i] = (2*Math.PI/(this.Immagini.length))*i
		this.x[i] = Math.cos(this.ang[i])*this.r
		this.y2d[i] = Math.sin(this.ang[i])*this.r
		this.y3d[i] = this.y2d[i]*this.AZ
		if(this.DM) this.dim[i] = this.DM - Math.round(Math.sin(this.ang[i])*this.AZrad*100)*0.01*(this.DM*this.Z)
		this.Img[i].ind = i
		if(!this.F) 
			this.Img[i].onclick = function(e) {this.ref.poster(this.ind);if(!e) e=window.event;if(e.preventDefault) e.preventDefault();else e.returnValue=true;return false;}
        }
	this.PGImm.ZInd = -Math.round(this.y2d[0]/this.r*10-10)
	this.PGImm.h = this.DMF*this.HWR - this.DM/2*this.HWR
	this.PGdid.h = this.PGldg.h = -(this.PGImm.h - this.DMF*this.HWR*2)/2
	this.PGImm.h = -this.PGImm.h/2
	this.PGImm.hOff = (this.r - Math.round(this.AZ*this.r))/this.r*this.DM*this.depth || 0
	this.PGImm.style.zIndex = this.ImZi ? this.PGImm.ZInd : 0
	this.PGdid.style.zIndex = this.PGldg.style.zIndex = this.PGImm.ZInd
	for (i=0;this.didSpan[i] && i<this.didSpan.length;i++) {
		this.didSpan[i].h = this.PGdid.h
		this.didSpan[i].zIndex = this.PGImm.ZInd
	}
	this.PGImm.ref = this
	this.PGImm.ind = -1;
	this.PGImm.onerror = function() {if(this.ind>-1)  this.src = this.ref.ImmBig[this.ind].src;}
	this.PGImm.onabort = function() {if(this.ind>-1)  this.src = this.ref.ImmBig[this.ind].src;}
	this.PGImm.onload = function() {if(this.ind>-1)  {this.ref.ImmBig[this.ind].loaded = 1;this.ref.didascalia(this.ind);}}
        this.display()
}
function PGdisplay() {
	for (i = 0; i < this.Immagini.length; i++) {
		this.Img[i].style.left = -this.x[i]
		this.Img[i].style.top = -this.y3d[i]
		this.Img[i].style.zIndex = -Math.round(this.y2d[i]*(1 - this.AZ)/this.r*10-10)+1
		if(this.dim[i]) this.Img[i].style.width = this.dim[i]
		if(this.dim[i]) this.Img[i].style.height = this.dim[i]*this.HWR
	}
	if(PGOp) {
		this.PGImm.style.zIndex = this.ImZi ? this.PGImm.ZInd : 0
		this.PGdid.style.zIndex =  this.PGldg.style.zIndex = this.PGImm.ZInd
	}
	this.PGImm.style.top = Math.ceil(this.PGImm.h - this.PGImm.hOff)
	this.PGdid.style.top = this.PGldg.style.top = Math.round(this.PGdid.h - this.PGImm.hOff)
	for (i=0;this.didSpan[i] && i<this.didSpan.length;i++) {
		this.didSpan[i].style.top = Math.round(this.didSpan[i].h - this.PGImm.hOff)
		this.didSpan[i].style.zIndex = this.didSpan[i].zIndex
	}
}
function PGdefXY(){
	for(i=0; i<this.Immagini.length; i++) {
		this.ang[i] = (this.ang[i]+this.AngRad)%(2*Math.PI)
		this.x[i] = Math.cos(this.ang[i])*this.r
		this.y2d[i] = Math.sin(this.ang[i])*this.r
		this.y3d[i] = Math.round(this.y2d[i]*this.AZ)
		if(this.DM) this.dim[i] = this.DM - Math.floor(Math.sin(this.ang[i])*this.AZrad*100)*0.01*(this.DM*this.Z)
	}
}
function PGplay(){
	if(this.action) {
		ref = this
		this.AngRad = this.or? (this.AS/180)*Math.PI : -(this.AS/180)*Math.PI
		this.defXY()
		this.display()
		this.action = setTimeout("ref.play()",this.minCPUres)
	}
}
function PGstop(){
	this.action = null
	clearTimeout(this.action)
}
function PGrotate(orario,AngleStep){
	clearTimeout(this.action)
	ref = this
	this.or = orario
	this.AS = AngleStep
	this.action = setTimeout("ref.play()",this.minCPUres)
}
function PGincline(inclinazione){
	var change
	ref = this
	change = (this.AZ != Math.cos((inclinazione/180)*Math.PI))? 1 : 0
	this.AZ = Math.cos((inclinazione/180)*Math.PI)
	this.AZrad = (inclinazione/180)*Math.PI
	this.PGImm.hOff = change ? (this.r - Math.round(this.AZ*this.r))/this.r*this.DM*this.depth : this.PGImm.hOff
	this.defXY()
	this.display()
}
function PGvisible(is){
	if(this.PGLevel) {
		this.stop()
 		this.PGLevel.style.visibility = is ? "visible" : "hidden"
		if(PGOp) this.display()
	}
}
function PGposter(index){
	this.PGImm.ind = index
	this.PGImm.style.zIndex = this.PGImm.ZInd
	if(PGOp) this.ImZi=1
	if(this.ImmBig[index].constructor == String){
		var ImUrl = this.ImmBig[index].src
		this.ImmBig[index] = new Image()
		this.ImmBig[index].src = ImUrl
	}
	this.PGImm.src = this.ImmBig[index].src
	this.didascalia(index);
}
function PGdid(index){
	if(PGOp) this.PGdid.style.visibility = this.PGldg.style.visibility = "hidden"
	else this.PGdid.style.display = this.PGldg.style.display = "none"
	for (i=0;i<this.didSpan.length && this.didSpan[i];i++) {
		if(PGOp) this.didSpan[i].style.visibility = "hidden"
		else this.didSpan[i].style.display = "none"
	}
	if((!this.ImmBig[index].complete && !PGOp5 && PGOp)||(!this.ImmBig[index].loaded && !PGOp)) {
		if(this.LoadingMsg){
			if(PGOp) this.PGldg.style.visibility = "visible"
			else this.PGldg.style.display = "inline"
		}
	}
	else if(this.didSpan[index]){
		if(PGOp) this.didSpan[index].style.visibility = "visible"
		else this.didSpan[index].style.display = "inline"
	}

}
PG.prototype.init = PGinit
PG.prototype.defXY = PGdefXY
PG.prototype.display = PGdisplay
PG.prototype.play = PGplay
PG.prototype.stop = PGstop
PG.prototype.rotate = PGrotate
PG.prototype.incline = PGincline
PG.prototype.visible = PGvisible
PG.prototype.poster = PGposter
PG.prototype.didascalia = PGdid
PG.prototype.depth = 2.1
PG.prototype.minCPUres = 20  
PG.prototype.LoadingMsg = "<br>Loading...<br><br>"  //Loading Message
PG.prototype.NoImagePath = "icons/1pix.gif"  //trasparent image path (if there's not initial Image)

function PGphoto(URLIcona,didascalia,URLPhoto,preloading){
	this.Ico = new Image()
	this.Ico.src = URLIcona
	this.pho = (preloading) ? new Image() : new String();
	this.pho.src = URLPhoto || URLIcona
	this.pho.loaded = (preloading && PGOp) ? 1 : 0;
	this.txt = didascalia || null
}
//-->