var holdCache = [];
function theImgHasLoaded() {
	var theLoadDiv = getRefToDiv('loadDiv'), thePicDiv = getRefToDiv('picDiv');
	window.currentClip = 10; expandClip();
	if( theLoadDiv.style ) { theLoadDiv.style.visibility = 'hidden'; thePicDiv.style.visibility = 'visible'; } else { theLoadDiv.visibility = 'hide'; thePicDiv.visibility = 'show'; }
}
function expandClip() {
	var thePicDiv = getRefToDiv('picDiv');
	if( thePicDiv.clip ) { thePicDiv.clip.bottom = 220 + window.currentClip; thePicDiv.clip.top = 220 - window.currentClip; } else
	if( thePicDiv.style ) { thePicDiv.style.clip = 'rect( '+(220-window.currentClip)+'px, 623px, '+(220+window.currentClip)+'px, 0px )'; }
	if( window.currentClip == 220 ) { window.doClipping = false; } else { window.currentClip += 10; }
}
function getRefToDiv(divID) {
	if( document.getElementById ) { return document.getElementById(divID); }
	if( document.all ) { return document.all[divID]; }
	if( document.layers ) { return document.layers[0].layers[divID]; }
	return document[divID];
}
function revealNextImage(imgName,oVert) {
	if( !( document.layers && document.classes ) && !( document.body && document.body.innerHTML ) ) { return true; }
	var theLoadDiv = getRefToDiv('loadDiv'), thePicDiv = getRefToDiv('picDiv'), oPix = document.childNodes ? 'px' : 0;
	if( !theLoadDiv ) { return true; } window.doClipping = false;
	if( window.getComputedStyle ) { if( getComputedStyle(thePicDiv,null).position != 'absolute' ) { return true; } }
	if( thePicDiv.currentStyle && thePicDiv.currentStyle.position != 'absolute' ) { return true; }
	if( window.storeImg ) { window.storeImg.className = ''; } window.storeImg = imgName; imgName.className = 'onThis';
	if( theLoadDiv.style ) { theLoadDiv.style.width = ((oVert?265:603)+2) + oPix; theLoadDiv.style.visibility = 'visible'; thePicDiv.style.visibility = 'hidden'; } else { theLoadDiv.width = ((oVert?265:603)+2); theLoadDiv.visibility = 'show'; thePicDiv.visibility = 'hide'; }
	if( !holdCache[imgName.href] ) { holdCache[imgName.href] = new Image(); holdCache[imgName.href].src = imgName.href; }
	thePicDiv.innerHTML = '<a href="javascript:cancelShow();"><img src="'+imgName.href+'" width="'+(oVert?265:603)+'"height="400" border="0"> Close</a>';
	if( thePicDiv.document && thePicDiv.document != document ) { thePicDiv.document.open(); thePicDiv.document.write(thePicDiv.innerHTML); thePicDiv.document.close(); }
	window.checkForImg = imgName.href; return false;
}
function cancelShow() {
	if( !( document.layers && document.classes ) && !( document.body && document.body.innerHTML ) ) { return; }
	var theLoadDiv = getRefToDiv('loadDiv'), thePicDiv = getRefToDiv('picDiv');
	if( !theLoadDiv ) { return; } window.doClipping = false; storeImg.className = ''; window.checkForImg = false;
	window.currentClip = 220; expandClip();
	thePicDiv.innerHTML = '';
	if( thePicDiv.document && thePicDiv.document != document ) { thePicDiv.document.open(); thePicDiv.document.write(thePicDiv.innerHTML); thePicDiv.document.close(); }
	if( theLoadDiv.style ) { theLoadDiv.style.visibility = 'hidden'; thePicDiv.style.visibility = 'hidden'; } else { theLoadDiv.visibility = 'hide'; thePicDiv.visibility = 'hide'; }
}
function reScroll() {
	if( document.documentElement && document.documentElement.scrollTop ) { var HScroll = document.documentElement.scrollTop; }
	else if( document.body && document.body.scrollTop ) { var HScroll = document.body.scrollTop; }
	else if( window.pageYOffset ) { var HScroll = window.pageYOffset; }
	else { var HScroll = 0; } if( HScroll < 0 ) { HScroll = 0; }
	HScroll -= 178; //to allow for container offset
	var theLoadDiv = getRefToDiv('loadDiv'), thePicDiv = getRefToDiv('picDiv'), oPix = document.childNodes ? 'px' : 0;
	if( !thePicDiv ) { return; } if( thePicDiv.style ) { thePicDiv = thePicDiv.style; theLoadDiv = theLoadDiv.style; }
	var currentTop = thePicDiv.top ? parseInt( thePicDiv.top ) : -173; var theDifference = ( ( 5 + HScroll ) - currentTop ) * 0.25;
	if( theDifference ) { theDifference = ( ( theDifference > 0 ) ? Math.ceil( theDifference ) : Math.floor( theDifference ) ) + currentTop;
		thePicDiv.top = theDifference + oPix; theLoadDiv.top = theDifference + oPix; }
	//could use <img .. onload> but Opera 7.5 does not fire this if the image is already in cache so repeatedly test for complete
	if( window.checkForImg ) { if( holdCache[checkForImg].complete ) { window.doClipping = true; window.checkForImg = false; theImgHasLoaded(); }
	} else if( window.doClipping ) { expandClip(); }
}
window.onload = function () { window.setInterval('reScroll();',50); };
