/////////////////////////////////////////////////////////////////////////////////
////////////// IMAGE VIEWER FOR lesliepotterart.com /////////////////////////////
////////////// AUTHOR: Jed Sweigard /////////////////////////////////////////////
////////////// ©2008 Kinetic Design Ltd. ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
var state = 'hidden';

function visible(){
	state = 'visible';
}

function invisible(){
	document.getElementById('placeholder').src = 'images/loading.gif';
	document.getElementById('placeholder').src = 'images/blank.gif';
	document.getElementById('title').childNodes[0].nodeValue = '';
	document.getElementById('desc').childNodes[0].nodeValue = '';
	document.getElementById('picContainer').style.marginLeft = -(document.getElementById('picContainer').offsetWidth/2) + 'px';
	document.getElementById('picContainer').style.marginTop = -(document.getElementById('picContainer').offsetHeight/2) + 'px';
	elem2 = document.getElementById('overLay');
	elem2.style.visibility = 'hidden';
	state = 'hidden';
}

function showLayer(whichLayer, whichPic, whichTitle, whichDesc){
	elem = document.getElementById(whichLayer);
	elem3 = document.getElementById('picContainer');
	elem4 = document.getElementById('preloader');
	
	if(state == 'hidden'){
		elem4.style.visibility = 'visible';
		elem4.style.opacity = 0;
		elem4.style.filter = 'alpha(opacity=0)';
		elem.style.visibility = 'visible';
		elem.style.opacity = 0;
		elem.style.filter = 'alpha(opacity=0)';
		elem3.style.opacity = 0;
		elem3.style.filter = 'alpha(opacity=0)';
		document.getElementById('title').childNodes[0].nodeValue = '';
		document.getElementById('desc').childNodes[0].nodeValue = '';
		
		invisiElement = function(){
			elem4.style.visibility = 'hidden';
		}
		
		//load content into container and position container
		insertContent = function(){
			new Effect.Appear(elem4, {duration:1.0, from:1.0, to:0.0, afterFinish: invisiElement});
			document.getElementById('placeholder').src = whichPic;
			document.getElementById('title').childNodes[0].nodeValue = whichTitle;
			document.getElementById('desc').childNodes[0].nodeValue = whichDesc;
			elem3.style.marginLeft = -(elem3.offsetWidth/2) + 'px';
			elem3.style.marginTop = -(elem3.offsetHeight/2) + 'px';
			new Effect.Appear(elem3, {delay:1.0, duration:1.0, from:0.0, to:1.0, afterFinish: visible});
		}
		
		//preload image
		imagePreloader = new Image();
		imagePreloader.onload = function(){
			insertContent();
		}
		imagePreloader.src = whichPic;
		
		new Effect.Appear(elem, {duration:1.0, from:0.0, to:1.0, queue: 'front'});
		new Effect.Appear(elem4, {duration:1.0, from:0.0, to:1.0});
	}else{
		new Effect.Appear(elem3, {duration:1.0, from:1.0, to:0.0, queue: 'front'});
		new Effect.Appear(elem, {delay: 1.0, duration:1.0, from:1.0, to:0.0, afterFinish: invisible});
	}	
}

/*if(navigator.appVersion.indexOf('MSIE') != -1){
	//document.getElementById('overlayBg').style.position = 'absolute';
	window.onscroll = function(){
		dV = document.getElementById('overlayBg')
		dV.style.top = document.documentElement.scrollTop + 0;
		dV.style.left = document.documentElement.scrollLeft + 0;
	}
}*/