
/*################################################################################*/
/*###############       Script per la gestione della tickbox       ###############*/
/*################################################################################*/
myTime = 0
unitaDiMisura = 40 //definisce lo spostamento di pixel per volta
unitaDiTempo = 1 //definisce l'intervallo di tempo in millisecondi tra uno spostamento e l'altro

function faiFade(tickPage,quanto){
	myTime = 1
	if(quanto<70){
		quanto += 5
		myTempObjZO = getTBObj(3)
		myTempObjZO.style.filter = "alpha(opacity="+quanto+")"
		myTempObjZO.style.opacity = "0."+(quanto)
		myTempObjZO.style.MozOpacity = "0."+(quanto)
		setTimeout("faiFade('"+tickPage+"',"+quanto+")",10)
	}else{
		myTime = 0
		openTickbox(tickPage,'','',1)
	}
}

function openTickbox(tickPage,myWidth,myHeight,step){
	showLoadingImage(1)
	myTempObjParent = getTBObj(1)
	myTempFrame = getTBObj(2)
	myTempObjZO = getTBObj(3)
	myTempObjZC = getTBObj(4)
	myTempObjOPF = getTBObj(5)
	myTempObj = getTBObj(6)
	myTempObjTop = getTBObj(7)
	
	if(step==0){
		myFPosition = setTimeout("setPosition('"+myHeight+"')",100)
		myTempObjZO.style.filter = "alpha(opacity=0)"
		myTempObjZO.style.opacity = "0"
		myTempObjZO.style.MozOpacity = "0"
		myTempObjZO.style.display = "block"
		myTempObjZC.style.display = "block"
		myTempFrame.location = tickPage
		myTempObjOPF.style.width = myWidth+"px"
		myTempObjOPF.style.height = myHeight+"px"
		faiFade(tickPage,0)
	}else{
		myTempObjParent.style.display="block"
	}
}

function setTickboxSize(){
	myParentBox = parent.document.getElementById("outerPopFrame")
	if(myParentBox){
		myParentBox.style.background = "none"
	}
}

function closeTickBox(){
	myTempObjParent = getTBObj(1)
	myTempFrame = getTBObj(2)
	myTempObjZO = getTBObj(3)
	myTempObjZC = getTBObj(4)
	
	myTempFrame.location = "about:blank"
	myTempObjParent.style.display="none"
	myTempObjZO.style.display = "none"
	myTempObjZC.style.display = "none"
	
	clearTimeout(myFPosition)
}

function getTBObj(myType){
	//Type: 1
	myObjParent = parent.document.getElementById("popFrame")
	//Type: 2
	myFrame = parent.popFrame
	//Type: 3
	myObjZO = parent.document.getElementById("lyrZoomOpacity")
	//Type: 4
	myObjZC = parent.document.getElementById("lyrZoomContent")
	//Type: 5
	myObjOPF = parent.document.getElementById("outerPopFrame")
	//Type: 6
	myObj = parent.document.getElementById
	//Type: 7
	myObjTop = parent.document.getElementById("myTop")
	
	myParentStr = ""
	parentNumber = 0
	counter = 0
	while(!myObjParent){
		counter = counter + 1
		if(counter > 10){
			return false;
		}
		parentNumber = parentNumber + 1
		for(i=0;i<parentNumber;i++){
			myParentStr += "parent."
		}
		//Type: 1
		eval("myObjParent = "+myParentStr+"document.getElementById('popFrame')")
		//Type: 2
		eval("myFrame = "+myParentStr+"popFrame")
		//Type: 3
		eval("myObjZO = "+myParentStr+"document.getElementById('lyrZoomOpacity')")
		//Type: 4
		eval("myObjZC = "+myParentStr+"document.getElementById('lyrZoomContent')")
		//Type: 5
		eval("myObjOPF = "+myParentStr+"document.getElementById('outerPopFrame')")
		//Type: 6
		eval("myObj = "+myParentStr+"document.getElementById")
		//Type: 7
		eval("myObjTop = "+myParentStr+"document.getElementById('myTop')")
	}
	switch (myType){
		case 1:
			return myObjParent
		case 2:
			//Type: 2
			return myFrame
		case 3:
			//Type: 3
			return myObjZO
		case 4:
			//Type: 4
			return myObjZC
		case 5:
			//Type: 5
			return myObjOPF
		case 6:
			//Type: 6
			return myObj
		case 7:
			//Type: 7
			return myObjTop
	}
}

function loadResizeFrame(){
	if(parent.myTime == 0){
		myInternalObjHeight = document.getElementById("myHeight")
		myInternalObjWidth = document.getElementById("myWidth")
		if(myInternalObjHeight){
			myTotHeight = ""
			myTotWidth = ""
			myInternalObjHeight.style.display="block"
			myTotHeight = myInternalObjHeight.offsetHeight
			if(myInternalObjWidth){
				myTotWidth = myInternalObjWidth.offsetWidth+32 //pił 32 a causa del padding e bordo destro e sinistro
			}
			myInternalObjHeight.style.display="none"
		}
		showLoadingImage(0)
		runToSize(myTotWidth,myTotHeight,'Height')
	}else{
		setTimeout("loadResizeFrame()",10)
	}
}

function runToSize(myTotWidth,myTotHeight,whichSize){
	myTempOPF = getTBObj(5)
	eval("myTotVar = myTot"+whichSize)
	eval("myTempSize = myTempOPF.offset"+whichSize)
	if(myTempSize > 0){
		segno = "-"
		if(myTempSize < myTotVar){
			segno = "+"
		}
		eval("myTempSize = myTempSize "+segno+" "+unitaDiMisura)
		if(segno == "+"){
			if(myTempSize > myTotVar){
				myTempSize = myTotVar
			}
		}else{
			if(myTempSize < myTotVar){
				myTempSize = myTotVar
			}
		}
		if(whichSize=="Height"){
			myTempOPF.style.height = myTempSize+"px"
		}else{
			myTempOPF.style.width = myTempSize+"px"
		}
		if(myTempSize == myTotVar){
			if(whichSize=="Height"){
				runToSize(myTotWidth,myTotHeight,'Width')
			}else{
				document.getElementById("myHeight").style.display="block"
				myMain = document.getElementById("main")
				myContent = document.getElementById("content")
				if(myMain && myContent) repeatFunc()
				if(mappa == 1) caricaMappa()
			}
		}else{
			setTimeout("runToSize("+myTotWidth+","+myTotHeight+",'"+whichSize+"')",unitaDiTempo)
		}
	}
}

function showLoadingImage(come){
	myTempZC = getTBObj(4)
	bgText = "none"
	if(come==1) bgText = "url(images/loadingAnim.gif)"
	myTempZC.style.background = bgText
	if(come==1){
		myTempZC.style.backgroundPosition = "center center"
		myTempZC.style.backgroundRepeat = "no-repeat"
	}
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {
		// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		// all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else {
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
} 


function getScreenScroll(){
	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;

	//IE
	if(!window.pageYOffset)
	{
		//strict mode
		if(!(document.documentElement.scrollTop == 0))
		{
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}
		//quirks mode
		else
		{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}
	//w3c
	else
	{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}
	return offsetY
}

function getScreenHeight(){
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}

	return h
}

function setPosition(myHeight) {
    myHeight = document.getElementById("outerPopFrame").offsetHeight
    
	myTempObjZO = getTBObj(3)
	myTempObjZC = getTBObj(4)
	myTempObjOPF = getTBObj(5)
	myTempObjTop = getTBObj(7)
	
	myArrSizes = getPageSizeWithScroll()
	myTempObjZO.style.height = myArrSizes[1]+"px"
	myTempObjZC.style.height = myArrSizes[1]+"px"
	
	
	myScreenHeight = getScreenHeight()
	myScreenScroll = getScreenScroll()
	
	
	/*
	alert("pageHeight = "+myArrSizes[1])
	alert("myScreenScroll = "+myScreenScroll)
	alert("myScreenHeight = "+myScreenHeight)
	*/
	
	
	myTopVar = parseInt( myScreenScroll + (myScreenHeight/2) )
	//alert(parseInt( myTopVar ))
	
	myTempObjTop.style.top = parseInt( myTopVar - (myHeight/2) ) + "px"
	myFPosition = setTimeout("setPosition('"+myHeight+"')",100)
}
/*################################################################################*/
/*###############       Script per la gestione della tickbox       ###############*/
/*################################################################################*/