$(document).ready(function() {
	
	$(".navigation li").hover(function() {
		$(this).find(".subnav").not(".home").show();
	}, function () {
		$(this).not(".selected").find(".subnav").hide();
	});
	$(".navigation li, .subnav").mouseleave(function() { setTimeout(refreshNav, 5); });
	
	$(".contact_form").submit(checkForm);
	
	$(".rollover").hover(imageRollover, imageRollover);
	
	$(".home .header a").hover(function() {
		$(".home .header .tag").show();
	}, function() {
		$(".home .header .tag").hide();
	});
});

function imageRollover()
{
	var oldSrc = $(this).find("img").attr("src");
	var newSrc = $(this).attr("rel");
	
	$(this).find("img").attr("src", newSrc);
	$(this).attr("rel", oldSrc);
}

function refreshNav()
{
	Cufon.refresh();
}

function checkForm()
{
	var allGood = true;
	if($(this).find("input[name=Name]").val() == "")
	{
		allGood = false;
	}
	
	if($(this).find("input[name=Phone]").val() == "")
	{
		allGood = false;
	}
	
	if($(this).find("input[name=email]").val() == "")
	{
		allGood = false;
	}
	
	if(!allGood)
	{
		alert("Please fill out all required fields before Submitting.");
		return false;
	}
}
