$(document).ready(function() {	
	
	// Main Menu Opacity (ie7,8,9)
	$("#navigation li:not('.current_page_item')").css('opacity',0.5);
	
	$("#navigation li:not('.current_page_item')").hover(function() {
		$(this).fadeTo(120, 1);
	}, function() {
			$(this).fadeTo(120, 0.5);
	});
	
	// Validation errors for different languages
	formMessages = {
		en: {
			emptyFields: "You must fill in all required fields.",
			nameLength: "Your name must be between 3 and 30 characters.",
			spamMessage: "Leave the spam field blank please.",
			invalidEmail: "Your email address was not valid.",
			generalError: "There was a problem sending the form.",
			success: "<h6>Thank You.</h6><p>Your message has been sent.</p>"
		},
		fr: {
			emptyFields: "Vous devez remplir tous les champs obligatoires.",
			nameLength: "Votre nom doit etre entre 3 et 30 caracteres.",
			spamMessage: "Leave the spam field blank please.",
			invalidEmail: "Votre adresse e-mail n'est pas valide.",
			generalError: "There was a problem sending the form.",
			success: "<h6>Merci.</h6><p>Votre message a ete envoye.</p>"
		}
	};
		
	$("#filter").hide();		
		
	// Setup Form Submit Options
	var options = {
		beforeSubmit: function() {
			$('#loader').fadeIn(50);
			},
			dataType: 'json',
			success: processJson
		}
	
	
	// Form Submit Function
	function processJson(data) {
		
		var status = data.status;
		$('#loader').fadeOut(300);		
				
		// If Fields are Empty
		if(status == 1) {$('#output').hide().empty().fadeIn(150).append("<p>"+ formMessages[LANG]['emptyFields'] +"</p>");}
		
		// If Name is Wrong
		if(status == 2) {$('#output').hide().empty().fadeIn(150).append("<p>"+ formMessages[LANG]['nameLength'] +"</p>");}								
		
		// If Spam Bot
		if(status == 3) {$('#output').hide().empty().fadeIn(150).append(""+ formMessages[LANG]['spamMessage'] +"</p>");}
		
		// If Fields are Empty
		if(status == 4) {$('#output').hide().empty().fadeIn(150).append("<p>"+ formMessages[LANG]['invalidEmail'] +"</p>");}
		
		// If Probems
		if(status == 6) {$('#output').hide().empty().fadeIn(150).append("<p>"+ formMessages[LANG]['generalError'] +"</p>");}
		
		// If Message Sent
		if(status == 5) {
						
			$('#contactForm #output').hide(50);								
			$('#contactForm').slideUp(600);	
			$('#output').empty().hide().append(formMessages[LANG]['success']).slideDown(600);														
			$('#loader').fadeOut(500);
			return false;						
		
		}// End of Status 5
						
	} 
	// End of processJson
	

	$('#contactForm').ajaxForm(options);
	
});