var topnav = new elcNavigation('topnav');
topnav.hasTimeout = false;
topnav.offLayer = null;

var pnav = new elcNavigation('pnav');
pnav.hasTimeout = false;
pnav.offLayer = "pNavOff";

var pgnav = new elcNavigation('pgnav');
pgnav.hasTimeout = false;
pgnav.offLayer = null;

var bottomnav = new elcNavigation('bottomnav');
bottomnav.hasTimeout = false;
bottomnav.offLayer = null;

// Left Nav
var leftnav = new elcNavigation('leftnav');
leftnav.hasTimeout = false;
leftnav.offLayer = "leftNavOff";

function smSetColors(smObj, sBgHex) {
	if (smObj && smObj.style) {
		smObj.style.backgroundColor = sBgHex;
	}
}

function goURL(sURL){
	document.location=sURL;
	return;
}

/* precache */
function cacheImg(path){
    var img = new Image();
    img.src = path;
    bcImageCache.store(path,img);
}

// Global Nav search and email field clear and replace functions

var condText;
function clearTextBoxOnCondition(textBox,conditionText){
        if(textBox.value == conditionText) {
          textBox.value="";
	  condText=conditionText;
	}
}    


function fillTextBoxOnCondition(textBox){
        if(textBox.value == "") {
          textBox.value=condText;
        }
}

function checkMaxLength (textarea, evt, maxLength) {
	if (textarea.selected && evt.shiftKey)
	// ignore shift click for select
		return true;
	var allowKey = false;
	if (textarea.selected && textarea.selectedLength > 0)
		allowKey = true;
	else {
		var keyCode = document.layers ? evt.which : evt.keyCode;
		if (keyCode < 32 && keyCode != 13)
			allowKey = true;
		else
			allowKey = textarea.value.length < maxLength;
		}
	textarea.selected = false;
	return allowKey;
}

// Pop a window
var popupWindow;
function popup(url,scrollbars,width,height,name,nav){
        name ? name : 'popup';
        nav ? nav : 0;
        popupWindow = open(url, name, 'toolbar='+nav+',location='+nav+',directories='+nav+',status='+nav+',menubars='+nav+',resizable='+nav+',scrollbars='+scrollbars+',width='+width+',height='+height+',top=20,left=20');
        if (popupWindow != null) {
                popupWindow.focus();
        }
}


// Close window
function closewindow() {
	this.window.close();
}

/* Copied from elcNavigation and head_common.tmpl */
if ((typeof wsmlMakeWebServiceHref) == "undefined")
{
  wsmlMakeWebServiceHref =
  wsmlMakeResourceHref =
  wsmlMakeResourceUrl =
  wsmlMakeLeakHref =
  wsmlMakeComponentHref =
  wsmlMakeCssHref = new Function ("u", "return u;");
}

// wsml functions are defined above
function elcSendURL( url ) {
//	printurl = wsmlMakeWebServiceHref(url);
//	alert(printurl);
	location.replace(wsmlMakeWebServiceHref(url));
}

// Rollover for Body Content
function setImg(imgName,imgObj) {
imgName.src = imgObj.src;
}

// javascript linking function
function go(mNum,mItemNum){
	var aItemProps=mProps[mNum][mItemNum],winProps="directories=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1";
	finishHide();
	if(aItemProps.pTarget=="newWin"){
		window.open(aItemProps.pUrl,"",winProps);
		return;
	}else if(aItemProps.pTarget=="pop"){
		window.open(aItemProps.pUrl,"",winProps);
		return;
	}else{
		document.location=aItemProps.pUrl;
		return;
	}
}
