//FUNZIONA SU IE, FIREFOX E OPERA

function getAnchor() 
	{if (!document.getElementsByTagName)
		{return; 
		}
	 var anchors = document.getElementsByTagName('a');
	 for (var i=0; i<anchors.length; i++)
	 	{var anchor = anchors[i];
		 var relAttribute = String(anchor.getAttribute('id'));
		 if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('box')))
		 	{anchor.onclick = function() 
				{Init(this); 
				 return false;
				}
			}
		}
	}

function Init(anchorClicked)
	{window.location.href = "#";
	 
	 var href = anchorClicked.getAttribute("rel");
	 	 
	 var arrayPageSize = getPageSize();
	
	 //var y2 = (arrayPageSize[1] / 2) - (HIframe / 2) - HClose_iframe;
	 var y2 = 100 - HClose_iframe;
	 var x2 = (arrayPageSize[0] / 2) - (WIframe / 2);	 
	 
	 var objBody = document.getElementsByTagName("body").item(0);
	 
	 var overlay = document.createElement("div");
	 overlay.setAttribute('id','overlay');
	 overlay.style.height = arrayPageSize[1] + "px";
	 overlay.style.width = arrayPageSize[0] + "px";
	 overlay.style.visibility = "visible";
	 objBody.appendChild(overlay);
	 
	 var iframe = document.createElement("iframe");
	 iframe.setAttribute('id','iframe');
	 
	 //var y = (arrayPageSize[1] / 2) - (HIframe / 2);
	 var y = 100;
	 var x = (arrayPageSize[0] / 2) - (WIframe / 2);
	 
	 iframe.style.top = y + "px";
	 iframe.style.left = x + "px";
	 iframe.style.height = HIframe + "px";
	 iframe.style.width = WIframe + "px";
	 iframe.style.visibility = "visible";
	 iframe.setAttribute('src', href);
	 iframe.setAttribute('scrolling','yes');
	 iframe.frameBorder = "0";
	 objBody.appendChild(iframe);
	 
	 var close_iframe = document.createElement("div");
	 close_iframe.setAttribute('id','close_iframe');
	 close_iframe.style.top = y2 + "px";
	 close_iframe.style.left = x2 + "px";
	 close_iframe.style.height = HClose_iframe + "px";
	 close_iframe.style.visibility = "visible";
	 objBody.appendChild(close_iframe);
	 
	 var Clink = document.createElement("img");
	 Clink.setAttribute('id','immagine');
	 Clink.setAttribute('src',chiudi);
	 Clink.onclick = function() {killIfrm(iframe,close_iframe,Clink,overlay);}
	 close_iframe.appendChild(Clink);
	 
	}

function killIfrm(iframe,close_iframe,Clink,overlay)
	{iframe.style.display = "none";
	 close_iframe.style.display = "none";
	 Clink.style.display = "none";
	 overlay.style.display = "none";
	 window.frames[0].location.reload();
	}

function F5Disabled() 
	{if (window.event && window.event.keyCode == 116) 
		{window.event.keyCode = 8;
		}
	 if (window.event && window.event.keyCode == 8) 
	 	{window.event.cancelBubble = true;
		 window.event.returnValue = false;
		 return false;
		}
	}
	
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll,yScroll)
	//arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight)
	return arrayPageSize;
}
