function fc_PreProcess(data, id) {
	var form_id = id;
	
	//Perform operations on form data only if the form is the 'add-subscription' form
	if (form_id == 'add-patient-satisfaction') {
	
		var errors = 0; // Let's define a variable to count the number of errors.
		var provider_state = $('#state').val(); // Let's grab the value entered in the State field.
		var provider_license = $('#license_number').val(); //Let's gran the value entered in the license number field.
		var provider_id = provider_state+provider_license;
		
		// Let's verify the user has selected a state
		if (!provider_state) { 
			// Let's print the error and add +1 to our errors variable:
			if ($("#state-error").length == 0) {
				$('#state').after("<label class=\"error\" id=\"state-error\">This field is required.</label>");
			}
			errors ++;
		} else {
			// If we've previously written an error, but the user fixed the issue let's remove the error.
			if ($("#state-error").length != 0) {$("#state-error").remove();}
		}
		
		// Let's verify the user has entered a license number
		if (!provider_license) {
			// Let's print the error and add +1 to our errors variable:
			if ($("#license-error").length == 0) {
				$('#license_number').after("<label class=\"error\" id=\"license-error\">This field is required.</label>");
			}
			errors ++;
		} else {
			// If we've previously written an error, but the user fixed the issue let's remove the error.
			if ($("#license-error").length != 0) {$("#license-error").remove();}
		}
		
		// Let's see if there are any errors. If there are, let's return false and reset the error count so the user can try again.
		if (errors > 0) {
			return false;
			errors = 0;
		} 
		//If there are no errors, let's do some more work with the data.
	}
	
	for(var i=0; i<fc_json.products.length; i++) {
		if (fc_json.products[i].name == $("#name").val()) {
			$(".duplicate").css("display","block");
			return false;
			break;
		}
	}
	
	return true;
}


var create_add_subscription_complete = false;

function resetAddSubscription() {
	$("#add-subscription").fadeOut("slow");
	$.scrollTo("#subscription-pricing");
	$("#subscribe-message").empty();
	create_add_subscription_complete = false;
	return false;
}

function createAddSubscription() {
	var provider_state = $('#state-verify').val(); // Let's grab the value entered in the State field.
	var provider_license = $('#license_number-verify').val(); //Let's gran the value entered in the license number field.
	var provider_id = provider_state+provider_license;
	
	//Let's create the variables that we'll be configuring.
	var discount = false;
	var message;
	
	$.post("http://www.dentra.com/_scripts/wds-lookup/",  { provider_lookup : provider_id }, function(results) {
		if (results > 0) {
			discount = true;
			message = "Congratulations, you are eligible for the WDS offer and will receive up to a three year subscription to PracticeView&trade; at no cost.";
			$('#category').val("WDS");
			$('#code').val("1001");
			$('#sub_frequency').val("3y");
			$('#price').val("2400.00");
			
			$('#category2').val("WDS");
			$('#code2').val("4101");
			$('#price2').val("100");
			
			$('#coupon').val("X9SEWRUC");			
		}
		else {
			message = "Although you are not eligible for the WDS offer, please click \"ADD TO CART\" to view PracticeView&trade; pricing.";
		}
		
		$('#state').val(provider_state);
		$('#license_number').val(provider_license);
		
		if (!create_add_subscription_complete) {		
			$("#subscribe-message").append(message);		
			$("#add-subscription").fadeIn("slow");
			$.scrollTo("#add-subscription");
			create_add_subscription_complete = true;
		}
	});
}