(function(){
    var player = {
        panel:null,
        init:function(){
            var tigger = yuiDom.get("playFlashVideo");
            yuiEvent.addListener(tigger,"click",this.loadPlayerBridge);
        },
        loadPlayer:function(){
            var videoURL = yuiDom.get("playFlashVideo").href;
            if (!this.panel){
                var flashPlayerPanel = document.createElement("div");
                flashPlayerPanel.id = "flashPlayerPanel";

                this.panel = new YAHOO.widget.Panel(flashPlayerPanel,{
                    close:false,
                    visible:false,
                    modal:true,
                    underlay:"none",
                    constraintoviewport:true,
                    fixedcenter: true,
                    zIndex:1030
                });
                this.panel.hideEvent.subscribe(function(){
                    var flashMovieContainer = yuiDom.get("flashmovie");
                    flashMovieContainer.innerHTML = "";
                });
                var flashPlayerClose = yuiDom.get("flashPlayerClose");

                yuiEvent.addListener(flashPlayerClose,"click",function(){
                    player.panel.hide();

                });
                var playerPopupContainer = yuiDom.get("playerPopupContainer");

                this.panel.setBody(playerPopupContainer);
                this.panel.render(document.body);
                yuiDom.setStyle(playerPopupContainer,"display","block");
            }

            this.panel.show();
            this.playMovie(videoURL);
        },
        playMovie:function(videoURL){
            var swfObj = new SWFObject("/whotels/happenings/news/flv_player.swf", "player", "320", "240", "8,0,0,0", "#ffffff");
            swfObj.addVariable("xContentPath",videoURL);
            swfObj.addParam("allowScriptAccess","sameDomain");
            swfObj.addParam("wmode","Opaque");
            // swfObj.setAttribute("redirectUrl","/whotels/index.html?type=nonflash");
            swfObj.write("flashmovie");
        },
        loadPlayerBridge:function(e){
            yuiEvent.preventDefault(e);
            player.loadPlayer();
        }
    };
    SW.local.flPlayerHighlight = player;
    yuiEvent.onDOMReady(player.init,player,true);

})();
