if (document.images)
{
  pic1= new Image(336, 140); 
  pic1.src="images/menu_img1.jpg"; 

  pic2= new Image(336, 140); 
  pic2.src="images/menu_img2.jpg";

  pic3= new Image(336, 140); 
  pic3.src="images/menu_img3.jpg";
  
}

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);
}

$(function() {
	var inSpeed = 450;
	var outSpeed = 450;
	var breakSpeed = 200;
	$('div#email_button').click(function() {
		$('#float').stop().animate({'marginLeft':'-2000px'}, outSpeed, function() {
			$('#box1').hide();
			$('#box2').show();
//			$('#float').css('margin-left', '2000px');
			$('#float').animate({'marginLeft':'50px'}, inSpeed, function() {
				$('#float').animate({'marginLeft':'0px'}, breakSpeed);
			});
		});
	});
	$('div#arrow').click(function() {
		$('#float').stop().animate({'marginLeft':'-2000px'}, outSpeed, function() {
			$('#box2').hide();
			$('#box1').show();
//			$('#float').css('margin-left', '2000px');
			$('#float').animate({'marginLeft':'50px'}, inSpeed, function() {
				$('#float').animate({'marginLeft':'0px'}, breakSpeed, function() {
					$("#notification").hide();
					$("#form_left").show();
					$("#form_right").show();
					$("#submit").show();
					$("#notice").show();   
				});
			});
		});
	});
	return false;					
});

$(document).ready(function(){
$(".error").hide();
$("form").submit(function(){


var str = $("form").serialize();

	$("label#name_error").hide();
	$("label#email_error").hide();
	$("label#phone_error").hide();
	$("label#message_error").hide();
	
    var name = $("input#name").val();
	if (name == "") {
        $("label#name_error").show();
        $("input#name").focus();
    }
	var email = $("input#email").val();
	if (!isValidEmailAddress(email)) {
        $("label#email_error").show();
        $("input#email").focus();
    }
	var phone = $("input#phone").val();
	if (phone == "") {
        $("label#phone_error").show();
        $("input#phone").focus();
	}

	if ((name == "") || (!isValidEmailAddress(email)) || (phone == "")) {
		return false;	
		
	}


   $.ajax({
   type: "POST",
   url: "contact.php",
   data: str,
   success: function(msg){

$("#notification").ajaxComplete(function(event, request, settings){

// Message Sent? Show the 'Thank You' message and hide the form

if(msg == 'OK')
{

result =
'<div id="sent_ok"></div><div class="notification_ok">Your message has been sent. Thank you!</div>';
	
	$("label#name_error").hide();
	$("label#email_error").hide();
	$("label#phone_error").hide();
	$("label#message_error").hide();
    $("#form_left").hide();
	$("#form_right").hide();
	$("#submit").hide();
	$("#notice").hide();
	$("#notification").show();
	var blank = "";
	$("input#name").val(blank);
	$("input#email").val(blank);
	$("input#phone").val(blank);
	$("textarea#message").val(blank);

}
else
{
	result = msg;

}

$(this).html(result);

});

}

 });

return false;

});

});
