$(document).ready(function(){	
	$("#registrationsubmit").click(function(event){
		SubmitForm = true;
		if (SubmitForm && ($("#workshop").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter a workshop name"); }
		if (SubmitForm && ($("#name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your name"); }
		if (SubmitForm && ($("#company_name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your company's name"); }
		if (SubmitForm && ($("#email").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your email address"); }
		if (SubmitForm && ($("#phone").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your telephone number"); }
		//if (SubmitForm && ($("#address1").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your address"); }
		//if (SubmitForm && ($("#city").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your city"); }
		//if (SubmitForm && ($("#state").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your state"); }
		//if (SubmitForm && ($("#zip").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your zip code"); }
		if ( ! SubmitForm) { event.preventDefault(); }		
	});

	$("#contactsubmit").click(function(event){
		SubmitForm = true;
		if (SubmitForm && ($("#name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your name"); }
		if (SubmitForm && ($("#company_name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your company's name"); }
		if (SubmitForm && ($("#email").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your email address"); }
		if (SubmitForm && ($("#phone").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your telephone number"); }
		if (SubmitForm && ($("#comment").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your comment or request"); }		
		if ( ! SubmitForm) { event.preventDefault(); }
	});

	$("#laborlawsubmit").click(function(event){
		SubmitForm = true;
		//CheckedBoxes = $(".poster_cart input[type=checkbox]:checked").length;
		CheckedBoxes = CountCart();
		if (SubmitForm && (CheckedBoxes <= 0)) { SubmitForm = SubmitForm && false; alert("Please choose at least one poster"); }
		if (SubmitForm && ($("#name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your name"); }
		if (SubmitForm && ($("#company_name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your company's name"); }
		if (SubmitForm && ($("#email").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your email address"); }
		if (SubmitForm && ($("#phone").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your telephone number"); }
		//if (SubmitForm && ($("#poster").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your poster choice"); }	
		if (SubmitForm && ($("#mailingaddress").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your mailing address"); }	
		//if (SubmitForm && ($("#billingaddress").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your billing address"); }
		if ( ! SubmitForm) { event.preventDefault(); }
	});
	
	/*
	$(".pster").click(function(event){ TotalCart(); });
	$(".qty").keyup(function(event){ TotalCart(); });
	$(".qty").click(function(event){ TotalCart(); });
	*/

	$("#membershipsubmit").click(function(event){
		SubmitForm = true;
//		if (SubmitForm && ($("#name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your name"); }
		if (SubmitForm && ($("#company_name").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your company's name"); }
		if (SubmitForm && ($("#streetaddress").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your street address"); }	
		if (SubmitForm && ($("#mailingaddress").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your mailing address"); }	
		if (SubmitForm && ($("#phone").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your telephone number"); }
		if (SubmitForm && ($("#fax").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your fax number"); }
		if (SubmitForm && ($("#website").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your website address"); }
		if (SubmitForm && ($("#businesstype").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your business type"); }	
		if (SubmitForm && ($("#employeecount").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your employee count"); }	
		if (SubmitForm && ($("#duescycle").val() == "")) { SubmitForm = SubmitForm && false; alert("Please enter your billing cycle choice"); }	
		if ( ! SubmitForm) { event.preventDefault(); }
	});
	
	$("#additionalPeople1").click(function(event){
		$("#MembershipForm_additional_info1").show("fast");
		$(this).hide("fast");
		$("#additionalPeople2").show("fast");
	});
	
	$("#additionalPeople2").click(function(event){
		$("#MembershipForm_additional_info2").show("fast");
		$(this).hide("fast");
		$("#additionalPeople3").show("fast");
	});
	
	$("#additionalPeople3").click(function(event){
		$("#MembershipForm_additional_info3").show("fast");
		$(this).hide("fast");
	});
});


function CountCart()
{
	intTotal = 0;
	strID = "";
	$(".poster_cart input:text").each( function() {
		strID = $(this).attr('id');
		Outboy = strID.search(/ty_/);
		if (Outboy > 0)
		{
			thisQty = $("#" + strID).val();
			if ( ! isPosNumber(thisQty)) { thisQty=0; }
			if (thisQty > 0) { intTotal = intTotal + thisQty; }
		}
	});
	return intTotal;
}

function TotalCart()
{
	intTotal = 0;
	strID = "";
	$(".poster_cart input:text").each( function() {
		strID = $(this).attr('id');
		if (strID.search(/price/) > 0)
		{
			thisPrice = $("#" + strID).val();
			thisQty = $("#" + strID.replace(/price/, "qty")).val();
			if ( ! isPosNumber(thisPrice)) { thisPrice=0; }
			if ( ! isPosNumber(thisQty)) { thisQty=0; }
			subTotal = thisPrice * thisQty
			if (subTotal > 0) { intTotal = intTotal + subTotal; }
		}
	});
	$("#CartTotal").html(intTotal.toFixed(2));
}

function TotalCartCheckboxes()
{
	intTotal = 0;
	strID = "";
	$(".poster_cart input[type=checkbox]:checked").each( function() {
		strID = $(this).attr('id');
		thisPrice = $("#" + strID.replace(/pster/, "price")).val();
		thisQty = $("#" + strID.replace(/pster/, "qty")).val();
		if ( ! isPosNumber(thisPrice)) { thisPrice=0; }
		if ( ! isPosNumber(thisQty)) { thisQty=0; }
		subTotal = thisPrice * thisQty
		if (subTotal > 0) { intTotal = intTotal + subTotal; }
	});
	$("#CartTotal").html(intTotal.toFixed(2));
}


function isPosNumber(n){
	blnResult = false;
	if (typeof(n) != "boolean" && !isNaN(n)) {
		if (n >= 0) {
			blnResult = true; } 
	}
	return blnResult;
}
