function displayImgDefault(id_image,id_color) {
	if ((id_color > 0) && (id_image > 0)) {
		document.getElementById("productMainImage").style.display = "block";
		document.getElementById("productOtherImage").style.display = "none";
		document.getElementById("imgButtonColor").style.display = "block";
		document.getElementById("imgButtonProduct").style.display = "none";
	} else if ((id_color > 0) && (id_image == 0)) { 
		document.getElementById("productMainImage").style.display = "none";
		document.getElementById("productOtherImage").style.display = "block";
		document.getElementById("imgButtonColor").style.display = "none";
		document.getElementById("imgButtonProduct").style.display = "none";
	} else {
		document.getElementById("productMainImage").style.display = "block";
		document.getElementById("productOtherImage").style.display = "none";
		document.getElementById("imgButtonColor").style.display = "none";
		document.getElementById("imgButtonProduct").style.display = "none";
	}
}
function displayImgColor() {
	document.getElementById("productMainImage").style.display = "none";
	document.getElementById("productOtherImage").style.display = "block";
	document.getElementById("imgButtonColor").style.display = "none";
	document.getElementById("imgButtonProduct").style.display = "block";
}
function displayImgProduct() {
	document.getElementById("productMainImage").style.display = "block";
	document.getElementById("productOtherImage").style.display = "none";
	document.getElementById("imgButtonColor").style.display = "block";
	document.getElementById("imgButtonProduct").style.display = "none";
}
function printImgProduct(img) {
	window.open(img);
}
/* popup photos */
var imgloading= '/images/loading.gif';
var divPopup;
var divBackground;
var chiudipop;
var bigimg;
var initiate = false;

function pageSize(pageWidth,pageHeight,windowWidth,windowHeight,scrollLeft,scrollTop,xScroll,yScroll){
	this.pageWidth=pageWidth;
	this.pageHeight=pageHeight;
	this.windowWidth=windowWidth;
	this.windowHeight=windowHeight;
	this.scrollLeft=scrollLeft;
	this.scrollTop=scrollTop;
	this.xScroll=xScroll;
	this.yScroll=yScroll;
}
function getPageSize(){
	var pageWidth,pageHeight,windowWidth,windowHeight;
	var xScroll, yScroll,scrollLeft,scrollTop;
	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;
	}
	if (self.pageYOffset) {
		scrollLeft = self.pageXOffset;
		scrollTop = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		scrollLeft = document.documentElement.scrollLeft;
		scrollTop = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		scrollLeft = document.body.scrollLeft;
		scrollTop = document.body.scrollTop;
	}
	// su tutto schermo
	if (xScroll < screen.width )
		xScroll = screen.width;
	if (yScroll < screen.height )
		yScroll = screen.height;
	return new pageSize(pageWidth,pageHeight,windowWidth,windowHeight,scrollLeft,scrollTop,xScroll,yScroll);
}
function hideImagebox(){
	divBackground.style.display = 'none';
	divPopup.style.display = 'none';	
	// IE le combo non vengono nascoste
	var selectElem = document.getElementsByTagName('select');
	for(var i=0 ; i< selectElem.length;i++)
		selectElem[i].style.display = 'block';
	//
}
function imgpopup(objLink,width,height){
	initFotogallery(width,height);
	bigimg.src = imgloading;
  bigimg.alt = 'loading ...';
	var imgPreload = new Image();
	imgPreload.onload = function(){
												bigimg.src = objLink.href;
												bigimg.alt = "";
  											return false;
											}
	imgPreload.src = objLink.href;
  if (divPopup.style.display == 'block')
  	return;
  var pageSize = getPageSize();
 	divPopup.style.visibility = 'hidden';
 	divPopup.style.display = 'block';
  var divPopupWidth = width + 20; //divPopup.offsetWidth;
	var divPopupHeight = height + 20; //divPopup.offsetHeight;
	divPopup.style.visibility = 'visible';
 	divPopup.style.display = 'none';
	var boxTop = Math.round((pageSize.windowHeight - divPopupHeight)/2);
	var boxLeft = Math.round((pageSize.pageWidth -  divPopupWidth)/2);
	boxTop += pageSize.scrollTop;
	boxLeft += pageSize.scrollLeft;
	divPopup.style.top = (boxTop < 0) ? '0px' : boxTop + 'px';
	divPopup.style.left = (boxLeft < 0) ? '0px' : boxLeft + 'px';
	divBackground.style.width = pageSize.xScroll +'px';
	divBackground.style.height = pageSize.yScroll +'px';
	// IE le combo non vengono nascoste
	var selectElem = document.getElementsByTagName('select');
	for(var i=0 ; i< selectElem.length;i++)
		selectElem[i].style.display = 'none';
	//	
	//divBackground.style.display = 'block';
	divPopup.style.display = 'block';
	return false;
}

function initFotogallery(width,height){
	if (!document.getElementsByTagName || !document.getElementById )
		 return;
	var objBody = document.getElementsByTagName("body").item(0);
	// div Background
	divBackground = document.createElement("div");
	divBackground.setAttribute('id','fotogbackground');
	divBackground.onclick = function () {hideImagebox(); return false;}
	objBody.appendChild(divBackground);
	// div foto
	divPopup = document.createElement("div");
	divPopup.setAttribute('id','fotopop');
	var wrapTocenter = document.createElement("div");
	wrapTocenter.setAttribute('class','wraptocenter');
	chiudipop = document.createElement("p");
	chiudipop.setAttribute('id','chiudipop');
	chiudipop.appendChild( document.createTextNode('CHIUDI X') );
	chiudipop.onclick = function () {hideImagebox(); return false;}
	bigimg = document.createElement("img");
	bigimg.setAttribute('id','fotogbigimg');
	bigimg.setAttribute('src','');
	bigimg.setAttribute('width',width);
	bigimg.setAttribute('height',height);
	wrapTocenter.appendChild(bigimg);
	divPopup.appendChild(chiudipop);
	divPopup.appendChild(wrapTocenter);
	objBody.appendChild(divPopup);
	initiate = true;
}
/* end popup photos */

