imageToSwap = "";
function swapImg(img)
{
	imageToSwap = img.src;
	$("#img_container").css("backgroundImage", "url("+imageToSwap+")");
	$("#main_img").fadeOut("slow", swapImg_callback);
}
function swapImg_callback()
{
	$("#main_img").attr("src", imageToSwap);
	$("#main_img").show();
}
function highlightThumb(img, highlight)
{
	if (highlight == true)
	{
		$(img).animate({opacity:0.88}, 500);
	}
	else
	{
		$(img).animate({opacity:1.0}, 700);
	}
}
function check(obj)
{
	if (obj.id == "chkBuilding" && obj.checked == true)
	{
		$("#chkRenovating").attr("checked", false);
	}
	if (obj.id == "chkRenovating" && obj.checked == true)
	{
		$("#chkBuilding").attr("checked", false);
	}
}
function submitContact()
{
	if (validateContact())
	{
		$("#contact_form").submit();
	}
}
function validateContact()
{
	var err_message = "";
	var is_valid = true;
	
	if ($("#txtName").val() == "")
	{
		err_message = "- Please enter a name\n";
		is_valid = false;
	}
	if ($("#txtPhone").val() == "")
	{
		err_message += "- Please enter a phone number\n";
		is_valid = false;
	}
	if ($("#txtEmail").val() == "")
	{
		err_message += "- Please enter an email address\n";
		is_valid = false;
	}
	
	if (err_message != "")
	{
		alert("Please correct the following before continuing:\n\n"+err_message);
	}
	else
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if (reg.test($("#txtEmail").val()) == false)
		{
			alert("Please correct the following before continuing:\n\nPlease enter a valid email address");
			is_valid = false;
		}
	}
	
	return is_valid;
}