



var currentPhoto = -1;
var closing=0;
var setNextFoto=-1;


function doFinish() {
	var PhotoBox = document.getElementById("PhotoPopup");
	if (!PhotoBox) return;
	currentPhoto=-1;
	closing=0;
	PhotoBox.style.top = "-900px";
	PhotoBox.style.display = "none";
	
	if (setNextFoto!=-1) {
		showPhoto(setNextFoto,setNextdropPos,setNextpicW,setNextpicH);
		setNextFoto=-1;
	}
}

function closePopup() {
	if (closing) return;
	closing=1;
	new Effect.Morph("PhotoPopup", {afterFinish: function() {doFinish();}, style: "top: -900px",duration: 0.4});
}


function showPhoto(Photo,dropPos,picW,picH) {
 	
 	if (currentPhoto==-1) {	
 		currentPhoto = Photo; 
 		setNextFoto=-1;
		var d = document.getElementById("PhotoBot"); if (d) d.style.width = (picW-29)+"px";
		var d = document.getElementById("PhotoTop"); if (d) d.style.width = (picW-29)+"px";
		var d = document.getElementById("PhotoLeft"); if (d) d.style.height = (picH-29)+"px";
		var d = document.getElementById("PhotoRight"); if (d) d.style.height = (picH-29)+"px";
		var d = document.getElementById("closeButton"); if (d) d.style.left = (picW+8)+"px";
		var d = document.getElementById("PhotoPopupContent"); if (d) {d.style.width = picW+"px";d.style.height = picH+"px";};
		var d = document.getElementById("PhotoPopupInner"); if (d) {d.style.width = (picW+9)+"px";d.style.height = (picH+9)+"px";};
		var l = 250-(Math.floor(picW / 2));		
		var d = document.getElementById("PhotoPopup"); if (d) {d.style.left = l+"px"; d.style.width = (picW+51)+"px";d.style.height = (picH+51)+"px";};
		dropPos=260-parseInt(picH/2);

		var PhotoBox = document.getElementById("PhotoPopup");
		if (!PhotoBox) return true;
		PhotoBox.style.top = "-700px";
		PhotoBox.style.display = "block";
		var PhotoContent = document.getElementById("PhotoPopupContent");
		if (!PhotoContent) return true;
		PhotoContent.innerHTML = '<div id="photoBoxMain" style="background-image: url('+Photo+'); width: '+picW+'px; height: '+picH+'px"></div><div id="loadingPhoto" style="width: '+picW+'px; height: '+picH+'px">Loading, Please Wait...</div>';

		new Effect.Morph("PhotoPopup", {style: "left: "+l+"px; top: "+(dropPos)+"px",duration: 0.4});
	} else {
		setNextFoto=Photo;
		setNextdropPos=dropPos;
		setNextpicW=picW;
		setNextpicH=picH;
		closePopup();
	}
	
	return false;
	
}


