// begin DTHML edit functions 
function dhtmlDisplay(domID,dVal) {
	document.getElementById(domID).style.display = dVal;
}

//site-specific functions
function Fsol_OnClick(sender)
{
	if(sender.checked)
	{
		if(sender.id.toLowerCase()=="fsol_fs")
			sender.form.Fsol_fl.checked = false;
		else
			sender.form.Fsol_fs.checked = false;
	}
}

//begin helpers for wiring-up event handlers
function addEventHandler_OnLoad(oFunc)
{
	var oldHandler = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = oFunc;
	} else {
		window.onload = function() {
			oldHandler();
			oFunc();
		}
	}
}

function addEventHandler_OnUnload(oFunc)
{
	var oldHandler = window.onunload;
	if (typeof window.onunload != 'function') {
		window.onunload = oFunc;
	} else {
		window.onunload = function() {
			oldHandler();
			oFunc();
		}
	}
}

function addEventHandler_OnLoadAndUnload(oFunc)
{
	addEventHandler_OnLoad(oFunc);
	addEventHandler_OnUnload(oFunc);
}

function addEventHandler_OnSubmit(oForm,oFunc)
{
	var oldHandler = oForm.onsubmit;
	if (typeof oForm.onsubmit != 'function') {
		oForm.onsubmit = oFunc;
	} else {
		oForm.onsubmit = function() {
			oldHandler();
			oFunc();
		}
	}
}

//common functions
function CheckBoxCheckALL(objCheckbox)
{
	if(objCheckbox)
	{
		var len = objCheckbox.length;
		if(!len)
			objCheckbox.checked=true;
		else
		{
			var i=0;
			for (i=0 ; i<len ; i++)
				objCheckbox[i].checked=true;
		}
	}
}

function CheckBoxUnCheckALL(objCheckbox)
{
	if(objCheckbox)
	{
		var len = objCheckbox.length;
		if(!len)
			objCheckbox.checked=false;
		else
		{
			var i=0;
			for (i=0 ; i<len ; i++)
				objCheckbox[i].checked=false;
		}
	}
}


function getkey(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}

function formFocus(strFormname, strElement) 
{
	var objE = eval('document.forms.' + strFormname + '.' + strElement);
	if (objE) objE.focus();
}

function ClearDayList(obj_selectDay)
{
	var i;
	var intLength;
	intLength = obj_selectDay.options.length = 1;
}
	
function IsLeapYear(int_year)
{
	var blnIsLeapYear = false;
	
	if ((((int_year % 4) == 0) && ((int_year % 100) != 0)) || ((int_year % 400) == 0))
	{
		blnIsLeapYear = true;
	}
	
	return(blnIsLeapYear);
}

function PopulateDays(obj_selectMonth, obj_selectDay, obj_selectYear, int_defaultDay)
{
	ClearDayList(obj_selectDay);
	
	var intYear = obj_selectYear.options[obj_selectYear.selectedIndex].value
	
	if (IsLeapYear(intYear) == true)
	{
		arrDaysInMonth[2] = 29;
	}
	else
	{
		arrDaysInMonth[2] = 28;
	}
	
	var intDaysInMonth	= arrDaysInMonth[obj_selectMonth.selectedIndex];
	var intDay			= '';
	
	for (i = 1; i <= intDaysInMonth; i++)
	{
		intDay = '' + i + ''
		if (intDay.length == 1)
		{
			intDay = '0' + intDay;
		}
		obj_selectDay.options[i] = new Option(intDay, intDay, false, false);
	}
	
	var intSelectedIndex = 0;
	
	if (int_defaultDay != '')
	{
		intSelectedIndex = int_defaultDay;
	}
	else
	{
		intSelectedIndex = 0;
	}
	
	obj_selectDay.selectedIndex = intSelectedIndex;
	
}

function ConstructDate(txt_hiddenField, int_monthSelected, int_daySelected, int_yearSelected)
{
	var txt_hiddenTemp;
	txt_hiddenTemp = int_monthSelected + '/' + int_daySelected + '/' + int_yearSelected;
	
	if(txt_hiddenTemp == '//')
	{
		txt_hiddenTemp = ''
	}
	
	txt_hiddenField.value = txt_hiddenTemp
}

function openPopup(theURL,winName,features,width,height)
{
	var winWidth	= width;
	var winHeight	= height;
	var strWinSize	= ",width=" + winWidth + ",height=" + winHeight;

	if (window.screen) {
		var winPosL = (screen.availWidth - winWidth) / 2;
		var winPosT = (screen.availHeight - winHeight) / 2;
		strWinSize += ",left=" + winPosL + ",screenX=" + winPosL + ",top=" + winPosT + ",screenY=" + winPosT;
	}	
	
	window.open(theURL,winName,features + strWinSize);
 	}

function openModule(moduleURL,moduleName,width,height,formName,inputVisible,inputHidden,qsArgs)
{
	var winWidth	= width;
	var winHeight	= height;
	var strWinSize	= ",width=" + winWidth + ",height=" + winHeight;

	if (window.screen) {
		var winPosL = (screen.availWidth - winWidth) / 2;
		var winPosT = (screen.availHeight - winHeight) / 2;
		strWinSize += ",left=" + winPosL + ",screenX=" + winPosL + ",top=" + winPosT + ",screenY=" + winPosT;
	}	
	
	moduleURL += "?fref=" + formName + "&iv=" + inputVisible + "&ih=" + inputHidden + qsArgs
	
	window.open(moduleURL,moduleName,'toolbar=0,status=0,scrollbars,location=0,menubar=0,resizable' + strWinSize);
 	}

function mediaPlayer(mediaID,gallery) {
	openPopup('/media/player.asp?id=' + mediaID + '&gallery=' + gallery,'media_player','',413,350);
}

function ClosePopup() { //v2.0
	 window.close(self);
}

function ul_onclick(jsObj)
{
   var i;
   var style;
  
   for (i = 0; i < jsObj.children.length; i++)
   {
       style = jsObj.children[i].style;
       if (style.display == "none")
       {
           style.display = "";
       }
       else
       {
           style.display = "none";
       }
   } 
}

function verifyMsg(jsStrURL, jsStrMsg) 
{
	if (confirm (jsStrMsg)) 
	{		
		this.window.location=jsStrURL;
		return true;
	}
}

function buildHumanSQL(objElement, strHeadline) {

	var inputLocal	= objElement;
	var strSQLHuman	= '<b>' + strHeadline + '</b>\n';
		strSQLHuman	+='<ul type=square style="margin-top:0; margin-left:15; padding:5">\n';
	var blnIsSelected = false;
	
	if (inputLocal) {
		var len = inputLocal.length;
		var i=0;
		for (i=0 ; i<len ; i++) {
		
			if (inputLocal.options[i].selected) {
				blnIsSelected = true;
				strSQLHuman += '<li>' + inputLocal.options[i].text + '<br></li>\n';
			}
		}
	}
	
	strSQLHuman += '</ul>'
	if (blnIsSelected) objElement.form.txt_sqlHuman.value = strSQLHuman;
	return true;
}

function checkKeyValue(obj, evt) {
var keyValue
var form = obj
keyValue = window.event.keyCode;

/*status = keyValue*/
	    
if (keyValue == 13) {
	/*alert(keyValue)*/
	javascript: form.submit();
}
return false
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// window functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var m_blnRefreshWindow = false;

function clickOpenerButton(buttonId,openerUrl)
{
	var openerForm;
	var buttonToClick;
	
	if(opener)
	{
		openerForm = opener.document.forms[0];
		if(openerForm) buttonToClick = eval('openerForm.'+buttonId);
	}
	if(buttonToClick)
	{
		buttonToClick.click();
	}
	else
	{
		openerLocation(openerUrl);
	}
	closePopup();
}

function closePopup()
{
	window.close(self);
	return false;
}

function focusOpener()
{
	if (windowIsOpen(opener)) {
		opener.focus();
	}
}

function focusPopup(objPopup,theURL,winName,features,width,height)
{
	if (!windowIsOpen(objPopup)) {
		objPopup = returnPopup(theURL,winName,features,width,height);
	}
	 objPopup.focus();
	 return objPopup;
}

function openPopup(theURL,winName,features,width,height)
{
	var objPopup = returnPopup(theURL,winName,features,width,height);
	objPopup.focus();
	return false;
}

function openerLocation(strLocation)
{
	if (windowIsOpen(opener)) {
		opener.location.href=strLocation;
		opener.focus();
	} else {
		window.open(strLocation);
		window.close(self);
	}
}

function refreshOpener(strDefaultURL,blnCloseMe)
{
	var blnExists = false;
	
	if (windowIsOpen(opener)) {
	 	if (opener.m_blnRefreshWindow==true) {
			opener.location.reload();
			opener.focus();
		} else {
			blnCloseMe = false;
		}
		blnExists = true;
	}
	
	if (blnExists==false) {
		window.open(strDefaultURL);
		blnCloseMe = true;
	}
	
	if (blnCloseMe==true) window.close(self);
}

function returnPopup(theURL,winName,features,width,height)
{
	var winWidth	= width;
	var winHeight	= height;
	var strWinSize	= ",width=" + winWidth + ",height=" + winHeight;

	if (window.screen) {
		var winPosL = (screen.availWidth - winWidth) / 2;
		var winPosT = (screen.availHeight - winHeight) / 2;
		strWinSize += ",left=" + winPosL + ",screenX=" + winPosL + ",top=" + winPosT + ",screenY=" + winPosT;
	}	
	
	return window.open(theURL,winName,features + strWinSize);
}

function setOpenerRefresh()
{
	if (windowIsOpen(opener)) {
		opener.m_blnRefreshWindow = true;
	}
}

function setWinStatus(value)
{
	window.status=value;
	return true;
}

function windowIsOpen(objWindow)
{
	var blnIsOpen = false;
	
	if (typeof(objWindow)=='object') {
		if (!objWindow.closed) {
			blnIsOpen = true;
		}
	}
	return blnIsOpen;
}
