function Navigate(sUrl, sTarget)
{
	if (sTarget != null && sTarget != "")
	{
		var oFrame = document.all(sTarget);
		if (oFrame != null)
			oFrame.src = sUrl;
	}
	else {
		if (window.parent.parent != null)
			window.parent.parent.navigate(sUrl);
		else
			window.parent.navigate(sUrl);
	}
}

function Popup(sUrl, sHeight, sWidth)
{
	var sFeatures = "dialogHeight:" + sHeight + "px; dialogWidth:" + sWidth + "px; edge:raised; scroll:no; center:Yes; help:No; resizable:No; unadorned:yes; status:no";
	return window.showModalDialog(sUrl, "", sFeatures);
}

var g_PageTimer__Timer = null;
function PageTimer()
{
	this.Start = PageTimer__Start;
	this.Fire = PageTimer__Fire;
	this.ForceLogin = PageTimer__ForceLogin;
	this.StartButtonTimer = PageTimer__StartButtonTimer;
	this.FireButtonTimer = PageTimer__FireButtonTimer;
}

function PageTimer__Start()
{
	g_PageTimer__Timer = window.setTimeout("new PageTimer().Fire();", 30 * 60000);
}

function PageTimer__Fire()
{
    // Commented out b/c we want to just redirect to login
	//window.clearTimeout(g_PageTimer__Timer);
	//var vtRet = Popup("/manage/Common/ValidateLoginContainer.htm", "142", "352");
	//if (vtRet == 1)
	//	this.Start();
	//else if (vtRet == 2)
	// TODO: create an intermediat page saying you've been logged out
		Navigate("/manage/login/default.aspx?AutoLogoff=true");
	//else
	//	this.ForceLogin();
}

function PageTimer__ForceLogin()
{
// Commented out b/c we want to just redirect to login
//	var vtRet = Popup("/manage/Common/LoginExpiredContainer.htm", "197", "408");
//	if (vtRet == 1)
//		this.Start();
//	else
		Navigate("/manage/login/default.aspx?AutoLogoff=true");
}

function PageTimer__StartButtonTimer()
{
	g_PageTimer__Timer = window.setTimeout("new PageTimer().FireButtonTimer();", 5 * 60000);
}

function PageTimer__FireButtonTimer()
{
	window.close();
}

var g_Menus = new String("");
function Menu(bParent)
{
	this.srcElement = event.srcElement;
	if (bParent == true)
		this.srcElement = this.srcElement.parentElement;
	this.HeaderClicked = Menu__HeaderClicked;
	this.onMouseOver = Menu__onMouseOver;
	this.onMouseOut = Menu__onMouseOut;
	this.ShowMenu = Menu__ShowMenu;
	this.onBlur = Menu__onBlur;
	this.BlurAll = Menu__BlurAll;
}

var g_nLastIndex;
function Menu__HeaderClicked(nIndex)
{
	if (g_nLastIndex == null)
		g_nLastIndex = document.all("hdnLeftNavIndex").value;
		
	if (g_nLastIndex == nIndex)
		return;
	tblHeader[g_nLastIndex].style.display = "none";
	tblHeader[nIndex].style.display = "";
	menuHeader[nIndex].className = "MenuParentOn";
	menuHeader[g_nLastIndex].className = "MenuParent"
	g_nLastIndex = nIndex;
}

function Menu__BlurAll()
{
	var arMenu = g_Menus.split(";");
	var i;
	for (i = 0; i < arMenu.length; i++)
	{
		document.all(arMenu[i]).className = "ComboboxInvisible";
	}
}

function Menu__onBlur()
{
	if (hdnCurrentMenu.value == "Action")
		return;
	var arMenu = g_Menus.split(";");
	var i;
	for (i = 0; i < arMenu.length; i++)
	{
		if (hdnCurrentMenu == "" || hdnCurrentMenu.value.indexOf(arMenu[i]) < 0)
			document.all(arMenu[i]).className = "ComboboxInvisible";
	}
}

function Menu__onMouseOver(sCurrentMenu)
{
	if (sCurrentMenu != null)
		hdnCurrentMenu.value = sCurrentMenu;
	else if (this.srcElement.child != null)
		hdnCurrentMenu.value = "";
	else
		hdnCurrentMenu.value = "Action";
	
	if (this.srcElement.className != "MenuParentOn")
		this.srcElement.className = this.srcElement.className + "Over";
}

function Menu__onMouseOut()
{
	hdnCurrentMenu.value = "";
	if (this.srcElement.className != "MenuParentOn")
		this.srcElement.className = this.srcElement.className.substring(0, this.srcElement.className.length - 4);
}		

function Menu__ShowMenu()
{
	if (this.srcElement.child == null)
		return;
	var oMenu = document.all(this.srcElement.child);
	g_Menus += (g_Menus == "" ? "" : ";") + this.srcElement.child;
	oMenu.style.left = new Number(this.srcElement.clientWidth) + new Number(event.x) - new Number(event.offsetX) - 1;
	oMenu.className = "MenuVisible";
	oMenu.style.top = new Number(event.y) - new Number(event.offsetY) + new Number(this.srcElement.clientHeight) - new Number(this.srcElement.offsetHeight) - 2;
	oMenu.focus();
}



function Checkbox()
{
	this.srcElement = event.srcElement;
	this.Clicked = Checkbox__Clicked;
}

function Checkbox__Clicked()
{
	if (this.srcElement == null || this.srcElement.parent == null || document.all(this.srcElement.parent) == null)
		return;
	
//	document.all(this.srcElement.parent)
}



function Combobox()
{
	this.srcElement = event.srcElement;
	this.Show = Combobox__Show;
	this.Hide = Combobox__Hide;
	this.onSelect = Combobox__onSelect;
	this.onEntriesOver = Combobox__onEntriesOver;
	this.onEntriesOut = Combobox__onEntriesOut;
	this.onEntryOver = Combobox__onEntryOver;
	this.onEntryOut = Combobox__onEntryOut;
}

function Combobox__Show()
{
	var oChild = document.all(this.srcElement.child);
	if (oChild == null)
		return;
	var oParent = this.srcElement.parentElement;
	oChild.style.width = oParent.clientWidth;
	oChild.style.top = new Number(oParent.offsetTop) + 18;
	oChild.style.left = oParent.offsetLeft;
	oChild.className = "ComboboxVisible";
	oChild.focus();
}

function Combobox__Hide()
{
	var status = document.all("ComboboxStatus");
	if (status.value != "Over")
		this.srcElement.className = "ComboboxInvisible";
}

function Combobox__onSelect(val)
{
	var sParent = this.srcElement.parent.substring(2);
	document.all("vis" + sParent).value = this.srcElement.innerText;
	document.all(sParent).value = val;
	document.all(this.srcElement.parent).className = "ComboboxInvisible";
}

function Combobox__onEntriesOver()
{
	document.all("ComboboxStatus").value = "Over";
}

function Combobox__onEntriesOut()
{
	document.all("ComboboxStatus").value = "Out";
}

function Combobox__onEntryOver()
{
	this.srcElement.className = "ComboboxOver";
}

function Combobox__onEntryOut()
{
	this.srcElement.className = "Combobox";
}



function ListBox()
{
	this.srcElement = event.srcElement;
	this.onClick = ListBox__onClick;
}

function ListBox__onClick()
{
	var oList = document.all(this.srcElement.id);
	if (oList.length != null)
		oList[this.srcElement.current].className = "Listbox";
	this.srcElement.className = "ListboxSelected";
	if (this.srcElement.parent != null && document.all(this.srcElement.parent) != null)
		document.all(this.srcElement.parent).value = this.srcElement.value;
}



function Framework()
{
	event.returnValue = false;
	this.SectionOver = Framework__SessionOver;
	this.SectionOut = Framework__SessionOut;
	this.SectionOn = Framework__SectionOn;
	this.SessionProperties = Framework__SessionProperties;
	this.SavePage = Framework__SavePage;
	this.EmailPage = Framework__EmailPage;
	this.HelpPage = Framework__HelpPage;
	this.onMouseOut = Framework__onMouseOut;
	this.onMouseOver = Framework__onMouseOver;
	this.onClick = Framework__onClick;
	this.PopupShow = Framework__PopupShow;
	this.PopupBlur = Framework__PopupBlur;
	this.PopupMouseOut = Framework__PopupMouseOut;
	this.PopupMouseOver = Framework__PopupMouseOver;
}

var g_Framework__Last = null;
function Framework__SessionOver(nIndex)
{
	var oSectionImage = document.all("SectionImage" + nIndex);
	var oSectionText = document.all("SectionText" + nIndex);
	if (oSectionImage == null || oSectionText == null)
		return;
	
	g_Framework__Last = oSectionImage.className;
	oSectionImage.className = oSectionText.className = "FrameworkSectionOver";
}

function Framework__SessionOut(nIndex)
{
	var oSectionImage = document.all("SectionImage" + nIndex);
	var oSectionText = document.all("SectionText" + nIndex);
	if (oSectionImage == null || oSectionText == null)
		return;
	
	oSectionImage.className = oSectionText.className = g_Framework__Last;
}

function Framework__SectionOn(nIndex)
{
	var oSectionImage = document.all("SectionImage" + nIndex);
	var oSectionText = document.all("SectionText" + nIndex);
	if (oSectionImage == null || oSectionText == null)
		return;
}

function Framework__SessionProperties()
{
	Popup("/manage/Common/SessionPropertiesContainer.htm", "195", "432");
}

function Framework__SavePage()
{
	Popup("/manage/Common/SavePageContainer.aspx", "331", "560");
}

function Framework__EmailPage()
{
	Popup("/manage/Common/EmailPageContainer.aspx", "342", "584");
}

function Framework__HelpPage()
{
	/*Popup("/manage/Common/EmailPageContainer.aspx", "342", "584");*/
}

function Framework__onMouseOver()
{
	var oSrcElement = event.srcElement;
	oSrcElement.className += "Over";
}

function Framework__onMouseOut()
{
	var oSrcElement = event.srcElement;
	oSrcElement.className = oSrcElement.className.substring(0, oSrcElement.className.length - 4);
}

function Framework__onClick(sPage, arKeys, arValues)
{
	var oSrcElement = event.srcElement;
	if (oSrcElement.Popup != null)
	{
		if (document.all(oSrcElement.Popup) != null)
			document.all(oSrcElement.Popup).className="PopupInvisible";
	}
	var hdnForm = document.all("hdnForm");
	if (hdnForm ==  null)
		return;
	
	var i, oTmp;
	hdnForm.action = hdnForm.target = "_top";
	for (i = 1; i < hdnForm.children.length; i++)
		hdnForm.removeChild(hdnForm.children[i]);
	if (event.ctrlKey)
		hdnForm.target = "_new";
	hdnForm.action = sPage;
	for (i = 0; i < arKeys.length; i++)
	{
		oTmp = document.createElement("INPUT");
		oTmp.type = "hidden";
		oTmp.name = arKeys[i];
		oTmp.value = arValues[i];
		hdnForm.appendChild(oTmp);
	}
	hdnForm.submit();
}

function Framework__PopupShow()
{
	var oSrcElement = event.srcElement;
	if (oSrcElement == null || oSrcElement.Popup == null)
		return;
	var oPopup = document.all(oSrcElement.Popup);
	if (oPopup == null)
		return;
	oPopup.style.left = new Number(event.x) - new Number(event.offsetX) - new Number(document.all("Master_" + oSrcElement.Popup).offsetWidth) - 6;
	oPopup.className = "PopupVisible";
	oPopup.focus();
}

function Framework__PopupBlur()
{
	var oSrcElement = event.srcElement;
	var status = document.all("hdnPopupStatus");
	if (status.value != "over")
		oSrcElement.className="PopupInvisible";
}

function Framework__PopupMouseOut()
{
	var status = document.all("hdnPopupStatus");
	status.value = "out";
}

function Framework__PopupMouseOver()
{
	var status = document.all("hdnPopupStatus");
	status.value = "over";
}