var Gore = {
    /*
     * TODO: Incorporate an AddEvent or similar function to manage such global events like document.onmouseup
     */
    
    Config : {
        ShopByNavigationDivID :             "nav_shop_by",
        
        GenericShowHide : {
            ToggleIDPrefix :                "toggle_",
            ToggleNodeOpenClassName :       "open"
        },
        
        ExclusiveShowHide : {
            PanelReferenceClassName :       "panel_ref",
            TabDesignatorClassName :        "exclusive_toggle",
            PanelSetDesignatorClassName :   "panel_set",
            PanelDesignatorClassName :      "panel",
            ActivePanelClassName :          "active",
            VisitedPanelClassName :         "visited",
            ProductItemClassName :          "product",
            ForceParentHeightShim :         25
        },
        
        ShowHide : {
            rootULID :                      "expand_retract",
            ToggleNodeClassName :           "toggle",
            ToggleNodeOpenClassName :       "open"
        },
        
        Flyout : {
            CompletelyOffAllFlyoutsDelay :  500,
            ClearOldFlyoutDelay :           200,
            ShowFlyoutDelay :               200,
            Ellipsis :                      "...",
            EllipsisClassName :             "ellipsis",
            ShopByActivityID :              "shop_by_activity",
            ShopByGearID :                  "shop_by_gear",
            HoverClassName :                "hover",
            ForceOpenClassName :            "selected",
            HasChildrenClassName :          "has_children",
            IFrameIDPrefix :                "ifrm"
        },
        
        PrintButton : {
            PrintClassName :                "printButton"
        },
        
        SubmitButtons : {
            SubmitClassName :               "button",
            ResetClassName :                "button clear",
            PlainButtonClassName :          "button plain"
        },
        
        ImageZoom : {                       // See [http://developer.mozilla.org/en/docs/DOM:window.open] for more information on window.open and its features
            NewWindowName :                 "ImageZoom",
            Top :                           "150",
            Left :                          "150",
            PopupHeight :                   "400",
            PopupWidth :                    "400",
            Location :                      "no",
            MenuBar :                       "no",
            Status :                        "no",
            Resizable :                     "yes",
            OtherFeatures :                 "" // should be a comma delimited feature set standard for window.open(). It should start with a comma as it will be added to an existing set.
        },
        
        LightBox : {
            CloseLightBox :                 "Close",
            CloseLightBoxID :               "close_lightbox",
            ScreenDimmerID :                "screen_dimmer",
            LightBoxID :                    "lightbox",
            AnchorIDPrefix :                "activate_"
        },
        
        Skin : {
            SelectBox : {
                ZIndexStart :               10000,
                OpenedClassName :           "open",
                ClosedClassName :           "closed",
                SelectedClassName :         "selected",
                HoverClassName :            "hover",
                FirstChildClassName :       "first_child",
                ULIDSuffix :                "_faux"
            }
        },
        
        CustomScrollBar : {
            ScrollBarWrapperClassName :     "scrollbar_wrapper",
            ScrollBarClassName :            "scrollbar",
            UpButtonClassName :             "scroll_up_button",
            DownButtonClassName :           "scroll_down_button",
            SlideAreaClassName :            "scroll_slide_area",
            SliderClassName :               "scroll_slider",
            ScrollUpValue :                 25,
            ScrollDownValue :               -25
        },
        
        Utils : {
            GenerateIDPrefix :              "g"
        }
    },
    
    Global : {
        Init : function(){
            Gore.ShopByNavigation.Init();
            Gore.Skin.Init(["country_selection"]);
            Gore.Behaviours.PrintButton.Init();
            Gore.Behaviours.SubmitButtons.Init();
        }
    },

    ShopByNavigation : {
        Init : function(){
            var menus = YAHOO.util.Dom.getElementsByClassName("menuRoot");
            Gore.local.menus = [];
            var menusLength = menus.length;
            for (var i=0; i<menusLength; i++) {
                menu = menus[i];
                Gore.local.menus[i] = new YAHOO.widget.Menu(menu, 
				        {
				            position: "static", 
				            lazyload: true, 
				            hidedelay: 750, 
				                effect: 
				                {
				                    effect: YAHOO.widget.ContainerEffect.FADE, 
				                    duration: 0.25
				                }
					    }
				); 
			    Gore.local.menus[i].render();
            }
        	
        	var aWithSubMenu = YAHOO.util.Dom.getElementsByClassName("hassubmenu", "a");
        	for (var i=aWithSubMenu.length-1; i>=0; i--) {
        		var ellipsis = document.createElement("span");
        			ellipsis.className = "ellipsis";
        			ellipsis.appendChild(document.createTextNode("..."));
        		aWithSubMenu[i].appendChild(ellipsis);
        		
        		/* Kill click action for menu items that don't have a valid URL.
        		 * Primarily a fix for IE. */
        		if (aWithSubMenu[i].href == "#") {
        		    aWithSubMenu[i].onclick = function () {
        		        return false;
        		    }
        		}
        	}
        },
        
        NavExists : function(){
            var nav = document.getElementById(Gore.Config.ShopByNavigationDivID);
            if(nav){
                return true
            }else{
                return false
            }
        }
    },
    
    Behaviours : {
        PrintButton : {
            Init : function(){
                Gore.Behaviours.PrintButton.CreatePrintButtons();
            },
            
            CreatePrintButtons : function(){
                var settings = Gore.Config.PrintButton;
                var spans = document.getElementsByTagName("span");
                for(var i=0; i<spans.length; i++){
                    var span = spans[i];
                    if(span.className.indexOf(settings.PrintClassName) != -1){
                        var a = document.createElement("a");
                        a.appendChild(document.createTextNode(span.title));
                        a.href="#";
                        a.onclick = function(){eval(this.nextSibling.getAttribute("onclick")); window.print(); return false};
                        span.parentNode.insertBefore(a, span);
                    }
                }               
            }
        },
        
        SubmitButtons : {
            Init : function(){
                Gore.Behaviours.SubmitButtons.FindAndReplace();
            },
            
            FindAndReplace : function(){
                var settings = Gore.Config.SubmitButtons;
                var inputs = document.getElementsByTagName("input");

                    for(var i=0; i<inputs.length; i++){
                    var input = inputs[i];
                    var inputType = input.getAttribute("type").toUpperCase();
                    if(inputType == "SUBMIT" || inputType == "RESET" || inputType == "BUTTON"){
                        
                        var a = document.createElement("a");
                        a.appendChild(document.createTextNode(input.value));
                        if(inputType == "SUBMIT"){
                            a.onclick = function(){
                                var frm = Gore.Behaviours.SubmitButtons.LocateParentForm(this);
                                if (frm && frm.onsubmit) {
                                    if (frm.onsubmit() != false) {
                                        frm.submit();
                                    }
                                } else if (frm) {
                                    frm.submit();
                                }
                                return false;
                            };
                            a.className = settings.SubmitClassName;
                        }else if(inputType == "RESET"){
                            a.onclick = function(){
                                var frm = Gore.Behaviours.SubmitButtons.LocateParentForm(this);
                                frm.reset();
                                return false;
                            };
                            a.className = settings.ResetClassName;
                        }else if(inputType == "BUTTON"){
                            a.onclick = input.onclick;
                            a.className = settings.PlainButtonClassName;
                        }
                        a.href="#";
                        input.parentNode.insertBefore(a, input.nextSibling);
                        input.style.display = "none";
                    }
                }
            },
            
            LocateParentForm : function(obj){
                var frm = obj.parentNode;
                while(frm.nodeName != "FORM"){
                    frm = frm.parentNode;
                }
                return frm;
            }
        },
        
        ImageZoom : {
            Init : function(images){
                for(var i=0; i<images.length; i++){
                    this.Bind(images[i]);
                }
            },
            
            Bind : function(imageID){
                var imageAnchor = document.getElementById(imageID);
                imageAnchor.onclick = this.Zoom;
            },
            
            Zoom : function(e){
                e = (!e) ? event : e;
                var config = Gore.Config.ImageZoom;
                window.open(this.href, config.NewWindowName, "top="+config.Top+",left="+config.Left+",resizable="+config.Resizable+",height="+config.PopupHeight+",width="+config.PopupWidth+",location="+config.Location+",menubar="+config.MenuBar+",status="+config.Status+config.OtherFeatures);
                return false
            }
        },
        
        LightBox : {
            content : null,
            contentBackRef : null,
            
            Init : function(lightBoxes){
                for(var i=0; i<lightBoxes.length; i++){
                    Gore.Behaviours.LightBox.Bind(lightBoxes[i]);
                }
            },
            
            Bind : function(lightBox){
                var aExists = false;
                if(lightBox instanceof Array){                      // is a lightbox/anchor set
                    var node = document.getElementById(lightBox[0]);
                    var a = document.getElementById(lightBox[1]);
                    aExists = true;
                }else{                                              // just content for a lightbox, generate anchor
                    var node = document.getElementById(lightBox);
                    var a = document.createElement("a");
                        a.id = Gore.Config.LightBox.AnchorIDPrefix + node.id;
                        a.appendChild(document.createTextNode(node.title));
                }
                
                if(!a.href) a.href = "#" + node.id;
                a.onclick = this.Show;
                
                if(!aExists) node.parentNode.insertBefore(a, node.previousSibling);
            },
            
            Show : function(e){
                e = (!e) ? event : e;
                var config = Gore.Config.LightBox;
                
                var screenDimmer = document.createElement("div");
                    screenDimmer.id = config.ScreenDimmerID;
                    screenDimmer.style.position = "absolute";
                    screenDimmer.style.top = "0px";
                    screenDimmer.style.left = "0px";
                    screenDimmer.style.zIndex = "15000";
                    //screenDimmer.style.width = screen.width + "px";
                    //screenDimmer.style.height = screen.height + "px";
                    screenDimmer.style.width = ((window.innerWidth) ? window.innerWidth : document.body.clientWidth) + "px";
                    screenDimmer.style.height = ((window.innerHeight) ? window.innerHeight : document.body.clientHeight) + "px";
                    
                var lightBox = document.createElement("div");
                    lightBox.id = config.LightBoxID;
                    lightBox.style.position = "absolute";
                    lightBox.style.zIndex = "15001";
                    
                var content = document.getElementById(this.href.substring(this.href.indexOf("#") + 1, this.href.length));//.cloneNode(true);
                    content.style.display = "block";
                    Gore.Behaviours.LightBox.content = content;
                    Gore.Behaviours.LightBox.contentBackRef = content.previousSibling;
                    
                var closeLightBox = document.createElement("p");
                
                var closeLightBoxA = document.createElement("a");
                    closeLightBox.id = config.CloseLightBoxID;
                    closeLightBoxA.className = "button close";
                    closeLightBoxA.onclick = Gore.Behaviours.LightBox.Hide;
                    
                    closeLightBoxA.appendChild(document.createTextNode(config.CloseLightBox));
                    closeLightBox.appendChild(closeLightBoxA);
                    lightBox.appendChild(closeLightBox);
                    lightBox.appendChild(content);
                    document.body.appendChild(screenDimmer);
                    document.body.appendChild(lightBox);
                    
                    lightBox.style.width = content.offsetWidth + "px";
                    lightBox.style.height = content.offsetWidth + closeLightBox.offsetHeight + "px";
                    //lightBox.style.top = (screen.height / 2 - lightBox.offsetHeight / 2) + "px";
                    //lightBox.style.left = (screen.width / 2 - lightBox.offsetWidth / 2) + "px";
                    lightBox.style.top = ((lightBox.offsetHeight/2) / screen.height * 100) + "%";
                    lightBox.style.left = (lightBox.offsetWidth / screen.width * 100) + "%";

                return false
            },
            
            Hide : function(){
                var vars = Gore.Behaviours.LightBox;
                var screenDimmer = document.getElementById(Gore.Config.LightBox.ScreenDimmerID);
                document.body.removeChild(screenDimmer);                                                    // remove the screen dimmer
                var lightBox = document.getElementById(Gore.Config.LightBox.LightBoxID);
                vars.contentBackRef.parentNode.insertBefore(vars.content, vars.contentBackRef.nextSibling); // put the content block back where you got it
                vars.contentBackRef.nextSibling.style.display = "none";
                document.body.removeChild(lightBox);                                                        // remove the lightbox
                return false
            }
        },
        
        CustomScrollBar : {
            MouseDownID : null,
            Dragging : false,
            CurrentSlider : null,
            PreviousMouseY : null,
            
            Init : function(containers){
                for(var i=0; i<containers.length; i++){
                    this.Bind(containers[i]);
                }
            },
            
            Bind : function(containerArray){
                var container = document.getElementById(containerArray[0]);
                var wrapperHeight = containerArray[1];
                var containerHeight = container.offsetHeight;
                
                // if the content container doesn't exist or the content is 
                // smaller than the wrapper height, then abort
                if(container == undefined || containerHeight < wrapperHeight) return;
                
                wrapperHeight += "px"
                var wrapper = document.createElement("div");
                    wrapper.className = Gore.Config.CustomScrollBar.ScrollBarWrapperClassName;
                    wrapper.style.position = "relative";
                    wrapper.style.height = wrapperHeight;
                    wrapper.onmousewheel = this.MouseHandler.Scroll;
                
                container.parentNode.insertBefore(wrapper, container);
                
                wrapper.appendChild(container);
                wrapper.appendChild(this.Create(wrapper, wrapperHeight));
                container.style.height = containerHeight + "px";
                container.style.position = "absolute";
            },
            
            Create : function(wrapper, containerHeight){
                var settings = Gore.Config.CustomScrollBar;
                
                var scrollBar = document.createElement("div");
                    scrollBar.className = settings.ScrollBarClassName;
                    
                var upButton = document.createElement("div");
                    upButton.className = settings.UpButtonClassName;
                    upButton.scrollValue = settings.ScrollUpValue;
                    upButton.onmousedown = this.MouseHandler.Click;
                    upButton.onmouseup = this.MouseHandler.Click;
                    
                var downButton = document.createElement("div");
                    downButton.className = settings.DownButtonClassName;
                    downButton.scrollValue = settings.ScrollDownValue;
                    downButton.onmousedown = this.MouseHandler.Click;
                    downButton.onmouseup = this.MouseHandler.Click;
                    
                var slideArea = document.createElement("div");
                    slideArea.className = settings.SlideAreaClassName;
                    
                var slider = document.createElement("div");
                    slider.className = settings.SliderClassName;
                    slider.onmousedown = this.MouseHandler.Click;
                    slider.onmouseup = this.MouseHandler.Click;
                    document.onmouseup = this.MouseHandler.Click;       // This is dangerous because it monopolizes the document.onmouseup event. AddEvent or a similar function should be used
                    document.onmousemove = this.MouseHandler.Drag;      // This is dangerous because it monopolizes the document.onmousemove event. AddEvent or a similar function should be used

                    
                scrollBar.appendChild(upButton);
                slideArea.appendChild(slider);
                scrollBar.appendChild(slideArea);
                scrollBar.appendChild(downButton);
                return scrollBar;
            },
            
            ComputeSizes : function(wrapper){
                var settings = Gore.Config.CustomScrollBar;
                var ul = wrapper.childNodes[0];
                
                // verify the existence of scrollbar elements by checking
                // against their class names because we're reading childNodes
                // which will always return true
                
                if (wrapper && wrapper.childNodes) {
						
					var scrollBar = wrapper.childNodes[1];
					if (scrollBar && scrollBar.className == settings.ScrollBarClassName) {
						scrollBar.style.position = "absolute";
						scrollBar.style.top = "0px";
						scrollBar.style.right = "0px";
						scrollBar.style.height = wrapper.offsetHeight + "px";
					}
						
					if (scrollBar && scrollBar.childNodes) {
						var upButton = scrollBar.childNodes[0];
						if (upButton && upButton.className == settings.UpButtonClassName) {
							upButton.style.position = "absolute";
							upButton.style.top = "0px";
							upButton.style.left = "0px";
							upButton.style.zIndex = "1000";
						}
							
						var downButton = scrollBar.childNodes[2];
						if (downButton && downButton.className == settings.DownButtonClassName) {
							downButton.style.position = "absolute";
							downButton.style.bottom = "0px";
							downButton.style.left = "0px";
							downButton.style.zIndex = "1001";
						}
							
						var slideArea = scrollBar.childNodes[1];
						if (slideArea && slideArea.className == settings.SlideAreaClassName) {
							slideArea.style.position = "absolute";
							slideArea.style.top = upButton.offsetHeight + "px";
							slideArea.style.left = "0px";
							slideArea.style.height = wrapper.offsetHeight - upButton.offsetHeight - downButton.offsetHeight + "px";
						}
					}
					
					if (slideArea && slideArea.childNodes) {
						var slider = slideArea.childNodes[0];
						if (slider && slider.className == settings.SliderClassName) {
							slider.style.position = "absolute";
							slider.style.top = "0px";
							slider.style.height = (wrapper.offsetHeight * slideArea.offsetHeight / ul.offsetHeight) + "px";
							slider.style.zIndex = "500";
						}
					}
				}
            },
            
            MouseHandler : {
                Scroll : function(e){
                    e = (!e) ? event : e;
                },
                
                Drag : function(e){
                    e = (!e) ? event : e;
                    var settings = Gore.Behaviours.CustomScrollBar;
                    var config = Gore.Config.CustomScrollBar;
                    
                    if(settings.Dragging){
                        var mouseY = (e.clientY) ? e.clientY : e.pageY;
                        var previousMouseY = (settings.PreviousMouseY != null) ? settings.PreviousMouseY : mouseY;
                        var slider = settings.CurrentSlider;
                        var shiftY = previousMouseY - mouseY;
                        var upperLimit = 0;
                        var lowerLimit = slider.parentNode.offsetTop + slider.parentNode.offsetHeight - slider.parentNode.nextSibling.offsetHeight;
                        var newY = slider.offsetTop - shiftY;
                        
                        if(newY > upperLimit && newY + slider.offsetHeight < lowerLimit) slider.style.top = newY + "px";
                        var content = slider.parentNode.parentNode.parentNode.childNodes[0];
                        
                        var contentHeight = content.offsetHeight;
                        var sliderOffset = slider.offsetTop;
                        var scrollAreaHeight = slider.parentNode.offsetHeight;
                        var contentPosition     = Math.round(contentHeight * sliderOffset / scrollAreaHeight);
                        
                        content.style.top = -1 * contentPosition + "px";
                    }
                    Gore.Behaviours.CustomScrollBar.PreviousMouseY = mouseY;
                },
                
                Click : function(e){
                    e = (!e) ? event : e;
                    switch(e.type){
                        case "mouseup":
                            Gore.Behaviours.CustomScrollBar.Dragging = false;
                            if(this.className && this.className.indexOf(Gore.Config.CustomScrollBar.SliderClassName) != -1){
                                Gore.Behaviours.CustomScrollBar.CurrentSlider = null;
                            }else{
                                window.clearInterval(Gore.Behaviours.CustomScrollBar.MouseDownID);
                            }
                        break;
                        case "mousedown":
                            Gore.Utils.ID.GenerateID(this);
                            if(this.className.indexOf(Gore.Config.CustomScrollBar.SliderClassName) != -1){
                                Gore.Behaviours.CustomScrollBar.Dragging = true;
                                Gore.Behaviours.CustomScrollBar.CurrentSlider = this;
                            }else{
                                Gore.Behaviours.CustomScrollBar.MouseDownID = window.setInterval("Gore.Behaviours.CustomScrollBar.Scroll('" + this.id + "')", 1);
                            }
                        break;
                    }
                }
            },
                
            Scroll : function(objID){
                var obj = document.getElementById(objID);
                if(obj == undefined) return;
                
                var getXY = Gore.Utils.GetXY;
                
                var content         = obj.parentNode.previousSibling;
                var contentTop      = content.offsetTop; // contentTop needs to be relative to its parent and not relative to the screen itself (thus getXY isn't used to get the top value)
                var contentBottom   = content.offsetTop + content.offsetHeight;
                
                var wrapper         = content.parentNode;
                var wrapperTop      = getXY(wrapper)[1];
                var wrapperBottom   = wrapper.offsetTop + wrapper.offsetHeight;
                
                var direction       = (obj.scrollValue == Math.abs(obj.scrollValue)) ? 1 : -1;
                var slider          = obj.parentNode.childNodes[1].childNodes[0];

                // Calculate Slider Position
                var contentOffset   = getXY(wrapper)[1] - getXY(content)[1];
                var scrollAreaHeight= obj.parentNode.childNodes[1].offsetHeight;
                var contentHeight   = content.offsetHeight;
                
                var sliderPosition  = Math.round(contentOffset * scrollAreaHeight / contentHeight);
                
                contentTop += obj.scrollValue;
                if(contentTop > 0 && direction == 1) contentTop = 0;
                if(contentBottom < wrapperBottom && direction == -1) contentTop = -(content.offsetHeight - wrapper.offsetHeight);
                content.style.top = contentTop + "px";
                
                slider.parentNode.style.position = "relative";
                slider.style.position = "absolute";
                slider.style.top = sliderPosition + "px";
            }           
        },
        
        GenericShowHide : {
            Init : function(){
                this.Crawl(document.body.childNodes);
            },
            
            Crawl : function(nodeset){
                var prefix = Gore.Config.GenericShowHide.ToggleIDPrefix;
                
                for(var i=0; i<nodeset.length; i++){
                    var node = nodeset[i];
                    
                    if(node.nodeType == 1){
                        if(node.id.substring(0, prefix.length) == prefix){
                            node.onclick = this.Toggle;
                        }
                        Gore.Behaviours.GenericShowHide.Crawl(node.childNodes);
                    }
                }
            },
            
            Toggle : function(){
                var modifyClass = Gore.Utils.ClassName;
                var prefix = Gore.Config.GenericShowHide.ToggleIDPrefix;
                var openClassName = Gore.Config.GenericShowHide.ToggleNodeOpenClassName;
                var node = document.getElementById(this.id.substring(prefix.length, this.id.length));
                
                if(node.className.indexOf(openClassName) == -1){
                    modifyClass.Add(node, openClassName);
                }else{
                    modifyClass.Remove(node, openClassName);
                }
            }
        },      
        
        ExclusiveShowHide : {
            PanelSets : [],
            Panels : [],
            Heights : [],
            RemoveAllFunctionality : false,
			
            Init : function(panels){
                this.Crawl(document.body.childNodes);
                this.Bind();
            },
            
            PanelHeights : function(heights){
                for(var i=0; i<heights.length; i++){
                    this.Heights[heights[i][0]] = heights[i][1];
                }
            },
            
            Crawl : function(nodeset){
                var panelRefName = Gore.Config.ExclusiveShowHide.PanelReferenceClassName;
                var panelSetName = Gore.Config.ExclusiveShowHide.PanelSetDesignatorClassName;
                var panelName = Gore.Config.ExclusiveShowHide.PanelDesignatorClassName;
                
                for(var i=0; i<nodeset.length; i++){
                    var node = nodeset[i];
                    
                    if(node.nodeType == 1){
                        if(node.className.indexOf(panelRefName) != -1){                                             // Found PanelRef && not Panel, add to Panels[]
                            this.AddPanels(node.getElementsByTagName("a"));
                            this.PanelSets[this.PanelSets.length] = this.Panels;                                    // Once back out add Panels Array to PanelSet Array
                            this.Panels = [];                                                                       // Clear Panels Array
                        }else{
                            Gore.Behaviours.ExclusiveShowHide.Crawl(node.childNodes);                               // Go in
                        }
                    }
                }
            },
            
            AddPanels : function(panelRefs){
                for(var i=0; i<panelRefs.length; i++){
                    var tab = panelRefs[i];
                    
                    // scan next siblings until associated panel is found
                    var panelID = panelRefs[i].href.substring(panelRefs[i].href.indexOf("#") + 1, panelRefs[i].href.length);
                    var heading = document.getElementById(panelID);
                    var panel = heading.nextSibling;
                    
                    var panelClassName = (panel.className == undefined) ? "" : panel.className;
                    
                    while(panelClassName.indexOf(Gore.Config.ExclusiveShowHide.PanelDesignatorClassName) == -1){
                        panel = panel.nextSibling;
                        panelClassName = (panel.className == undefined) ? "" : panel.className;
                    }
                    
                    this.Panels[this.Panels.length] = [tab, heading, panel];                        // Store tab, heading and panel
                                                                                                    //   Note: in some scenarios the anchor in the panel_ref <ul> is used as the tab.
                                                                                                    //         This is the "tab" that's being stored. In other cases the heading (h2, h3, dt, etc...)
                                                                                                    //         immediately preceding the panel will be used. This is the "heading" that's being stored.
                }
            },
            
            /*
            AddPanel : function(panel){
                
                // scan previous siblings until associated tab is found
                var tab = panel.previousSibling;
                var tabClassName = (tab.className == undefined) ? "" : tab.className;
                
                while(tabClassName.indexOf(Gore.Config.ExclusiveShowHide.TabDesignatorClassName) == -1){
                    tab = tab.previousSibling;
                    tabClassName = (tab.className == undefined) ? "" : tab.className;
                }
                
                // store panel/tab combination
                if(this.Heights[panel.id] == undefined){                            // no height defined, force parent height
                    Gore.Behaviours.ExclusiveShowHide.ForceParentHeight(panel);
                }
                this.Panels[this.Panels.length] = [tab, panel];                     // store panel and tab
            },
            */
            
            Bind : function(){
                var panelSets = Gore.Behaviours.ExclusiveShowHide.PanelSets;
                
                for(var i=0; i<panelSets.length; i++){
                    for(var j=0; j<panelSets[i].length; j++){
                        panelSets[i][j][0].onclick = this.SetActive;
                        panelSets[i][j][0].panelSet = i;
                        panelSets[i][j][1].onclick = this.SetActive;
                        panelSets[i][j][1].panelSet = i;                            // ".panelSet" is a proprietary property used in SetActive() and
                                                                                    //   serving to track which panelset this link belongs to
                    }
                }
            },
            
            SetActive : function(e){
                e = (!e) ? event : e;
                
                var settings        = Gore.Behaviours.ExclusiveShowHide;
                var panels          = settings.PanelSets[this.panelSet];
                var cs_settings     = Gore.Config.CustomScrollBar;
                var modifyClass     = Gore.Utils.ClassName;
                var customScrollBar = Gore.Behaviours.CustomScrollBar;
                var config          = Gore.Config.ExclusiveShowHide;
                var active          = config.ActivePanelClassName;
                var visited         = config.VisitedPanelClassName;
                var product         = config.ProductItemClassName;
                
				var removeAll = (this.className.indexOf(active) != -1) ? true : false;
				
				// single product check before anything else
                for(var i=0; i<panels.length; i++){
                    var tab         = panels[i][0];
                    var heading     = panels[i][1];
                    var panel       = panels[i][2];
                    
					if(this == tab || this == heading){
						var pnlChildren = panel.childNodes;
                    	var childCount = 0;
                    	var productURL = "";
                    	for(var z=0; z<pnlChildren.length; z++){
	                    	if(pnlChildren[z].className && pnlChildren[z].className.indexOf(product) != -1){
		                    	childCount++;
		                    	productURL = pnlChildren[z].getElementsByTagName("a")[0];
	                    	}
                    	}
                    	if(childCount === 1){
	                    	document.location = productURL;
		                	return;
                    	}
                	}
				}
				
				// toggle panels
                for(var i=0; i<panels.length; i++){
                    var tab         = panels[i][0];
                    var heading     = panels[i][1];
                    var panel       = panels[i][2];
                    
					if(removeAll == true && settings.RemoveAllFunctionality == true){
                        modifyClass.Remove(tab, active);
                        modifyClass.Remove(heading, active);
                        modifyClass.Remove(panel, active);
                        modifyClass.Remove(tab, visited);
                        modifyClass.Remove(heading, visited);
                        modifyClass.Remove(panel, visited);
						if(panel.parentNode.className.indexOf(cs_settings.ScrollBarWrapperClassName) != -1){ // if the panel is in a faux scroll area, set the scroll area's class name too
                            modifyClass.Remove(tab.parentNode, active);
                            modifyClass.Remove(heading.parentNode, active);
                            modifyClass.Remove(panel.parentNode, active);
                            modifyClass.Add(tab.parentNode, visited);
                            modifyClass.Add(heading.parentNode, visited);
                            modifyClass.Add(panel.parentNode, visited);
						}
					}
					else if(this == tab || this == heading){
                        modifyClass.Add(tab, active);
                        modifyClass.Add(heading, active);
                        modifyClass.Add(panel, active);
                        modifyClass.Remove(tab, visited);
                        modifyClass.Remove(heading, visited);
                        modifyClass.Remove(panel, visited);
                        if(panel.parentNode.className.indexOf(cs_settings.ScrollBarWrapperClassName) != -1){ // if the panel is in a faux scroll area, set the scroll area's class name too
                            modifyClass.Add(tab.parentNode, active);
                            modifyClass.Add(heading.parentNode, active);
                            modifyClass.Add(panel.parentNode, active);
                            modifyClass.Remove(tab.parentNode, visited);
                            modifyClass.Remove(heading.parentNode, visited);
                            modifyClass.Remove(panel.parentNode, visited);
                            customScrollBar.ComputeSizes(panel.parentNode);
                        }
                    }else{
                        modifyClass.Remove(tab, active);
                        modifyClass.Remove(heading, active);
                        modifyClass.Remove(panel, active);
                        modifyClass.Add(tab, visited);
                        modifyClass.Add(heading, visited);
                        modifyClass.Add(panel, visited);
                        if(panel.parentNode.className.indexOf(cs_settings.ScrollBarWrapperClassName) != -1){ // if the panel is in a faux scroll area, set the scroll area's class name too
                            modifyClass.Remove(tab.parentNode, active);
                            modifyClass.Remove(heading.parentNode, active);
                            modifyClass.Remove(panel.parentNode, active);
                            modifyClass.Add(tab.parentNode, visited);
                            modifyClass.Add(heading.parentNode, visited);
                            modifyClass.Add(panel.parentNode, visited);
                        }
                    }
                    // if the panel's height is larger than the defined fixed height AND the panel isn't already within a faux scrollbar (i.e. hasn't already been processed)
                    if(panel.offsetHeight > settings.Heights[panel.id] && panel.parentNode.className.indexOf(cs_settings.ScrollBarWrapperClassName) == -1){
                        customScrollBar.Bind([panel.id, settings.Heights[panel.id]]);               // bind the panel to a scrollbar (thus inserting it into a scrollbar wrapper)
                        customScrollBar.ComputeSizes(panel.parentNode);                             // compute the scrollbar's heights
                    }
                    // if no height is specified for the current panel, force its parent's height
                    if(settings.Heights[panel.id] == undefined){
                        //settings.ForceParentHeight(panel);
                    }
                }
                return false
            },
            
            
            ForceParentHeight : function(node){
                var newHeight =  node.offsetHeight + Gore.Config.ExclusiveShowHide.ForceParentHeightShim;
                var config = Gore.Config.ExclusiveShowHide;
                if(node.className.indexOf(config.ActivePanelClassName) != -1) node.parentNode.style.height = newHeight + "px"; // The 25 is an arbitrary number but seems to make things sit flush
            }
        },
        
        ShowHide : {
            Init : function(contentToToggleClassName){
                this.Parse(contentToToggleClassName);
            },
            
            Parse : function(nodeClass){
                var ULs = document.body.getElementsByTagName("ul");
                for(var i=0; i<ULs.length; i++){
                    if(ULs[i].className == nodeClass){
                        ULs[i].style.display = "none";
                        Gore.Utils.ID.GenerateID(ULs[i]);
                        
                        var tmpNode = ULs[i].previousSibling;
                        while(tmpNode.className != "toggle"){
                            tmpNode = tmpNode.previousSibling;
                        }
                        tmpNode.nodeToToggle = ULs[i].id;
                        tmpNode.onclick = this.ToggleDisplay;
                    }
                }
            },
            
            ToggleDisplay : function(){
                var nodeToToggle = document.getElementById(this.nodeToToggle);
                var settings = Gore.Config.ShowHide;
                var modifyClass = Gore.Utils.ClassName;
                
                if(this.className == settings.ToggleNodeClassName){
                    modifyClass.Add(this, settings.ToggleNodeOpenClassName);
                }else{
                    modifyClass.Remove(this, settings.ToggleNodeOpenClassName);
                }
                if(nodeToToggle.style.display == "none"){
                    nodeToToggle.style.display = "block";
                }else{
                    nodeToToggle.style.display = "none";
                }
            }
        },
        
        Flyout : {
            Stack : [],
            CompletelyOffAllFlyoutsTimeoutID : null, // Stores the TimeoutID for a Flyout that was just opened and needs to stay open until the mouse gets to it
            ClearOldFlyoutTimeoutID : null, // Stores the TimeoutID for a Flyout that was opened but the focus is no longer on it (i.e. currently on an item that has no flyout)
            ShowFlyoutTimeoutID : null, // Stores the TimeoutID for a Flyout that is about to be opened (if the mouse stays on it for a while)
                        
            Init : function(nodes){
                this.PrepNodes(nodes);
            },
            
            PrepNodes : function(rootUL){
                if(rootUL == undefined) return;
                var settings = Gore.Config.Flyout;
                var modifyClass = Gore.Utils.ClassName;
                
                var ULs = rootUL.getElementsByTagName("ul");
                var LIs = rootUL.getElementsByTagName("li");
                Gore.Utils.ID.AssignIDs(ULs);
                Gore.Utils.ID.AssignIDs(LIs);
                
                for(var i=0; i<LIs.length; i++){
                    var obj = LIs[i];
                    var processLI = true;
                    /*while(obj.parentNode){
                        if(obj.className == settings.ForceOpenClassName) processLI = false;
                        obj = obj.parentNode;
                    }
                    if(processLI){*/
                        if(LIs[i].getElementsByTagName("ul").length > 0){
                            LIs[i].style.position = "relative";
                            this.AddEllipsis(LIs[i]);
                            modifyClass.Add(LIs[i], settings.HasChildrenClassName);
                        }
                        LIs[i].onmouseover = this.Actions.Over;
                        LIs[i].onmouseout = this.Actions.Out;
                    //}
                }
            },
            
            AddEllipsis : function(node){
                var settings = Gore.Config.Flyout;
                var ellipsis = document.createTextNode(settings.Ellipsis);
                var span = document.createElement("span");
                span.appendChild(ellipsis);
                span.className = settings.EllipsisClassName;
                
                // element
                if(node.firstChild.nodeType == 1){
                    node.firstChild.insertBefore(span, node.firstChild.firstChild.nextSibling);
                }
                // #text
                else if(node.firstChild.nodeType == 3){
                    node.firstChild.nextSibling.insertBefore(span, node.firstChild.nextSibling.firstChild.nextSibling);
                }
            },
        
            
            Actions : {
                Over : function(e){
                    e = (!e) ? event : e;
                    e.cancelBubble = true;
                    if (e.stopPropagation) e.stopPropagation();
                    var settings = Gore.Config.Flyout;
                    var modifyClass = Gore.Utils.ClassName;
                    
                    modifyClass.Add(this.parentNode.parentNode, settings.HoverClassName);
                    modifyClass.Add(this, settings.HoverClassName);
                
                    var ul = this.getElementsByTagName("ul")[0];
                    var TimeoutIDs = Gore.Behaviours.Flyout;
                    
                    window.clearTimeout(TimeoutIDs.CompletelyOffAllFlyoutsTimeoutID);
                    window.clearTimeout(TimeoutIDs.ClearOldFlyoutTimeoutID);
                    window.clearTimeout(TimeoutIDs.ShowFlyoutTimeoutID);
                    
                    if(ul == undefined) {
                        TimeoutIDs.ClearOldFlyoutTimeoutID = window.setTimeout("Gore.Behaviours.Flyout.Actions.Rollup('"+this.id+"')", settings.ClearOldFlyoutDelay);
                        return;
                    }else{
                        TimeoutIDs.ShowFlyoutTimeoutID = window.setTimeout("Gore.Behaviours.Flyout.Actions.Show('"+this.id+"')", settings.ShowFlyoutDelay);
                    }
                },
                
                Show : function(objID){
                    var obj = document.getElementById(objID);
                    var settings = Gore.Config.Flyout;
                    var stack = Gore.Behaviours.Flyout.Stack;
                    var actions = Gore.Behaviours.Flyout.Actions;
                    var ul = obj.getElementsByTagName("ul")[0];
                    
                    actions.Rollup(obj.id);
                    if(stack.join("").indexOf(ul.id) == -1) stack[stack.length] = ul.id;
                    
                    ul.style.position = "absolute";
                    ul.style.top = "0px";
                    ul.style.left = obj.offsetWidth + "px";
                    ul.style.zIndex = "1000";
                    ul.style.display = "block";
                    
                    if(document.all && document.getElementById(settings.IFrameIDPrefix + ul.id) != undefined){
                        document.getElementById(settings.IFrameIDPrefix + ul.id).style.display = "block";
                    }
                    else if(document.all){
                        var tmpIframe = document.createElement("iframe");
                        tmpIframe.style.position = "absolute";
                        tmpIframe.style.top = "0px";
                        tmpIframe.style.left = ul.offsetLeft + "px";
                        tmpIframe.style.height = ul.offsetHeight + "px";
                        tmpIframe.style.width = ul.offsetWidth + "px";
                        tmpIframe.frameBorder = 0;
                        tmpIframe.style.zIndex = "1";
                        tmpIframe.style.display = "block";
                        tmpIframe.id = settings.IFrameIDPrefix + ul.id;
                        ul.parentNode.insertBefore(tmpIframe, ul.nextSibling);
                    }
                },
                
                Out : function(e){
                    e = (!e) ? event : e;
                    e.cancelBubble = true;
                    if (e.stopPropagation) e.stopPropagation();
                    var settings = Gore.Config.Flyout;
                    var childULs = this.getElementsByTagName("ul");
                    if(childULs.length == 0 || childULs[0].style.display != "block") Gore.Utils.ClassName.Remove(this, settings.HoverClassName);
                    Gore.Behaviours.Flyout.CompletelyOffAllFlyoutsTimeoutID = window.setTimeout("Gore.Behaviours.Flyout.Actions.Rollup()", settings.CompletelyOffAllFlyoutsDelay);
                },
                
                Rollup : function(objID){
                    var settings = Gore.Config.Flyout;
                    var stack = Gore.Behaviours.Flyout.Stack;
                    var stackCopy = Gore.Behaviours.Flyout.Stack.slice();
                    var rollUpAll = false;
                    
                    if(objID){
                        var mouseObj = document.getElementById(objID);
                        var currentUL = (mouseObj) ? mouseObj.parentNode : null;
                        var currentULID = (currentUL) ? currentUL.id.toString() : null;
                        var currentChildUL = (mouseObj) ? mouseObj.getElementsByTagName("ul")[0] : null;
                        var currentChildULID = (currentChildUL != null) ? currentChildUL.id.toString() : null;
                    }else{
                        rollUpAll = true;
                    }
                    for(var i=stackCopy.length-1; i>-1; i--){
                        if(rollUpAll != true && (stackCopy[i].toString() == currentULID || stackCopy[i].toString() == currentChildULID)){
                            break;
                        }else{
                            var ul = document.getElementById(stackCopy[i]);
                            Gore.Utils.ClassName.Remove(ul.parentNode, settings.HoverClassName);
                            if(document.all) document.getElementById("ifrm" + ul.id).style.display = "none";
                            ul.style.display = "none";
                            Gore.Behaviours.Flyout.Stack.length--;
                        }
                    }
                }
            }       
        }
    },
    
    Skin : {
        LastClicked : null,
        
        Init : function(selectBoxIDs){
            for(var i=0; i<selectBoxIDs.length; i++){
                this.SelectBox(selectBoxIDs[i]);
            }
        },
        
        SelectBox : function(selectBoxID){
            var selectBox = document.getElementById(selectBoxID);
            var settings = Gore.Config.Skin.SelectBox;
            var modifyClass = Gore.Utils.ClassName;
            
            if(selectBox == undefined) return;
            
            var ul = document.createElement("ul");
            ul.id = selectBox.id + settings.ULIDSuffix;
            ul.className = settings.ClosedClassName;
            var foundSelected = false;
            
            for(var i=0; i<selectBox.options.length; i++){
                var li = document.createElement("li");
                if(i == 0) modifyClass.Add(li, settings.FirstChildClassName);
                if(selectBox.options[i].selected){
                    modifyClass.Add(li, settings.SelectedClassName);
                    foundSelected = true;
                }
                li.selectBoxID = selectBox.id;
                li.idx = i;
                li.onclick = this.ChangeSelectedIndex;
                li.onmouseover = this.HoverClass.Add;
                li.onmouseout = this.HoverClass.Remove;
                var txt = document.createTextNode(selectBox.options[i].text);
                li.appendChild(txt);
                ul.appendChild(li);
            }
            if(!foundSelected){
            	modifyClass.Add(ul.childNodes[0], settings.SelectedClassName);
            }
            selectBox.parentNode.insertBefore(ul, selectBox.nextSibling);
            selectBox.parentNode.style.zIndex = settings.ZIndexStart--;
            selectBox.style.display = "none";
        },
        
        HoverClass : {
            Add : function(){
                Gore.Utils.ClassName.Add(this, Gore.Config.Skin.SelectBox.HoverClassName)
            },
            Remove : function(){
                Gore.Utils.ClassName.Remove(this, Gore.Config.Skin.SelectBox.HoverClassName)
            }
        },
        
        ChangeSelectedIndex : function(e){
            e = (!e) ? event : e;
            var settings = Gore.Config.Skin.SelectBox;
            var modifyClass = Gore.Utils.ClassName;
            var lastClicked = Gore.Skin.LastClicked;
            
            if(this.className.indexOf(settings.SelectedClassName) != -1){
                if(this.parentNode.className == settings.ClosedClassName){
                    modifyClass.Remove(this.parentNode, settings.ClosedClassName);
                    modifyClass.Add(this.parentNode, settings.OpenedClassName);
                    if(lastClicked != null && lastClicked != this){
                        modifyClass.Remove(lastClicked.parentNode, settings.OpenedClassName);
                        modifyClass.Add(lastClicked.parentNode, settings.ClosedClassName);
                    }
                }else{
                    modifyClass.Remove(this.parentNode, settings.OpenedClassName);
                    modifyClass.Add(this.parentNode, settings.ClosedClassName);
                    if(lastClicked != null && lastClicked != this){
                        modifyClass.Remove(lastClicked.parentNode, settings.ClosedClassName);
                        modifyClass.Add(lastClicked.parentNode, settings.OpenedClassName);
                    }
                }
            }else{
                modifyClass.Remove(this.parentNode, settings.OpenedClassName);
                modifyClass.Add(this.parentNode, settings.ClosedClassName);
            }
            
            var LIs = this.parentNode.getElementsByTagName("li");
            for(var i=0; i<LIs.length; i++){
                if(LIs[i].idx != this.idx){
                    modifyClass.Remove(LIs[i], settings.SelectedClassName);
                }else{
                    modifyClass.Add(LIs[i], settings.SelectedClassName);
                }
            }
            
            var selectBox = document.getElementById(this.selectBoxID);
            selectBox.selectedIndex = this.idx;
            
            Gore.Skin.LastClicked = this;
            // START: Jeffrey B Hougentogler
            // Only run these events if the class is already set to OpenedClassName 
            //  i.e. - The user can see the choices 
            if(this.parentNode.className.indexOf(settings.ClosedClassName) != -1){ 
                    eval(selectBox.getAttribute("onchange")); 
                    if (document.all) { 
                            selectBox.fireEvent("onchange"); 
                    } 
            } 
            // END: Jeffrey B Hougentogler
        }
    },
    
    FormFunctions : {
        ApplyFilter : function(){
        }
    },
    
    Utils : {
        ID : {
            IDCounter : 0,
            AssignIDs : function(nodeset){
                for(var i=0; i<nodeset.length; i++){
                    this.GenerateID(nodeset[i]);
                }
            },
            
            GenerateID : function(node){
                if(node.id.length == 0) node.id = Gore.Config.Utils.GenerateIDPrefix + this.IDCounter++;
            }
        },
        
        ClassName : {
        /*
         * The Add() and Remove() methods ensure the safe handling of class names without
         * the risk of overwriting existing class names during the assignation/removal process
         */
            Add : function(obj, str){
                if(obj.className.indexOf(str) != -1) return
                var space = (obj.className.length == 0) ? "" : " ";
                obj.className += space + str;
            },
            Remove : function(obj, str){
                obj.className = obj.className.replace(str, "");
                obj.className = obj.className.replace("  ", " "); // get rid of double spaces
                obj.className = obj.className.replace(/^\s*|\s*$/g,""); // trim extra start or end spaces
            }
        },
        
        GetXY : function(obj){
            xy = [0,0];
            while(obj.offsetParent){
                xy[0] += obj.offsetLeft;
                xy[1] += obj.offsetTop;
                obj = obj.offsetParent;
            }
            return xy
        }
    }
}

/**
 * Namespaces for page level variables and functions
 */
Gore.local = Gore.local || {};
Gore.local.vars = Gore.local.vars || {};

/**
 * Binds itself to an iframe and turns it into a fully funcitonal "technology
 * widget"
 * 
 * @constructor
 * @param {String/Ref} ifrm   The ID/ref that points to the iframe element that
 *                            is to be used by the widget code
 * @param {Object} userConfig A JSON object that contains user configurable 
 *                            parameters for the widget:
 *                            {Int}         defaultHeight  The height for the widget should iframe content height not be determinable
 *                            {Float}       animSpeed      Number of seconds to take for the expand/retract animation
 *                            {Bool}        startOpen      Whether or not the iframe first renders open or closed (defaults to closed)
 *                            {Object}      toggleButton   A JSON object containing the ID of where to place the toggle button as well as showLabel and hideLabel strings for the toggle button messages
 *                            {Object}      hideButton    A JSON object containing the ID of where to place the close button as well as a label string for the close button message
 */
Gore.Behaviours.TechnologyWidget = function(ifrm, userConfig){
	// Set initial values
	this.userConfig = userConfig || {}; // make sure this.userConfig object exists
	this.ifrm = YAHOO.util.Dom.get(ifrm);
	this.startOpen = !!(userConfig.startOpen); // if undefined, falsey or false then value = false
	this.resizeHeight = (this.startOpen) ? this.getHeight() : 0;
	this.firstLoad = false; // first content has yet to be loaded into iframe

	// Create Toggle Button
	if(this.userConfig.toggleButton && this.userConfig.toggleButton.id){
		this.toggleButtonHolder = YAHOO.util.Dom.get(this.userConfig.toggleButton.id);
		this.toggleShowLabel = this.userConfig.toggleButton.showLabel || "Show technology window";
		this.toggleHideLabel = this.userConfig.toggleButton.hideLabel || "Hide";
		
		this.toggleButton = document.createElement("span");
		var initialToggleLabel = (this.resizeHeight === 0) ? this.toggleShowLabel : this.toggleHideLabel;
		this.toggleButton.appendChild(document.createTextNode(initialToggleLabel));
		YAHOO.util.Event.addListener(this.toggleButtonHolder, "click", this.toggle, this, true);
	}
	
	// Create Close Button
	if(this.userConfig.hideButton && this.userConfig.hideButton.id){
		this.hideButtonHolder = YAHOO.util.Dom.get(this.userConfig.hideButton.id);
		this.hideLabel = this.userConfig.hideButton.label || "Close Window";
		
		this.hideButton = document.createElement("span");
		this.hideButton.appendChild(document.createTextNode(this.hideLabel));
		YAHOO.util.Event.addListener(this.hideButton, "click", this.hide, this, true);
	}
}

Gore.Behaviours.TechnologyWidget.prototype.render = function(){
	/* 1. Clone iframe from DOM
	 * 2. Remove iframe from DOM
	 * 3. Add scrolling="no" attribute to cloned iframe
	 * 4. Insert clone into DOM
	 * This is the only way IE will recognize the new iframe attribute */
	var copyIfrm = this.ifrm.cloneNode(true);
	var insertPoint = this.ifrm.nextSibling;
	this.ifrm.parentNode.removeChild(this.ifrm);
	copyIfrm.setAttribute("scrolling", "no");
	insertPoint.parentNode.insertBefore(copyIfrm, insertPoint);
	
	// Reset this.ifrm reference
	this.ifrm = YAHOO.util.Dom.get(copyIfrm.id);
	
	// Create Yahoo! animation object with initial values	
	this.anim = new YAHOO.util.Anim(this.ifrm, {height:{to:this.resizeHeight}}, (this.userConfig.animSpeed || 0.5), YAHOO.util.Easing.easeOut); 
	this.anim.onStart.subscribe(this.buttonStates, this, true);
	
	// Bind iframe onload event with iframe resize method
	YAHOO.util.Event.addListener(this.ifrm, "load", this.newContentLoaded, this, true);
	
	if(this.toggleButtonHolder && this.toggleButton) this.toggleButtonHolder.appendChild(this.toggleButton);
	if(this.hideButtonHolder && this.hideButton) this.hideButtonHolder.appendChild(this.hideButton);
	this.resize();
}

Gore.Behaviours.TechnologyWidget.prototype.toggle = function(){
	this.resizeHeight = (this.resizeHeight != 0) ? 0 : this.getHeight();
	this.resize();
}

Gore.Behaviours.TechnologyWidget.prototype.hide = function(){
	this.resizeHeight = 0;
	this.resize();
}

Gore.Behaviours.TechnologyWidget.prototype.buttonStates = function(){
	// Alternate toggleButton text based on iframe visibility
	if(this.toggleButtonHolder && this.toggleButton){
		this.toggleButton.innerHTML = "";
		if(this.resizeHeight === 0){
			this.toggleButton.appendChild(document.createTextNode(this.toggleShowLabel));
			Gore.Utils.ClassName.Remove(this.toggleButtonHolder, this.userConfig.toggleButton.hideClass);
			Gore.Utils.ClassName.Add(this.toggleButtonHolder, this.userConfig.toggleButton.showClass);
		}else{
			this.toggleButton.appendChild(document.createTextNode(this.toggleHideLabel));
			Gore.Utils.ClassName.Remove(this.toggleButtonHolder, this.userConfig.toggleButton.showClass);
			Gore.Utils.ClassName.Add(this.toggleButtonHolder, this.userConfig.toggleButton.hideClass);
		}
	}
	
	// Show or hide the hideButton based on iframe visibility
	if(this.hideButtonHolder && this.hideButton){
		if(this.resizeHeight === 0){
			this.hideButtonHolder.style.display = "none";
		}else{
			this.hideButtonHolder.style.display = "block";
		}
	}
}

Gore.Behaviours.TechnologyWidget.prototype.newContentLoaded = function(){
	if(this.firstLoad === true){
		this.resizeHeight = this.getHeight();
		this.resize();
	}else{
		this.firstLoad = true;
	}
}

Gore.Behaviours.TechnologyWidget.prototype.getHeight = function(){
	/**
	 * Both Safari and Firefox return a value for offsetHeight but Safari's value is 0
	 * IE doesn't return a value on offsetHeight, both it and Safari return the right value
	 * for scrollHeight. scrollHeight only sometimes works in Firefox which is why we're
	 * buidling the following routine in such an elaborate way.
	 */
	var offsetHeight, scrollHeight, returnHeight;
	
	// Assign offsetHeight for both Firefox and Safari, value will be 0 for Safari
	if (this.ifrm.contentDocument) {
		offsetHeight = this.ifrm.contentDocument.documentElement.offsetHeight;
		returnHeight = offsetHeight;
		if (offsetHeight == 0) {
			returnHeight = this.ifrm.contentDocument.documentElement.scrollHeight;
		}
	} else if (this.ifrm.contentWindow) { // Assign scrollHeight to IE
		returnHeight = this.ifrm.contentWindow.document.documentElement.scrollHeight;
	}
	return returnHeight;
}

Gore.Behaviours.TechnologyWidget.prototype.resize = function(){	
	this.anim.attributes.height = { to: this.resizeHeight }; 
	this.anim.animate();
}

// Set up Panels
Gore.Behaviours.initPanels = function(toggleClassName){
	var toggles = YAHOO.util.Dom.getElementsByClassName(toggleClassName || "panelToggle");
	if(toggles){
		for(var i=toggles.length-1; i>=0; i--){
			Gore.local.panels = [];
			var panelId = toggles[i].href.substring(toggles[i].href.indexOf("#")+1);
			Gore.local.panels[i] = new YAHOO.widget.Panel(panelId, {
				width:"460px",
				underlay:"none",
				close:true,  
				visible:false,  
				draggable:false,
				modal:true,
			    fixedcenter: true,  
				constraintoviewport: true
			});
			Gore.local.panels[i].setHeader(panelId);
			Gore.local.panels[i].render(document.body);
			
			YAHOO.util.Event.addListener(toggles[i], "click", function(e, obj){
				obj.show();
				YAHOO.util.Event.preventDefault(e);
			}, Gore.local.panels[i]);
		}
	}
}
