String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
};
YAHOO.namespace("mastop");
YAHOO.mastop.Video = function(){
    var yud = YAHOO.util.Dom;
    var yue = YAHOO.util.Event;
    var dialog = YAHOO.My.UI.Dialog;

    return {
        init: function(){
            yue.onDOMReady(this.loadVideo, this, true);
        },
        loadVideo: function(){
            yue.on("videoDiv", "click", this.videoClick, null, true);
            yue.on("videoDiv", "mouseover", function(){yud.get('vidPlay').style.backgroundPosition="bottom";}, null, true);
            yue.on("videoDiv", "mouseout", function(){yud.get('vidPlay').style.backgroundPosition="top";}, null, true);
        },
        writeVideo: function(code){
            var oConfig = {};
            if(code){
                oConfig = {
                    width: (swfWidth+30),
                    height: (swfHeight+30),
                    resize: false,
                    buttonText: 'Fechar',
                    html: '<div id="videoBox"><p>Para ver este vídeo você precisa instalar o <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=BrazilianPortuguese" target="_blank">Flash Player</a>.</p></div>'
                };
                var oResult = dialog.modal(oConfig);
                var theFLV = new SWFObject(swfURL+'/'+code, "myMovie", swfWidth, swfHeight+25, "9", "#000");
                theFLV.addParam("allowFullScreen", "true");
                theFLV.addVariable("newWidth", swfWidth);
                theFLV.addVariable("newHeight", swfHeight+25);
                theFLV.addVariable("autoStart", "true");
                theFLV.write("videoBox");
            }
            return true;
        },
        videoClick: function(e){
            YAHOO.mastop.Video.writeVideo(videoCode);
        }
    };
}();
YAHOO.mastop.Video.init();
