Ext.onReady(function(){
	//****************contact me popup************************

    var contactForm;

    var form = new Ext.form.FormPanel({
        baseCls		: 'x-plain',
        labelWidth	: 95,
        url			:'/forms/contactform',
        waitMsg		: 'Submitting your request',
        defaultType	: 'textfield',
        items: [{
            fieldLabel: 'Title',
            name: 'title',
            anchor:'100%'  // anchor width by percentage
        },{
            fieldLabel: 'First Name',
            name: 'fname',
            anchor: '100%'  // anchor width by percentage
        },{
            fieldLabel: 'Last Name',
            name: 'lname',
            anchor:'100%'  // anchor width by percentage
        },{
            fieldLabel: 'Email',
            name: 'email',
            anchor:'100%'  // anchor width by percentage
        },{
            fieldLabel: 'Phone',
            name: 'phone',
            anchor:'100%'  // anchor width by percentage
        },{
        	xtype: 'textarea',
            fieldLabel: 'How Did you hear about us?',
            name: 'source',
            anchor:'100%'  // anchor width by percentage and height by raw adjustment
        },{
            xtype: 'textarea',
            fieldLabel: 'Comments',
            name: 'comments',
            anchor: '100%'  // anchor width by percentage and height by raw adjustment
        }]
    });

	contact = function(jobID){
	    // create the window on the first click and reuse on subsequent clicks
		if(!contactForm){
			contactForm = new Ext.Window({
				title		: 'Contact Spot On Recruiting',
		        applyTo     : 'contactBox',
		        layout      : 'fit',
		        width       : 600,
		        height      : 350,
		        x			: 150,
		        y			: 100,
		        closeAction :'hide',
		        modal		: true,
		        plain       : true,
		        items: form,
		        buttons: [{
		            text     : 'Submit',
		            //disabled : true,
		            handler  : function(){
		        		form.getForm().submit({
		        			params: {'jobID':jobID},
		        			failure	: function() {Ext.Msg.alert("Communication Error!","We were unable to submit your contact information.  Please re-try later.");},
		        	        success	: function() {Ext.Msg.alert("Success!","Your contact information has been sent. Someone will contact you shortly.");}
		        		});//passes job ID along with submit.
		        		contactForm.hide();
		        	}
			    },
			    {
		            text     : 'Cancel',
		            handler  : function(){contactForm.hide();}
			    }]
			});
		}
		contactForm.show();
	};
});