imgArrowDown = new Image();
imgArrowDown.src = '/layout/images/arrow_down.gif';
imgArrowDownOn = new Image();
imgArrowDownOn.src = '/layout/images/arrows_downover.gif';

imgArrowRight = new Image();
imgArrowRight.src = '/layout/images/arrow_right.gif';
imgArrowRightOn = new Image();
imgArrowRightOn.src = '/layout/images/arrows_rightover.gif';

imgGo = new Image();
imgGo.src = '/layout/images/button_go.gif';
imgGoOn = new Image();
imgGoOn.src = '/layout/images/button_go_on.gif';
imgLogon = new Image();
imgLogon.src = '/layout/images/button_logon.gif';
imgLogonOn = new Image();
imgLogonOn.src = '/layout/images/button_logon_on.gif';

imgGoWhite = new Image();
imgGoWhite.src = '/layout/images/go_whitebkgrd.gif';
imgGoOnWhite = new Image();
imgGoOnWhite.src = '/layout/images/go_on_whitebkgrd.gif';

imgEconomicsRight = new Image();
imgEconomicsRight.src = '/layout/images/arrow_right.gif';
imgEconomicsRightOn = new Image();
imgEconomicsRightOn.src = '/layout/images/arrows_rightover.gif';


var t;

function ClearText(textbox)
{
	if (textbox.value == "Search")
	{
		textbox.value = "";
	}
}

function searchWatermark(textbox)
{
    if (textbox.value == "")
        textbox.value = "Search";
}

function ShowHideDiv(divName, altDivName, imageName, altImageName, forceOpen)
{
	var oDiv = document.getElementById(divName);
	var oAltDiv = document.getElementById(altDivName);
	
	if (navigator.userAgent.toLowerCase().indexOf("netscape") > 0 )
	{
		var versionInfo = navigator.userAgent.split("/");
		if (versionInfo.length > 0)
		{
			if (versionInfo[versionInfo.length - 1] < 8.0)
			{
				return false;
			}
		}
	}
	if (oDiv != null)
	{
		if (oDiv.style.visibility == "hidden" || forceOpen)
		{
			oDiv.style.visibility = "visible";
			oDiv.style.display = "inline";
			SwitchArrowImage(imageName, false);
			
			if (oAltDiv != null)
			{
				oAltDiv.style.visibility = "hidden";
				oAltDiv.style.display = "none";
				SwitchArrowImage(altImageName, true);
			}
		}
		else
		{
			oDiv.style.visibility = "hidden";
			oDiv.style.display = "none";
			SwitchArrowImage(imageName, true);
		}
	}
	
	return false;
}

function SwitchArrowImage(imageName, isDown)
{
	var oImg = document.getElementById(imageName);
	
	if (oImg != null)
	{
		if (isDown)
		{
			oImg.src = imgArrowRight.src;
		}
		else
		{
			oImg.src = imgArrowDown.src;
		}
	}
}

function ChangeImage(img, isOut)
{
	//if (isOut)
	//{
		if (img.src == imgArrowDownOn.src)
		{
			img.src = imgArrowDown.src;
		}
		else if (img.src == imgArrowRightOn.src)
		{
			img.src = imgArrowRight.src;
		}
	//}
	//else
	//{
		else if (img.src == imgArrowDown.src)
		{
			img.src = imgArrowDownOn.src;
		}
		else if (img.src == imgArrowRight.src)
		{
			img.src = imgArrowRightOn.src;
		}
	//}
//	if (img.src = imgArrowDown.src)
//	{
//		img.src = imgArrowDownOn.src
//	}
//	else if (img.src = imgArrowRight.src)
//	{
//		img.src = imgArrowRightOn.src
//	}
}

function Highlight(currentLink, statLink)
{
	currentLink.style.backgroundColor = "#e6e6e6";
	var oLink = document.getElementById(statLink);
	oLink.style.color = "#006600";
}

function UnHighlight(currentLink, statLink)
{
	currentLink.style.backgroundColor = "#FFFFFF";
	var oLink = document.getElementById(statLink);
	oLink.style.color = "#000000";
}

function ShowMenu (menuItem, tableCell)
{
	var oDiv = document.getElementById(menuItem);
	if (oDiv == null || oDiv.getElementsByTagName('tr').length <= 1)
	{
		return;
	}
	var oItem = document.getElementById(tableCell);
	oDiv.style.visibility = "visible";
	oDiv.style.display = "inline";
	oDiv.style.position = "absolute";
	var oSecurityAlert = document.getElementById("ctl00$ctl00$securityalert1$hidActive");
	if (navigator.appName.toLowerCase() == "netscape")
	{
		oSecurityAlert = document.getElementById("ctl00_ctl00_securityalert1_hidActive");
		if (navigator.userAgent.toLowerCase().indexOf("apple") > 0)
		{
			oDiv.style.left = 119;
			var topHeight = oItem.offsetParent.offsetTop + oItem.offsetParent.offsetParent.offsetTop + oItem.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop + 124;
			if (oSecurityAlert != null && oSecurityAlert.value == "true")
			{
				topHeight += 24;
			}
			oDiv.style.top = topHeight;
		}
		else
		{
			// firefox and netscape
			oDiv.style.left = 121;
			var topHeight = oItem.offsetParent.offsetTop + oItem.offsetParent.offsetParent.offsetTop + oItem.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop + 131;
			if (oSecurityAlert != null && oSecurityAlert.value == "true")
			{
				topHeight += 24;
			}
			oDiv.style.top = topHeight;
		}
	}
	else
	{
		// various versions of IE
		//alert(oSecurityAlert.value);
		oDiv.style.left = 119;
		var topHeight = oItem.offsetParent.offsetTop + oItem.offsetParent.offsetParent.offsetTop + oItem.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop + 133;
		if (oSecurityAlert != null && oSecurityAlert.value == "true")
		{
			topHeight += 21;
		}
		oDiv.style.top = topHeight;
	}
}

function HideMenu (menuItem)
{
	//t = setTimeout("VanishMenu('" + menuItem + "')", 600);
	VanishMenu(menuItem);
}

function VanishMenu(menuItem)
{	
	var oDiv = document.getElementById(menuItem);
	if (oDiv != null)
	{
		oDiv.style.visibility = "hidden";
		oDiv.style.display = "none";
	}
}

function Clear()
{
	clearTimeout(t);
}

function LinkAlert() 
{
	var name = confirm('Please note: by clicking on any of the links below you will be leaving the National Bank Internet site and going to a site provided by another party. The National Bank is not responsible for any loss or damage suffered by you as a result of use of or reliance on the information provided on that third partys site. Do you wish to continue?');
	
	if(name)
	{
		return true;
	}
	else
	{
		return false;
	}
}


function OpenNewDemoWindow(windowUrl)
{
	window.open(windowUrl, 'nationalbank', 'resizable=0, height=500, width=700, scrollbars=1');
	return false;
}

function ShowHideDivOnPage(divName, showDiv)
{
	var oDiv = document.getElementById(divName);
	
	if (navigator.userAgent.toLowerCase().indexOf("netscape") > 0 )
	{
		var versionInfo = navigator.userAgent.split("/");
		if (versionInfo.length > 0)
		{
			if (versionInfo[versionInfo.length - 1] < 8.0)
			{
				return false;
			}
		}
	}
	if (oDiv != null)
	{
		if (showDiv)
		{
			oDiv.style.visibility = "visible";
			oDiv.style.display = "block";
		}
		else
		{
			oDiv.style.visibility = "hidden";
			oDiv.style.display = "none";
		}
	}
	
	return false;
}

			
function ConvertToNumber(numberString)
{
	if (Trim(numberString) != "")
	{
		if (isNaN(parseFloat(numberString)))
		{
			return 0;
		}
		else
		{
			return parseFloat(numberString);
		}
	}
	else
	{
		return 0;
	}
}

function Trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
