function changeSlide(slideNum) {
	var loc = document.location.protocol + "//" + document.location.hostname + document.location.pathname;
	var params = document.location.search.split("&");
	var pString = "";
	var amp = "";
	var seg = "";
	for (i=0; i<params.length; i++) {
		seg = params[i];
		if (seg.indexOf("PhotoID") == 0) {
			seg = "PhotoID=" + slideNum;
		}
		pString += amp + seg;
		amp = "&"
	}
	document.location = loc + pString;
}

function editBox(thisItem) {
	var noteWindow;
	var url = thisItem.getAttribute("url");
	bWidth = Math.round(screen.width *.40);
	bHeight = Math.round(screen.height *.30);
	noteWindow = window.open(url,"noteWindow","location=0,status=0,scrollbars=0,width=" + bWidth + ",height=" + bHeight);
	noteWindow.moveTo(screen.width/2 - bWidth/2,screen.height/2 - bHeight/2);
}

function isPastDate(dateString) {
	var today = new Date();
	var then = new Date(dateString);
	
	return (then.getTime() - today.getTime()) <= 0;
}

function popPage(thisObj) {
	bWidth = Math.round(screen.width *.80);
	bHeight = Math.round(screen.height *.60);
	url = thisObj.getAttribute("url");
	var popWindow = window.open(url,"popWindow","location=0,status=0,scrollbars=1,width=" + bWidth + ",height=" + bHeight);
  	popWindow.moveTo((screen.width/2 - bWidth/2)+20,(screen.height/2 - bHeight/2)+20);
}

function popWindow(url) {
	bWidth = Math.round(screen.width *.80);
	switch (true) {
		case (screen.height <= 600) :
			bHeight = 540;
			break;
		case (screen.height <= 768) :
			bHeight = 690;
			break;
		case (screen.height <= 1024) :
			bHeight = 900;
			break;
	}
	noteWindow = window.open(url,"docWindow","resizable=1,location=0,status=0,scrollbars=2,width=" + bWidth + ",height=" + bHeight);
  	noteWindow.moveTo(screen.width/2 - bWidth/2,screen.height/2 - bHeight/2);
}

function setupMenu() {
	var spans = document.getElementsByTagName("span");
	var className = null;
	for (var i=0; i<spans.length; i++) {
		if (spans[i].className == "menu") {
			with (spans[i].style) {
				visibility = "visible";
			}
			spans[i].onmouseover = function() {
					this.style.background = "#FFF0C5";
			}
			spans[i].onmouseout = function() {
					this.style.background = "";
			}
			spans[i].onmousedown = function() {
					menuClicked(this);
			}
		}
	}
}
function showEnlargement(thisItem) {
	var noteWindow;
	var url = thisItem.getAttribute("url");
	var pWidth = thisItem.getAttribute("pWidth");
	var pHeight = thisItem.getAttribute("pHeight");
	if (pWidth < 225)
		pWidth = 225;
	url += "&screen=" + screen.width + "X" + screen.height;
	bWidth = Math.round(pWidth * 1.25);
	bHeight = Math.round(pHeight * 1.25);
	noteWindow = window.open(url,"noteWindow","location=0,status=0,scrollbars=0,resizable=0,width=" + bWidth + ",height=" + bHeight);
	noteWindow.moveTo(screen.width/2 - bWidth/2,screen.height/2 - bHeight/2);
}
function focusMe()	{
	focusTime = setTimeout("self.focus()",250);
}

function popListX(listName,closeOnly) {
	var allDivs = document.getElementsByTagName("div");
	var thisList = document.getElementById("pop_" + listName);
	var listTarget = document.getElementById("field_" + listName);
	var listPop = document.getElementById("list_" + listName);
	var listBtn = document.getElementById("btn_" + listName);
	var listCancel = document.getElementById("cancel_" + listName);
	var thisArray;
	var brower = new browserDetect;
	var subtractX = 0;
	var subtractY = 0;
	
	for(var i=0; i<allDivs.length; i++) {
		if (allDivs[i].id.indexOf('pop_') == 0) {
			allDivs[i].style.visibility = "hidden";
			if (allDivs[i].className == "dropshadow") {
				if (!browser.isIE)
					subtractX = 4
				subtractY = 4;
			}
		}
	}
	unfocus();
	if (currentPop == listName) {
		closeList(currentPop,true);
		return;
	}
	if (browser.isIE)
		hideSelects(listTarget);
	if (closeOnly) {
		listBtn.style.visibility = "hidden";
		listCancel.value = "Close";
	}
	with (thisList.style) {
	alert(subtractX);
		left = getX(listTarget) - subtractX;
		top = getY(listTarget) + listTarget.offsetHeight - subtractY;
		zindex = 5;
		visibility = "visible";
	}
	listTarget.className += '_focus';
	try {
		//*** Read items from the field into the list
		thisArray = listTarget.getAttribute("value").split(",");
		for(var i=0; i<thisArray.length; i++) {
			for(var j=0; j<listPop.options.length; j++) {
				if (listPop.options[j].text == Trim(thisArray[i])) {
					listPop.options[j].selected = true
				}
			}
		}
	} catch(e) {
	}
	currentPop = listName;
	return;
}

function closeList(listName,closeOnly) {
	var outList = "";
	var comma = "";
	var thisList = document.getElementById("pop_" + listName);
	var listPop = document.getElementById("list_" + listName);
	var listTarget = document.getElementById("field_" + listName);
	
	thisList.style.visibility = "hidden";
	currentPop = "";
	unfocus();
	if (browser.isIE)
		showSelects();
	if (closeOnly)
		return;
	if (!closeOnly) {
		for(var i=0; i<listPop.options.length; i++) {
			if(listPop.options[i].selected == true) {
				if(i != -1) {
					outList += comma + listPop.options[i].text;
					comma = ", ";
				}
			}
		}
		if (outList != "" )
			listTarget.value = outList;
	}
	return;
}

function hideSelects(popList) {
	var allDDs = document.getElementsByTagName("select");
	var allTDs = document.getElementsByTagName("td");
	var popLeft = getX(popList);
	var popWidth = parseInt(popList.style.width);
	var listLeft;
	var sIndex;
	var sText;
	for (var i=0; i<allDDs.length; i++) {
		if (allDDs[i].size == 0) {
			listLeft = getX(allDDs[i]);
			listWidth = allDDs[i].style.width
			allDDs[i].style.visibility = "hidden";
		}
	}
}
function showSelects() {
	var allDDs = document.getElementsByTagName("select");
	for (var i=0; i<allDDs.length; i++) {
		if (allDDs[i].size == 0) {
			allDDs[i].style.visibility = "visible";
		}
	}
}

