<!--

function swapVisible( obj ) {

	if ( typeof(obj) != "object" ) { obj = document.getElementById(obj); }
	if ( obj.className.indexOf("normal") != -1 ) { obj.className = obj.className.replace("normal", "hidden"); return false; }
	else { obj.className = obj.className.replace("hidden", "normal"); return true; }

}		

function getPageScroll(){

	if ( self.pageYOffset ) { return ( self.pageYOffset ); }
	else if ( document.documentElement && document.documentElement.scrollTop ) { return ( document.documentElement.scrollTop ); } // Explorer 6 Strict
	else if ( document.body ) { return ( document.body.scrollTop ); } // all other Explorers

}

function getPageSize(){

	var scroller, viewport;

	if ( window.innerHeight && window.scrollMaxY ) { scroller = { x: document.body.scrollWidth, y: ( window.innerHeight + window.scrollMaxY ) }; }
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { scroller = { x: document.body.scrollWidth, y: document.body.scrollHeight }; } // all but Explorer Mac
	else { scroller = { x: document.body.offsetWidth, y: document.body.offsetHeight }; } // Explorer Mac (also work in Explorer 6 Strict, Mozilla and Safari)
	
	if ( self.innerHeight ) {	viewport = { width: self.innerWidth, height: self.innerHeight }; } // all except Explorer
	else if ( document.documentElement && document.documentElement.clientHeight ) { viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight }; } // Explorer 6 Strict Mode
	else if ( document.body ) { viewport = { width: windowWidth = document.body.clientWidth, height: document.body.clientHeight }; } // other Explorers
	
	return { pagewidth: ( scroller.x < viewport.width ) ? viewport.width : scroller.x, pageheight: ( scroller.y < viewport.height ) ? viewport.height : scroller.y, viewportwidth: viewport.width, viewportheight: viewport.height };

}

function deleteElement( obj ) {

	if ( typeof(obj) != "object" ) { obj = document.getElementById(obj); }
	obj.parentNode.removeChild(obj);
	
}

function displayOverlay( imgurl, linkurl, contentlink ) {

	if ( ! document.getElementById("lightbox") ) {
		var lightbox = document.createElement("div"); lightbox.id = "lightbox"; lightbox.className = "hidden";
		var lightbox_mask = document.createElement("div"); lightbox_mask.id = "lightbox_mask"; lightbox_mask.className = "hidden"; lightbox.onclick = lightbox_mask.onclick = function() { deleteElement('lightbox'); deleteElement('lightbox_mask'); }
		if ( linkurl ) { var lightbox_link = document.createElement("a"); lightbox_link.href = linkurl; lightbox_link.target = "_blank"; if (contentlink == "YES") {lightbox_link.onclick = function() { deleteElement('lightbox'); deleteElement('lightbox_mask'); ajaxUpdate('content', '/content/friend.php'); return false; }  } else { lightbox_link.onclick = function() { deleteElement('lightbox'); deleteElement('lightbox_mask');  }} }
		var lightbox_photo = document.createElement("img"); lightbox_photo.id = "lightbox_photo";
		document.body.appendChild( lightbox );
		document.body.appendChild( lightbox_mask );
		if ( linkurl ) { lightbox.appendChild( lightbox_link ); lightbox_link.appendChild( lightbox_photo ); }
		else { lightbox.appendChild( lightbox_photo ); }
	}
		
	var pagesize = getPageSize();
	document.getElementById("lightbox_mask").style.height = pagesize.pageheight + "px";
	lightbox_preload = new Image();
	lightbox_preload.onload = function(){
		var lightbox_top = ( getPageScroll() + ( pagesize.viewportheight - 35 - lightbox_preload.height ) / 2 );
		var lightbox_left = ( ( pagesize.pagewidth - 20 - lightbox_preload.width ) / 2 );
		document.getElementById("lightbox").style.top = ( lightbox_top < 0 ) ? "0px" : lightbox_top + "px";
		document.getElementById("lightbox").style.left = ( lightbox_left < 0 ) ? "0px" : lightbox_left + "px";
		document.getElementById("lightbox_photo").src = lightbox_preload.src;
		swapVisible("lightbox_mask");
		swapVisible("lightbox");
	}
	
	lightbox_preload.src = imgurl;

}

//-->