function changeImage(sImage, sPath){
	document.images[sImage].src = sPath;
}

function showLayer(sLayer){
	document.getElementById(sLayer).style.display = 'inline';
}

function hideLayer(sLayer){
	document.getElementById(sLayer).style.display = 'none';
}

function setCookie(sKey, sValue) {
	if(document.getElementById("saveMySelections").checked){
		var dExpiration = new Date;
		dExpiration.setMonth(dExpiration.getMonth() + 3);
		document.cookie = sKey + '=' + sValue + ';expires=' + dExpiration.toGMTString();
	}
	else{
		document.cookie = sKey + '=' + sValue;
	}
	
}

function getCookie(sKey) {
	var sValue = '';

	var oCookie = '' + document.cookie;
	var iIndex1 = oCookie.indexOf(sKey + '=');
	
	if (iIndex1 == -1 || sKey == '') 
	 	return sValue; 
	
	var iIndex2 = oCookie.indexOf(';', iIndex1);
	 
	if (iIndex2 == -1) 
	 	iIndex2 = oCookie.length; 
	 	
	sValue = unescape(oCookie.substring(iIndex1 + sKey.length + 1, iIndex2));
	
	if(sValue == ';')
		sValue = '';
	
	return sValue;
}

function deleteCookie(sKey){
	var dExpiration = new Date;
	dExpiration.setMonth(dExpiration.getDate() - 1);
	document.cookie = sKey + '=;expires=' + dExpiration.toGMTString();
}

function getQueryString(sKey){
	var sValue = '';
	
	lsQueryString = location.search.substring(1, location.search.length);

	if(lsQueryString == 0) 
		return;

	lsQueryString = lsQueryString.replace(/\+/g, ' ');
	var laArgs = lsQueryString.split('&');
	
	for (var x = 0; x < laArgs.length; x++) {
		var laKeyValuePair = laArgs[x].split('=');
		var lsKey = unescape(laKeyValuePair[0])
		
		if (lsKey == sKey){
			if (laKeyValuePair.length == 2)
				sValue = unescape(laKeyValuePair[1])
		}
	}
	
	return sValue;
}

// Returns Item in collection based on String Id
function getObjectFromArray(oArray, sId){
	var i;
	for( i in oArray){
		if (oArray[i].Id == sId)
			return oArray[i];
	}
}

// Returns Item in collection based on String Id
function getObjectIndexFromArray(oArray, sId){
	var i;
	for( i in oArray){
		if (oArray[i].Id == sId)
			return i;
	}
}

//////////////////////////////////////////////////
// Functions to expire legacy cookies
//////////////////////////////////////////////////
function expireLegacyCookies() {
	if (cookieExists("productIndex")) {
		expireCookie("productIndex");
		expireCookie("regionIndex");
		expireCookie("industryIndex");
		// Clears out new cookies in case user saved with legacy cookies in cache
		expireCookie('region');
		expireCookie('product');
		expireCookie('industry');
		expireCookie('saveToolSettings');
	}
}
function cookieExists(sKey){
	var oCookie = '' + document.cookie;
	var iIndex = oCookie.indexOf(sKey + '=');
	
	if (iIndex == -1 || sKey == '')
		return false;
	else
		return true;
}
function expireCookie(sKey){
	var dExpiration = new Date;
        dExpiration.setTime(dExpiration.getTime()+( -1 *24*60*60*1000)); //set back in time 1 day

	document.cookie = sKey + '=;expires=' + dExpiration.toGMTString();
}
//////////////////////////////////////////////////


/*****************************************************************************
	Copyright (c) 2000, Derek Petillo
	All rights reserved.

	Redistribution and use in source and binary forms, with or without 
	modification, are permitted provided that the following conditions are
	met:

	Redistributions of source code must retain the above copyright notice,
	this list of conditions and the following disclaimer. 
	
	Redistributions in binary form must reproduce the above copyright 
	notice, this list of conditions and the following disclaimer in the 
	documentation and/or other materials provided with the distribution. 
	
	Neither the name of Praxis Software nor the names of its contributors 
	may be used to endorse or promote products derived from this software 
	without specific prior written permission.
	 
	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
	IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
	TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
	PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
	OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
	LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
	OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

******************************************************************************/
function QueryString() {
	var data = [];
	this.Read = function() 
	{
		var aPairs, aTmp;
		var queryString = new String(window.location.search);
		queryString = queryString.substr(1, queryString.length); //remove "?"
		aPairs = queryString.split("&");	
		
		for (var i=0 ; i<aPairs.length; i++)
		{
			aTmp = aPairs[i].split("=");
			data[aTmp[0]] = aTmp[1];
		}
	}
	
	this.GetValue = function( key )
	{
		return data[key];
	}
	this.SetValue = function( key, value )
	{
		if (value == null)
			delete data[key];
		else 
			data[key] = value;
	}
	this.ToString = function()
	{
		var queryString = new String(""); 
		
		for (var key in data)
		{	
			if (queryString != "")
				queryString += "&"
			if (data[key])
				queryString += key + "=" + data[key];		
		}
		if (queryString.length > 0)
			return "?" + queryString;
		else
			return queryString;
	}
	this.Clear = function()
	{
		delete data;
		data = [];
	}
}
/****************************************************************************/

function getGradientTextObject(id, text){
	var oGradientText = new Object();
	oGradientText.Id = id;
	oGradientText.Text = text;
	return oGradientText;
}