/* brand-specific common library */
function elcSendURL( url ) {
//	alert( 'elcSendURL url: ' + "\t" + wsmlMakeWebServiceHref(url) );
	location.replace(wsmlMakeWebServiceHref(url));
}
function sendURL(targetURI) {
//	alert( targetURI + "\t" + wsmlMakeWebServiceHref(targetURI) );
	window.location = wsmlMakeWebServiceHref(targetURI);
}
function elcGotoURL( url ) {
	if (url != null && url != '') {
//              alert( wsmlMakeWebServiceHref( url ) );
		self.location.href = wsmlMakeWebServiceHref(url);
	}
}

var gnav = new elcNavigation('gnav');
gnav.hasTimeout = false;
gnav.offLayer = "pNavOff";
var pnav = new elcNavigation('pnav');
pnav.hasTimeout = false;
pnav.offLayer = "pNavOff";
var psnav = new elcNavigation('psnav');
psnav.hasTimeout = true;
psnav.offLayer = "pNavOff";
var leftNav = new elcNavigation('leftNav');
var bNav = new elcNavigation('bNav');

// normal	
var navMenuBGColorOn = '#F7E5F0';
var navMenuBGColorOff = '#FFFFFF';
var navMenuColorOn = '#72255A';
var navMenuColorOff = '#222221';

var se2BorderOnColor = '#B7B6B5';
var se2BorderOffColor = '#FFFFFF';
	
elcNavigation.prototype.hSetOn = function(oItem){
	if (oItem.myLayer) {
		oItem.myLayer.css.color = navMenuColorOn;
		oItem.myLayer.css.backgroundColor = navMenuBGColorOn;
	}
}
	
elcNavigation.prototype.hSetOff = function(oItem){
	if (oItem.myLayer) {
		oItem.myLayer.css.color = navMenuColorOff;
		oItem.myLayer.css.backgroundColor = navMenuBGColorOff;
	}
}

/* popup window */
function popWin(url, winName, popWidth, popHeight, popTop, popLeft, popScroll){
	var top = (popTop == "undefined" || popTop < 0) ? 20 : popTop;
	var left = (popLeft == "undefined" || popLeft < 0) ? 20 : popLeft;
	var options = 'width='+popWidth+',height='+popHeight+',scrollbars='+popScroll+',top='+top+',left='+left+',location=no,toolbar=0,menubar=0,resizable=0,directories=0';
	var myWin = window.open(url, winName, options);
	myWin.focus();
}
  	
function properWindowOpener(url, w, h){
	var windowWidth  = w;
	var windowHeight = h;

  	//find out how big the screen is
	var screenWidth  = screen.availWidth;
	var screenHeight = screen.availHeight;

  	//get the left position - which is half the screen width minus half the window width
	var leftPoint = parseInt(screenWidth/2) - parseInt(windowWidth/2);
	//get the top position - which is half the screen height minus half the window height
	var topPoint  = parseInt(screenHeight/2) - parseInt(windowHeight/2);
  
	var winprops = 'height='+h+', left='+leftPoint+', top='+topPoint+', width='+w+', resizable=1'
	var win = window.open( url, "win", winprops);

	if (parseInt(navigator.appVersion) >= 4) { win.window.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;
        }
}


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

function storeSelection (field) {
	if (document.all) {
		field.selected = true;
		field.selectedLength = field.createTextRange ? document.selection.createRange().text.length : 1;
	}
}

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

function rotatorOnClickHandler(url,w,h){
    var returnString =  "properWindowOpener('" + wsmlMakeLeakHref( url ) + "'," + w + "," + h + ");return false;";
    return returnString;
}
