﻿///<reference path="jquery-1.4.1-vsdoc.js"/>

$(function () {

	Cufon.replace("legend")
                 ("blockquote")
                 ("#header li a")
                 ("#mainMedia .teaser h2")
                 (".cufon")
                 ("#standardPage h1")
                 ("#casePage #body > h2");

	if ($("#casePage").length) {
		CaseMedia();
	}

	$("a[rel='external']").each(function () {
		this.target = "_blank";
	});

	$(".clickable").click(function () {
		var a = $("a:first", this);
		var href = a.attr("href");
		if (a.attr("target") == "_blank") {
			window.open(href);
		} else {
			location.href = href;
		}
	});

	$("#SubmitContactForm").click(function () {
		if ($("#ContactForm").validate({
			errorPlacement: function (error, element) {
				error.appendTo(element.prev());
			},
			messages: {
				nameTextBox: {
					required: " *"
				},
				emailTextBox: {
					required: " *",
					email: " *"
				}
			}
		}).form()) {
			$.post("/Contact/SendContactForm", {
				name: $("#nameTextBox").val(),
				email: $("#emailTextBox").val()
			}, function (html) {
				$("#ContactResponseDiv").html(html).show();
				$("#nameTextBox").val("");
				$("#emailTextBox").val("");
			}, "html");

		}

		return false;
	});


});
