// Arasian Photo Gallery Version 1.0

var winWidth=0;
var winHeight=0;

var pageYScroll=0;
var pageXScroll=0;

function getWinSize() {

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}
	
	if( typeof( window.pageYScroll ) == 'number' ) {
		//Netscape compliant
		pageYScroll = window.pageYOffset;
		pageXScroll = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		pageYScroll = document.body.scrollTop;
		pageXScroll = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		pageYScroll = document.documentElement.scrollTop;
		pageXScroll = document.documentElement.scrollLeft;
	}

}

function getPage(path,target) {

	var xmlHttp;
	try {
	  // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
	  // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	  
	
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			target.innerHTML=xmlHttp.responseText;
		} else {
			target.innerHTML="<img src='images/loading.gif'>";	
		}
	}
	
	xmlHttp.open("GET",path,true);
	xmlHttp.send(null);
		

}

function openPopUp(page,width,height) {
	
	getWinSize();
	
	var popup = document.getElementById("popup");
	
	getPage(page,document.getElementById('popupcontent'));
				
	if(width) {
		popup.style.width = String(width) + "px";
		popup.style.left = String(winWidth/2 - width/2) + "px";
	}
	
	if(height) {
		popup.style.height = String(height) + "px";
		popup.style.top = String((winHeight/2 - height/2) + pageYScroll) + "px";
	} else {
		popup.style.top = String(pageYScroll + 100) + "px";
	}
	
	var black = document.getElementById("black");
	
	black.style.width = winWidth + "px";
	black.style.height = winHeight + "px";
	black.style.top = pageYScroll + "px";
	black.style.display='table-cell';
	
	popup.style.display="table-cell";
	
	
}

function closePopUp() {
	
	document.getElementById('black').style.display='none';
	document.getElementById("popup").style.display="none";
	
}

function showClose() {

	document.getElementById('closepopup').style.display="block";

}

function hideClose() {
	
	document.getElementById('closepopup').style.display="none";

}
