jQuery(function($){
	$("select[name=country]").live("change", function(){
		var value = $("select[name=country]").val();
		$("input[name=phone]").val("+" + value);
	});
	
	$("#request_quote input[type=submit]").live("click", function(event){
		event.preventDefault();
		
		if($("input[name=fname]").val().length == 0)
		{
			alert("You must enter your first name");
			$("input[name=fname]").focus();
		}
		else if($("input[name=lname]").val().length == 0)
		{
			alert("You must enter your last name");
			$("input[name=lname]").focus();
		}
		else if($("input[name=company]").val().length == 0)
		{
			alert("You must enter your company name");
			$("input[name=company]").focus();
		}
		else if($("input[name=email]").val().length == 0 || $("input[name=email]").val() != $("input[name=verifyEmail]").val())
		{
			alert("You must enter an email and the email has to be the same as the verify email");
			$("input[name=email]").focus();
		}
		else if($(".formColumn input[type=checkbox]:checked").length == 0)
		{
			alert("You have to choose at least one product of interest");
			$("input[name=email]").focus();
		}
		else
		{
			$("#request_quote").submit();
		}
	});
	
	
	var flow = $("select[name=size]").children("option.remove");
	var other = $("select[name=size]").children("option:not(.remove)");
	
	$("select[name=size]").children("option").remove();
	
	$("input[name=product_1]").live("change", function(){
		if($(this).is(":checked"))
		{
			if($("select[name=size]").children("option").length == 0)
			{
				$("select[name=size]").show();
				$("label[for=size]").show();
			}
			$("select[name=size]").append(flow);
		}
		else
		{
			// if($("input[name=product_6]").attr('checked') == false)
				$("select[name=size]").children("option.remove").remove();
			if($("select[name=size]").children("option").length == 0)
			{
				$("select[name=size]").hide();
				$("label[for=size]").hide();
			}
		}
	});
	
	$("input[name=product_2]").live("change", function(){
		if($(this).is(":checked"))
		{
			if($("select[name=size]").children("option").length == 0)
			{
				$("select[name=size]").show();
				$("label[for=size]").show();
			}
			$("select[name=size]").append(other);
		}
		else
		{
			// if($("input[name=product_6]").attr('checked') == false)
				$("select[name=size]").children("option:not(.remove)").remove();
			if($("select[name=size]").children("option").length == 0)
			{
				$("select[name=size]").hide();
				$("label[for=size]").hide();
			}
		}
	});
	
	if($("select[name=size]").children("option").length == 0)
	{
		$("select[name=size]").hide();
		$("label[for=size]").hide();
	}
	
	/* $("input[name=product_6]").live("change", function(){
		if($(this).is(":checked"))
		{
			if($("select[name=size]").children("option").length == 0)
			{
				$("select[name=size]").show();
				$("label[for=size]").show();
			}
			$("select[name=size]").append(other);
			$("select[name=size]").append(flow);
		}
		else
		{
			if($("input[name=product_1]").attr('checked') == false)
				$("select[name=size]").children("option.remove").remove();
			if($("input[name=product_2]").attr('checked') == false)
				$("select[name=size]").children("option:not(.remove)").remove();
			if($("select[name=size]").children("option").length == 0)
			{
				$("select[name=size]").hide();
				$("label[for=size]").hide();
			}
		}
	}); */
	
});
