var topnav = new elcNavigation();
var pnav = new elcNavigation('pnav');
pnav.hasTimeout = false;
pnav.offLayer = "pNavOff";
var psnav = new elcNavigation('psnav');
psnav.hasTimeout = false;
var pgnav = new elcNavigation('pgnav');
pgnav.hasTimeout = false;
var CMSGlobal = new elcNavigation();

/* popup window */
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function popWin(url,winName, popWidth,popHeight,popScroll, popResize, popPosition) { 
	    var popPlacement = "";
	    if (popPosition == "top-right") {
	        var winW = f_clientWidth();
                var settop = 5;
      		var setleft = (winW - popWidth);
      		popPlacement = ',top=' + settop + 'px, left=' + setleft + 'px';
	    }
	    if (!popScroll) { popScroll = 'no'}
	    if (!popResize) { popResize = 0}
	    var options = 'width='+popWidth+',height='+popHeight+',scrollbars='+popScroll+',location=no,toolbar=0,menubar=0,resizable='+popResize+',directories=0'+popPlacement;
            var myWin = window.open(url, winName, options);
	    myWin.focus();
}

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


// Pop a window
var popWindow;
function popup(url,scrollbars,width,height){
    popWindow = open(url, 'jmpopWindow', 'toolbar=0,location=0,directories=0,status=0,menubars=0,resizable=0,scrollbars='+scrollbars+',width='+width+',height='+height+',top=20,left=20');
    if (popWindow != null) {
        popWindow.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 in templates/includes/head_common.tmpl
function elcSendURL( url ) {
//	printurl = wsmlMakeWebServiceHref(url);
//	alert(printurl);
	location.replace(wsmlMakeWebServiceHref(url));
}

function popWindow(w,h,x,y) {
var subwindow = window.open('','subWindow_name','toolbar=no,menubar=no,location=no,scrollbars=yes,width='+w+',height='+h+',left='+x+',top='+y);
subwindow.resizeTo(w,h);
subwindow.moveTo(x,y);
subwindow.focus();
}

function setPNGtrans(img) {
        img.src='/images/global/spacer.gif';
}
