SW.domWidget.add({
    id:"topNavHighlight",
    load:function() {
        if (yuiDom.get("topNavigation")) {
            this.isSupported = true;
            this.setup();
        }
    },
    setup:function(root) {
        var self = this;
        if (self.isSupported) {
            yuiDom.getElementsByClassName("dhtmlSelect", "div", "topNavigation",
                    function(container) {
                        var config = {
                            container:container,
                            trigger:yuiDom.getElementsByClassName("dhtmlSelectTrigger", null, container)[0]
                        };
                        SW.domWidget.dhtmlSelect.setConfig([config.trigger,config.container], config);
                        // show/hide top navigation drop-downs
                        yuiEvent.addListener(container, "mouseover", SW.domWidget.dhtmlSelect.showBridge);
                        yuiEvent.addListener(container, "mouseout", SW.domWidget.dhtmlSelect.hideBridge);
                        // hide/show select boxes in find & replace form 
                        /*yuiEvent.addListener(container, "mouseover", self.showSelect);
                        yuiEvent.addListener(container, "mouseout", self.hideSelect);*/
                        /*Commented the above code, because it hides the dropdowns on the page when language dropdown opens*/
                    });
        }
    },
    showSelect:function() {
        yuiDom.addClass(yuiDom.get("findReserveModule"), "hideFindReserveSelect");
    },
    hideSelect:function() {
        yuiDom.removeClass(yuiDom.get("findReserveModule"), "hideFindReserveSelect");
    }
});

SW.domWidget.add({
  id:"sIFRManager",
    /* every param in config is required */
    selectors: [{
                    sSelector: "h1",
                    sFlashSrc:"/luxury/sIFR/chalet.swf",
                    sColor:"#3A2117",
                    sLinkColor:"#8c8c8c",
                    sBgColor:"#FFFFFF",
                    sHoverColor: "#3A2117",
                    sFlashVars:"textalign=left&offsetTop=0",
                    sWmode: "transparent"
                },
                {
                    sSelector: "#standardView h2",
                    sFlashSrc:"/luxury/sIFR/chalet.swf",
                    sColor:"#3A2117",
                    sLinkColor:"#8c8c8c",
                    sBgColor:"#FFFFFF",
                    sHoverColor: "#3A2117",
                    sFlashVars:"textalign=left&offsetTop=0",
                    sWmode: "transparent"
                },
                {
                    sSelector: "#layoutSecondary #enrollNowContainer h2",
                    sFlashSrc:"/luxury/sIFR/chalet.swf",
                    sColor:"#704738",
                    sFlashVars:"textalign=left&offsetTop=0",
                    sWmode: "transparent"
                },
                {
                    sSelector: "#next_txt h2",
                    sFlashSrc:"/luxury/sIFR/chalet.swf",
                    sColor:"#666666",
                    sBgColor:"#FFFFFF",
                    sFlashVars:"textalign=left&offsetTop=0",
                    sWmode: "transparent"
                },
                {
                    sSelector: "#prev_txt h2",
                    sFlashSrc:"/luxury/sIFR/chalet.swf",
                    sColor:"#666666",
                    sBgColor:"#FFFFFF",
                    sFlashVars:"textalign=left&offsetTop=0",
                    sWmode: "transparent"
                },
                {
                    sSelector: "#socialMediaHeader h2",
                    sFlashSrc:"/luxury/sIFR/chalet.swf",
                    sColor:"#533D34",
                    sBgColor:"#FFFFFF",
                    sFlashVars:"textalign=left&offsetTop=0",
                    sWmode: "transparent"
                }
            ],
  initialize:function(config){
        this.selectors.push(config);
  },
  load:function(){
    // do load stuff, find elements and setup
    var locale = SW.tools.Cookie.get("LOCALECOOKIE");
    if(typeof sIFR == "function"){
        if(locale == "ja_JP" || locale == "zh_CN"){
            // this is a hack to remove main sifr class - due to sIFR.js containing sIFR.setup()
            yuiDom.getElementsByClassName("sIFR-hasFlash").forEach(function(el){
                yuiDom.removeClass(el,"sIFR-hasFlash");
            });
        }else{
            this.isSupported = true;
    //      sIFR.debug();
//            sIFR.setup();// DL: removed this call, as I do not think it is needed
          this.setup();
        }
    }
  },
  update:function(root){
    // do update stuff, find elements and setup. root element is passed in.
    if(self.isSupported){

        }
    },
    setup: function(root) {
        var self = this;
        if (self.isSupported) {
            self.selectors.forEach(function(config) {
                sIFR.replaceElement(named(config));
            });
        }
    }
});

SW.domWidget.dhtmlSelect.setEnabled(true);
SW.domWidget.toolTips.setEnabled(true);
SW.domWidget.inputLabels.setEnabled(true);
SW.domWidget.sIFRManager.setEnabled(true);
SW.domWidget.topNavHighlight.setEnabled(true);
SW.domWidget.bodyClickHandler.setEnabled(true);
