/* 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";
	
    /* Aaron Dancygier: 20090807  globalnav changes for makeup arts collection 2009 */
    /* Standard navigation on and off colors */
	var navMenuColorOn = '#FFFFFF';
	var navMenuColorOff = '#999999';

    /* hash mapping domids to on off colors. Need to pass the id in as a
       second parameter in setOn() see level1() in webadmin/navgen_subs.tmpl */
    var navMenuColorsHash = {
        collectionsN10: {
            on: "#810262",
            off: "#999999"
        },
        collectionsN11: {
            on: "#4bc8b6",
            off: "#999999"
        },
        collectionsN12: {
            on: "#e51d9b",
            off: "#999999"
        },
        looksN2: {
            on: "#810262",
            off: "#999999"
        },
        looksN3: {
            on: "#4bc8b6",
            off: "#999999"
        },
        looksN4: {
            on: "#e51d9b",
            off: "#999999"
        }
    };

    /* redefining hSetOn and hSetOff to do hash lookup of on and off states */
	elcNavigation.prototype.hSetOn = function(oItem){
		if (oItem.myLayer) {
            if (arguments[1] == undefined) {
			    oItem.myLayer.style.color = navMenuColorOn;
            }
            else {
			    oItem.myLayer.style.color = navMenuColorsHash[arguments[1]].on;
            }
		}
	}
	
	elcNavigation.prototype.hSetOff = function(oItem){

		if (oItem.myLayer) {
            if (arguments[1] == undefined) {
			    oItem.myLayer.style.color = navMenuColorOff;
            }
            else {
			    oItem.myLayer.style.color = navMenuColorsHash[arguments[1]].off;
            }
		}

	}

    /* overiding setOn, setOff, and _processDOMSetOn to handle optional parameter with domId gets passed appropriately. */
    elcNavigation.prototype.setOn = function(key){
        var oItem = this.getItem(key);
        this.childrenSetOff();
        if(this.last && this.last != oItem) this.setLastOff();
        if(this.defaultItemKey && this.thisDefaultItemKey != key) this.setOff(this.defaultItemKey);
        if (DEBUG) {
            if (oItem == "undefined" || oItem == null || oItem.image == "undefined"){
                alert('Error in elcNavigation.setOn: missing object ' + key + ' in nav object ' + this.name)
                return
            }
        }
        if (oItem.type=="ns4css2"){
            this._processNS4SetOn(oItem);
        } else if (oItem.type=="image" || oItem.type=="dom"){
            if (arguments[1] == undefined) {
                this._processDOMSetOn(oItem);
            }
            else {
                this._processDOMSetOn(oItem, arguments[1]);
            }
        } else {
            // type not recognized
            return false;
        }
        if(oItem.layer){
            this._processSubLayerSetOn(oItem);
        } else if(this.defaultItemKey) {
            this.setDefaultItemOn();
        }

        if(this.off) this.off.show();
        this.last = oItem;
    }

    elcNavigation.prototype.setOff = function(key){
        oItem = this.getItem(key);
        if (DEBUG) {
            if (oItem == "undefined" || oItem == null || oItem.image == "undefined") {
                alert('Error in elcNavigation.setOff: missing object ' + key + ' in nav object ' + this.name)
                return;
            }
        }
        if (!oItem.isDefault){
            if (oItem.type=="ns4css2"){
                oItem.onSubLayer.hide();
            } else {
                oItem.image.setOff();
                if (typeof this.hSetOff == 'function') {
                    if (arguments[1] == undefined) {
                        this.hSetOff(oItem);
                    }
                    else {
                        this.hSetOff(oItem, arguments[1]);
                    }
                }
            }
        }
        if (oItem.layer) this._processSubLayerSetOff(oItem);
        if (this.off) this.off.hide();
    }

    elcNavigation.prototype._processDOMSetOn = function(oItemObj){
        oItemObj.image.setOn();

        if (arguments[1] == undefined) {
            if (typeof this.hSetOn == 'function') this.hSetOn(oItemObj);
        }
        else {
            if (typeof this.hSetOn == 'function') this.hSetOn(oItemObj, arguments[1]);
        }
    }

/* End changes for Makeuparts collection 2009 */




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

