/***********************************************
* TapsWeb ZoomPix
* Copyright 2010 All Rights Reserved TapsWeb, Media, PA at www.tapsweb.com
* Please email us at info@tapsweb.com if you are interested in using this.
***********************************************/

var smallPath='images/Spring_2010/'
var largePath='images/Spring_2010/full/';
var tempName='';
var started=false;
var url="";
var ie4=!(document.all == null);
var imgHeight=375;
var imgWidth=500;
var isShown=true;
var lastDesc='';

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function pageWidth(){
	return window.innerWidth != null? window.innerWidth:document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth: document.body != null ? document.body.clientWidth : null;
} 

function pageHeight() {
	var tempVar= window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
	return tempVar;
}

function imageName(thisPath){
	var begin=0;
	var end=0;
	if (thisPath.length > smallPath.length ) {
		begin=thisPath.indexOf(smallPath);
		end=thisPath.indexOf('.jpg');
		tempName=thisPath.substring(begin+smallPath.length,end);
	}
	else{
		tempName='';
	}
} 	

function hideIt() {
  	document.getElementById('layer1').style.visibility='hidden';
}

function showIt() {
	document.getElementById('layer1').style.visibility='visible';
}

function popImage(img){
	if (!started){
		started=true;
		placeIt();
	}
	if ((pageWidth()<(imgWidth+300))||(pageHeight()<(imgHeight+50))){
			alert('Browser window is too small for larger picture');
	}
	imageName(img.src);
	url=largePath+tempName+'.JPG';
	lastDesc=img.alt;
	document.getElementById('layer1').innerHTML='<img src="'+url+'" width="'+imgWidth+'px" height="'+imgHeight+'px"><p class="ctr">'+lastDesc+'</p>';
	showIt();
}

function placeIt() {
	var curObj=document.getElementById('layer1');
	var topEdge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset;
	var leftEdge=(pageWidth()/2)-(imgWidth/2);
	curObj.style.top=topEdge+(pageHeight()/2)-(imgHeight/2);
	curObj.style.left=leftEdge;
	if ((pageWidth()<(imgWidth+300))||(pageHeight()<(imgHeight+50))){
		if (isShown){
			alert('Browser window is too small for larger picture');
		}
		//curObj.innerHTML='';
		//curObj.style.top=topEdge+(pageHeight()/2);
		//curObj.style.left=(pageWidth()/2);
		hideIt();
		isShown=false;
	}
	else{
		if (!isShown){
			//curObj.innerHTML='<img src="'+url+'" width="'+imgWidth+'px" height="'+imgHeight+'px"><p class="ctr">'+lastDesc+'</p>';
			isShown=true;
			showIt();
		}
	}
  	self.setTimeout(placeIt, 10);
}
