jQuery(document).ready(function($){

	//Remove first and last borders on Navigation elements
	$(".nav ul > li:first-child > a").css({ borderLeft: 'none' });
	$(".nav ul > li:last-child > a").css({ borderRight: 'none' });
	$(".procedures ul li:first-child").css({ borderTop: 'none' });
	$(".procedures ul li:last-child").css({ borderBottom: 'none' });

	
	$('.gradient').css({ backgroundPosition: "500px 0" }); // To solve bugs in IE and FF2, set background-position inline or through javascript.
	
	// Banner text background animation / sheen effect.
	function headerEffect(){
		$('.gradient').animate({ backgroundPosition: "(-600px 0)" }, { 
			duration: 6000,
			easing: 'easeInOutQuad',
			complete: function(){ // Once the first part of the animation is complete, reverse animation to return to the starting position.
				$('.gradient').animate({ backgroundPosition: "(500px 0)" }, { 
					duration: 6000,
					easing: 'easeInOutQuad'
				});
				headerEffect(); // Repeat this function again forever.
			}
		})
	}
	
	headerEffect(); // Initialize the header effect.
	
	// Menu styling
	$('.header .menu:first').css({ borderTop: 'none' });
	$('.header .menu:last').css({ borderBottom: 'none' });
	
	// Sidebar contact form.
	$('.labelify').labelify(); 
	$('#contactform').validate({
		ignoreTitle: true,
		errorElement: 'div',
		errorPlacement: function(error, element) {
			error.insertBefore(element);
			$('.labelify').labelify();
 		},
		submitHandler: function(form) {
			$(form).ajaxSubmit({
 				success: function(){
					$(form).slideUp(function(){
						$('.notification.success').slideDown();
 					});
				}
			});
 		}
	});
	
	//Ajax Newsletter Subscription
	$('#newsform').submit(function (e) {
		e.preventDefault();
		$.getJSON(
		this.action + "?callback=?",
		$(this).serialize(),
		function (data) {
			if (data.Status === 400) {
				alert("Error: " + data.Message);
			} else { // 200
				$('#newsform').slideUp(function(){
					$('.newssuccess').slideDown();
				});
			}
		});
	});
	
	//Ajax Newsletter Subscription
	$('#contactform').submit(function (e) {
		$.getJSON(
		"http://login.mailprince.com/t/r/s/fuljik/?callback=?",
		{
			'cm-name': $(this).find('input[name="name"]').val(),
			'cm-fuljik-fuljik': $(this).find('input[name="email"]').val()
		});
	});

});


