$(document).ready(function () {
	function a(b) {
		if (!$.trim(b).length) {
			return true
		} else {
			return false
		}
	}
	$("#mailsub").click(function () {
		if ($("#realname").val() == "" || $("#realname").val() == " ") {
			alert("Please enter your name.");
			$("#realname").focus()
		} else {
			if ($("#mremail").val() == "" || $("#mremail").val() == " ") {
				alert("Please enter your email address.");
				$("#mremail").focus()
			} else {
				if ($("#mrphone").val() == "" || $("#mrphone").val() == " ") {
					alert("Please enter your phone number.");
					$("#mrphone").focus()
				} else {
					if ($("#mrhowhear").val() == "0") {
						alert("Please select how you heard of us.");
						$("#mrhowhear").focus()
					} else {
						if ($("#mrsubject").val() == "" || $("#mrsubject").val() == " ") {
							alert("Please enter your subject.");
							$("#mrsubject").focus()
						} else {
							if ($("#mrmessage").val() == "" || $("#mrmessage").val() == " ") {
								alert("Please enter your message.");
								$("#mrmessage").focus()
							} else {
								if ($("#mapson").val() == "") {
									$.post("mrit.ajax.php", {
										op: "email",
										conname: $("#realname").val(),
										conmail: $("#mremail").val(),
										connumber: $("#mrphone").val(),
										conhowhear: $("#mrhowhear").val(),
										subject: $("#mrsubject").val(),
										message: $("#mrmessage").val()
									}, function (b) {
										if (b == "yay") {
											alert("Great! That's sent!");
											$("#realname").val("");
											$("#mremail").val("");
											$("#mrphone").val("");
											$("#mrhowhear").val("");
											$("#mrsubject").val("");
											$("#mrmessage").val("")
										} else {
											alert("There was a problem. Sorry!")
										}
									})
								}
							}
						}
					}
				}
			}
		}
		return false
	});
	$("#callsend").click(function () {
		if (a($("#conname").val())) {
			alert("Please enter your name.");
			$("#conname").focus()
		} else {
			if (a($("#connumber").val())) {
				alert("Please enter your number.");
				$("#connumber").focus()
			} else {
				if (a($("#contype").val())) {
					alert("Please enter the nature of your enquiry.");
					$("#contype").focus()
				} else {
					$.post("mrit.ajax.php", {
						op: "callreq",
						conname: $("#conname").val(),
						connumber: $("#connumber").val(),
						contype: $("#contype").val()
					}, function (b) {
						if (b == "yay") {
							$("#callsendbut").html('<p class="c"><strong>Great! We\'ll call ASAP!</strong></p>');
							$("#conname").val("");
							connumber: $("#connumber").val("");
							$("#contype").val("")
						} else {
							alert("There was a problem. Sorry!")
						}
					})
				}
			}
		}
		return false
	});
	$(".fourclick").mouseover(function () {
		$("#fd-" + this.id).stop(true, true).slideDown("slow")
	}).mouseleave(function () {
		$("#fd-" + this.id).stop(true, true).delay(800).slideUp("slow")
	});
	$("#nav li").mouseover(function () {
		$(this).find("ul.children").stop(true, true).slideDown("fast").show()
	}).mouseleave(function () {
		$(this).find("ul.children").stop(true, true).slideUp("fast").show()
	});
	$(".footlogo").mouseover(function () {
		$("#" + this.id).attr("src", "res/logo-" + this.id + "-on.png")
	}).mouseleave(function () {
		$("#" + this.id).attr("src", "res/logo-" + this.id + "-off.png")
	})
});
var _gaq = _gaq || [];
_gaq.push(["_setAccount", "UA-579688-6"]);
_gaq.push(["_trackPageview"]);
(function () {
	var b = document.createElement("script");
	b.type = "text/javascript";
	b.async = true;
	b.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
	var a = document.getElementsByTagName("script")[0];
	a.parentNode.insertBefore(b, a)
})();
