$(document).ready(function() {
						   
	var hash = window.location.hash.substr(1);
	var href = $('#menu a').each(function(){
		var href = $(this).attr('href');
		if((hash==href.substr(0,href.length-5)) || (hash!='contact')){
			var toLoad = hash+'.html #content';
			$('#content').load(toLoad)
		} else if (hash=='contact') {
					$(".loader").hide("fast");
		
							$('#load').fadeIn('normal');
							$("#bar").hide("normal");
									$("#content").hide('fast');
									$("#contact1").show("normal");
									$('#load').fadeOut('normal');
		}
	});

	$('#menu a').click(function(){
					$(".loader").hide("fast");
				$("#contact1").hide("fast");
					$("#bar").hide("fast");	  
		var toLoad = $(this).attr('href')+' #content';
		$('#content').hide('fast',loadContent);
		$('#load').remove();
		$('#wrapper').append('<span id="load"><img src=\'images/ajax-loader.gif\'></span>');
		$('#load').fadeIn('normal');
		
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
		function loadContent() {
			$('#content').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#content').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#load').fadeOut('normal');
		}
		$('#load').fadeOut('normal');
		return false;
		
	});
 $('#Image5').click(function(){
							 		$(".loader").hide("fast");
		
							$('#load').fadeIn('normal');
							$("#bar").hide("normal");
									$("#content").hide('fast');
									$("#contact1").show("normal");
									$('#load').fadeOut('normal');
										}); 
});
//Contact form stuff
//engage on the page load
$(function() {
  //trigger ajax on submit
  $('#contactForm').submit( function(){

    //hide the form
    $('#contact1').hide();

    //send the ajax request
	$('#load').fadeIn('normal');
    $.get('mail.php',{name:$('#name').val(),
                      email:$('#email').val(),
                      recaptcha_response_field:$('#recaptcha_response_field').val(),
                      comment:$('#message').val()},
					  

    //return the data
    function(data){
	  $('.loader').replaceWith("<div class=\"loader\">" + data + "</div>");


	 $('#load').fadeOut('normal');
	 $(".loader").show("fast");
	 $("#bar").show("fast");
    });

  //stay on the page
  return false;
  });
});

