
// for all pages, perform any actions that need to occur AFTER a page has loaded:
window.onload = fn_performGlobalActions;

// browser data information:
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// site root path:
var siteRoot = "/acplc";

// navigation images:
/*var imgHome = new Image(35,21);
var imgHomeOver = new Image(35,21);
var imgProducts = new Image(63,21);
var imgProductsOver = new Image(63,21);
var imgSupport = new Image(55,21);
var imgSupportOver = new Image(55,21);
var imgCompany = new Image(60,21);
var imgCompanyOver = new Image(60,21);
var imgSolutions = new Image(69,21);
var imgSolutionsOver = new Image(69,21);

imgHome.src = siteRoot + "/Images/GUI/Home_Off.gif";
imgHomeOver.src = siteRoot + "/Images/GUI/Home_On.gif";
imgProducts.src = siteRoot + "/Images/GUI/Products_Off.gif";
imgProductsOver.src = siteRoot + "/Images/GUI/Products_On.gif";
imgSupport.src = siteRoot + "/Images/GUI/Support_Off.gif";
imgSupportOver.src = siteRoot + "/Images/GUI/Support_On.gif";
imgCompany.src = siteRoot + "/Images/GUI/Company_Off.gif";
imgCompanyOver.src = siteRoot + "/Images/GUI/Company_On.gif";
imgSolutions.src = siteRoot + "/Images/GUI/Solutions_Off.gif";
imgSolutionsOver.src = siteRoot + "/Images/GUI/Solutions_On.gif";*/

function fn_performGlobalActions ()
{
	fn_browserFixes();
}

function fn_browserFixes ()
{
	// netscape:
	if (document.layers && is_major == 4) fn_netscape4Fix();
}

function fn_netscape4Fix ()
{
	// *** PROBLEM ***
	// On versions 4 of Netscape, CSS support is rubbish, therefore a lot of gui
	// elements are all over the place - take up of this browser is miminal anyway
	// therefore not really justifying the extra work to make it compatible
	
	// *** SOLUTION ***
	// Redirect the user to another page that informs the user of the essential information
	// about the company
	window.location.href = siteRoot + "/InvalidBrowser.aspx";
}

function fn_search ()
{
	// ok, first ensure that user has entered in a search term:
	var searchRef;
	var formRef;
	
	if (document.all && !document.getElementById && !document.layers) // for ie 4:
	{
		searchRef = document.all.ucSearch_txtSearch;
		formRef = document.all.frmGlobalSearch;
	}
	else if (document.getElementById)
	{
		searchRef = document.getElementById('ucSearch_txtSearch');
		formRef = document.getElementById('frmGlobalSearch');
	}
	else return false;
	
	if (searchRef.value == "")
	{
		// empty search:
		alert("You must enter in a search term");
		return false;
	}
	
	// this search functionality is encapsulated in all webpages (ie, could be in any directory) so need
	// to point to the search page using the root location:
	formRef.action = siteRoot + "/Search.aspx";
	formRef.submit();
}

function fn_webCallback (cur_url)
{
	// obtain a ref to a new window:
	var ref = window.open(siteRoot + "/Products/Armstrong/WebAgent/Setup.aspx?url=" + cur_url, "webAgent", "width=790,height=540,scrollbars=yes");
	ref.focus();
}

function fn_showGlossaryDiv (content, x)
{
	var ref;
	var footer = "<br /><br />-------------------------------------------------------------------------<br />";
	footer += "<span style=\"color:gray;\"><b>Note:</b> An in-depth description of this term can be found in the \"About\" -> \"Glossary\" section of the website</span>";
	if (document.getElementById) ref = document.getElementById('glossaryOutline');
	else if (document.all) ref = document.all.glossaryOutline;
	else return;
	
	if (ref)
	{
		ref.innerHTML = content + footer;
		ref.style.display = "block";
		//ref.style.visibility = "visible";
	}
}



function fn_track(e)
{
	// function that will track the movements of the mouse cursor. Will be
	// used when user hovers over a question icon next to a glossary term - a div will pop up
	// containing outline info on that term:
	
	if (document.getElementById)
	{
		if (!document.getElementById('glossaryOutline')) return;
		else ref = document.getElementById('glossaryOutline');
	}
	else if (document.all)
	{
		if (!document.all.glossaryOutline) return;
		else ref = document.all.glossaryOutline;
	}
	else return;
	
	var isIE4 = (document.all) ? 1 : 0;
	var x = (window.event) ? window.event.x : e.pageX;
	var y = (window.event) ? window.event.y : e.pageY;
    
    if (isIE4)
    {
		x += document.body.scrollLeft ;    
		y += document.body.scrollTop ;    
    }
    
    x += 15;
    y += 20;
    
    ref.style.top = y;
	ref.style.left = x;
}
document.onmousemove = fn_track;

function fn_hideGlossaryDiv ()
{
	// want to hide the div that popped up containing glossary term info:
	var ref;
	if (document.getElementById) ref = document.getElementById('glossaryOutline');
	else if (document.all) ref = document.all.glossaryOutline;
	else return;
	
	ref.innerHtml = "";
	ref.style.display = "none";
	//ref.style.visibility = "hidden";
}

function fn_loadRollover (menuItem, object, mode)
{
	// function fired when the user hovers over and off a
	// navigation button at the top of the gui:
	var ref = null;
	if (document.getElementById) ref = document.getElementById(object);
	else if (document.all) ref = document.all.object;
	if (mode == 'off') object.src = eval("img" + menuItem).src;
	else object.src = eval("img" + menuItem + "Over").src;
}

function fn_printView (url)
{
	// need to load the current page into a brand new
	// one and strip out the content at certain points
	// and ONLY display that content - ie, no menu, breadcrumb etc
	var printPage = siteRoot + "/PrintView.aspx?url=";
	var name = "printview";
	var features = "width=800,height=600,scrollbars=yes,resizable=yes";

	var ref = window.open(printPage + url, name, features);
	// bring it up to front:
	ref.focus();
}

function fn_printPage ()
{
	window.print();
}

function fn_statusBarMsg (text)
{
	window.status = text;
	return true;
}