<!--
/* <![CDATA[ */

var yourBrowserIsNotGoodEnough = !document.getElementsByTagName;
var yourBrowserIsGoodEnough = !yourBrowserIsNotGoodEnough;
var thumbsA = new Array;
var thePhotoDiv;
var thePhotoTitleSpan;
var thePhotoDescriptionSpan;
var largePhotoLinkSpan;
var xlargePhotoLinkSpan;
var takesDiv;
var takeThumbsDiv;
var currentPhotoIndex;
var currentTakeIndex;
var permaEdit;
var includeTakes = true;
var primaryShowDIV;
var secondaryDIVpadder;

var auto = 'off';
var autoTime = 5000;
var autoTimer;

var debug = false;
var inited = false;

function photoIMG(index,imgId,urlDir,fileType,title,sw,sh,lw,lh,xw,xh,w,h) {
	this.index=index;
	this.id=imgId;
	this.imgObj=document.getElementById("IMG_" + imgId);
	if (!this.imgObj) {
		this.imgObj=new Image();
		if (document.all&&navigator.appVersion.indexOf("Mac") == -1) {
			this.imgObj.style.cursor='hand';
		} else {
			this.imgObj.style.cursor='pointer';
			}
		this.imgObj.width=w;
		this.imgObj.height=h;
		this.imgObj.className='showThumbs'+w;
		this.imgObj.src=urlDir+imgId+'.'+fileType;
		this.imgObj.id=imgId
		}
	this.imgObj.parentObj=this;
	this.imgObj.onclick=this.clicked;
	if (!document.all) this.imgObj.click = this.clicked;
	this.imgObj.onmouseover=this.mousedover;
	this.imgObj.onmouseout=this.mousedout;
	this.urlDir=urlDir;
	this.fileType=fileType;
	this.setTitle(title);
	this.smallImgW=sw;
	this.smallImgH=sh;
	this.smallImgPath=urlDir+imgId+'.'+fileType;
	this.xlargeImgW = xw;
	this.xlargeImgH = xh;
	if (lw!='') {
		this.largeImgW=lw;
		this.largeImgH=lh;
		this.largeImgPath=urlDir+imgId+'.'+fileType;
		this.largePhotoLink='[<a onclick="callOpenWindowPhoto(\'l\'); return false" href="show.asp?file=gottaGetThisFile&amp;loadImageID='+imgId+'&amp;takeID='+imgId+'&amp;size=l">'+lw+'x'+lh+'</a>]';
		}
	if (xw!='') this.xlargePhotoLink='[<a onclick="callOpenWindowPhoto(\'x\'); return false" href="show.asp?file=gottaGetThisFile&amp;loadImageID='+imgId+'&amp;takeID='+imgId+'&amp;size=x">'+xw+'x'+xh+'</a>]';
	
	this.takes=new Array;
	//this.takes[0]=new takeIMG(0,this.imgObj.id,this,this.imgObj.width,this.imgObj.height);
	}

photoIMG.prototype.clicked = function photoIMGprototypeclicked () {
	if (isSetThumbChecked()) {
		var placedEditSetForm = document.getElementById('placedEditSetForm');
		placedEditSetForm.setThumb.checked=false;
		placedEditSetForm.thumbPath.value=this.parentObj.urlDir+this.parentObj.id+'.'+this.parentObj.fileType;
		placedEditSetForm.thumbW.value=this.width;
		placedEditSetForm.thumbH.value=this.height;
		sendChangesToServer('set');
		return;
	}
	
	if (isChangeParentChecked()) {
		if (currentPhotoIndex!=this.parentObj.index) {
			var placedEditForm = document.getElementById('placedEditForm');
			placedEditForm.parentId.value=this.id;
			placedEditForm.newParentIndex.value=this.parentObj.index;
			placedEditForm.changeParent.checked=false;
			sendChangesToServer('photo');
			//placedEditForm.submit();
			}
		return;
		}
	// if this is already being displayed, let's get out of here
	if (currentPhotoIndex==this.parentObj.index && currentTakeIndex==0) {
		return;
		}

	// load up the proper size image for display
	loadDisplayImg(this);

	// swap in the thumb for display
	displayImgW=(size=='l')?this.parentObj.largeImgW:this.parentObj.smallImgW;
	displayImgH=(size=='l')?this.parentObj.largeImgH:this.parentObj.smallImgH;
	if (currentPhotoIndex!=-1) {
		//if this is not the current thumb 
		//thePhotoDiv.innerHTML='<img id="thePhotoImg" src="'+this.src+'" width="'+displayImgW+'" height="'+displayImgH+'" title="'+this.parentObj.title+'" />';
		document.getElementById("thePhotoImg").width=displayImgW;
		document.getElementById("thePhotoImg").height=displayImgH;
		document.getElementById("thePhotoImg").title=cleanBreaks(this.parentObj.title);
		}
	
	// write in the title, description and links
	thePhotoTitleSpan.innerHTML=this.parentObj.title;
	thePhotoDescriptionSpan.innerHTML=displayBreaks(this.parentObj.description);
	largePhotoLinkSpan.innerHTML=this.parentObj.largePhotoLink || '';
	xlargePhotoLinkSpan.innerHTML=this.parentObj.xlargePhotoLink || '';
	
	// remove all the takes (which are there from the previous displayed thumb)
	// then insert this thumb's takes
	if (this.parentObj.takes.length>1) {
		// let's only go through this trouble if this thumb has takes
		var tl=takeThumbsDiv.childNodes.length;
		for (t=0;t<tl;t++) {
			takeThumbsDiv.removeChild(takeThumbsDiv.childNodes[0])
			}
		if (this.parentObj.takes.length>1) {
			for (t=0;t<this.parentObj.takes.length;t++) {
				takeThumbsDiv.appendChild(this.parentObj.takes[t].imgObj);
				}
			}
		}

	// turn on or off the div that holds the takes
	takesDiv.style.display='none'; // Because NS6 sometimes won't display takesDiv unless we turn it off and then on
	takesDiv.style.display=(this.parentObj.takes.length>1)?'block':'none';
	// because IE5 mac has weird display crap if takeThumbsDiv has no childNodes:
	takeThumbsDiv.appendChild(document.createElement('span'));
	
	// unfade things
	if (currentPhotoIndex!=this.parentObj.index) {
		// if this is not the current thumb
		that=thumbsA[currentPhotoIndex];
		if (that) unFadeIt(that.imgObj,'white');
		}
	if (thumbsA[currentPhotoIndex]) {
		// if the current thumb still exists
		that=thumbsA[currentPhotoIndex].takes[currentTakeIndex];
		if (that) unFadeIt(that.imgObj,'#ccc');
		}
	
	//fade things
	fadeIt(this);
	fadeIt(this.parentObj.takes[0].imgObj);
	
	// reset the current indexes
	currentTakeIndex=0;
	currentPhotoIndex=this.parentObj.index;
		
	// let's make sure the display image is on screen as much as possible
	moveNavnPic();
	
	// show the edit form if in permaEdit mode
	if (permaEdit) showEditForm();
	}

photoIMG.prototype.mousedover = function photoIMGprototypemousedover() { window.status=cleanBreaks(this.parentObj.title); }
photoIMG.prototype.mousedout = function photoIMGprototypemousedout() { window.status=''; }
photoIMG.prototype.setDescription = function photoIMGprototypesetDescription(description) { this.description=description||''; }
//Allowed NULL Title - lbeuchat - 07082003
photoIMG.prototype.setTitle = function photoIMGprototypesetTitle(title) { this.title=title; }
//photoIMG.prototype.setTitle = function photoIMGprototypesetTitle(title) { this.title=title||'untitled'; }
photoIMG.prototype.toString = function photoIMGprototypetoString() { return '[a photoIMG with id: '+this.id+']'; }

function takeIMG(index,imgId,parent,fileType,w,h,urlDir,title,sw,sh,lw,lh,xw,xh) {
	this.parentObj=parent;
	this.index=index;
	this.id=imgId;
	this.fileType=fileType;
	this.imgObj=new Image();
	if (document.all&&navigator.appVersion.indexOf('Mac') == -1) {
		this.imgObj.style.cursor='hand';
	} else {
		this.imgObj.style.cursor='pointer';
		}
	this.imgObj.onclick=this.clicked;
	if (!document.all) this.imgObj.click = this.clicked;
	this.imgObj.parentObj=this;
	this.imgObj.onmouseover=this.mousedover;
	this.imgObj.onmouseout=this.mousedout;
	this.imgObj.width=w;
	this.imgObj.height=h;
	this.imgObj.className='showTakes'+w;
	if (index==0) {
		// the first take IMG is always the same as the parent Image
		this.imgObj.src=parent.imgObj.src;
		this.urlDir=parent.urlDir;
		this.title=parent.imgObj.title;
		this.description=parent.description;
		this.smallImgW=parent.smallImgW;
		this.smallImgH=parent.smallImgH;
		this.smallImgPath=parent.smallImgPath;
		this.largeImgW=parent.largeImgW;
		this.largeImgH=parent.largeImgH;
		this.xlargeImgW=parent.xlargeImgW;
		this.xlargeImgH=parent.xlargeImgH;
		this.largeImgPath=parent.largeImgPath;
		this.largePhotoLink=parent.largePhotoLink;
		this.xlargePhotoLink=parent.xlargePhotoLink;
	} else {
		this.imgObj.src=urlDir+imgId+'.'+fileType;
		this.urlDir=urlDir;
		this.setTitle(title);
		this.smallImgW=sw;
		this.smallImgH=sh;
		this.smallImgPath=urlDir+imgId+'.'+fileType;
		this.xlargeImgW = xw;
		this.xlargeImgH = xh;
		if (lw!='') {
			this.largeImgW=lw;
			this.largeImgH=lh;
			this.largeImgPath=urlDir+imgId+'.'+fileType;
			this.largePhotoLink='[<a onclick="callOpenWindowPhoto(\'l\'); return false" href="show.asp?file=gottaGetThisFile&amp;loadImageID='+imgId+'&amp;takeID='+imgId+'&amp;size=l">'+lw+'x'+lh+'</a>]';
			}
		if (xw!='') this.xlargePhotoLink='[<a onclick="callOpenWindowPhoto(\'x\'); return false" href="show.asp?file=gottaGetThisFile&amp;loadImageID='+imgId+'&amp;takeID='+imgId+'&amp;size=x">'+xw+'x'+xh+'</a>]';
		}
	}

takeIMG.prototype.clicked = function takeIMGprototypeclicked () {
	if (isSetThumbChecked()) {
		var placedEditSetForm = document.getElementById('placedEditSetForm');
		placedEditSetForm.setThumb.checked=false;
		placedEditSetForm.thumbPath.value=this.parentObj.urlDir+this.parentObj.id+'.'+this.fileType;
		placedEditSetForm.thumbW.value=this.width;
		placedEditSetForm.thumbH.value=this.height;
		sendChangesToServer('set');
		return;
		}
	if (isChangeParentChecked()) {
		if (currentTakeIndex==this.parentObj.index) {
			var placedEditForm = document.getElementById('placedEditForm');
			placedEditForm.parentId.value=this.parentObj.id;
			placedEditForm.newParentIndex.value='';
			placedEditForm.changeParent.checked=false;
			sendChangesToServer('photo');
			//placedEditForm.submit();
			}
		return;
		}
	
	// if this is the first take, pass the click along to the thumb
	if (this.parentObj.index==0) {
		// but only if this isn't the take already displayed
		if (currentTakeIndex!=0) this.parentObj.parentObj.imgObj.click();
		return;
		}
	
	// swap in the thumb for display
	//if (currentPhotoIndex!=this.parentObj.parentObj.index||currentTakeIndex!=this.parentObj.index) {
	if (currentTakeIndex!=this.parentObj.index) {
		displayImgW=(size=='l')?this.parentObj.largeImgW:this.parentObj.smallImgW;
		displayImgH=(size=='l')?this.parentObj.largeImgH:this.parentObj.smallImgH;
		//thePhotoDiv.innerHTML='<img id="thePhotoImg" src="'+this.src+'" width="'+displayImgW+'" height="'+displayImgH+'" title="'+this.parentObj.title+'" />';
		}
	
	// write in the title, description and links
	thePhotoTitleSpan.innerHTML=this.parentObj.parentObj.title;
	if (this.parentObj.title!='' && this.parentObj.index!=0) {
		thePhotoTitleSpan.innerHTML+=' : '+this.parentObj.title;
		}
	thePhotoDescriptionSpan.innerHTML=displayBreaks(this.parentObj.description);
	largePhotoLinkSpan.innerHTML=this.parentObj.largePhotoLink || '';
	xlargePhotoLinkSpan.innerHTML=this.parentObj.xlargePhotoLink || '';
	
	// unfade things
	that=this.parentObj.parentObj.takes[currentTakeIndex].imgObj;
	unFadeIt(that,'#ccc');
	
	//fade things
	fadeIt(this);
	
	// reset the currentTakeIndex
	currentTakeIndex=this.parentObj.index;
	
	// load up the proper size image for display
	loadDisplayImg(this);
	
	// let's make sure the display image is on screen as much as possible
	moveNavnPic();
	
	// show the edit form if in permaEdit mode
	if (permaEdit) showEditForm();
	}

takeIMG.prototype.mousedover = function takeIMGprototypemousedover() { window.status=cleanBreaks(this.parentObj.title) || 'untitled'; }
takeIMG.prototype.mousedout = function takeIMGprototypemousedout() { window.status=''; }
takeIMG.prototype.setDescription = function takeIMGprototypesetDescription(description) { this.description=description||''; }
takeIMG.prototype.setTitle = function takeIMGprototypesetTitle(title) { this.title=title||''; }
takeIMG.prototype.toString = function takeIMGprototypetoString() { return '[a takeIMG with id: '+this.id+']'; }

function loadDisplayImg(obj) {
	temp = new Image();
	temp.onload=imageLoaded;
	temp.src=(size=='l')?obj.parentObj.largeImgPath:obj.parentObj.smallImgPath;
	}

function imageLoaded() {
	document.getElementById('thePhotoImg').src=this.src;
	if (autoTimer) clearTimeout(autoTimer); // because we don't want these to build up on one another
	if (auto=='on') autoTimer = setTimeout('autoShow()',autoTime);
	}

function callOpenWindowPhoto(s) {
	var obj=(currentTakeIndex>0)?thumbsA[currentPhotoIndex].takes[currentTakeIndex]:thumbsA[currentPhotoIndex]
	if (s=='x') {
		openWindowPhoto(obj.urlDir, obj.id, 'x', obj.xlargeImgH, obj.xlargeImgW);
	} else {
		openWindowPhoto(obj.urlDir, obj.id, 'l', obj.largeImgH, obj.largeImgW);
		}
	}

function displayBreaks(txt) {
	return txt.replace(/\r/g,"<br />");
	}

function cleanBreaks(txt) {
	txt = txt.replace(/(<([^>]+)>)/ig,"");
	return txt;
	}

function isChangeParentChecked() {
	var placedEditForm = document.getElementById('placedEditForm');
	if (placedEditForm && placedEditForm.changeParent.checked) return true;
	return false;
	}

function isSetThumbChecked() {
	var placedEditSetForm = document.getElementById('placedEditSetForm');
	if (placedEditSetForm && placedEditSetForm.setThumb.checked) return true;
	return false;
	}

function shiftArray(a,i) {
	for (t=i;t<a.length;t++) {
		a[t-1] = a[t];
		a[t-1].index = a[t-1].index-1;
		}
	a.length=a.length-1;
	}

function fadeIt(img) {;
	img.style.borderColor='black';
	}

function unFadeIt(img,bc) {;
	img.style.borderColor=bc;
	}
	
function nextPhoto() {
	if (yourBrowserIsNotGoodEnough) return true;
	if (includeTakes && thumbsA[currentPhotoIndex].takes.length) {
		nextTakeIndex = currentTakeIndex+1;
		if (nextTakeIndex<thumbsA[currentPhotoIndex].takes.length) {
			thumbsA[currentPhotoIndex].takes[nextTakeIndex].imgObj.click();
			return false;
			}
		}
	nextIndex=(currentPhotoIndex+1==thumbsA.length)?0:currentPhotoIndex+1;
	thumbsA[nextIndex].imgObj.click();
	return false;
	}
	
function prevPhoto() {
	if (yourBrowserIsNotGoodEnough) return true;
	if (includeTakes && thumbsA[currentPhotoIndex].takes.length) {
		nextTakeIndex = currentTakeIndex-1;
		if (nextTakeIndex>-1) {
			thumbsA[currentPhotoIndex].takes[nextTakeIndex].imgObj.click();
			return false;
			}
		}
	prevIndex=(currentPhotoIndex-1==-1)?thumbsA.length-1:currentPhotoIndex-1;
	thumbsA[prevIndex].imgObj.click();
	return false;
	}

var setEditDiv
function init() {
	// freaking NS6 ignores the bottom margin of the top nav header bar, so:
	if (!document.all) document.getElementById('secondaryShowDIV').style.marginTop='10px';
	
	secondaryDIVpadder = document.getElementById('secondaryDIVpadder');
	primaryShowDIV = document.getElementById('primaryShowDIV');
	
	window.onresize=moveNavnPic;
	watchForScroll();
	inited = true;
	
	imgs = document.getElementsByTagName("img")
	for (r=0;r<imgs.length;r++) {
		if (imgs[r].className=='showThumbs64' || imgs[r].className=='showThumbs48') {
		//alert(imgs[r].title)
		
		} else {
			//alert(imgs[r].className)
			}
		}
	}

lastS = 0
thisS = 0
function watchForScroll() {
	thisS=(document.body.scrollTop)?document.body.scrollTop:window.pageYOffset
	thisS=(thisS)?thisS:0;
	if (thisS!=lastS) {
		lastS=thisS;
		moveNavnPic();
	}
	setTimeout('watchForScroll()',50);
	}

function moveNavnPic() {
	if (!inited) return false;
	dHeight = getMyProperty(secondaryDIVpadder,'height') + 34;
	cHeight = (window.body)?window.body.offsetHeight:window.innerHeight;
	if (cHeight > dHeight) {
		myS=thisS;
	} else if ((cHeight+thisS) > dHeight) {
		myS=cHeight+thisS-dHeight;
	} else {
		myS = 0;
		}
	secondaryDIVpadder.style.marginTop=myS+'px';
	}

var clickee;
function smallShow() {
	if (size=='s') return false;
	size = 's';
	shouldBeMarginRight = 362;
	shouldBeWidth = 342;
	that=(currentTakeIndex>0)?thumbsA[currentPhotoIndex].takes[currentTakeIndex]:thumbsA[currentPhotoIndex];
	clickee=that.imgObj;
	changingSizePauseShow();
	decrease();
	return false;
	}
	
function largeShow() {
	if (size=='l') return false;
	size = 'l';
	shouldBeMarginRight = 682;
	shouldBeWidth = 662;
	that=(currentTakeIndex>0)?thumbsA[currentPhotoIndex].takes[currentTakeIndex]:thumbsA[currentPhotoIndex];
	clickee=that.imgObj;
	changingSizePauseShow();
	increase();
	return false;
	}

var shouldBeMarginRight;
var shouldBeWidth;
var resizeInc = 20;

function increase() {
	done1 = false
	done2 = false
	var actualMarginRight = parseInt(document.getElementById("primaryShowDIV").style.marginRight)
	var actualWidth = parseInt(document.getElementById("secondaryShowDIV").style.width);
	if (!actualMarginRight) actualMarginRight = 362
	if (!actualWidth) actualWidth = 342
	if (actualMarginRight+resizeInc<shouldBeMarginRight) {
		var newMarginRight = actualMarginRight+resizeInc
	} else {
		var newMarginRight = shouldBeMarginRight
		done1 = true
		}
		
	if (actualWidth+resizeInc<shouldBeWidth) {
		var newWidth = actualWidth+resizeInc
	} else {
		var newWidth = shouldBeWidth
		done2 = true
		}
	
	that=(currentTakeIndex>0)?thumbsA[currentPhotoIndex].takes[currentTakeIndex]:thumbsA[currentPhotoIndex];
	newImgW = (newWidth/shouldBeWidth) * that.largeImgW
	newImgH = (newWidth/shouldBeWidth) * that.largeImgH
	document.getElementById('thePhotoImg').width = newImgW
	document.getElementById('thePhotoImg').height = newImgH
	
	document.getElementById("primaryShowDIV").style.marginRight = newMarginRight+'px';
	document.getElementById("secondaryShowDIV").style.width = newWidth+'px';
	if (done1&&done2) {
		currentPhotoIndex=-1
		clickee.click();
		if (auto=='changingSizePause') resumeShow();
	} else {
		setTimeout('increase()',50);
		}
	}

function decrease() {
	done1 = false
	done2 = false
	var actualMarginRight = parseInt(document.getElementById("primaryShowDIV").style.marginRight)
	var actualWidth = parseInt(document.getElementById("secondaryShowDIV").style.width);
	if (!actualMarginRight) actualMarginRight = 682
	if (!actualWidth) actualWidth = 662
	if (actualMarginRight-resizeInc>shouldBeMarginRight) {
		var newMarginRight = actualMarginRight-resizeInc
	} else {
		var newMarginRight = shouldBeMarginRight
		done1 = true
		}
		
	if (actualWidth-resizeInc>shouldBeWidth) {
		var newWidth = actualWidth-resizeInc
	} else {
		var newWidth = shouldBeWidth
		done2 = true
		}
	
	that=(currentTakeIndex>0)?thumbsA[currentPhotoIndex].takes[currentTakeIndex]:thumbsA[currentPhotoIndex];
	newImgW = ((actualWidth-20)/(shouldBeWidth)) * that.smallImgW
	newImgH = ((actualWidth-20)/shouldBeWidth) * that.smallImgH
	document.getElementById('thePhotoImg').width = newImgW
	document.getElementById('thePhotoImg').height = newImgH
	document.getElementById("primaryShowDIV").style.marginRight = newMarginRight+'px';
	document.getElementById("secondaryShowDIV").style.width = newWidth+'px';
	if (done1&&done2) {
		currentPhotoIndex=-1
		clickee.click();
		if (auto=='changingSizePause') resumeShow();
	} else {
		setTimeout('decrease()',50);
		}
	}

function startShow() {
	if (auto=='on') return;
	if (auto=='pause') {
		resumeShow()
		return;
		}
	auto = 'on';
	currentPhotoIndex=(currentPhotoIndex==0)?-1:currentPhotoIndex
	thumbsA[0].imgObj.click();
	}

function resumeShow() {
	auto = 'on';
	autoShow();
	}

function autoShow() {
	if (auto!='on') return;
	nextPhoto();
	}

function changingSizePauseShow() {
	if (auto!='on') return;
	auto = 'changingSizePause';
	clearTimeout(autoTimer);
	}

function pauseShow() {
	auto = 'pause';
	clearTimeout(autoTimer);
	}

function stopShow() {
	auto = 'off';
	clearTimeout(autoTimer);
	}
	
/* ]]> */
//-->




