/*
	Copyright David Trewern Design         :: www.dtdesign.com ::
	Unauthorised modification / use is a criminal offence, and
	will be prosecuted to the fullest extent permitted by law.
	All Rights Reserved
*/

/*NAVarr = new Array("home", "about", "mem", "corp", "emp", "inv", "tool", "edu", 
				   "zhome", "zabout", "zmem", "zcorp", "zemp", "zinv", "ztool", "zsupern", 
				   "downloadnow", "downloadnow2", "ret", "contact", "email", "print", "login", 
				   "login2", "contactForm_submit", "_ctl0_go", "_ctl7_go", "go", "go2", "go3", 
				   "corporatePlanLogin_imgButton", "memberg", "employerg", "member", "employer", 
				   "submit", "compare", "yes", "no", "arf", "sta", "fin", "proceed", "restart", 
				   "buysell", "close", "view", "view2", "exit", "startwizard", "back", "display", 
				   "launch", "dont", "go3", "member3", "employer3", "findoutmore", "join", 
				   "home_join", "home_learnmore", "runreport", "getreport", "more", "enternow", 
				   "tabtools", "tabformslinks"
);
if (document.images) {
	for (var NAVitem in NAVarr) {
		 for (var NAVicount=0; NAVicount < 2; NAVicount++) {
				eval("b" + NAVarr[NAVitem] + NAVicount + " = new Image()");
				eval("b" + NAVarr[NAVitem] + NAVicount + ".src = 'assets/swap_" + NAVarr[NAVitem] + "_" + NAVicount + ".gif'");
		 }
	}
}*/


function BturnOnInput(imageName) {
	if (document.getElementById(imageName)) { document.getElementById(imageName).src = eval("b" +imageName + "1.src");   }
}
function BturnOffInput(imageName) {
	if (document.getElementById(imageName)) { document.getElementById(imageName).src = eval("b" + imageName + "0.src");   }
}

//state: '1' is ON, '0' is OFF
function Btoggle(obj,imageName, state)
{
	if (obj.src)
	{
		if (state == '1')
		{
			obj.src = eval("b" + imageName + "1.src");
		}
		else
		{
			obj.src = eval("b" + imageName + "0.src");
		}
	}
}

function BturnOnImageButton(obj,imageName) {
	if (obj.src) {
		obj.src = eval("b" + imageName + "1.src");
	}
}

function BturnOffImageButton(obj,imageName) {
	if (obj.src) {
		obj.src = eval("b" + imageName + "0.src");
	}
}


function BturnOn(imageName) {

	if (imageName == "launch1" || imageName == "launch2" || imageName == "launch3" || imageName == "launch4")
	{
		if (document.images) { document [imageName].src = eval("b" + "launch" + "1.src");   }
	}
	else if (imageName == "display1" || imageName == "display2" || imageName == "display3" || imageName == "display4")
	{
		if (document.images) { document [imageName].src = eval("b" + "display" + "1.src");   }
	}
	else
	{
		if (document.images) { document [imageName].src = eval("b" + imageName + "1.src");   }
	}
}

function BturnOff(imageName) {

	if (imageName == "launch1" || imageName == "launch2" || imageName == "launch3" || imageName == "launch4")
	{
		if (document.images) { document [imageName].src = eval("b" + "launch" + "0.src");   }
	}
	else if (imageName == "display1" || imageName == "display2" || imageName == "display3" || imageName == "display4")
	{
		if (document.images) { document [imageName].src = eval("b" + "display" + "0.src");   }
	}
	else
	{
		if (document.images) { document [imageName].src = eval("b" + imageName + "0.src");   }
	}
}


function imgPopup(path) {
	if (path) {
		window.open("utils_imagepopup.aspx?path=" + path, "popup", "width=400, height=300, toolbar=no, status=no, scrollbars=yes, resizable=yes");
	}
}

function popWin(path) {
	if (path) {
		window.open(path, "popup", "width=450, height=400, toolbar=no, status=no, scrollbars=yes, resizable=yes");
		return false;
	}
}

function launchAppForm(path) {
	if (path) {
		window.open(path, "popup", "width=800, height=700, toolbar=no, status=no, scrollbars=yes, resizable=yes");
		return false;
	}
}

function launchASX(path) {
	if (path) {
		window.open(path, "ASX200", "width=790, height=550, toolbar=no, status=no, scrollbars=yes, resizable=yes");
	}
}


function launchCalculator() {
	if(document.getElementById("calculatorDropdown"))
	{
	if(document.getElementById("calculatorDropdown").value != 0)
	{
		var path = document.getElementById("calculatorDropdown").value;
		window.open(path, "ASX200", "width=790, height=550, toolbar=no, status=no, scrollbars=yes, resizable=yes");
		}
	}
}

function launchASXPDF(path) {
	if (path) {
		window.open(path, "ASX200PDF", "width=790, height=600, toolbar=no, status=no, scrollbars=yes, resizable=yes");
	}
}


function whichTarget(path) {

	if (path.substring(4,0) == "http")
	{
		window.open(path, "");
	}
	else
	{
		self.location = path;
	}

}

function toTop() {
        self.scrollTo(0, 0)
}

function casualsDisplay(displayElement) {
	if (displayElement == 'hide') {
		document.getElementById("casualBasis").style.display = 'none';
	} else {
		document.getElementById("casualBasis").style.display = 'block';
	}
}

function defaultFundsTable(displayElement) {
	if (displayElement == 'init') {
			hideAllDefaultFunds();
	} else {
		hideAllDefaultFunds();

		var numToShow = parseInt(displayElement);

		for (i=1; i<numToShow+1; i++) {
			eval(document.getElementById("defaultFund" + i)).style.display = 'block';
		}
	}

}

function hideAllDefaultFunds() {
		document.getElementById("defaultFund1").style.display = 'none';
		document.getElementById("defaultFund2").style.display = 'none';
		document.getElementById("defaultFund3").style.display = 'none';
		document.getElementById("defaultFund4").style.display = 'none';
}



function ddRedirect(dd) {
	if (dd.options[dd.selectedIndex].value != "") self.location = dd.options[dd.selectedIndex].value;
}
function ddRedirectGo(dd) {
	if (dd.options[dd.selectedIndex].value != "") window.open(dd.options[dd.selectedIndex].value, "");
}

function showTip(obj, text) {
	document.getElementById(obj).innerHTML=text;
}
function hideTip(obj) {
	document.getElementById(obj).innerHTML='&nbsp;';
}

function printPage() {

  if(window.print) {
   	window.print();
   } else {
	if(agt.indexOf("mac") != -1) {
		alert("To print this page press Command-P.");
	} else {
		alert("To print this page press Control-P.");
	}
   }

}




function show_style_switcher() {
	document.write('<a href="#" onclick="setActiveStyleSheet(' + "'large'" + '); return false;">+ Larger Font</a></li>');
	document.write('<li style="border:none;"><a href="#" onclick="setActiveStyleSheet(' + "''" + '); return false;">- Smaller Font</a>');
}

/* Sourced from http://www.alistapart.com/stories/alternate/ */

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  initGlossary();
  scrollHere();
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}


function targetAnchor()
{
	var loc = new String(document.forms[1].action);

	if(loc.indexOf("#formResp") < 0)
	{

		document.forms[1].action = loc + "#formResp";
	}
}


function hideAllFields()
{
	 for(i=1; i<12; i++)
	 {
		document.getElementById('language' + i).style.display = 'none';
		document.getElementById('hide' + i).style.display = 'none';

	 }
}


function displayThis(id)
{

		document.getElementById('language' + id).style.display = 'block';
		document.getElementById('show' + id).style.display = 'none';
		document.getElementById('hide' + id).style.display = 'inline';


}


function hideThis(id)
{
	document.getElementById('language' + id).style.display = 'none';
	document.getElementById('show' + id).style.display = 'inline';
	document.getElementById('hide' + id).style.display = 'none';
}


function hideAllFields2(name, count)
{
	for (i = 0; i < count; i++)
	{
		document.getElementById(name + i).style.display = 'none';
		document.getElementById('icon-hide' + i).style.display = 'none';
		document.getElementById('text-hide' + i).style.display = 'none';
	}
}


function displayThis2(name, id)
{
	document.getElementById(name + id).style.display = 'block';

	document.getElementById('icon-show' + id).style.display = 'none';
	document.getElementById('icon-hide' + id).style.display = 'inline';

	document.getElementById('text-show' + id).style.display = 'none';
	document.getElementById('text-hide' + id).style.display = 'inline';
}


function hideThis2(name, id)
{
	document.getElementById(name + id).style.display = 'none';

	document.getElementById('icon-show' + id).style.display = 'inline';
	document.getElementById('icon-hide' + id).style.display = 'none';

	document.getElementById('text-show' + id).style.display = 'inline';
	document.getElementById('text-hide' + id).style.display = 'none';
}

/* Tools & Forms page tab switcher */
function TabSwitcher(button)
{
	var tabs = document.getElementById("tabs").getElementsByTagName("img");
	var contentItems = document.getElementById("tabcontent").getElementsByTagName("div");
	
	if(button == "tools")
	{
		BturnOn("tabtools");
		BturnOff("tabformslinks");
		for (i=0; i<contentItems.length; i++)
		{
			if (contentItems[i].className.indexOf("curved_box03") != -1)
			{
				contentItems[i].className = "curved_box03 visibletabcontent";
			}
		}
		document.getElementById("formspublications").style.display = "none";
		document.getElementById("mostpopularlinks").style.display = "none";
	} else if (button == "formslinks")
	{
		BturnOn("tabformslinks");
		BturnOff("tabtools");
		for (i=0; i<contentItems.length; i++)
		{
			if (contentItems[i].className.indexOf("curved_box03") != -1)
			{
				contentItems[i].className = "curved_box03 hiddentabcontent";
			}
		}
		document.getElementById("faqs").style.display = "block";
		document.getElementById("formspublications").style.display = "block";
		document.getElementById("mostpopularlinks").style.display = "block";
	}
}

// Maintain scroll position on reload
function maintainScroll()
{
	var scrollPosition = 0;
	if(typeof(window.pageYOffset) == "number")
	{
		scrollPosition = window.pageYOffset;
	} else {
		scrollPosition = document.documentElement.scrollTop;
	}
	createCookie("scrollY", scrollPosition);
}

function scrollHere()
{
	if(readCookie("scrollY"))
	{
		var scrollValue = readCookie("scrollY");
		window.scroll(0,scrollValue);
	}
}


/* Client-side access to querystring name=value pairs
	Version 1.3
	28 May 2008
	
	License (Simplified BSD):
	http://adamv.com/dev/javascript/qslicense.txt
	
	http://adamv.com/dev/javascript/querystring
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}


/* Investment Choice (InvestmentOptionResults.ascx) Tab switcher */

function show_1invest()
{
	document.getElementById("invch_tabs_1invest").style.display = "block";
	document.getElementById("invch_1invest").style.display = "block";
	document.getElementById("invch_tabs_2fytd").style.display = "none";
	document.getElementById("invch_2fytd").style.display = "none";
	document.getElementById("invch_tabs_3month").style.display = "none";
	document.getElementById("invch_3month").style.display = "none";
}

function show_2fytd()
{
	document.getElementById("invch_tabs_1invest").style.display = "none";
	document.getElementById("invch_1invest").style.display = "none";
	document.getElementById("invch_tabs_2fytd").style.display = "block";
	document.getElementById("invch_2fytd").style.display = "block";
	document.getElementById("invch_tabs_3month").style.display = "none";
	document.getElementById("invch_3month").style.display = "none";
}

function show_3month()
{
	document.getElementById("invch_tabs_1invest").style.display = "none";
	document.getElementById("invch_1invest").style.display = "none";
	document.getElementById("invch_tabs_2fytd").style.display = "none";
	document.getElementById("invch_2fytd").style.display = "none";
	document.getElementById("invch_tabs_3month").style.display = "block";
	document.getElementById("invch_3month").style.display = "block";
}

function LoadInvChTabs()
{
	document.getElementById("invch_tabs").style.display = "block";
	
	document.getElementById("invch_content").className = "invch_content_applied";
	
	var qs_i = new Querystring()
	var load_invch_tab = qs_i.get("load_invch_tab", "1")
	if (load_invch_tab == "2")
	{
		show_2fytd();
	}
	else if (load_invch_tab == "3")
	{
		show_3month();
	}
	else 
	{
		show_1invest();
	}
	
	var areaContainer = document.getElementById("invch_content");
	var areaHeadings = areaContainer.getElementsByTagName("h4");
	for (var areaHeadingsIndex = 0; areaHeadingsIndex < areaHeadings.length; areaHeadingsIndex++)
	{
		areaHeadings[areaHeadingsIndex].style.display = "none";
	}

}


//*** Start Glossary Parsing
function chk(obj,val,showhtmltext)
{

	var resultArray = new Array();

	for(var property in obj)
	{
		if(val)
		{
			if(val == property)
			{
				checkIfFunction(resultArray, property, obj);
			}
		}
		else
		{
			if(showhtmltext)
			{
				checkIfFunction(resultArray, property, obj);
			}
			else
			{
				if(property != 'innerHTML' && property != 'innerText' && property != 'outerHTML' && property != 'outerText')
					checkIfFunction(resultArray, property, obj);
			}
		}

	 }
	resultArray.sort();
	var message = new String(resultArray);
	alert(message.replace(/,/g,', '));
}

document.onclick = doGOff;

function checkIfFunction(array, property, object)
{
	if(object[property])
	{
		var theValue = new String(object[property]);

		//alert(theValue);

		if(theValue.indexOf("function") < 0)
		//if(theValue.substring(1,9) != 'function')
			array.push(property + ' = ' + theValue);
	}
}


var gLinks = new Array();
var glossaryText = new Array();
var glossaryCount = 0;

var gLoadingComplete = false;

var bVersion = 0;
var bBrowser = null;
var bPlatform = null;


function checkBrowser()
{

	//bVersion = parseInt(navigator.appVersion);
	
	//bBrowser = (navigator.userAgent.indexOf("MSIE") > -1) ? "IE" : "Other";
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		bBrowser = "IE";
		temp = navigator.appVersion.split("MSIE")
		bVersion = parseFloat(temp[1]);
		
	}
	else
	{
		bBrowser = "Other";
	}
		
	if(bBrowser != "IE")
	{
		bBrowser = (navigator.userAgent.indexOf("Netscape") > -1) ? "Netscape" : "FireFox";
	}

	if(navigator.userAgent.indexOf("Opera") > -1)
		bBrowser = "Opera";

	if(navigator.userAgent.indexOf("Safari") > -1)
		bBrowser = "Safari";

	bPlatform = (navigator.userAgent.indexOf("Mac") > -1) ? "Mac" : "PC";

	
}

function doGOff(e)
{


		if(document.getElementById("glossaryTarget"))
		{
			var target = document.getElementById("glossaryTarget");
			target.style.display = "none";
		}
}

var obj = null;


function doGOver(e)
{

	if(gLoadingComplete)
	{

		var ev;

		//if(document.all)
		if (bBrowser == "IE")
		{
			ev = window.event;
			obj  = ev.srcElement;
		}
		else
		{
			ev = e;
			obj  = e.currentTarget;
		}

		var target = document.getElementById("glossaryTarget");
				
		target.style.display = "inline";

		if(glossaryText[obj.gid] == "undefined" || glossaryText[obj.gid] == null)
		{
			target.style.display = "none";
			return;
		}

		document.getElementById("definition").innerHTML = glossaryText[obj.gid];

		var height = document.getElementById("definition").offsetHeight;
		var width2 = document.getElementById("definition").offsetWidth;

		var offest = 0;
		target.style.left = (obj.offsetLeft + offest - 30) + "px";
		
		//if(document.all)
		if (bBrowser == "IE")
		{
			target.style.position = "fixed";
			
			//IE6 fix
			if (bVersion == 6)
			{
				var HtmlScrollTop = $("html").scrollTop();
				var HtmlScrollLeft = $("html").scrollLeft();
				target.style.position = "absolute";
				target.style.pixelTop = (ev.clientY+HtmlScrollTop-height) - 37;
			}
			else
			{
				target.style.pixelTop = (ev.clientY-height) - 37;
			}
			target.style.left = (ev.clientX+HtmlScrollLeft-width2) + 191;
			
		}
		else
		{
			target.style.top = (ev.pageY-height) - 37 + "px";
			//target.style.left = (obj.offsetLeft + offest - 30) + "px";
			target.style.left = (ev.pageX-width2) + 192 + "px";
		}

	}
}


function initGlossary()
{
  checkBrowser();

	if(bBrowser == "IE" && bPlatform == "Mac" || (document.layers))
	{
		return;
	}

				for(i=0;i<document.links.length;i++)
				{
					// if this is a glossary link
					if(String(document.links[i].href).indexOf("toolsandforms_glossary.aspx?g") > -1)
					{
						//set mouseover
						document.links[i].onmouseover = doGOver;
						document.links[i].onmouseout = function(){doGOff()};

						//Set glossary link style
						document.links[i].className = "g";


						// split href.search param on constant delimeter
						var str = unescape(document.links[i].search).split("?g=");
						
						strFixed = str[1];
						
						while (strFixed.indexOf("&") != -1)
						{
							strFixed = strFixed.replace("&", "%26");
						}
						
						//load the glossary title into the glossary array
						gLinks.push(strFixed);

						//set expando/custom property "gid" which is the title of the glossary item
						//so we can access the right glossary item for each link.
						document.links[i].gid = str[1];

						glossaryCount ++;
					}
				}
				 buildQuery()


}


function buildQuery()
{
	var str = new String();

	// loop through glossary array and delimit with ####
	for(i=0;i<gLinks.length;i++)
	{
		str += gLinks[i];
		if(i < gLinks.length-1)
		str += "####";
	}
	
	if(str.length > 0){

		// this will be a Form item called "q" in the ajax request
		str = "q=" + str;

		//call server with supplied callback function and params
		http( "POST", "glossary.ashx" , parseResponse,str);
		
	}
	
}


function parseResponse(result)
{
	/*
		The text from the server contains the glossary title and glossary content
		Glossary items are delimited by $$$$
		Each glossary items is then delimited by ####
	*/



	var returnedText = result.split("$$$$");
	var gText;

	for(i=0;i<returnedText.length;i++)
	{
		gText = returnedText[i].split("####");
		//set associative array key to be title of glossary
		//set associative array value to be content of glossary
		glossaryText[gText[0]] = gText[1];
	}
	gLoadingComplete = true;

}

//*** end glossary items parsing



//**** Start engine.js code
/* --------------------------------------------------------------------------------------------------------------
*	API:			JSMX (JavaScript MX) - Universal Ajax API for ColdFusion, PHP, .NET, or anything other language.
*	AUTHOR: 		Todd Kingham [todd@lalabird.com] with contributions by Jan Jannek [jan.jannek@Cetecom.de]
*	CREATED:		8.21.2005
*	VERSION:		2.6.1
*	DESCRIPTION:	This API uses XMLHttpRequest to post/get data from a ColdFusion interface.
*					The CFC's/CFM's will return a string representation of a JS variable: response_param.
*					The "onreadystatechange event handler" will eval() the string into a JS variable
*					and pass the value back to the "return function". To Download a full copy of the sample
*					application visit: http://www.lalabird.com/JSMX/?fa=JSMX.downloads
*
*	HISTORY:		2.0.0:	Todd: Scripted Out Original Version
*					2.1.0:	Todd: Modified for Download
*					2.2.0:	Todd: Modified the firstWord() function to be backward compatable with
*								  CF5 and to be more stable all-around.
*					2.3.0:	Todd: Added "wait div" functionality
*					2.4.0:	Todd: XML!!!! Now JSMX will allow you to pass XML Documents to the API in
*								  addition to the original JavaScript method.
*					2.4.1:	Jan:  2006-02-16, XMLHTTP requests can now handle more than one request at once. By placing the onreadystatechange event as a local variable inside the actual http() function.
*							Jan:  Added fix for strange IE bug that returned Header Info.
*							Todd: Added the jsmx object to allow users to override defaults and set custom "async", "wait" and "error" methods
*					2.5.0:	Todd: Added JSON Support! So now you can pass JavaScript, XML, or JSON.
*					2.5.1:	Todd: Version 2.5.0 was premature. Needed to fix an eval() bug when I introduced JSON.
*					2.5.2:	Todd: Fixed a bug in the onreadystatechange. Based on the order you call the event handler... "State Change 1" gets called twice. Added code to only process code inside 'CASE 1:' once
*					2.5.3:	Todd: Fixed a bug in the try/catch of the parser by placing the callback() call within the try/catch statement. This caused errors in the callback function to be "masked" and appear as "parsing errors", even when the parse was successful.
*					2.6.0: 	Todd: Added WDDX Parser! Now you can return WDDX Strings as well.
					2.6.1:	Todd: Streamlined the ClassicMode and JSON parser into one function.
*
*	LICENSE:		THIS IS AN OPEN SOURCE API. YOU ARE FREE TO USE THIS API IN ANY APPLICATION,
*               	TO COPY IT OR MODIFY THE FUNCTIONS FOR YOUR OWN NEEDS, AS LONG THIS HEADER INFORMATION
*              	 	REMAINS IN TACT AND YOU DON'T CHARGE ANY MONEY FOR IT. USE THIS API AT YOUR OWN
*               	RISK. NO WARRANTY IS EXPRESSED OR IMPLIED, AND NO LIABILITY ASSUMED FOR THE RESULT OF
*               	USING THIS API.
*
*               	THIS API IS LICENSED UNDER THE CREATIVE COMMONS ATTRIBUTION-SHAREALIKE LICENSE.
*               	FOR THE FULL LICENSE TEXT PLEASE VISIT: http://creativecommons.org/licenses/by-sa/2.5/
*
-----------------------------------------------------------------------------------------------------------------*/
// UNCOMMENT THE FOLLOWING LINE IF YOU WILL BE RETURNING QUERY OBJECTS. (note: you may need to point the SRC to an alternate location.
/*document.writeln('<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="/CFIDE/scripts/wddx.js"></SCRIPT >');*/

var jsmx = new jsmxConstructor();
function jsmxConstructor(){
	this.isJSMX = true;
	this.async = true;
	this.debug = false;
	this.waitDiv = 'JSMX_loading';
	this.http = http;
	this.onWait = _popWait;
	this.onWaitEnd = _killWait;
	this.onError = _onError;
}
// perform the XMLHttpRequest();
function http(verb,url,cb,q) {
	var self = (this.isJSMX) ? this : jsmx ;
	//reference our arguments
	var qryStr = (!q) ? '' : _toQueryString(q);
	var calledOnce = false; //this is to prevent a bug in onreadystatechange... "state 1" gets called twice.
	try{//this should work for most modern browsers excluding: IE Mac
		var xhr = ( window.XMLHttpRequest ) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ;
			xhr.onreadystatechange = function(){
				switch(xhr.readyState){
					case 1:
						if(!calledOnce){
							self.onWait(self.waitDiv);
							calledOnce = true;
						} 	break;
					case 2: break;
					case 3: break;
					case 4:
						self.onWaitEnd(self.waitDiv);
						if ( xhr.status == 200 ){// only if "OK"
							var success = true;
							try{
								var rObj = _parseResponse( xhr );
							}catch(e){
;
								self.onError(xhr,self,1);
								success = false;
							}
							if(success){ cb( rObj ); }
						}else{

							self.onError(xhr,self,2);
						}
					delete xhr.onreadystatechange; //clean this function from memory once we re done with it.
					break;
				}
			};
			xhr.open( verb , _noCache(url) , self.async );
			if(verb.toLowerCase() == 'post') { xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); }
			xhr.send(qryStr);
	}catch(e){
		self.onError(xhr,self,3);
	}
}

/*--- BEGIN: RESPONSE PARSING FUNCTIONS ---*/
function _parseResponse($$){

	var str = _cleanString($$.responseText);
	return str;
	/*

	 var xml = $$.responseXML;
	//FIRST TRY IT AS XML
		if(xml != null && xml.childNodes.length){ return xml; }
	//NEXT TRY IT AS WDDX
		if(str.indexOf("<wddxPacket") == 0){ return _parseWDDX(str); }
	//NEXT TRY IT AS JSON
		try{ return eval('('+str+')'); }
	//NEXT TRY IT AS JavaScript
		catch(e){ return _parseJS(str); }
	*/
}
// jan.jannek@cetecom.de, 2006-02-16, weird error: some IEs show the responseText followed by the complete response (header and body again)
function _cleanString(str){
	//Left Trim
	var rex = /\S/i;
	str = str.substring(str.search(rex),str.length);

	var i = str.indexOf("HTTP/1");
	if (i > -1) {
		str = str.substring(i, str.length);
		i = str.indexOf(String.fromCharCode(13, 10, 13, 10));
		if (i > -1) { str = str.substring(i + 2, str.length); }
	}
	return str;
}
function _parseJS(str){
	eval(str);
	var r = eval(str.split('=')[0].replace(/\s/g,''));
	return r;
}
function _parseWDDX(str){ var wddx = xmlStr2Doc(str); var data = wddx.getElementsByTagName("data"); return _parseWDDXnode(data[0].firstChild); } function xmlStr2Doc(str){ var xml; if(typeof(DOMParser) == 'undefined'){ xml=new ActiveXObject("Microsoft.XMLDOM"); xml.async="false"; xml.loadXML(str); }else{ var domParser = new DOMParser(); xml = domParser.parseFromString(str, 'application/xml'); } return xml; } function _parseWDDXnode(n){ var val; switch(n.tagName){ case 'string': val = _parseWDDXstring(n); break; case 'number': val = parseInt(n.firstChild.data); break; case 'boolean': val = n.getAttribute('value'); break; case 'dateTime': val = Date(n.firstChild.data); break; case 'array': val = _parseWDDXarray(n); break; case 'struct': val = _parseWDDXstruct(n); break; case 'recordset': val = _parseWDDXrecordset(n); break; case 'binary': val = n.firstChild.data; break; case 'char': val = _parseWDDXchar(n);; break; case 'null': val = ''; break; default: val = n.tagName; break; } return val; } function _parseWDDXstring(node){ var items = node.childNodes; var str = ''; for(var x=0;x < items.length;x++){ if(typeof(items[x].data) != 'undefined') str += items[x].data; else str += _parseWDDXnode(items[x]); } return str; } function _parseWDDXchar(node){ switch(node.getAttribute('code')){ case '0d': return '\r'; case '0c': return '\f'; case '0a': return '\n'; case '09': return '\t'; } } function _parseWDDXarray(node){ var items = node.childNodes; var arr = new Array(); for(var i=0;i < items.length;i++){ arr[i] = _parseWDDXnode(items[i]); } return arr; } function _parseWDDXstruct(node){ var items = node.childNodes; var obj = new Object(); for(var i=0;i < items.length;i++){ obj[items[i].getAttribute('name').toLowerCase()] = _parseWDDXnode(items[i].childNodes[0]); } return obj; } function _parseWDDXrecordset(node){ var qry = new Object(); var fields = node.getElementsByTagName("field"); var items; var dataType; var values; for(var x = 0; x < fields.length; x++){ items = fields[x].childNodes; values = new Array(); for(var i = 0; i < items.length; i++){ values[values.length] = _parseWDDXnode(items[i]); } qry[fields[x].getAttribute('name').toLowerCase()] = values; } return qry; }
/*--- END: RESPONSE PARSING FUNCTIONS ---*/


/*--- BEGIN: REQUEST PARAMETER FUNCTIONS ---*/
	function _toQueryString(obj){
		//determine the variable type
		if(typeof(obj) == 'string') { return obj; }
		if(typeof(obj) == 'object'){
			if(typeof obj.elements == 'undefined') {return _object2queryString(obj); }//It's an Object()!
			else{ return _form2queryString(obj); }//It's a form!
		}
	}
	function _object2queryString(obj){
		var ar = new Array();
		for(x in obj){ ar[ar.length] = x+'='+obj[x]; }
		return ar.join('&');
	}
	function _form2queryString(form){
		var obj = new Object();
		var ar = new Array();
		for(var i=0;i < form.elements.length;i++){
			try {
				elm = form.elements[i];
				nm = elm.name;
				if(nm != ''){
					switch(elm.type.split('-')[0]){
						case "select":
							for(var s=0;s < elm.options.length;s++){
								if(elm.options[s].selected){
									if(typeof(obj[nm]) == 'undefined'){ obj[nm] = new Array(); }
									obj[nm][obj[nm].length] = escape(elm.options[s].value);
								}
							}
							break;
						case "radio":
							if(elm.checked){
								if(typeof(obj[nm]) == 'undefined'){ obj[nm] = new Array(); }
								obj[nm][obj[nm].length] = escape(elm.value);
							}
							break;
						case "checkbox":
							if(elm.checked){
								if(typeof(obj[nm]) == 'undefined'){ obj[nm] = new Array(); }
								obj[nm][obj[nm].length] = escape(elm.value);
							}
							break;
						default:
							if(typeof(obj[nm]) == 'undefined'){ obj[nm] = new Array(); }
							obj[nm][obj[nm].length] = escape(elm.value);
							break;
					}
				}
			}catch(e){}
		}
		for(x in obj){ ar[ar.length] = x+'='+obj[x].join(','); }
	return ar.join('&');
	}
/*--- END: REQUEST PARAMETER FUNCTIONS ---*/

//IE likes to cache so we will fix it's wagon!
function _noCache(url){
	var qs = new Array();
	var arr = url.split('?');
	var scr = arr[0];
	if(arr[1]){ qs = arr[1].split('&'); }
	qs[qs.length]='noCache='+new Date().getTime();
return scr+'?'+qs.join('&');
}
function _popWait(id){
	proc = document.getElementById(id);
	if( proc == null ){
		var p = document.createElement("div");
		p.id = id;
		document.body.appendChild(p);
	}
}
function _killWait(id){
	proc = document.getElementById(id);
	if( proc != null ){ document.body.removeChild(proc); }
}
function _onError(obj,inst,errCode){
	var msg;

	//alert(obj.responseText);

	switch(errCode){
		case 1:/*parsing error*/
			msg = (inst.debug) ? obj.responseText : 'Parsing Error: The value returned could not be evaluated.';
			break;
		case 2:/*server error*/
			msg = (inst.debug) ? obj.responseText : 'There was a problem retrieving the data:\n' + obj.status+' : '+obj.statusText;
			break;
		case 3:/*browser not equiped to handle XMLHttp*/
			msg = 'Unsupported browser detected.';
			return;/*you can remove this return to send a message to the screen*/
			break;
	}
	if(inst.debug){
		var debugWin = window.open('','error');
		debugWin.document.write(msg);
		debugWin.focus();
	}else{
		alert(msg);
	}
}
/*function $(id){ return document.getElementById(id); }*/


// Funtions for Global Tabs hover states


function TabHoverOn(id) {
	document.getElementById(id).className="global-tab-active";
}

function TabHoverOff(id) {
	document.getElementById(id).className="";
}

//*** end engine.js code



// Load Movie Function (Omniture)

function loadMovie(values) {
    var title = values[0];
    var duration = values[1];

    s.prop10 = s.eVar11 = title;
    s.events = "event9";

    s.Media.trackVars = "prop10,evar11,events";
    s.Media.trackEvents = "event9";

    s.Media.open(title, duration, "Flash Player");
    s.Media.play(title, 0);
}

function stopMovie(values) {
    var title = values[0];
    var stoppedTime = values[1];

    s.prop10 = s.eVar11 = title;
    s.events = "event10";

    s.Media.trackVars = "prop10,evar11,events";
    s.Media.trackEvents = "event10";

    s.Media.stop(title, stoppedTime);
    s.Media.close(title);
}

// Download and Order Tracking (Omniture)
function trackDownload(title)
{
    s.linkTrackVars='eVar14,events'; 
    s.linkTrackEvents='event13'; 
    s.events='event13'; 
    s.eVar14=title; 
    s.tl(this,'d',title);
}


// Reveal Phone Number Function

function revealPhoneNumber(controlId, trackingId) {
    document.getElementById(controlId).style.display = 'block';
}


