/**
 * file Setting.js with Setting class
 * @author Janusz Rygał
 * @date 22.09.2008 
 */

/**
 * @class Help to create help window and problems report module
 * Help class
 */
 Help = function(){
	/**problems panel*/
	this.problemsPanel;
	/**screen form*/
	this.problemsForm;
	/**tutorial panel*/
	this.tutorialPanel;
	/**tab panel*/
	this.tabPanel;
	/**settings window*/
	this.window;
	
	/**
	 * method to create problems form
	 */
	this.createProblemsForm = function(){
		 this.problemsForm  = new Ext.FormPanel({
											labelWidth: 50,
											url:project_url + 'SaveProblem',
											id: 'saveProblemForm',
											name:'saveProblemForm', 
											frame:true,
											disabled: false,
											draggable: false,
											style:'margin: 0 auto;',
											bodyStyle:'padding:5px 5px 0;',
											width: 580,
											autoHeight: true,
											defaults: {width: 430},
											defaultType: 'textfield',
											buttons: [{
														text: context.translator.translate('save'),
														disabled:false,
														handler: function(){
																	if (Ext.ComponentMgr.get('saveProblemForm').getForm().isValid()) {
																		Ext.ComponentMgr.get('saveProblemForm').getForm().submit({
																			url:project_url + 'SaveProblem', 
																			waitMsg:'Saving Data...',														        	
																			success: function(form, action) {	
																					 	
																					 },
										                                	failure: function(form, action) {		
																					Ext.Msg.alert('OMS',"Error occured while sending error information !");
										                                	}							        	
																		});																
																	}
																}
													 }]
							});
			
			
							  					
            problemArea =  new Ext.form.TextArea({
						     fieldLabel: context.translator.translate('problem'),
						     hiddenName:'problem',
						     name: 'problem_area',
						     id: 'problem_area',
						     height: 300,
						     typeAhead: true,
						     allowBlank:false
			           });     
			 this.problemsForm.add(problemArea);          
	} 
	
	/**
	 * method to initialize
	 */
	this.init = function(){
		this.createProblemsForm();
		
		var problemsText = new Ext.Panel({
							   autoHeight: true,			
						       html: "<div style='margin-top: 10px;'>"+'&nbsp&nbsp;&nbsp;'+context.translator.translate('problems_info')+"</div>"	
						     });
		
		this.problemsPanel = new Ext.Panel({
						                    region:'center',
											title: context.translator.translate('problems'),
						                    deferredRender:false,
						                    layout: 'fit',
						                    style: 'background: #FFFFFF;',
						                    id: 'problems_panel',
						                    activeTab:0,
						                    autoScroll:true,
						                    autoHeight: true,
						                    items: [
						                    	problemsText,	
						                    	this.problemsForm]  
						               });
		
		var tutorialsText = new Ext.Panel({
							   autoHeight: true,			
						       html: "<div style='margin-top: 10px;'>"+'&nbsp&nbsp;&nbsp;'+context.translator.translate('tutorial_construct')+"</div>"	
						     });
		
		this.tutorialPanel = new Ext.Panel({
						                    region:'center',
											title: context.translator.translate('tutorial'),
						                    deferredRender:false,
						                    layout: 'fit',
						                    style: 'background: #FFFFFF;',
						                    id: 'screen_settings',
						                    activeTab:0,
						                    autoScroll:true,
						                    autoHeight: true,
						                    items: [tutorialsText]
						               });
	
		this.tabPanel = new Ext.TabPanel({
		                    region:'center',
		                    deferredRender:false,
		                    id: 'main_tab_problems',
		                    activeTab:0,
		                    autoHeight: true,
		                    autoScroll:true,
		                    items: [this.problemsPanel,
		                    	    this.tutorialPanel]
		                });
	
		this.window = new Ext.Window({
							id: 'helpWindow',
						  	title: context.translator.translate('help'),
							autoHeight: true,
							//height: 600,
							autoScroll: true,
							resizable: false,
							closable: true,
							manager: null,
							listeners: null,
							modal: true,
							width:     550,
							iconCls: 'help',
							items: [this.tabPanel],
							shim:true,
							animCollapse:false,
							constrainHeader:true					  			
						  });
	}
	
	/**
	 * method to show problems window
	 */
	this.showProblemsWindow = function(){
		this.window.show();
	} 
	
	/**
	 * starting method
	 */
	this.start = function(){
		context.help.init();
		context.help.showProblemsWindow();
	} 
	 	
}