function mailform(){
	
	formfieldBehaviours() ;
	
	jQuery("#mail-form").css('display','none') ;
			
	// Contact Form Drop Down
	
	contactFormState = "0" ; // 0 = Up ; 1 = Down ; 3 = Moving Down ; 4 = Moving Up ;
	
	jQuery('#contact-email').mousedown(function(){
		
		if(contactFormState == 0){
			
			contactFormState = 3 ;
			
			jQuery("#mail-form").slideDown(1000, function(){
				jQuery(".contact-email-arrow").css('background-position','-360px -25px') ;
				contactFormState = 1 ;
			}) ;
			
		}else if(contactFormState == 1){
			
			contactFormState = 4 ;
			
			jQuery("#mail-form").slideUp(1000, function(){
				jQuery(".contact-email-arrow").css('background-position','-360px 0') ;
				contactFormState = 0 ;
			}) ;
			
		} else {
			
			// No action in transit
			
		}
		
		
	});
	
	
	// AJAX FORM
	
	jQuery("#ajax-contact-form").submit(function(){
		
		jQuery('#send-message').attr("disabled", true) ;
		jQuery('#send-message').text('Sending...');
		
		jQuery('#ajax-contact-form').find('input').each(function(){ 
		
			if(jQuery(this).attr('value') == jQuery(this).attr('title')){
					jQuery(this).attr('value', '') ;
				};
		
		}) ;
		
		// 'this' refers to the current submitted form
		var str = jQuery(this).serialize();
		
		jQuery.ajax({
		   type: "POST",
		   url: "contact-php/contact.php",
		   data: str,
		   success: function(msg){
				//alert(msg);
				jQuery("#note").ajaxComplete(function(event, request, settings){
					//alert(msg)
					if(msg == 'OK'){
						jQuery('#send-message').text('Message Sent!');
						jQuery('#form-error').slideDown() ;
						jQuery('#form-error').text('Thank you. Your message has been sent and I will get back to you as soon as possible');
						jQuery('#form-error').addClass('form-success');
						
					} else {
						jQuery('#send-message').attr("disabled", false) ;
						jQuery('#send-message').text('Send Message');
						jQuery('#form-error').slideDown() ;
						jQuery('#form-error').text(msg) ;
					}
				
				});
				
			}
		
		});
		
		jQuery('#ajax-contact-form').find('input').each(function(){ 		
			if(jQuery(this).attr('value') == ''){
					jQuery(this).attr('value', jQuery(this).attr('title')) ;
				};
		}) ;
		
		return false;
	
	});

}

function formfieldBehaviours(){
	
	
	// If IE add a true and make that attach CSS rules instead of relyin gon focus
	jQuery('#ajax-contact-form').find('input').each(function(){
			
			jQuery(this).attr('value', jQuery(this).attr('title')) ;
			
			jQuery(this).focus(function(){ 
				if(jQuery(this).attr('value') == jQuery(this).attr('title')){
					jQuery(this).attr('value', '') ;
					if(jQuery.browser.msie){ jQuery(this).addClass('ieInputFocus') } ;
				}
			}) ;
			
			jQuery(this).blur(function(){
				if(jQuery(this).attr('value') == ''){
					jQuery(this).attr('value', jQuery(this).attr('title')) ;
					if(jQuery.browser.msie){ jQuery(this).removeClass('ieInputFocus') } ;
				}
			}) ;
		
	});
	
} ;