$(document).ready(function() {
	$('.navworks').children().hover(function() {
			$(this).siblings().stop().fadeTo(500,0.5);
		}, function() {
			$(this).siblings().stop().fadeTo(500,1);
	});
	$('p.inputBoxstyle input').focus(function(){
		$(this).parent().addClass('inputBoxstyleActive');
	});
	$('p.inputBoxstyle input').blur(function(){
		$(this).parent().removeClass('inputBoxstyleActive');
	});
	$('p.textAreastyle textarea').focus(function(){
		$(this).parent().addClass('textAreastyleActive');
	});
	$('p.textAreastyle textarea').blur(function(){
		$(this).parent().removeClass('textAreastyleActive');
	});
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
			&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});	
	$(".navworks a").fancybox();
	function isValidEmailAddress(emailAddress) {
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	}

	$('#submit').click(function(){
		$errorMsg=false;
		$contact_name=$('#contact_name').val();
		$contact_email=$('#contact_email').val();
		$contact_message=$('#contact_message').val();
		if($contact_name==""){
			$.jGrowl("Invalid Name");
			$errorMsg=true;
		}
		if(!isValidEmailAddress($contact_email)){
		$.jGrowl("Invalid Email");
			$errorMsg=true;
		}
		if($contact_message=="") {
		$.jGrowl("Invalid Message");
			$errorMsg=true;
		}
		if($errorMsg==true){
		return false;
		}else{
		$('#contactform').submit();
		return true;
		}
	});
	$('#top-link').topLink({
		min: 300,
		fadeSpeed: 500
	});
});