$(function(){
	// creating the slider
	$('#slider').nivoSlider();
	
	// hiding the pages
	$('.pages>div').hide();
	$('.close').hide();
	
	// Animating the main menu and close button
	$('.menu li, .close').hover(
		function(){
			el = $(this);
			el.fadeTo(200,0.5);
		},
		function(){
			el = $(this);
			el.fadeTo(200,1);
		}
	);
	
	// Animating the logo
	$('.logo').hover(
		function(){
			el = $(this);
			el.animate({right:100},200);
		},
		function(){
			el = $(this);
			el.animate({right:31},200);
		}
	);
	
	// menu clicking behaviour on clicking
	$('.menu li a').click(function(){
		var el = $(this);
		$('.menu').fadeOut(500, function(){		
										 
			clas = '.'+el.attr('rel');
			$(clas).fadeIn(500);
			$('.close').fadeIn(500);
			
		});
	});
	
	// close button behaviour
	$('.close, .logo').click(function(){
		$('.pages>div:visible').fadeOut(500, function(){
													  
			$('.close').fadeOut(500);
			$('.menu').fadeIn(500);
			
		});
	});
});

function validate(){
	$name = $('#name');
	$email = $('#email');
	$subject = $('#subject');
	$body = $('#body');
	pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if( $name.val().length==0 || $email.val().length==0 || $email.val().length==0 ){
		alert( 'Please Fill the form fields');
		return false;
	}else if( !pattern.test($email.val()) ){
		alert( 'Please enter a valid Email address');
		return false;
	}
	return true;
}
