function addListItem(listID, optionValue, optionText) {
	var optionList = document.getElementById(listID);
   	//*** Add option to the bottom of the list
	if (optionText == "null" || optionText == null) {
		optionText = "";
		optionValue = "";
	}
   optionList[optionList.length] = new Option(optionText, optionValue);
}

function getX(obj) {
	return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
}

function getY(obj) {
   return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );  
}

function showPic(picID) {
	var pic = document.getElementById("big_" + picID);
	var picWidth = pic.width;
	if (picWidth < minWidth)
		picWidth = minWidth;
	bg.yoffset = getTop() +	15;
	bg.xoffset = (screen.width / 2) - (picWidth / 2);
	bg.pop_element("pop_" + picID,"pop_anchor");
}

function hidePic(picID) {
	bg.close_element("pop_" + picID);
}

function getQueryVariable(variable, defaultVal) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0; i<vars.length; i++) {
    	var pair = vars[i].split("=");
    	if (pair[0] == variable) {
      		return pair[1];
    	}
    }
	return defaultVal;
}

function getTop() {
	//*** Firefox, Safari, Opera, etc.
	if (window.pageYOffset)
		return window.pageYOffset;
	//*** IE 7
	if (document.documentElement);
		return document.documentElement.scrollTop;
	//*** IE 6
	if (document.body && !window.pageYOffset);
		return document.body.scrollTop;
		
}

function insertAfter(referenceNode, newNode) {
    referenceNode.parentNode.insertBefore(newNode,referenceNode.nextSibling);
}

function isFunction(a) {
	return typeof a == 'function';
}

function isNull(a) {
	return typeof a == 'object' && !a;
}

function isNumber(a) {
	return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
	return typeof a == 'string';
}

function isUndefined(a) {
	return typeof a == 'undefined';
} 

function relativeToDate(startDate, endDate) {
	var today = new Date();
	var testDate;
	var start = new Date(startDate);
	var end = new Date(endDate);
	var startDiff;
	var endDiff;
	var sdays;
	var edays;
	if (startDate == null || start == "Invalid Date" || endDate == null || end == "Invalid Date")
		return 0;
	startDiff = (start - today);
	endDiff = (end - today);
	sdays = Math.round(startDiff/(1000*60*60*24));
	edays = Math.round(endDiff/(1000*60*60*24));

	//alert(sdays + " -- " + edays);
	 //*** Start and end are both in the future
	if (sdays >= 0 && edays >= 0)
		return -1;
	
	//*** Today is between the start and end dates
	if (sdays < 0 && edays >= -1)
		return 1;
		
	 //*** Start and end are in the past
	if (sdays < -1 && edays < -1)
		return 2;	
}

function getParamValue(paramKey) {
	var searchString = document.location.search;
	var searchParts;
	var paramValue = null;
	
	searchString = searchString.replace("?","");
	searchParts = searchString.split("&");
	if (paramKey.indexOf("=") == -1)
		paramKey += "=";
	for (var s=0; s<searchParts.length; s++) {
		param = searchParts[s];
		if (param.indexOf(paramKey) != -1) {
			paramValue = param.replace(paramKey,"");
		}
	}
	return paramValue;
}

function setMenu(defaultMenu) {
	var searchString = document.location.search;
	searchString = searchString.replace("?","");
	var searchParts = searchString.split("&");
	var allAs = document.getElementsByTagName("a");
	var param;
	var thisID;
	var pageID = defaultMenu;
	
	pageID = getParamValue("pg");
	
	for (var i=0; i<allAs.length; i++) {
		thisID = allAs[i];
		if (thisID.id == pageID) {
			thisID.className = thisID.className + "-highlit";
			return;
		}
	}
}



