Ext.onReady(function(){
     var contactForm = new Ext.FormPanel({
	  //		url:'save-form.php',
	  renderTo:'contactForm',
	  id:'theContactForm',
	  frame:false,
	  width: 410,
	  border:false,
	  layout:'column',
	  bodyStyle: 'background-color: #212225',
	  items:[{
	       width:160,
	       bodyStyle: 'background-color: #212225;',
	       layout:'form',
	       defaults: {
		    width: 156,
		    hideLabel:true
	       },
	       defaultType: 'textfield',
	       border:false,
	       items: [{
		    name: 'yourName',
		    emptyText:'Your Name',
		    allowBlank:false,
		    id:'contactName'
	       },{
		    name: 'yourEmail',
		    emptyText:'Email Address',
		    vtype:'email',
		    allowBlank:false,
		    id:'contactEmail'
	       },{
		    emptyText: 'Phone Number',
		    name: 'yourPhone',
		    id:'contactPhone'
	       }]
	  },{
	       width:250,
	       bodyStyle: 'background-color: #212225;',
	       layout:'form',
	       defaults: {
		    width: 250,
		    hideLabel:true
	       },
	       defaultType: 'textfield',
	       border:false,
	       items: [{
		    xtype:'textarea',
		    name: 'yourMessage',
		    emptyText:'Your Message',
		    allowBlank:false,
		    height:74,
		    id:'yourMessage'
	       //},{
	       //	xtype:'checkbox',
	       //	boxLabel:'Add me to your mailing list!<br><i>(Your info is kept private and never shared)</i>',
	       //	checked:true
	       }]
	  }],
	  listeners:{
	       render: function(){
		    $.get('http://www.shamrockvideo.com/token.php',function(unix){
			 contactForm.add({
			      xtype:'hidden',
			      value:unix,
			      id:'ts',
			      name:'ts'
			 });
			 contactForm.doLayout();
		    });
	       }
	  }
     });

});

$(document).ready(function(){

     $('#sendMsgBtn').bind('click',function() {

	  $('#contactFormErrors').hide();
	  $('#cFC').hide();
	  $('#pleaseWait').show();
		
	  Ext.getCmp('theContactForm').getForm().submit({
	       clientValidation: true,
	       url: 'http://www.shamrockvideo.com/sendMessage.php',
	       params: {
		    dummy: 'on'
	       },
	       success: function(form, action) {
		    $('#pleaseWait').hide();
		    $('#messageSent').show();
	       },
	       failure: function(form, action) {
		    $('#contactFormErrors').show();
		    $('#cFC').show();
		    switch (action.failureType) {
			 case Ext.form.Action.CLIENT_INVALID:
			      $('#cFETxt').text('You must provide all required information before sending the message.');
			      $('#contactFormErrors').show();
			      break;
			 case Ext.form.Action.CONNECT_FAILURE:
			      $('#cFETxt').text('The connection to the server was unsuccessful. Are you still online?');
			      $('#contactFormErrors').show();
			      break;
			 case Ext.form.Action.SERVER_INVALID:
			      $('#cFETxt').text(action.result.msg);
			      $('#contactFormErrors').show();
		    }
	       }
	  });

		
		
     });
 
  
});

