$(document).ready(function() {
	$('#nav a, #our_expertise a').bind('click',function(event) {
		var $anchor = $(this);
		$('a').removeClass('active')
		$anchor.addClass("active");

		$('html, body').stop().animate({
			scrollTop: $($anchor.attr('href')).offset().top - $("#h").height()
		}, 1500,'easeInOutExpo');
		
		event.preventDefault();
	});
});

$(document).ready(function() {
	$("#fmContact").submit(function() {
		var element = $(this);
		var form = $(this).serialize();
		var url = $(this).attr("action") + ".json";
		$.ajax({
			type: "POST",
			url: url,
			data: form,
			success: function(data) {
				element.parent().find(".errors").remove();
				if(data.status === "ok") {
					element.fadeOut(800, function() {
						element.before("<div class='notice' style='display: none;'><p>" + data.message + "</p></div>").parent().find(".notice").fadeIn(200);
						setTimeout(function() {
							element.parent().find(".notice").fadeOut(500, function() {
								element.fadeIn(1500);
							}).remove();
						}, 4000);
					});
				}
				else {
					var error_html = $("<div class='errors'/>");
					error_html.prepend("<p>To continue and send your message, please enter the following:</p>");
					var list_html = $("<ul/>");
					$.each(data.errors, function(index, error) {
						list_html.append("<li>" + error + "</li>");
					});
					list_html.appendTo(error_html);
					error_html.insertBefore(element);
				}
			}
		});
		return false;
	});
});

/*if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
{
     $("#header").css("position", "static");
};*/

