
/*==========================================================*/
// Post RFQ form information to Insite Metrics
function insitePost(formId) {
	// Set Insite Metrics URL
	var url = "http://www.topfloortech.com/insitemetrics/uRMJ/uniformv2.php";
	// Include other non-form variables
	url += "?imReferrerField=" + escape(document.referrer);
	url += "&imEmailField=" + escape($("[name=Email_REQ]").val());
	url += "&" + $('input,textarea', '#'+formId).not(':submit').serialize();	
	// Create image and use it to post the URL to Insite Metrics
	//alert(url);
	img = new Image(0, 0);
	setTimeout(function(){img.src = url;}, 100);
}

var country_selected = '';
var usa = 'United States';

jQuery(function($) {

	$("#rfqForm").submit(function() {
		if($("#country").val() == '') {
			alert("Country is a required field");
			return false;
		}
		else if(country_selected != usa) {
			var errormsg = "";
			$(".rqd_cntry").each(function() {
				if(this.value == '') {
					errormsg += $(this).attr('name').replace(/\_/g, ' ') + " is a required field \n";
				}
			});
			if(errormsg) {
				alert(errormsg); return false;
			}
			else {
				insitePost(this.id);
				return true;
			}
		}
	});


	$("#country").change(function() {
		country_selected = this.value;
		if(country_selected != usa) {
			$("#fizzle").show();
		}
		else {
			$("#fizzle").hide();
		}
	});

});

