/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

	var sigo_id = 1;

	// Create these explicitly so we can manipulate them later
    var wordCount = new Ext.Toolbar.TextItem('Words: 0');
    var charCount = new Ext.Toolbar.TextItem('Chars: 0');

	var logo_form = new Ext.FormPanel({
        id: 'logo_form',  
       	region: 'center',
        labelAlign: 'top',
        frame:true,
        autoScroll: true,
		url: location.href,
        bodyStyle:'padding:5px 5px 0',
        width: 100,
        height: 140,
        items: [{
            xtype:'textfield',
            fieldLabel: 'Name',
            name: 'sigo_name',
            anchor:'95%'
        },{
            xtype:'textfield',
            fieldLabel: 'Slogan',
            name: 'sigo_slogan',
            anchor:'95%'
        }],
         // inline buttons
		buttons: [{
	        text: 'Save', 
	        handler: function() {
	            // check form value 
	            if (logo_form.getForm().isValid()) {
	 		        logo_form.getForm().submit({
						params: {sigo_id:1,sigo_delete:0,cmd:'save',edit_logo:1},
			            //waitMsg:'In processing',
			            failure: function(form, action) {
						    Ext.MessageBox.alert('Error Message', action.result.errorInfo);
						},
						success: function(form, action) {
						    //Ext.MessageBox.alert('Confirm', action.result.info);
						    logo_window.hide();
						    location=location.href;
						}
			        });                   
	            } else{
					Ext.MessageBox.alert('Errors', 'Please fix the errors noted.');
				}             
	        }
	    },{
	        text: 'Cancel',
	        //handler: function(){window.hide();}
	        handler: function()
	        {
	        	logo_window.hide();
	        	location=location.href;
	        }
	    }]
    });

/*
 * ================  BorderLayout config  =======================
 */

    // define window and show it in desktop
    var logo_window = new Ext.Window({
        title: 'Edit Name and Tagline',
        width: 200,
        height:200,
        animate:true,
        frame: true,
        //minHeight: 250,
        layout: 'border',
        plain:true,
        closeAction:'hide',
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        id:'logo_window',
    	items:[logo_form]
    });
	//////////////////////////////
	 	logo_window.show(); 
		logo_window.hide();
	//////////////////////////////
});
		
function show_logo_window()
{
 	Ext.getCmp("logo_window").show(); 
	Ext.getCmp("logo_form").load({
			url:location.href,
			failure:function(){Ext.getCmp("logo_form").getForm().reset();},
			method: 'post',
			params: {sigo_id:1,cmd:'load',edit_logo:1}
		});	
};
