// Image Show

function ClosePopup_prod(clospopid) {
	var cont = document.getElementById(clospopid);
	cont.style.display = "none";
	var shade = document.getElementById("ip_shade");
	shade.style.display = "none";
	var metre = document.getElementById("ip_measure");
	metre.style.display = "none";
}

function ShowPopupProd(popid) {
	var cont = document.getElementById(popid);
	cont.style.display = "block";
	var cls = document.getElementById(popid+"ip_close");
	var shade = document.getElementById("ip_shade");
	var metre = document.getElementById("ip_measure");
	metre.style.display = "block";
	shade.style.display = "block";
	shade.style.height = document.body.scrollHeight;
	// Placing the close button
	cls.style.top = "0px";
	cls.style.left = (cont.clientWidth - cls.clientWidth) + "px";
	// Placing the popup in the center
	//cont.style.top = document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2;
	cont.style.top = (Math.round(document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2)<0)?(document.body.scrollTop + 30):(Math.round(document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2)) + "px";
	cont.style.left = Math.round(shade.clientWidth/2 - cont.clientWidth/2) + "px";
}



function ShowPopup() {
	var cont = document.getElementById("ipopup");
	cont.style.display = "block";
	var cls = document.getElementById("ip_close");
	var shade = document.getElementById("ip_shade");
	var metre = document.getElementById("ip_measure");
	metre.style.display = "block";
	shade.style.display = "block";
	shade.style.height = document.body.scrollHeight;
	// Placing the close button
	cls.style.top = 0;
	cls.style.left = cont.clientWidth - cls.clientWidth;
	// Placing the popup in the center
	//cont.style.top = document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2;
	cont.style.top = (Math.round(document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2)<0)?(document.body.scrollTop + 30):(Math.round(document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2));
	cont.style.left = Math.round(shade.clientWidth/2 - cont.clientWidth/2);
}

function ShowSmartPopup(which) {
	var cont = document.getElementById("ipopup_"+which);
	cont.style.display = "block";
	// Checking image dimensions
	if (img_isIE) {
		var theImg = cont.childNodes[2].childNodes[0].childNodes[1].childNodes[1].childNodes[0];
	} else {
		var theImg = cont.childNodes[3].childNodes[1].childNodes[2].childNodes[3].childNodes[0];
	}
	var myX = theImg.offsetWidth;
	var myY = theImg.offsetHeight;
	var scrX = document.body.scrollWidth;
	var scrY = document.body.clientHeight;
	if (myX > 780) {
		// resize by X
		var newX = 780;
		var ratio = newX / myX;
		var newY = Math.round(myY*ratio);
	} else if (myY > scrY*0.9) {
		var newY = Math.round(scrY*0.9);
		var ratio = newY / myY;
		var newX = Math.round(myX*ratio);
	} else {
		var newX = myX;
		var newY = myY;
	}
	theImg.style.width = newX+"px";
	theImg.style.height = newY+"px";
	var cls = document.getElementById("ip_close_"+which);
	var shade = document.getElementById("ip_shade");
	var metre = document.getElementById("ip_measure");
	metre.style.display = "block";
	shade.style.display = "block";
	shade.style.height = document.body.scrollHeight;
	// Placing the close button
	cls.style.top = 0;
	cls.style.left = cont.clientWidth - cls.clientWidth;
	// Placing the popup in the center
	cont.style.top = Math.round(document.body.scrollTop + metre.clientHeight/2 - cont.clientHeight/2);
	cont.style.left = Math.round(shade.clientWidth/2 - cont.clientWidth/2);
}


function ClosePopup() {
	var cont = document.getElementById("ipopup");
	cont.style.display = "none";
	var shade = document.getElementById("ip_shade");
	shade.style.display = "none";
	var metre = document.getElementById("ip_measure");
	metre.style.display = "none";
}

function CloseSmartPopup(which) {
	var cont = document.getElementById("ipopup_"+which);
	cont.style.display = "none";
	var shade = document.getElementById("ip_shade");
	shade.style.display = "none";
	var metre = document.getElementById("ip_measure");
	metre.style.display = "none";
}