QoDesk.TellAFriend = Ext.extend(Ext.app.Module, {
	
	moduleType : 'form',  //appType
	moduleId : 'tell-a-friend-win',
	//submitUrl: Ext.BASE_URL+'/tellafriend/tellafriend',
	
    init : function(){
        this.launcher = {
        	menuText: 'Tell a Friend',
            iconCls: 'menu-icon-tellaf',
            handler : this.createWindow,
            scope: this,
			shortcutIconCls: 'tell-new',
            text: 'Tell a Friend',
            tooltip: '<b>Tell a Friend</b><br />Tell about the site to your friends.'
        }
    },

    createWindow : function(){
		var ot = (typeof this[0] != "undefined") ? this[0] : this;
   		var desktop = ot.app.getDesktop();
    //	var desktop = this.app.getDesktop();
      var win = desktop.getWindow('tell-a-friend-win');
        
      if(!win){
				var form;
				var formPanel = new Ext.form.FormPanel({
					/*baseCls: 'x-plain',*/
					labelWidth: 55,
					frame: true,
					defaultType: 'textfield',	
					items: [{
						fieldLabel: 'From',
						name: 'from_name',
						allowBlank:false ,
						anchor:'95%'  // anchor width by percentage
					},{
						fieldLabel: 'To',
						name: 'to',
						allowBlank:false,
						anchor: '95%'  // anchor width by percentage
					}, {
						xtype: 'textarea',
						hideLabel: true,
						allowBlank:false,
						value: 'You need to check out this new concept in the web called HAM-IT.Its first of its kind and it addresses many of the issues we always wanted the web to address. I wont spoil the surprise just take a look and experience the world of HAM-IT.             http://www.ham-it.com' ,
						name: 'message',
						anchor: '100% -53'  // anchor width by percentage and height by raw adjustment
					}],					
					region: 'south',					
					url:Ext.BASE_URL+'/tellafriend/tellafriend' // this.submitUrl
				});
				
				form = formPanel.getForm();			
				win = new Ext.Window({
					title: 'Tell a Friend',
					id : 'tell-a-friend-win',
					width: 500,
					height:300,
				//	minWidth: 300,
				//	minHeight: 200,
					resize :false,
					layout: 'fit',
					modal: true,
					iconCls: 'menu-icon-tellaf',
					animCollapse:false,
					constrainHeader:true,
					minimizable:false,
    				maximizable:false,					
					bodyStyle:'padding:0px;',
					buttonAlign:'center',
					items: formPanel,
					buttons: [{
						handler: function(){
							form.submit({
									waitMsg: 'Please Wait...',
									reset:true,
									success:this.Success,
									failure:this.Failure,
									scope:this
							});
						},
						scope:this,
						text: 'Send'
					}]
				});
	 }
	  win.on('show', function() {
					//Ext.getCmp('from_name').focus();
				}, null, {delay: 20}); 
	  win.show();  
      
    },		
		Success: function(f,a){
		
			Ext.MessageBox.alert('Success', 'Mail successfully send.');
			/*
			if(a && a.result){
				var path = window.location.pathname,
					path = path.substring(0, path.lastIndexOf('/') + 1);
					
				set_cookie(Ext.COOKIE_PREFIX+'memberName', a.result.name, '', path, '', '' );
				window.location = path;				
			}
		 */		  
		}
		/*
		,
		Failure: function(f,a){
		if(typeof a != 'undefined') {
			var rt = Ext.util.JSON.decode(a.responseText);
				if(rt.errors[0].id == 'to'){
					Ext.Msg.alert('Error', rt.errors[0].msg);
				}
			}
		}
		*/
});

/*
Ext.BasicForm.prototype.afterAction=function(action, success){
	this.activeAction = null;
	var o = action.options;
	var ar = action.response
	if(o.waitMsg){
		Ext.MessageBox.updateProgress(1);
		Ext.MessageBox.hide();
	}
	if(success){
		if(o.reset){
			this.reset();
		}
		Ext.callback(o.success, o.scope, [this, action]);
		this.fireEvent('actioncompleted', this, action);
	}else{
		if(typeof ar != 'undefined') {
			var rt = Ext.util.JSON.decode(ar.responseText);
			if(rt.errors[0].id == 'to'){
				Ext.Msg.alert('Error', rt.errors[0].msg);
			}
		}
		Ext.callback(o.failure, o.scope, [this, action]);
		this.fireEvent('actionfailed', this, action);
	}
}
*/
//Ext.onReady(TellaFriend.Init, TellaFriend, true);
