//JavaScript Document
var rel = 'gallery'; // What you want to use for rel = "...." to make the pictures and links open up the picture gallery

var resizable = 1; //Whether the photo gallery is resizable, 1 for yes, 0 for no

var scrollbars = 0; //Whether the photo gallery has scrollbars, 1 for yes, 0 for no

var width = 720; //Width of photo gallery pop-up window

var height = 640; //height of photo gallery pop-up window

var photoUrl = 'photoGallery.php'; //Pop-up photo gallery filename


function popUp(url)
{
	day = new Date();
	id = day.getTime();
	if (document.all || document.layers) {
   		w = screen.availWidth;
  		h = screen.availHeight;
	}
	else
	{
		w = screen.width;
		h = screen.height;
	}
	var leftPos = (w-width)/2, topPos = (h-height)/2;
	eval("page" + id + " = window.open('"+url+"', '" + id + "', 'toolbar=0,scrollbars="+scrollbars+",location=0,statusbar=0,menubar=0,resizable="+resizable+",width="+width+",height="+height+",left = "+leftPos+",top = "+topPos+"');");
}

function popUpGallery(subject)
{
	url = photoUrl+"?subject="+subject;
	popUp(url);
}

function primePage()
{
	rel='gallery';
	anchors = document.getElementsByTagName('a');
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("rel") == rel){
			anchor.href = "javascript:popUpGallery('"+anchor.getAttribute("name")+"');";
		}
	}
	imgs = document.getElementsByTagName('img');
	for (var i=0; i<imgs.length; i++){
		var imgTemp = imgs[i];

		if (imgTemp.getAttribute("rel") == rel){
			imgTemp.setAttribute("onclick") = "popUpGallery(this.name);"
		}
	}
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

function include(destination) {
var e=document.createElement('script');
e.src='destination';
e.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(e);
}

function includeVariables()
{
	include('variables.js');
}


addLoadEvent(primePage);


