function viewReport(iReportId)
{
	var strURL = "/net/Public/ViewReport.aspx?id=" + iReportId + "&username=IntAegisWS";
	openReport(strURL);
}

function viewReportMisc(iReportId, miscType)
{
	var strURL = "/net/Public/ViewReport.aspx?id=" + iReportId + "&username=IntAegisWS&misc=" + miscType;
	openReport(strURL);
}

function viewPrintableReport(strType)
{
	// get security for report
	var oSecId = document.getElementById("SecIdValue");

	if (oSecId != null)
	{
		viewPrintableReportForSecurity(strType, oSecId.value, "")
	}
}

function viewPrintableReportForSecurity(strType, strSecId, strMisc)
{
	var strURL = "";

	if (strType == "ondemandbrief")
		strURL = "/net/Public/ViewReport.aspx?id=1";

	if (strType == "ondemanddetail")
		strURL = "/net/Public/ViewReport.aspx?id=2";

	if (strType == "ondemandholst")
		strURL = "/net/Public/ViewReport.aspx?id=3";

	if (strType == "ondemandnocoverage")
		strURL = "/net/Public/ViewReport.aspx?id=4";

	if (strType == "ondemandhybriddetail")
		strURL = "/net/Public/ViewReport.aspx?id=7";

	if (strType == "ondemandhybridbrief")
		strURL = "/net/Public/ViewReport.aspx?id=8";

	if (strType == "ondemanddetailsa")
		strURL = "/net/Public/ViewReport.aspx?id=18";

	if (strType == "ondemandclient1")
		strURL = "/net/Public/ViewReport.aspx?id=19";

	if (strType == "ondemandclient2")
		strURL = "/net/Public/ViewReport.aspx?id=20";

	if (strType == "ondemandclient3")
		strURL = "/net/Public/ViewReport.aspx?id=21";

	if (strType == "ondemandclient4")
		strURL = "/net/Public/ViewReport.aspx?id=22";

	if (strType == "ondemandhybriddetailsa")
		strURL = "/net/Public/ViewReport.aspx?id=25";
		
	if (strURL != "")
	{
		if (strSecId != "")
			strURL = strURL + "&e=asx&m=" + strSecId;

		if (strMisc != "")
			strURL = strURL + "&misc=" + strMisc;

		openReport(strURL);
	}
}

function openHelp(freshurl)
{
	 HelpWin = window.open(freshurl, 'smallwindow', 'status,scrollbars,resizable,toolbar,height=550,width=600');
	 if (window.focus) {
		 HelpWin.focus();
	 }
	 if (HelpWin.opener == null)
		 HelpWin.opener = window;
	 HelpWin.opener.name = "ParentWindow";
}

function openContact()
{
	openHelp('/ASP/Help/Answer.asp?catid=1&qid=210')
}

function countChars(me, iLimit)
{
	var iChars = me.value.length;

	if ((oCounter = document.getElementById(me.name + "Count")) != null)
		oCounter.innerHTML = iChars.toString();

	if (iChars >= iLimit)
		event.returnValue = false;
}

//simple browser check
is_v4up = (parseInt(navigator.appVersion)>=4)?1:0;
is_ie = (document.all && is_v4up)?1:0;
is_ns = (document.layers && is_v4up)?1:0;

currentMenu = -1;
currentMouseX = 0
currentMouseY = 0;

//deal with cursor over layer
document.onmousemove = menu_getmousepos;
if (is_ns) document.captureEvents(Event.MOUSEMOVE);

//code for drops
function menu_showdrop(i)
{
	//hide all dropdowns first
	currentMenu = i;
	menu_hideall();

	//hide combos
	a = document.getElementsByTagName("select");
	for (j=0; j<a.length; j++)
	{
		a[j].style.visibility = "hidden";
	}

	//show dropdown
	if ((oDropdown = document.getElementById("drop" + i)) != null)
	{
		if(is_ie)
			oDropdown.style.visibility = "visible";

		if(is_ns)
			oDropdown.visibility = "show";
	}

}

function menu_hidedrop(i)
{
	if ((oDropdown = document.getElementById("drop" + i)) != null)
	{
		if (is_ie && currentMenu != i)
			oDropdown.style.visibility = "hidden";

		if (is_ns && currentMenu != i)
			oDropdown.visibility="hide";
	}
}

function menu_hideall()
{
	//show combos
	a = document.getElementsByTagName("select");
	for (j=0; j<a.length; j++)
	{
		a[j].style.visibility = "visible";
	}

	i = 0;
	do
	{
		if ((oDropdown = document.getElementById("drop" + i)) != null)
			menu_hidedrop(i);

		i++;

	} while (oDropdown != null)
}

function menu_getmousepos(e)
{
	if(is_ie){currentMouseX=event.clientX; currentMouseY=event.clientY;}
	if(is_ns){currentMouseX=e.pageX; currentMouseY=e.pageY}

	menu_checkmousepos();
}

function menu_checkmousepos()
{
	if (currentMenu > -1)
	{
		if ((oDropdown = document.getElementById("drop" + currentMenu)) != null)
		{
			if (is_ie)
			{
				x_min = oDropdown.offsetLeft;
				y_min = oDropdown.offsetTop - 20;
				x_max = x_min + oDropdown.offsetWidth;
				y_max = y_min + oDropdown.offsetHeight + 20;
			}
			if (is_ns)
			{
				x_min = oDropdown.left;
				y_min = oDropdown.top;
				x_max = x_min + oDropdown.clip.width;
				y_max = y_min + oDropdown.clip.height;
			}
		}

		if (!(currentMouseX >= x_min && currentMouseX <= x_max && currentMouseY >= y_min && currentMouseY <= y_max))
		{
			currentMenu = -1;
			menu_hideall();
		}
	}
}
