/*
 * Vroomtrap
 * Copyright(c) 2008, Nubesoft, LLC.
 */
Ext.namespace('Ext.welcomewindow');
Ext.welcomewindow.welcomewindow = function(){
  var welcomeWin;
  return {
     openWelcomeWindow: function(messageDate) {
       welcomeWin = new Ext.Window({
         title    : 'Welcome to Vroomtrap',
         closable : true,
         closeAction: 'close',
         draggable: false,
         resizable: false,
         modal    : true,
         width    : 660,
         height   : 425,
         plain    : true,
         layout   : 'border',
         items    : [
         new Ext.Panel({
           region      : 'center',
           collapsible : false,
           bodyStyle   :'padding:0px 0px 0px 0px',
           id          : 'welcomePanel',
           html  : '<iframe width="644" height="355" align="left" scrolling="no" frameborder="0" src="/welcome/'+messageDate+'"/>',
       
           buttons: [{
             text   : 'Watch Getting Started Video',
             handler: function(){
               welcomeWin.close();
               Ext.videowindow.videowindow.openVideoWindow(0);
             }
           },{
             text   : 'Create Account',
             handler: function(){
               welcomeWin.close();
               Ext.Ajax.request({
               	url : 'proxy' , 
               	params : { v : 'login' },
               	method: 'GET',
               	success: function ( result, request ) { 
               	  data = Ext.util.JSON.decode(result.responseText);
               		location.replace(data.login);
               	},
               	failure: function ( result, request) { 
               		Ext.MessageBox.alert('Failed', result.responseText); 
               	} 
               });
             }
           },{
             text   : 'Mobile Software Downloads',
             handler: function(){
               welcomeWin.close();
               nubesoft.google.Vroomtrap.addTab("downloads");
             }
           },{
             text   : 'Close',
             handler: function(){
               welcomeWin.close();
             }
           },{
             text   : 'Close Forever',
             handler: function(){
               Ext.Ajax.request({
               	url : 'proxy' , 
               	params : { v : 'dswa' },
               	method: 'GET',
               	success: function ( result, request ) { 
              	  message = result.responseText.split(":")
              	  Ext.popup.msg(message[0], message[1]);
               	},
               	failure: function ( result, request) { 
               		Ext.MessageBox.alert('Failed', result.responseText); 
               	} 
               });
               welcomeWin.close();
             }
           }]
         })
         ]
       });

       welcomeWin.show();
       welcomeWin.center();
     },
     init : function() {}
  }
}();

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