var strippageimg = new Array();
var galpage = 1;

function changeStripPage ( page ){
	//Strip images
	if (lastpage >= page){
		document.getElementById("img1").innerHTML = strippageimg [ page ] [ 1 ];
		
		if (lastpageimg < 2 && lastpage == page){
			document.getElementById("img2").innerHTML = '';
		}
		else{
			document.getElementById("img2").innerHTML = strippageimg [ page ] [ 2 ];
		}
		
		
		if (lastpageimg < 3 && lastpage == page){
			document.getElementById("img3").innerHTML = '';
		}
		else{
			document.getElementById("img3").innerHTML = strippageimg [ page ] [ 3 ];
		}
		
		
		if (lastpageimg < 4 && lastpage == page){
			document.getElementById("img4").innerHTML = '';
		}
		else{
			document.getElementById("img4").innerHTML = strippageimg [ page ] [ 4 ];
		}
		
		
		if (lastpageimg < 5 && lastpage == page){
			document.getElementById("img5").innerHTML = '';
		}
		else{
			document.getElementById("img5").innerHTML = strippageimg [ page ] [ 5 ];
		}
		
		
		if (lastpageimg < 6 && lastpage == page){
			document.getElementById("img6").innerHTML = '';
		}
		else{
			document.getElementById("img6").innerHTML = strippageimg [ page ] [ 6 ];
		}
	}
	
	//Next button
	if (lastpage > page){
		document.getElementById("nextbutton").innerHTML = '<a href="javascript:changeStripPage(' + (page+1) + ')"><img src="arrowright.png" class="arrowright" alt="[Next Page]" title="Next Page"/></a>'
	}
	else{
		document.getElementById("nextbutton").innerHTML = '<img src="arrowright30.png" class="arrowright" alt="<del>[Next Page]</del>" title="You are already at the last page"/>';
	}
	
	//Prev Button
	if (page != 1){
		document.getElementById("prevbutton").innerHTML = '<a href="javascript:changeStripPage(' + (page-1) + ')"><img src="arrowleft.png" class="arrowleft" alt="[Previous Page]" title="Previous Page"/></a>'
	}
	else{
		document.getElementById("prevbutton").innerHTML = '<img src="arrowleft30.png" class="arrowleft" alt="<del>[Previous Page]</del>" title="You are already at the first page"/>';
	}
	
	//
	document.getElementById("page number").innerHTML = 'Page ' + page + ' of ' + lastpage + '<br /><br />';
	document.getElementById("dirpagenumber").innerHTML = ' > Page ' + page;
	
}

function changeStripImage ( dispimg , picstyle , subtitle ){
	document.getElementById("imgcontainer").innerHTML = "<img src=\'loading.gif\' style=\'position:absolute;top:275px;left:275px;\' alt=\'\'/><img class='galleryimglrg' src='galleryimg.php?" + dispimg + "&amp;size=600' alt='' style='" + picstyle + "display:none;' onload='unhide(this)'/>";
	document.getElementById("ImgSubtitle").innerHTML = "Image: " + subtitle;
}

function showImage( arg , width , height ){
	var ovrlay = document.getElementById("ovrlay");
	var ovrlayimg = document.getElementById("ovrlayimg");
	var ovrlayimgbox = document.getElementById("ovrlayimgbox");
	var ovrlayimgboxback = document.getElementById("ovrlayimgboxback");
	var ovrlayimgboxcont = document.getElementById("ovrlayimgboxcont");
	var loadingspinner = document.getElementById("spinner");
	ovrlayimg.src = "";
	ovrlayimg.style.display = "none";
	loadingspinner.style.display = "inline";
	ovrlay.style.display = "inline";
	ovrlayimgboxcont.style.display = "inline";
	if(width == 1000){
		ovrlayimgbox.style.marginTop = (Math.floor((1000-height)/2))-1 + "px";
		ovrlayimgbox.style.marginLeft = "-500px";
		ovrlayimgbox.style.width = "1000px";
		loadingspinner.style.left = "500px";
		loadingspinner.style.top = (Math.floor(height/2)) + "px";
		ovrlayimgbox.style.height = (Math.floor(height)) + "px";
		
		ovrlayimgboxback.style.marginTop = (Math.floor((1000-height)/2)) -8 + "px";
		ovrlayimgboxback.style.marginLeft = "-508px";
		ovrlayimgboxback.style.width = "1017px";
		ovrlayimgboxback.style.height = (Math.floor(height))+42 + "px";
	}
	else if(height == 1000){
		ovrlayimgbox.style.marginLeft = -(Math.floor(width/2))-1 + "px";
		ovrlayimgbox.style.marginTop = "0px";
		ovrlayimgbox.style.height = "1000px";
		loadingspinner.style.top = "500px";
		loadingspinner.style.left = (Math.floor(width/2)) + "px";
		ovrlayimgbox.style.width = Math.floor(width) + "px";
		
		ovrlayimgboxback.style.marginLeft = -(Math.floor(width/2)) -8 + "px";
		ovrlayimgboxback.style.marginTop = "-8px";
		ovrlayimgboxback.style.height = "1042px";
		ovrlayimgboxback.style.width = Math.floor(width)+17 + "px";
	}
	else{
		if(width >= height){
			var newheight = (height*1000)/width;
			
			ovrlayimgbox.style.marginTop = (Math.floor((1000-newheight)/2))-1 + "px";
			ovrlayimgbox.style.marginLeft = "-500px";
			ovrlayimgbox.style.width = "1000px";
			loadingspinner.style.left = "500px";
			loadingspinner.style.top = (Math.floor(newheight/2)) + "px";
			ovrlayimgbox.style.height = (Math.floor(newheight)) + "px";
			
			ovrlayimgboxback.style.marginTop = (Math.floor((1000-newheight)/2)) -8 + "px";
			ovrlayimgboxback.style.marginLeft = "-508px";
			ovrlayimgboxback.style.width = "1017px";
			ovrlayimgboxback.style.height = (Math.floor(newheight))+42 + "px";
		}
		else{
			var newwidth = (width*1000)/height;
			
			ovrlayimgbox.style.marginLeft = -(Math.floor(newwidth/2))-1 + "px";
			ovrlayimgbox.style.marginTop = "0px";
			ovrlayimgbox.style.height = "1000px";
			loadingspinner.style.top = "500px";
			loadingspinner.style.left = (Math.floor(newwidth/2)) + "px";
			ovrlayimgbox.style.width = Math.floor(newwidth) + "px";
			
			ovrlayimgboxback.style.marginLeft = -(Math.floor(newwidth/2)) -8 + "px";
			ovrlayimgboxback.style.marginTop = "-8px";
			ovrlayimgboxback.style.height = "1042px";
			ovrlayimgboxback.style.width = Math.floor(newwidth)+17 + "px";
		}
	}
	ovrlayimg.onload = function (){
		ovrlayimg.style.display = "inline";
		loadingspinner.style.display = "none";
	}
	ovrlayimg.src = "galleryimg.php?" + arg + "&size=1000";
}

function hideImage(){
	var ovrlay = document.getElementById("ovrlay");
	var ovrlayimg = document.getElementById("ovrlayimg");
	var ovrlayimgbox = document.getElementById("ovrlayimgbox");
	var ovrlayimgboxcont = document.getElementById("ovrlayimgboxcont");
	var ovrlayimgboxclose = document.getElementById("ovrlayimgboxclose");
	ovrlay.style.display = "none";
	ovrlayimgboxcont.style.display = "none";
	ovrlayimgboxclose.style.display = "inline";
	//ovrlayimgbox.style.display = "none";
	ovrlayimg.src = "";
	var w = parseFloat(ovrlayimgbox.style.width);
	var h = parseFloat(ovrlayimgbox.style.height);
	var ml = parseFloat(ovrlayimgbox.style.marginLeft);
	var mt = parseFloat(ovrlayimgbox.style.marginTop);
	ovrlayimgboxclose.style.width = 0.85*w + "px";
	ovrlayimgboxclose.style.height = 0.85*h + "px";
	ovrlayimgboxclose.style.marginLeft = ml + (0.075*w) + "px";
	ovrlayimgboxclose.style.marginTop = mt + (0.075*h) + "px";
	setTimeout(	"zoomBox(" + w + " , " + h + ");", 50 );
}

function zoomBox( w1 , h1 ){
	var ovrlayimgboxclose = document.getElementById("ovrlayimgboxclose");
	var w = parseFloat(ovrlayimgboxclose.style.width);
	var h = parseFloat(ovrlayimgboxclose.style.height);
	var ml = parseFloat(ovrlayimgboxclose.style.marginLeft);
	var mt = parseFloat(ovrlayimgboxclose.style.marginTop);
	if (w >= 0.15*w1 && h >= 0.15*h1){
		ovrlayimgboxclose.style.width = w - (0.15*w1) + "px";
		ovrlayimgboxclose.style.height = h - (0.15*h1) + "px";
		ovrlayimgboxclose.style.marginLeft = ml + (0.075*w1) + "px";
		ovrlayimgboxclose.style.marginTop = mt + (0.075*h1) + "px";
		setTimeout(	"zoomBox(" + w1 + " , " + h1 + ");", 50 );
	}
	else{
		ovrlayimgboxclose.style.display = "none";
	}
}

function unhide(img){
	img.style.display = "inline";
}

/*
function checkViewport(){
	var ovrlayimgbox = document.getElementById("ovrlayimgbox");
	
	viewportSize[0] = window.innerWidth;
	viewportSize[1] = window.innerHeight;
	
	if (viewportSize[1] <= 600 || viewportSize[0] <= 600){
		ovrlayimgbox.style.position = "absolute";
		ovrlayimgbox.style.top = "50%";
	}
	if (viewportSize[1] > 600 || viewportSize[0] > 600){
		ovrlayimgbox.style.position = "fixed";
		ovrlayimgbox.style.top = "250px";
	}
	setTimeout(	"checkViewport();" , 200 );
}

window.onload=function(){
	checkViewport();
}*/

