/*
 * Vroomtrap
 * Copyright(c) 2008, Nubesoft, LLC.
 */
Ext.namespace('Ext.videowindow');
Ext.videowindow.videowindow = function(){
  var videoWin;
  var videoWindowDisabled = true;
  var previousTitle = "";
  return {
    openVideoWindow: function(activeTab) {
      if (videoWindowDisabled) {
          videoWin = new Ext.Window({
            title    : 'Video',
            closable : true,
            draggable: false,
            resizable: false,
            width    : 744,
            height   : 620,
            plain    : true,
            layout   : 'border',
            items    : [
                new Ext.Panel({
                  region      : 'center',
                  split       : false,
                  width       : 468,
                  height      : 200,
                  buttonAlign : 'right',
                  collapsible : false,
                  margins     : '0 0 0 0',
                  cmargins    : '0 0 0 0',
                  bodyStyle   :'padding:0px 0px 0px 0px',
                  items: new Ext.TabPanel({
                    id              : 'videotabs',
                    resizeTabs      : true,
                    minTabWidth     : 115,
                    tabWidth        : 200,
                    enableTabScroll : true,
                    activeTab       : 0,
                    width           : 732,
                    height          : 553,
                    defaults        : {autoScroll:false},
                    items:[{
                      title : 'Website Getting Started',
                      html  : '<object width="727" height="434"><param name="movie" value="http://www.youtube.com/v/-PIjiRrUGpk&hl=en&fs=1&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-PIjiRrUGpk&hl=en&fs=1&color1=0x3a3a3a&color2=0x999999&hd=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="727" height="434"></embed></object>',
                      listeners : {
                        beforeshow : function(tabPanel) {
                            SWFAddress.setValue("/video/website-getting-started");
                            SWFAddress.setTitle(Trap.constants.siteTitle+"Website Getting Started Video");
                            SWFAddress.setHistory(false);
                        }
                      }
                    },{
                      title : 'iPhone Getting Started',
                      html  : '<object width="727" height="434"><param name="movie" value="http://www.youtube.com/v/bojSWemY_00&hl=en&fs=1&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bojSWemY_00&hl=en&fs=1&color1=0x3a3a3a&color2=0x999999&hd=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="727" height="434"></embed></object>',
                      listeners : {
                        beforeshow : function(tabPanel) {
                            SWFAddress.setValue("/video/iphone-getting-started");
                            SWFAddress.setTitle(Trap.constants.siteTitle+"iPhone Getting Started Video");
                            SWFAddress.setHistory(false);
                        }
                      }
                    }]
                  }),
                  buttons: [{
                    text    : 'Close',
                    handler : function(){
                      videoWin.close();
                    }
                  }]
                }),
                new Ext.Panel({
                  region      : 'south',
                  closeAction: 'hide',
                  split       : false,
                  width       : 728,
                  height      : 90,
                  collapsible : false,
                  margins     : '0 0 0 0',
                  cmargins    : '0 0 0 0',
                  bodyStyle   :'padding:0px 0px 0px 0px',
                  html        : '<iframe width="728px" height="90px" align="left" scrolling="no" frameborder="0" src="/ads/adblock728.html"/>'
                })
            ],
            listeners : {
              close : function(panel) {
                videoWindowDisabled = true;
                SWFAddress.back();
                SWFAddress.setTitle(previousTitle);
                SWFAddress.setHistory(true);
              }
            }
          });
          previousTitle = SWFAddress.getTitle();
          Ext.getCmp('videotabs').setActiveTab(activeTab);
          videoWin.show();
          videoWin.center();
          videoWindowDisabled = false;
        }
    },
    init : function() {}
  }
}();

Ext.onReady(Ext.videowindow.videowindow.init, Ext.videowindow.videowindow);