$(document).ready(function(){

$(function(){
  $(window).bind( 'hashchange', function(e) {
    // Get the hash (fragment) as a string, with any leading # removed. Note that
    // in jQuery 1.4, you should use e.fragment instead of $.param.fragment().
    var url = $.param.fragment();
    var menus = url.substring(0,4);

	$('#container').removeClass().addClass('wrap' + url);

    if (menus == 'menu') {
		var menu = url.substring(5);
		$(".panel").hide();
		$("#insert-menu #menu").hide();
		$("div.menus").show();
		$("#insert-menu div." + menu).show();
		$("#menulist a").removeClass('active');
		$("#menulist a." + url).addClass('active');
		$("#nav a").removeClass('on');
		$("#nav a.menus").addClass('on');
	}
	if (url == 'location' || url == 'contact' || url == 'atmosphere') {
		$(".panel").hide();
		$("div." + url).show();
		$("#nav a").removeClass('on');
		$("#nav a." + url).addClass('on');
	} 
  })
  // Since the event is only triggered when the hash changes, we need to trigger
  // the event now, to handle the hash the page may have loaded with.
  $(window).trigger( 'hashchange' );
});
		
	$("a.close").click(function () {
		$(".panel").fadeOut(1000);
		$("#nav a").removeClass('on');
	});
	
	$("#continue").click(function() {
		if($('#daform #email').val() != "" && $('#daform #email').val() != "Your E-mail Address") {
			$("#daform").animate({
				opacity: 0
			},
			{
				duration: 400,
				complete: function() {			
				$.ajax({
						url: '/shipEmailShort.php',
						type: 'POST',
						data: $("#daform").serialize(),
						success: showResponse
					});
				}
			});
		} else {
			alert("Please enter your e-mail address");	
		}
	});

	// post-submit callback 
	function showResponse(data, textStatus)  {
		$("h3.updates").after(data);
		$("p.thanks").css("display","none");
		$("#daform").css("display","none");
		$("p.thanks").fadeIn(800);
	}
	
	
	$("#contactus").click(function() {
		if($('#contactform #email').val() != "" && $('#contactform #name').val() != "" && $('#contactform #comments').val() != "") {
			$("#contactform").animate({
				opacity: 0
			},
			{
				duration: 400,
				complete: function() {			
				$.ajax({
						url: '/shipContact.php',
						type: 'POST',
						data: $("#contactform").serialize(),
						success: function(data, textStatus) {
								$('#contactform').fadeOut(200);
								$("#contactform").replaceWith(data).fadeIn(800);
						}
					});
				}
			});
		} else {
			alert("Please enter your name, e-mail address and comments");	
		}
	});  //end contactus
	
}); //end doc ready

