jQuery(document).ready(function($) {
$(".hide_if_javascript_enabled").css({ display: "none"});
var windowHeight = $(window).height();
var windowHeight = windowHeight -360;
$('.page_shadow').css({minHeight:windowHeight});






$('*').localScroll({
					  hash:true,
					  offset: -240,
					  onBefore: function(){
						  $('.header').fadeTo(50, 0);
						  },
					  onAfter: function(){
						  $('.header').fadeTo(150, 1);
						  }
					  });
$.localScroll.hash({offset: -240})

if ($('#s3slider').length) {
// include slider plugin
$('#s3slider').s3Slider({
      timeOut: 4000
   });
};

function to_top() {
	$(".to_top").click(function(){
		var thisHref = $(this).parent().attr('id')
		$.scrollTo("#" + thisHref, { offset: -240}, 500);
		return false
	});
};
$(".page_shadow").each(function(){
	var pageHeight = $(this).outerHeight(false) -100;
	var thisPageId = $(this).attr('id')
	if (pageHeight > windowHeight) {
		$(this).append('<a href="#'+thisPageId+'" class="to_top" >&#8673;</a>');
		to_top();
		}
});



$('#portfolio_list a.brand').wrapInner('<span />').hover(function(){
				$('span',this).stop().fadeTo(300, 1)
			},
			function(){
				$('span',this).stop().fadeTo(1000, 0)
			})
$('a.brand span').stop().fadeTo(200, 0);

/*if ($('#google_map').length) {
	$.getScript("http://maps.google.com/maps/api/js?sensor=true&async=2");
}*/
function load_gmaps() {

    var latlng = new google.maps.LatLng(51.72456,0.463338);
    var myOptions = {
      zoom: 9,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("google_map"),
        myOptions);
	var contentString = '<h6>Inmeres Solution Ltd</h6><p>The Old Surgery, Moulsham Street<br />Chelmsford, Essex CM2 0JJ<br /><a href="tel:01245 392 282">01245 392 282</a><br /><a href="tel:0800 622 6888">0800 622 6888</a>';

var infowindow = new google.maps.InfoWindow({
    content: contentString,
	maxWidth:300
});

var marker = new google.maps.Marker({
    position: latlng,
    map: map,
    title:"Inmeres Solution Ltd"
});


$('#google_map').animate({height:300}, 100);

google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
  map.setZoom(15);
  map.setCenter(latlng);
});

}//load_gmaps
if ($('#google_map').length) {
	setTimeout(load_gmaps, 5000);
}



if ($('#contact').length) {
	$.getScript("//cdn.insurengine.com/js/insurengine_form.js");
}
var use_ajax=true;
$("#contact-form").submit(function(e){
			if(!$('#name').val().length)
			{
				return false;
			}
			if(!$('#email').val().length)
			{
				return false;
			}
			if(use_ajax)
			{
				$.post('inc/submit.php',$(this).serialize()+'&ajax=1',
				
					function(data){
						$("#contact-form").hide('slow').after('<strong class="success">Thank you! We\'ll be in contact as soon as we can.</strong>');
					}
				
				);
			}
			e.preventDefault();
	})




});//jquery



	


