/* BEGIN GLOBAL NAV CODE */
	function elcSendURL( url ) {
		location.replace(wsmlMakeWebServiceHref(url));
	}
	function sendURL(targetURI) {
		window.location = wsmlMakeWebServiceHref(targetURI);
	}

	// define retailerId in head_common.tmpl
	function elcLeakURL( url ) {
		if (!retailerId) {
			location.replace(wsmlMakeLeakHref(url));
		} else {
			var newUrl;
			if (url.indexOf("?") > -1) {
				var urlParamString = url.substr(url.indexOf("?") +1);
alert(urlParamString);
				if (urlParamString != '') {
					newUrl = url + '&retailer-id=' + retailerId;
				} else {
					newUrl = url + 'retailer-id=' + retailerId;
				}
			} else {
					newUrl = url + '?retailer-id=' + retailerId;
			}
			location.replace(wsmlMakeLeakHref(newUrl));
		}
	}

	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 pssnav = new elcNavigation('pssnav');
	pssnav.hasTimeout = true;
	pssnav.offLayer = "pNavOff";
	
	var navMenuColorOn = '#FFFFFF';
	var navMenuColorOff = '#999999';
	
	elcNavigation.prototype.hSetOn = function(oItem){
		if (oItem.myLayer) {
			oItem.myLayer.style.color = navMenuColorOn;
		}
	}
	
	elcNavigation.prototype.hSetOff = function(oItem){
		if (oItem.myLayer) {
			oItem.myLayer.style.color = navMenuColorOff;
		}
	}
/* END GLOBAL NAV CODE */

/* NAV VARIABLES */
var leftnav = new elcNavigation('leftnav');
var rightnav = new elcNavigation('rightnav');
var footnav = new elcNavigation('footnav');
/* END NAV VARIABLES */

var originals      = new elcNavigation('originals');
var mouseoverImage = new elcNavigation('mouseoverImage');

/* popup window */
function popWin(url,winName, popWidth,popHeight,popScroll,popResize) {
	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';
	var myWin = window.open(url, winName, options);
	myWin.focus();
}
  	
  function properWindowOpener(url, w, h, scroll, resize)
  {
  	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+',scrollbars=1 ,resizable=1'
	var winprops = 'height='+h+', left='+leftPoint+', top='+topPoint+', width='+w+', resizable=1, scrollbars='+scroll;

	var win = window.open( url, "macwin", winprops);
  
  	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
  }

function goParent(url) {
	var parent = window.opener;
	if (!parent) {
		parent = self;
	}
	parent.location.href = url;
}
 
function clearTextBoxOnCondition(textBox,conditionText){
        if(textBox.value == conditionText)
          textBox.value="";
    }   

function checkMaxLength (textarea, evt, maxLength) {
	var keyCode = (evt.charCode) ? evt.charCode : 
		((evt.keyCode) ? evt.keyCode :
			((evt.which) ? evt.which : 0));
	var printableKey = ((keyCode > 31) || (keyCode == 13)) ? 1 : 0;	
	if ((textarea.value.length + printableKey) > maxLength) {
		textarea.value = textarea.value.substring(0, maxLength);
		textarea.select();
		return false;
	}
	return true;
}

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

/* COMMERCE */
function mADD(qtyBox, formName) {
	if (!formName) {
		formName = 'prodform';
	}
	if (!document.forms[formName].elements[qtyBox].value) {
		document.forms[formName].elements[qtyBox].value=1;
	}
	document.forms[formName].submit();
}

