var sURL = window.location.pathname;
function refresh() {
	//standard refresh. A more useful version (JS 1.1 specific) is in refresh11.js
	window.location.href=sURL;
}

var footerHeight = 0;
function setHeight () {
	var leftColHeight=document.getElementById('divLeft').offsetHeight;
	var mainColHeight=document.getElementById('MainArea').offsetHeight;
	if (leftColHeight<mainColHeight) {
		document.getElementById('divLeft').style.setExpression("height",mainColHeight);
	}
	if (document.getElementById('hometable')!=null) {
		if (mainColHeight<leftColHeight) {
			document.getElementById('hometable').style.setExpression("height",leftColHeight);
		}
	}
}

function getAbsoluteOffset(obj) {
	//returns collection [x,y]
	x=0;
	y=0;
	while (obj.offsetParent!=null) {
		x+=obj.offsetLeft;
		y+=obj.offsetTop;
		obj=obj.offsetParent;
	}
	var retVal = new Array();
	retVal['x']=x;
	retVal['y']=y;
	return retVal;
}

function getYpos(obj) {
	var pos = getAbsoluteOffset(obj);
	return pos['y'];
}
function getXpos(obj) {
	var pos = getAbsoluteOffset(obj);
	return pos['x'];
}

function showDiv2(iDiv) {	// hides/displays content of joining, parents, advancement pages
	var oDivs=document.Form1.getElementsByTagName('div');
	var oCurr=document.getElementById('currentRecord');
	var iLoop;
	var iLen='divcontent'.length;
	for(iLoop=0;iLoop<oDivs.length;iLoop++) {
		var szId=oDivs[iLoop].id;
		if (szId.substr(0,iLen)=='divContent') {
			var iRec=szId.substr(iLen);
			var sStyle=oDivs[iLoop].getAttribute('style');
			if (iRec==iDiv) {
				if (isIE) {
					oDivs[iLoop].style.display='block';
				} else {
					sStyle=sStyle.replace('display: none','display: block');
					oDivs[iLoop].setAttribute('style',sStyle);
				}
				oCurr.value=iDiv;
			} else {
				if (isIE) {
					oDivs[iLoop].style.display='none';
				} else {
					sStyle=sStyle.replace('display: block','display: none');
					oDivs[iLoop].setAttribute('style',sStyle);
				}
			}
		}
	}
}

function fnDone() {
	if (bNeedRefresh) opener.refresh();
	window.close();
}

function toggleEditImage(ev) {
	try {
		if (ev.altKey || ev.shiftKey) {
			var editLink = document.getElementsByName("editSwitch");
			var adminLink = document.getElementsByName("adminSwitch");
			var szHidden = editLink.item(0).style.visibility;
			if (szHidden == 'hidden') {
				editLink.item(0).style.visibility = 'visible';
				adminLink.item(0).style.visibility = 'visible';
			} else {
				editLink.item(0).style.visibility = 'hidden';
				adminLink.item(0).style.visibility = 'hidden';
			}
		}
	}
	catch (e) {
	}
}

function goEditMenu(tgt,ev) {
	try {
		if (ev.altKey || ev.shiftKey) {
			window.navigate('Admin/PageSelect.aspx');
			return false;
		}
	}
	catch (e) {
	}
}

function editContent(tgtID) {
	window.open('Admin/AddEditContent.aspx?recID='+tgtID ,"" ,"height=650,width=900,resizable=yes,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,titlebar=no");
}

function AddContent(pagetype) {
	window.open('Admin/AddEditContent.aspx?pagetype='+pagetype ,"" ,"height=650,width=900,resizable=yes,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,titlebar=no");
}

function deleteRecord(tgtID) {
	var msg = 'Are you sure you want to delete this information?\nClick Ok to delete it; click Cancel to stop.';
	if (confirm(msg)) {
		document.Form1.task.value='delete';
		document.Form1.delID.value=tgtID;
		document.Form1.submit();
	}
}

function launchImagePop() {
	var oTgt = document.getElementById('txtImage');
	var url='imageSelect_pop.aspx?sel='+oTgt.value;
	var image_window=window.open(url,'image_window','width=550,resizable=yes,scrollbars=yes,status=yes');
	image_window.focus();
}

function launchCalendar(tgt) {
	var oTgt = document.getElementById(tgt);
	var url='';
	if (document.URL.indexOf('/Admin/')>0) url='../';
	url+='calendar_pop.aspx?formname=Form1.'+tgt+'&tgtdate='+oTgt.value;
	var calendar_window=window.open(url,'calendar_window','width=180,height=210,resizable=yes');
	calendar_window.focus();
}

function isIE () {
    var ua = window.navigator.userAgent;
    isIE = (ua.indexOf("MSIE")>=1);
}
