function trim(strText) {
	if (strText && strText.length > 0) {
		// this will get rid of leading spaces 
		while (strText.substring(0,1) == ' ') 
				strText = strText.substring(1, strText.length);
		// this will get rid of trailing spaces 
		while (strText.substring(strText.length-1,strText.length) == ' ')
				strText = strText.substring(0, strText.length-1);
	}
	return strText; 
}

function isEmpty(value) {
	if ((value && trim(value) != "") || value === 0) { //is this right?
		return false;
	} else {
		return true;
	}
}



function getDisplay(obj_id) {
	return (document.getElementById(obj_id))? document.getElementById(obj_id).style.display: "";
}

function setDisplay(obj_id, value) {
	if (document.getElementById(obj_id)) document.getElementById(obj_id).style.display = value;
}

function getVisibility(obj_id) {
	return (document.getElementById(obj_id))? document.getElementById(obj_id).visibility: "";
}

function setVisibility(obj_id, value) {
	if (document.getElementById(obj_id)) {
		document.getElementById(obj_id).style.visibility = value;
	}
}

function getInnerHTML(obj_id) {
	return (document.getElementById(obj_id))? document.getElementById(obj_id).innerHTML: "";
}

function setInnerHTML(obj_id, value) {
	if (document.getElementById(obj_id)) document.getElementById(obj_id).innerHTML = value; //formatForWeb(value);
}

function getSrc(obj_id) {
	return (document.getElementById(obj_id))? document.getElementById(obj_id).src: "";
}

function setSrc(obj_id, value) {
	if (document.getElementById(obj_id)) document.getElementById(obj_id).src = value;
}

function getZIndex(obj_id) {
	return (document.getElementById(obj_id))? document.getElementById(obj_id).style.zIndex: "";
}

function setZIndex(obj_id, value) {
	if (document.getElementById(obj_id)) document.getElementById(obj_id).style.zIndex = value;
}



function showModalBG() {
	setVisibility("modalBGFade", "visible");
}

function hideModalBG() {
	Opacity.setTransparent("modalBGFade");
	setVisibility("modalBGFade", "hidden");
}

function showLargeImage(image, caption, credit) {
	showModalBG();
	Opacity.animateOpacity("modalBGFade", 0, 85, .75, 30, "showLargeImageContainer('"+image+"', '"+caption+"', '"+credit+"')");
}

function showLargeImageContainer(image, caption, credit) {
	setSrc("large_img", image);
	if (!isEmpty(caption) || !isEmpty(credit)) {
		var caption_html = "";
		if (!isEmpty(caption)) caption_html += "<p class='caption'>"+caption+"</p>";
		if (!isEmpty(credit)) caption_html += "<p class='credit'>"+credit+"</p>";
		setInnerHTML("large_img_caption", caption_html);
		setDisplay("large_img_caption", "block");
	} else {
		setDisplay("large_img_caption", "none");
	}
	setVisibility("imageContainer", "visible");
}

function hideLargeImage() {
	setVisibility("imageContainer", "hidden");
	Opacity.animateOpacity("modalBGFade", 85, 0, .6, 30, "hideModalBG()");
	setSrc("large_img", "../common/images/spacer.gif");
	setInnerHTML("large_img_caption", "");
	setDisplay("large_img_caption", "none");
}

