<!--

window.onload = function() {
	for( var i = 0; i < document.links.length; i++ ) {
		if( document.links[i].className.match( /\bimgpopup\b/ ) ) {
			document.links[i].onclick = function() {
				ImgPop_Show( this.firstChild.alt, this.href );
				return false;
			};
		}
	}
};

var inlineWindow = null;
function ImgPop_Show( imgTitle, imgSrc ) {
	if( inlineWindow == null ) {
		inlineWindow = document.createElement( 'div' );
		inlineWindow.id = "inlineWindow";
		inlineWindow.innerHTML = '<div class="overlay"></div><div class="display"><div class="titlebar"><a href="#" class="close">Close [X]</a><span class="title"></span></div><div class="image"><img src="" title="" alt="" /></div></div>';
		inlineWindow.firstChild.onclick = ImgPop_Hide;	// Hide when overlay is clicked
		if( window.attachEvent ) {	// IE Fix to mimic position:fixed
			inlineWindow.style.top = document.documentElement.scrollTop;
			document.documentElement.onscroll = function() {
				inlineWindow.style.top = document.documentElement.scrollTop;
			}
		}
		document.body.appendChild( inlineWindow );
	}

	inlineWindow.lastChild.firstChild.firstChild.onclick = ImgPop_Hide;	// Hide when close button clicked
	inlineWindow.lastChild.firstChild.lastChild.innerHTML = imgTitle;	// Title
	inlineWindow.lastChild.lastChild.firstChild.src = imgSrc;			// Begin Preloading Image
	inlineWindow.lastChild.lastChild.firstChild.onload = function() {
		this.style.visibility = 'hidden';
		this.style.display = 'block';
		this.style.left = ( this.offsetWidth > this.parentNode.offsetWidth ) ? 0 : ( ( this.parentNode.offsetWidth - this.offsetWidth ) / 2 ) + "px";
		this.style.top = ( this.offsetHeight > this.parentNode.offsetHeight ) ? 0 : ( ( this.parentNode.offsetHeight - this.offsetHeight ) / 2 ) + "px";
		this.style.visibility = 'visible';
	};
	inlineWindow.lastChild.lastChild.firstChild.onerror = function() {
		alert("Error loading image");
		ImgPop_Hide();
	}
	inlineWindow.style.display = 'block';
}

function ImgPop_Hide() {
	inlineWindow.lastChild.lastChild.firstChild.style.display = 'none';
	inlineWindow.style.display = 'none';
	return false;
}
//-->