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;

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

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

/* 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));
}


