﻿// JScript File


Ext.onReady(function() {
    // Turn on Quick tips
	Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';
});


    // Enable quick tips
    //Ext.QuickTips.init();

UI.createResourcetForm = function(requestType){
  

  
  var formpanel = new Ext.FormPanel({

        id: 'ContacForm',
        url:'http://daytonyoga.com/KE/ResourcesFormProcess.aspx',
        frame: false,
        style: 'margin-left: 10px;margin-top:10px;',
        bodyStyle:'padding:2px 2px 2px 2px; border-color: #ffffff;',
        width: 480,
        items: [
                {
                    xtype:'fieldset',
                    id: 'contactFieldSet',
                    bodyStyle: "padding: 2px 2px 2px 2px;text-align: left;",
                    width: 450,
                    style: 'margin-left: 5px;margin-top:5px; text-align:right;', 
                    title: 'Your Contact Information and recomendation',
                    collapsible: false,
                    autoHeight:true,
                    defaults: {width: 300},
                    defaultType: 'textfield',
                    items :[
                            {
                            fieldLabel: 'Name',
                            id: 'name',
                            name: 'name',
                            allowBlank:false,
                            labelStyle: 'text-align:right'
                            },
                            {
                            fieldLabel: 'Email',
                            id: 'email',
                            name: 'email',
                            vtype:'email',
                            allowBlank:false,
                            labelStyle: 'text-align:right'
                            },
                            {
                            fieldLabel: 'Phone',
                            id: 'phone',
                            name: 'phone',
                            allowBlank:false,
                            labelStyle: 'text-align:right'
                            },
                            {
                            xtype:'textarea',
                            id: 'Recomendation',
                            name: 'Recomendation',
                            allowBlank:false,
                            fieldLabel:'Recomendation',
                            labelStyle: 'text-align:right',
                            height:150,
                            anchor:'98%'     
                            },
                            {
                            id: 'requestType',
                            name: 'requestType',
                            allowBlank:false,
                            hidden: true,
                            value: requestType,
                            labelSeparator: ""
                            }
                          ]
                }
               ]

  });
    
  var win = new Ext.Window({
                        title: "Recomend a '" + requestType +"' Form" ,
                        layout: "border",
                        modal: true,
                        maximizable: true,
                        height: 380,
                        width: 500,
                        Reset: function(f) {
                                this.form.form.reset();
                                },
                        items:[ new Ext.Panel({
		                    region: "center",
		                    layout: "absolute",
		                    bodyBorder: false,
		                    height:410,
		                    width: 515,
		                    bodyStyle: "padding: 5px 5px 5px 5px",
		                    items: [formpanel]
                        }) // end of panel
                        ], 

                buttons: [{
                    id: 'submit',
                    text: 'Submit',
                    handler: function() {
                    formpanel.getForm().submit();
                    Ext.MessageBox.wait("Processing", "Sending your contact information", {interval: 500});
                    }
                },
                {
                    id: 'reset',
                    type: 'reset',
                    text: 'Clear Form',
                    handler: function() {formpanel.getForm().reset(); }
                },
                {
                    text: 'Cancel',
                    handler: function() { win.close(); }
                }
                
                ]
                       
                        
                         
  }); // End Window definition
            
  win.show();
  
// Set up Handlers for the response form the form submition
formpanel.on(
 		{
 		// -- Successful form submition, prompt user and close avtivation tab
 		actioncomplete: function(form,action) {
 		Utils.alertBox("Results", action.result.message);
 		win.close();},
 		
 		// Form submition failed, report error
 		actionfailed: function(form,action) {

 		if (action.result == undefined){
 			 Utils.alertBox("Results", "HTTP Error: Servor could not be reached'");
 			 win.close();
 			 }
 		else {
 		Utils.alertBox("Results", "Server Error: '" + action.result.ErrMsg + "'");
 		win.close();
 		    }
 		
 		}
	});
formpanel.startMonitoring();        
}; // End of Instructor Contact Function




















/*
items: [
		                            {
                                        xtype:'fieldset',
                                        bodyStyle: "padding: 2px 2px 2px 2px",
                                        style: 'margin-left: 10px;margin-top:5px;', 
                                        title: 'Your Contact Information',
                                        collapsible: false,
                                        autoHeight:true,
                                        defaults: {width: 210},
                                        defaultType: 'textfield',
                                        items :[
                                                {
                                                fieldLabel: 'Name',
                                                name: 'name',
                                                labelStyle: 'text-align:right'
                                                },
                                                {
                                                fieldLabel: 'Email',
                                                name: 'email',
                                                labelStyle: 'text-align:right'
                                                },
                                                {
                                                fieldLabel: 'Phone',
                                                name: 'phone',
                                                labelStyle: 'text-align:right'
                                                },
                                                {
                                                xtype:'textarea',
                                                id:'message',
                                                fieldLabel:'Message',
                                                labelStyle: 'text-align:right',
                                                height:200,
                                                anchor:'98%'     
                                                }
                                              ]
                                              
                                    
                                    }
                                   ]
        					
        					
        					
        					
		                    //html: "<div>test</div>"
	                    }),
        				
        				
	                    buttons: [
	                                {
		                                id: "userSubmit",
		                                text: "Sumbit",
		                                disabled: true
	                                },
	                                {
		                                text: "Cancel",
		                                handler: function() { win.close(); }
	                                }
                                ]
	

	
	
*/	
	
	
