// Functions by Matthyz webdesign & development - www.matthyz.nl; copying is not allowed
function showIMG(imgID) {
	//If the container element already exists, delete it
	if(document.getElementById("bigphoto") != null) {
		document.body.removeChild(document.getElementById("bigphoto"));
	}
	
	//If there is a flash element on the page, hide it
	if(document.getElementById("simpleviewer") != null) {
		document.getElementById('simpleviewer').style.visibility = "hidden";
	}
	
	//Set the opacity to 0.4
	var Cstyle = document.getElementById("content").style;	
	Cstyle.opacity = 0.4;
	Cstyle.MozOpacity = 0.4;
	Cstyle.KhtmlOpacity = 0.4;
	Cstyle.filter = "alpha(opacity=" + 40 + ")";
	
	//Create the image element
	var img = document.createElement('img');
	img.setAttribute('id', imgID);
	img.setAttribute('src', "images/imgsize.php?img="+imgID+".jpg&w=500&h=500&constrain");
	img.setAttribute("data-magnifysrc", 'images/imgsize.php?img='+imgID+'.jpg&w=1500&h=1500&constrain');
	img.setAttribute("border", "0px");
	
	//Wait for the image to be loaded so we know the height
	var h = img.height;
	for(var i=0; i<100 && h!=0; i++) {
		setTimeout("h = img.height;",100);
	}
	h = (h==0) ? 500 : h;
	
	//Create the container
	var container = document.createElement('center');
	container.setAttribute('id', "bigphoto");
	container.style.width = "100%";
	container.style.height = h+"px";
	container.style.position = "absolute";
	container.style.left = "0px";
	container.style.top = getcenter(h)+"px";
	container.appendChild(img);
	document.body.appendChild(container);
	
	//Make the image magnifiable
	MojoMagnify.makeMagnifiable(  
		document.getElementById(imgID),   
		'images/imgsize.php?img='+imgID+'.jpg&w=1500&h=1500&constrain'  
	); 
}
function hideIMG() {
	//If there is a flash element on the page, show it again
	if(document.getElementById("simpleviewer") != null) {
		document.getElementById('simpleviewer').style.visibility = "visible";
	}
	
	//Reset the opacity
	var Cstyle = document.getElementById("content").style;
	Cstyle.opacity = 1;	
	Cstyle.MozOpacity = 1;
	Cstyle.KhtmlOpacity = 1;
	Cstyle.filter = "alpha(opacity=" + 100 + ")";

	//Remove the container
	document.body.removeChild(document.getElementById("bigphoto"));
}
function getcenter(height) {
	var Ya = parseFloat(window.pageYOffset);	
	var Yb = parseFloat(document.body.scrollTop);	
	var Yc = parseFloat(document.documentElement.scrollTop);	
	if(!isNaN(Ya)&&Ya!=0) {Y=Ya;} else if(!isNaN(Yb)&&Yb!=0) {Y=Yb;} else if(!isNaN(Yc)&&Yc!=0) {Y=Yc;} else {Y=0;}
	
	var Sa = parseFloat(window.innerHeight);	
	var Sb = parseFloat(document.body.clientHeight);	
	var Sc = parseFloat(document.documentElement.clientHeight);	 
	if(!isNaN(Sa)&&Sa!=0) {S=Sa;} else if(!isNaN(Sb)&&Sb!=0) {S=Sb;} else if(!isNaN(Sc)&&Sc!=0) {S=Sc;} else {S=0;}	
	
	var top = (0.5*(S-height))+Y; return top;
}

function getscroll() {
	var Ya = parseFloat(window.pageYOffset);	
	var Yb = parseFloat(document.body.scrollTop);	
	var Yc = parseFloat(document.documentElement.scrollTop);	
	if(!isNaN(Ya)&&Ya!=0) {Y=Ya;} else if(!isNaN(Yb)&&Yb!=0) {Y=Yb;} else if(!isNaN(Yc)&&Yc!=0) {Y=Yc;} else {Y=0;}
	return Y;
}
function getImgSize(imgSrc) {
	var newImg = new Image();
	newImg.src = imgSrc;
	return newImg.height;
}
