/*!
 * Ext JS Library 3.1.1
 * Copyright(c) 2006-2010 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
  Ext.BLANK_IMAGE_URL = 'http://www.cicana.com/public/view/libs/extjs/resources/images/black/s.gif';
        
                                    
function loadContact()
	{

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';
    
    var myData = 
    [ 
    	['General','General'],
    	['Payments','Payments'],
    	['Medias','Medias'],
    	['Membership','Membership']
	];

      // create the data store
    var store = new Ext.data.SimpleStore({
        fields: [
           	{name: 'theme'},{name: 'th'}	],
           	data: myData
    });

    // manually load local data
   // store.loadData(myData);

    
    
    
   var top = new Ext.FormPanel({
        labelAlign: 'top',
        frame:true,
        layout:'form',
        autoHeight: true,
        waitMsgTarget: true,
        standardSubmit: true,
        baseParams: {
            id: 1
        },
        formId :"form_contact",
        title: 'Contact Us',
        url:'send-contact.html',
        bodyStyle:'padding:5px 5px 0',
        width: 1000,
        items: [{
            layout:'column',
            items:[{
                columnWidth:.5,
                layout: 'form',
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'First Name',
                    name: 'first',
                    allowBlank:false,
                    anchor:'90%'
                }, {
                    xtype:'textfield',
                    fieldLabel: 'Company',
                    name: 'company',
                    anchor:'90%'
                },
                  new Ext.form.ComboBox({
                        fieldLabel: 'Subject',
                        id:'theme',
                        displayField:'theme',
                        typeAhead: true,
                        mode: 'local',
                        triggerAction: 'all',
                        emptyText:'Select a subject...',
                        store: store,
						//valueField:'abbr',
                        selectOnFocus:true,
                         allowBlank:false,
                       anchor:'90%'
                    })

                ]
            },{
                columnWidth:.5,
                layout: 'form',
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Last Name',
                    name: 'last',
                    allowBlank:false,
                    anchor:'90%'
                },{
                    xtype:'textfield',
                    fieldLabel: 'Email',
                    name: 'email',
                    allowBlank:false,
                    vtype:'email',
                    anchor:'90%'
                }]
            }]
        },{
            xtype:'htmleditor',
            id:'messagecontent',
            fieldLabel:'Message',
            allowBlank:false,
            height:200,
            anchor:'90%'
            
        }],

       buttons: [{
        text: 'Send',
        handler: function()
        {
         
        	var form = top.getForm();
                if (form.isValid()) {
            	  if (top.url) 
                        form.getEl().dom.action = form.url;

                // check if there are baseParams and if
                // hiddent items have been added already
                if (top.baseParams && !top.paramsAdded) {
                    // add hidden items for all baseParams
                    for (i in top.baseParams) {
                        top.add({
                            xtype: 'hidden',
                            name: i,
                            value: top.baseParams[i]
                        });
                    }
                    top.doLayout();
                    // set a custom flag to prevent re-adding
                    top.paramsAdded = true;
                     form.submit();
                }
                else {
                    Ext.MessageBox.alert('Errors', 'Please fill in fields before saving..');
                }

               
            }
        }
    }]

    });



    top.render(Ext.get('contact'));


   
}
