// JavaScript by Luc Vandamme for Projectweb Copyright 2008
//
function showAlbumViewer(ontvangen,recx,recy){
	// INIT
	recOntvangen = ontvangen;
	recX	=	recx;
	recY	=	recy;
	postempX=	0;
	postempY=	0;
	winW	=	0;	// window width
	winH	=	0;	// window height
	scrOfX	=	0;
	scrOfY	=	0;
	xPop	=	0;	// xpos popup
	yPop	=	0; // ypos popup
	//
	document.getElementById("albumviewer").style.visibility = "visible";
	document.getElementById("thewindowbackground").style.visibility = "visible";
	// GET RATIO OF IMAGE
	if(recX > recY){
		// als x groter is dan y -> landscape
		flagBase	=	"X";
		maxSize	= Math.ceil(recX/50)*50;
		incrW = 50;
		incrH = Math.round((50*recY)/recX);
		decrX = incrW/2;
		decrY = Math.round(incrH/2);
	}else if(recX < recY){
		// als y groter is dan x -> portret
		flagBase	=	"Y";
		maxSize	= Math.ceil(recY/50)*50;
		incrW = Math.round((50*recX)/recY);
		incrH = 50;
		decrX = Math.round(incrW/2);
		decrY = incrH/2;
	}else{
		// als ze gelijk zijn -> vierkant
		flagBase	=	"X";
		maxSize	= Math.ceil(recX/50)*50;
		incrW = 50;
		incrH = 50;
		decrX = incrW/2;
		decrY = incrH/2;
		
	}
	// GET TYPE OF BROWSER
	/*if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}*/
	// GET WINDOW INNER SIZE
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	  }
	// GET SCROLLED VALUES
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	  }
	//
	document.getElementById("thewindowbackground").style.width = winW+scrOfX;
	document.getElementById("thewindowbackground").style.height = winH+scrOfY;
	//
	xPop = winW/2;
	yPop = scrOfY+(winH/2);
	//
	function pumpThePop(){
		if(flagBase == "X"){
			baseCoor	=	postempX;
		}else{
			baseCoor	=	postempY;
		}
		if( baseCoor < maxSize ){
			xPop = xPop	- decrX;
			yPop = yPop - decrY;
			postempX = postempX + incrW;
			postempY = postempY + incrH;
			document.getElementById("albumviewer").style.left = xPop + 'px';
			document.getElementById("albumviewer").style.top = yPop + 'px';
			document.getElementById("albumviewer").style.width = postempX + 'px';
			document.getElementById("albumviewer").style.height = postempY + 'px';
		}else{
			postempY = postempY + 32;
			document.getElementById("albumviewer").style.height = postempY + 'px';
			clearInterval(t);
			showDaPic();
		}
	}
	//
	var t = setInterval(pumpThePop, 2);
	//
}


function showDaPic(){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Browser ondersteunt geen HTTP Request");
	  return;
	} 
	var url = "getpicalbumall.php?albumallid=" + recOntvangen + "&rdn=" + Math.floor(Math.random()*101);
	xmlHttp.onreadystatechange=stateAlbumChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	

function stateAlbumChanged(){ 
	   if (xmlHttp.readyState==4)
	   {
		  if(xmlHttp.status == 200)
		  { 
			document.getElementById("albumviewer").innerHTML=xmlHttp.responseText;
		  } 
	   }
}


function hideAlbumViewer(){
	document.getElementById("albumviewer").style.visibility = "hidden";
	document.getElementById("thewindowbackground").style.visibility = "hidden";
	document.getElementById("albumviewer").style.width = 0 + 'px';
	document.getElementById("albumviewer").style.height = 0 + 'px';
	document.getElementById("albumviewer").innerHTML='';
}




