
/**
 * file Starter.js with user shortcut
 * @author Janusz Rygał
 * @date 1.04.2009
 */
Ext.namespace("Wpi.oms");

Starters = function(){
    this.items = null;
    
    this.init = function(){
        var iter = 0;
        this.items = new Array(3);

       var elem = null;
        
       this.items[0] = new Starter(0,'application.png', 'Minimizer');
       this.items[0].createStarter();
       elem = Ext.get('starter_0');
        elem.on('click', function(bl, el){
              var desktop = context.menu.programs.app.getDesktop();
              desktop.minimizeAll();
        });

       this.items[1] = new Starter(1,'user_comment.png', 'Communicator');
       this.items[1].createStarter();
       elem = Ext.get('starter_1');
        elem.on('click', function(bl, el){
              context.communicator.createCommunictorWindow();
        });

       //this.items[1] = new Starter(1,'wrench_orange.png', 'Communicator');
       //this.items[1].createStarter();
    }
    
}

/**
 * @class Starter
 * shortcut class
 */
Starter = function( id_ , image_url_, text_){ 

        this.id       = id_; 
        this.imageUrl = image_url_;
        this.text     = text_;
        this.x        = 0;
        this.y        = 0;
		
		/**
		 * method to create starter
		 */
 		this.createStarter = function(){ 

                var iconWidth = 16;

                /*
                var count = 0;
                for(var i=0; context.starters.items.length(); ++i){
                    if(context.starters.items[i] != null){
                        count++;
                    }
                }
                */
                var marginLeft = 25 + (this.id*25);
                var marginTop =  2;
                if(this.id > 0)
                    marginTop = -16;

 				this.panel = new Ext.Panel({
 							width: iconWidth,
 							height: 16,
 							draggable: true,
 							renderTo: 'small-menu',
                            width: 16,
 							style: 'float: left; margin-left: '+marginLeft+'px; margin-top: '+marginTop+'px;',
 							id:  'starter_'+this.id,
 							text: this.text,
 							items:[
 									new Ext.Panel({
 											width: iconWidth,
                                            autoShow: true,
 											shadow: false,
 											height: 16,
 											bodyStyle: "float: left; background-color: transparent;  cursor: pointer;",
 											border: false,
 											html: "<div style='float: left;'><img src='/../../imc/images/omsImages/main/icons/"+this.imageUrl+"' ></img></div>"
 										})	
 								  ],
 							bodyStyle: "float: left;   background-color: transparent; ",
 							shadow: false,
 							border: false
 						});	
 			   			
 			   this.panel.show();
 			  /*
 			  elem = Ext.get('starter_'+this.id);
 			  if(this.type == 'STANDARD'){
		 			  elem.on('dblclick', function(bl, el){
		 			  				tmpArray = this.id.split('_-_');
		 			  				this.windowId = tmpArray[1]; 
		 			  				this.shid    = tmpArray[tmpArray.length - 1];
		 			  				this.url  	 = tmpArray[tmpArray.length - 2];	
		 			  				this.winText = tmpArray[tmpArray.length - 3];
		 			  				this.type    = 'standard';
		 			  		 		context.menu.programs.openProgramWindow(this);
		 			  		 });
		 	 }
		 	 else{
		 	 		elem.on('dblclick', function(bl, el){
		 	 				tmpArray = this.id.split('_-_');
		 			  		this.windowId = tmpArray[1]; 
		 			  		this.shid    = tmpArray[tmpArray.length - 1];
		 			  		this.url  	 = tmpArray[tmpArray.length - 2];	
		 			  		this.winText = tmpArray[tmpArray.length - 3];
		 			  		this.type    = 'ajax'; 
		 	 				var arr = this.url.split('/');
		 	 				context.applyModule(this, false);
		 	 				//alert(arr[0]+'-----'+arr[1]);
		 	 		});
		 	 }*/
 		}
 		
 		
 }

