/* BEGIN GLOBAL NAV CODE */
	function elcSendURL( url ) {
		location.replace(wsmlMakeWebServiceHref(url));
	}
	function sendURL(targetURI) {
		window.location = wsmlMakeWebServiceHref(targetURI);
	}
	var gnav = new elcNavigation('gnav');
	gnav.hasTimeout = false;
	gnav.offLayer = "gNavOff";
	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 = '#00A1E1'; */
	var navMenuColorOn = '#999999';
	var navMenuColorOff = '#000000';

    /* 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 = {
        launchesN47: {
            on: "#810262",
            off: "#000000"
        },
        launchesN48: {
            on: "#4bc8b6",
            off: "#000000"
        },
        launchesN49: {
            on: "#e51d9b",
            off: "#000000"
        }
    };

	
//	elcNavigation.prototype.hSetOn = function(oItem){
//		if (oItem.myLayer) {
//			oItem.myLayer.css.color = navMenuColorOn;
//		}
//	}
//	
//	elcNavigation.prototype.hSetOff = function(oItem){
//		if (oItem.myLayer) {
//			oItem.myLayer.css.color = navMenuColorOff;
//		}
//	}



    /* 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.css.color = navMenuColorOn;
            }
            else {
                            oItem.myLayer.css.color = navMenuColorsHash[arguments[1]].on;
            }
                }
        }

        elcNavigation.prototype.hSetOff = function(oItem){
                if (oItem.myLayer) {
            if (arguments[1] == undefined) {
                            oItem.myLayer.css.color = navMenuColorOff;
            }
            else {
                            oItem.myLayer.css.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 */

/* popup window */
function popWin(url,winName, popWidth,popHeight,popScroll, popResize, popLocation) { 
	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';
	    if (popLocation == 'upperleft') {
			options += ',top=10,left=100';
		}
            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+',scrollbars=1 ,resizable=1'
	//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(); }
  }

 
function clearTextBoxOnCondition(textBox,conditionText){
        if(textBox.value == conditionText)
          textBox.value="";
    }   

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

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