function Highlight(ElementID){

	// get the old element and set it to nothing
	try{
		var obj = document.getElementById(currentElementID);
		obj.className="";
	}
	catch(e){}

	// set the new element border and color
	try{
		var obj = document.getElementById(ElementID);
		obj.className="Sel";
	}
	catch(e) {}

	// make the new element the current element
	try{
		currentElementID = ElementID
		document.getElementById('current').value = ElementID;
	}
	catch(e){}
}



function Hide(ElementID){

	// set the new element border and color
	try{
		var obj = document.getElementById(ElementID);
		obj.style.display="none";
	}
	catch(e) {}
}

function SwapImg(ElementID,strSrc,strWidth,strHeight){
	// swap img src
	try{
		var obj = document.getElementById(ElementID);
		obj.src=strSrc;
		obj.width=strWidth;
		obj.height=strHeight;
		obj.title='';
	}
	catch(e) {}
}




function getElementPosition(elemID) {
   	try {	
		var offsetTrail = document.getElementById(elemID);
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail) {
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if (navigator.userAgent.indexOf("Mac") != -1 &&
			typeof document.body.leftMargin != "undefined") {
			offsetLeft += document.body.leftMargin;
			offsetTop += document.body.topMargin;
		}
		return {left:offsetLeft, top:offsetTop};
	}catch(e){
	   return {left:0, top:0};
	}
}




function ResizeToHeight(BoxElementID) {

	try {
		if(document.body.clientHeight > 0){
			var ElementHeight = document.body.clientHeight - 1 - getElementPosition(BoxElementID).top + "px";
		}
		document.getElementById(BoxElementID).style.height=ElementHeight;
	}catch(e){}
}



AttachFunction = function() {
	try{
		ResizeToHeight('PhotoIndex');
	}
	catch(e){}
}


if(window.addEventListener) window.addEventListener('load', AttachFunction, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', AttachFunction, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', AttachFunction);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			AttachFunction();
		}
	} else {
		window.onload = function() {
			AttachFunction();
		}
	}
}


if(window.addEventListener) window.addEventListener('resize', AttachFunction, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('resize', AttachFunction, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onresize', AttachFunction);
} else { // mac/ie5
	if(typeof window.onresize == 'function') {
		var existing = onresize;
		window.onresize = function() {
			existing();
			AttachFunction();
		}
	} else {
		window.onresize = function() {
			AttachFunction();
		}
	}
}