var RegistrationDetails = new Object();

$(document).ready(function() {

	$.initRegistrationForm();

	$('#existingCustomerReg').click(function(event) {
		event.preventDefault();
		$.handleExistingRegCheck();
	})

});

$.initRegistrationForm = function() {
	var api = $("#registrationLink").overlay({
		top: 50,
		left: "center",
		closeOnClick: false,
	    expose: { 
	        color: '#333', 
	        loadSpeed: 300, 
	        opacity: 0.3
	    },
		onLoad: $.resetRegForm,
		onClose: $.resetRegForm, 
		api: true
	});

	$('#regForm').validationEngine({
		promptPosition: 'centerRight'
	});
	
	$('#newCustomerReg').click(function(event) {
		event.preventDefault();
		$('#regOptionForm').hide();
		$.startNewRegProcess();
	});
	
	$('#newLoginButton').click(function(event) {
		event.preventDefault();
		$.handleNewLoginCreate();
	});

/*	
	$('#registrationTypeContract').click(function(event) {
		event.preventDefault();
		$('#custNum').removeClass('validate[required]');
		$('#wholesalerZipCode').removeClass('validate[required]');
		$('#contractNum').addClass('validate[required]');
		$('#contractZipCode').addClass('validate[required]');
	});
	
	$('#registrationTypeWholesaler').click(function(event) {
		event.preventDefault();
		$('#contractNum').removeClass('validate[required]');
		$('#contractZipCode').removeClass('validate[required]');
		$('#custNum').addClass('validate[required]');
		$('#wholesalerZipCode').addClass('validate[required]');
	});
	*/
};

$.resetRegForm = function() {
	$('#regErrorDiv').html('');
	$('#newRegFormDiv').hide();
	$('#existingRegFormDiv').hide();
	$('#successMessageDiv').html('');
	$('#regOptionForm').show();
	$.validationEngine.closePrompt('.formError',true);
	$.initCurveInputs();

};

// check whether to show form for existing customer numbers
$.handleExistingRegCheck = function() {
	
	var isValid = $('#regForm').validationEngine({returnIsValid:true, promptPosition: 'centerRight'});
	
	if (isValid) {
	
		$.postJSON("services/json/UserService.cfc?returnFormat=json&method=checkRegEligibility", {
			customer: $('#contractNum').val(),
			zip: $('#contractZipCode').val()
		}, function(json){
			if (checkJsonError(json)) {
				if (json.length) {
					$('#regErrorDiv').html(json);
					$('#regErrorDiv').show();
				}
				else {
				
					$.postJSON("services/json/UserService.cfc?returnFormat=json&method=getHintQuestions", {}, function(json){
						$('#hintquestion').find('option').remove();
						var optionArray = new Array();
						optionArray.push('<option value=""></option>');
						
						$.each(json, function(i, item){
							var currOptionValue = item.LOGIN_HINT_ID;
							var currOptionDisplay = item.LOGIN_HINT_TXT;
							optionArray.push('<option value="' + currOptionValue + '">' + currOptionDisplay + '</option>');
						});
						
						$('#hintquestion').append(optionArray.join(""));
					});
					
					$('#custNumRegForm').html('<b>' + $('#contractNum').val() + '</b>&nbsp;&nbsp;');
					$('#regOptionForm').hide();
					$('#existingRegFormDiv').show();
					$("#existingRegForm").validationEngine({promptPosition: 'centerRight'});
					$.initCurveInputs();
					$('#customer_num').val($('#customer').val());
				}
			}
		});
		
	}
	
}

$.handleNewLoginCreate = function() {
	
	var isValid = $('#existingRegForm').validationEngine({returnIsValid:true, promptPosition: 'centerRight'});
	
	if (isValid) {
	
		$.postJSON("services/json/UserService.cfc?returnFormat=json&method=createLogin", {
			userlogin: $('#userlogin').val(),
			password1: $('#password1').val(),
			password2: $('#password2').val(),
			hintquestion: $('#hintquestion').val(),
			hintanswer: $('#hintanswer').val(),
			title: $('#title').val(),
			first_name_display: $('#first_name_display').val(),
			last_name_display: $('#last_name_display').val(),
			requested_by_email: $('#requested_by_email').val(),
			confirm_email: $('#confirm_email').val(),
			chkReceive: $('#chkReceive').val(),
			customer_num: $('#customer_num').val()
		}, function(json){
			if (checkJsonError(json)) {
				var isSuccess = false;
				var msgHTML = new Array();
				var isInEContracts = $('#isInEContracts').val();
				var errorMessage = 'There was an issue with your registration. Please verify that the information entered is correct.';
				if (json.MESSAGE.length) {
				
					if (json.MESSAGE == 'SUCCESS') {
						isSuccess = true;
						msgHTML.push('			<p>&nbsp;</p> ');
						msgHTML.push(' 			<p style="font-weight: bold;">Your Registration was Successful!</p> ');
						msgHTML.push('			<p>&nbsp;</p> ');
						msgHTML.push(' 			<p>Please remember to store your User Name and Password in a safe place.<br/> ');
						msgHTML.push(' 			Your password is case sensitive.</p> ');
						msgHTML.push(' 			<form action="index.cfm" method="post" name="jsform"> ');
						msgHTML.push(' 				<input type="hidden" name="fa" value="auth.login"/> ');
						msgHTML.push(' 				<input type="hidden" name="username" value="{username}"/> ');
						msgHTML.push(' 				<input type="hidden" name="password" value="{password}"/> ');
						msgHTML.push(' 			</form><br/><br/> ');
						if (isInEContracts) {
							msgHTML.push('			<a href="#" onclick="$.closeRegOverlay(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_close.gif"></a>');
						} else {
							msgHTML.push('			<a href="#" id="newRegBack" style="margin-left:5px;"><img src="images/buttons/btn_enter_contract_econnection.gif"></a>');
						} 
						msgHTML.push('			<p>&nbsp;</p> ');
						msgHTML.push('			<p>If you have any questions, please contact the support center at 1-800-VACCINE (1-800-822-2463)</p> ');
						msgHTML.push('			<p>&nbsp;</p> ');
						msgHTML.push('			<p style="font-weight: bold;">Thank you from all of us at Contract eConnection</p> ');
						
					}
					else if (json.MESSAGE == 'DUPLICATE') {
						msgHTML.push('We have encountered a problem with creating a new user.  The user name that you have chosen is not available.');
					}
					else if (json.MESSAGE == 'LOGIN MATCH CUSTOMER') {
						msgHTML.push('We have encountered a problem with creating a new user. The login name matches the customer number.');
					}
					else if (json.MESSAGE == 'PASSWORD MATCH CUSTOMER') {
						msgHTML.push('We have encountered a problem with creating a new user. The password matches either the customer number or the login name.');
					}
					else if (json.MESSAGE == 'PASSWORD MATCH LOGIN') {
						msgHTML.push('We have encountered a problem with creating a new user. The password matches either the customer number or the login name.');
					}
					else if (json.MESSAGE == 'PASSWORD NOT MATCH') {
						msgHTML.push('We have encountered a problem with creating a new user. The passwords do not match.');
					}
					else if (json.MESSAGE == 'EMAIL NOT MATCH') {
						msgHTML.push('We have encountered a problem with creating a new user. The e-mails do not match.');
					}
					else if (json.MESSAGE == 'EMAIL BLOCKED') {
						msgHTML.push('We are unable to grant access at this time, please call sanofi pasteur at 1-800-VACCINE (1-800-822-2463).  Thank you.');
					}
					else if (json.MESSAGE == 'INPUT') {
						msgHTML.push('We have encountered a problem with creating a new user. Please check the information that you have submitted.');
					}			
								
				}
				
				if (isSuccess) {
				
					$('#existingRegFormDiv').hide();
					$('#successMessageDiv').html(msgHTML.join('\n'));
					$("#successMessageDiv").show();
					$('#newRegBack').click(function(event){
						event.preventDefault();
						$.handleAutologin();
					})
					
				}
				else {
					$('#existingRegErrorDiv').html(msgHTML.join('\n'));
					$('#existingRegErrorDiv').show();
				}
				$.initButtons();
			}
		});
		
	}
	
}

$.handleAutologin = function() {
	$('input[id=username]').val($('#userlogin').val());
	$('input[id=password]').val($('#password1').val());
	$.closeRegOverlay();
	$('#loginButton').click();
}

$.closeRegOverlay = function() {
	$("#registrationLink,#registerButton").each(function() {
		$(this).overlay().close(); 
	});
}

$.startNewRegProcess = function () {
	RegistratioDetails = new Object();
	RegistrationDetails.Contacts = [];
	$.buildNewRegShippingForm();
}

$.buildNewRegShippingForm = function(){
	$.validationEngine.closePrompt('.formError',true);
	
	var shippingFormHTML = [];
	
	$.showRegFormLoading();
	
	shippingFormHTML.push(
		'<div style="width:auto; text-align:right;"><span class="required_field">* </span>= Required Field</div>'
		,'<form id="newRegShippingForm" method="post" action="index.cfm">'
			,'<table cellspacing="0" cellpadding="5" border="0" style="width:auto;">'
				,'<tr><td colspan="3"><span class="standard_bold_text">Shipping Information</span></td></tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td width="33%" align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Facility/Name of Doctor:</td>'
					,'<td width="40%" align="left" valign="top"><input type="text" name="reg_facility_name" id="reg_facility_name" class="regular_input validate[required]" style="width:200px;" maxlength="100" /></td>'
					,'<td width="27%">&nbsp;</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Shipping Address:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_shipping_address" id="reg_shipping_address" class="regular_input validate[required]" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>City:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_shipping_city" id="reg_shipping_city" class="regular_input validate[required]" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>State:</td>'
					,'<td align="left" valign="top" colspan="2">'
						, $.buildRegistrationStateDropDown('reg_shipping_state',true)
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Postal Code:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_shipping_postal_code" id="reg_shipping_postal_code" class="regular_input validate[required,custom[onlyNumber]]" style="width:80px;" maxlength="5" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span>&nbsp; </span>ATTN line (for shipping):</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_attention_line" id="reg_attention_line" class="regular_input" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Delivery Days:</td>'
					,'<td align="left" valign="top" colspan="2">'
						,'<select name="reg_delivery_day_from" id="reg_delivery_day_from" style="width:75px;">'
		              		,'<option value="Mon">Mon</option>'
		              		,'<option value="Tue">Tue</option>'
							,'<option value="Wed">Wed</option>'
							,'<option value="Thur">Thur</option>'
							,'<option value="Fri">Fri</option>'
						,'</select>'
						,'&nbsp;-&nbsp;'
						,'<select name="reg_delivery_day_to" id="reg_delivery_day_to" style="width:75px;">'
							,'<option value="Fri">Fri</option>'
							,'<option value="Mon">Mon</option>'
							,'<option value="Tue">Tue</option>'
							,'<option value="Wed">Wed</option>'
							,'<option value="Thur">Thur</option>'
						,'</select>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Delivery Hours:</td>'
					,'<td align="left" valign="top" colspan="2">'
						,'<div style="float:left;"><input type="text" name="reg_delivery_time_from" id="reg_delivery_time_from" class="regular_input validate[required]" style="width:50px;" maxlength="5" /></div>'
						,'<div style="float:left;">&nbsp;-&nbsp;</div>'
						,'<div style="float:left;"><input type="text" name="reg_delivery_time_to" id="reg_delivery_time_to" class="regular_input validate[required]" style="width:50px;" maxlength="5" /></div>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span>&nbsp; </span>Other Delivery Information:</td>'
					,'<td align="left" valign="top" colspan="2">'
						,'<textarea id="reg_other_information" class="curve_textarea" style="width:200px; margin-left:-2px;" maxlength="300"></textarea>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Practice/Specialty/Facility:</td>'
					,'<td align="left" valign="top" colspan="2">'
						,'<select name="reg_specialty" id="reg_specialty" style="width:175px;" class="validate[required]">'
							,'<option value=""></option>'
							,'<option value="Pediatrician">Pediatrician</option>'
							,'<option value="Primary Care Physician">Primary Care Physician</option>'
							,'<option value="Hospital">Hospital</option>'
							,'<option value="Health Department">Health Department</option>'
							,'<option value="Pharmacy">Pharmacy</option>'
							,'<option value="Allergists">Allergists</option>'
							,'<option value="Urologists">Urologists</option>'
							,'<option value="Oncologists">Oncologists</option>'
							,'<option value="OB/GYN">OB/GYN</option>'
							,'<option value="Academic Institution">Academic Institution</option>'
							,'<option value="Corporation">Corporation</option>'
							,'<option value="Military">Military</option>'
							,'<option value="VA Hospital">VA Hospital</option>'
							,'<option value="Internal Medicine">Internal Medicine</option>'
							,'<option value="Cardiologists">Cardiologists</option>'
							,'<option value="Specialty Physicians">Specialty Physicians</option>'
							,'<option value="Long Term Care">Long Term Care</option>'
							,'<option value="Emergency Care">Emergency Care</option>'
							,'<option value="Laboratories">Laboratories</option>'
							,'<option value="HMO Staff">HMO Staff</option>'
							,'<option value="Travel Clinic">Travel Clinic</option>'
						,'</select>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Telephone:</td>'
					,'<td align="left" valign="top"><input type="text" name="reg_phone" id="reg_phone" class="regular_input validate[required,custom[telephone]]" style="width:200px;" maxlength="15" /></td>'
					,'<td align="left" valign="top">(xxx) xxx-xxxx</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Fax:</td>'
					,'<td align="left" valign="top"><input type="text" name="reg_fax" id="reg_fax" class="regular_input validate[required, custom[telephone]]" style="width:200px;"  maxlength="15" /></td>'
					,'<td align="left" valign="top">(xxx) xxx-xxxx</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>E-mail Address:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_email" id="reg_email" class="regular_input validate[required,custom[email]]" style="width:200px;"  maxlength="200" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Please Confirm Your E-mail Address:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_confirm_email" id="reg_confirm_email" class="regular_input validate[required,confirm[reg_email],custom[email]]" style="width:200px;" maxlength="200" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:20px;"></td></tr>'
				,'<tr>'
					,'<td colspan="3">'
						,'<a href="#" onclick="$.resetRegForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_back.gif"></a>'
						,'<a href="#" onclick="$.processRegShippingForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_next.gif"></a>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:5px;"></td></tr>'
				,'<tr>'
					,'<td colspan="3" align="center">'
						,'<a href="#" onclick="$.closeRegOverlay(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_cancel.gif"></a>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:10px;"></td></tr>'
			,'</table>'
		,'</form>'
	);

	$("#newRegFormDiv").html(shippingFormHTML.join(''));
	$.hideRegFormLoading();
	$.initCurveInputs();
	$("#newRegShippingForm").validationEngine({promptPosition: 'centerRight'});
	
	typeof(RegistrationDetails.FacilityName) != 'undefined' ? $("#reg_facility_name").val(RegistrationDetails.FacilityName) : $("#reg_facility_name").val('');
	typeof(RegistrationDetails.ShippingAddress) != 'undefined' ? $("#reg_shipping_address").val(RegistrationDetails.ShippingAddress) : $("#reg_shipping_address").val('');
	typeof(RegistrationDetails.ShippingCity) != 'undefined' ? $("#reg_shipping_city").val(RegistrationDetails.ShippingCity) : $("#reg_shipping_city").val('');
	typeof(RegistrationDetails.ShippingState) != 'undefined' ? $("#reg_shipping_state").val(RegistrationDetails.ShippingState) : $("#reg_shipping_state").val('');
	typeof(RegistrationDetails.ShippingPostalCode) != 'undefined' ? $("#reg_shipping_postal_code").val(RegistrationDetails.ShippingPostalCode) : $("#reg_shipping_postal_code").val('');
	typeof(RegistrationDetails.AttentionLine) != 'undefined' ? $("#reg_attention_line").val(RegistrationDetails.AttentionLine) : $("#reg_attention_line").val('');
	typeof(RegistrationDetails.DeliveryDayFrom) != 'undefined' ? $("#reg_delivery_day_from").val(RegistrationDetails.DeliveryDayFrom) : $("#reg_delivery_day_from").val('');
	typeof(RegistrationDetails.DeliveryDayTo) != 'undefined' ? $("#reg_delivery_day_to").val(RegistrationDetails.DeliveryDayTo) : $("#reg_delivery_day_to").val('');
	typeof(RegistrationDetails.DeliveryTimeFrom) != 'undefined' ? $("#reg_delivery_time_from").val(RegistrationDetails.DeliveryTimeFrom) : $("#reg_delivery_time_from").val('');
	typeof(RegistrationDetails.DeliveryTimeTo) != 'undefined' ? $("#reg_delivery_time_to").val(RegistrationDetails.DeliveryTimeTo) : $("#reg_delivery_time_to").val('');
	typeof(RegistrationDetails.OtherInformation) != 'undefined' ? $("#reg_other_information").val(RegistrationDetails.OtherInformation) : $("#reg_other_information").val('');
	typeof(RegistrationDetails.Specialty) != 'undefined' ? $("#reg_specialty").val(RegistrationDetails.Specialty) : $("#reg_specialty").val('');
	typeof(RegistrationDetails.Phone) != 'undefined' ? $("#reg_phone").val(RegistrationDetails.Phone) : $("#reg_phone").val('');
	typeof(RegistrationDetails.Fax) != 'undefined' ? $("#reg_fax").val(RegistrationDetails.Fax) : $("#reg_fax").val('');
	typeof(RegistrationDetails.Email) != 'undefined' ? $("#reg_email").val(RegistrationDetails.Email) : $("#reg_email").val('');
}

$.processRegShippingForm = function () {
	isValid = $('#newRegShippingForm').validationEngine({returnIsValid:true, promptPosition: 'centerRight'});

	if (isValid) {
		RegistrationDetails.FacilityName = $("#reg_facility_name").val();
		RegistrationDetails.ShippingAddress =  $("#reg_shipping_address").val();
		RegistrationDetails.ShippingCity =  $("#reg_shipping_city").val();
		RegistrationDetails.ShippingState =  $("#reg_shipping_state").val();
		RegistrationDetails.ShippingPostalCode =  $("#reg_shipping_postal_code").val();
		RegistrationDetails.AttentionLine =  $("#reg_attention_line").val();
		RegistrationDetails.DeliveryDayFrom =  $("#reg_delivery_day_from").val();
		RegistrationDetails.DeliveryDayTo =  $("#reg_delivery_day_to").val();
		RegistrationDetails.DeliveryTimeFrom =  $("#reg_delivery_time_from").val();
		RegistrationDetails.DeliveryTimeTo =  $("#reg_delivery_time_to").val();
		RegistrationDetails.OtherInformation =  $("#reg_other_information").val();
		RegistrationDetails.Specialty =  $("#reg_specialty").val();
		RegistrationDetails.Phone =  $("#reg_phone").val();
		RegistrationDetails.Fax =  $("#reg_fax").val();
		RegistrationDetails.Email =  $("#reg_email").val();
		
		$.buildNewRegPersonalForm();
	}

}

$.buildNewRegPersonalForm = function(){
	var personalFormHTML = [];

	$.showRegFormLoading();
	
	personalFormHTML.push(
		'<div style="float:right;"><span class="required_field">* </span>= Required Field</div>'
		,'<div style="clear:both; height:5px;"></div>'
		,'<form id="newRegPersonalForm" method="post" action="index.cfm">'
			,'<table cellspacing="0" cellpadding="5" border="0" style="width:auto;">'
				,'<tr><td colspan="3"><span class="standard_bold_text">Personal Information</span></td></tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td width="5%" align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>State License:</td>'
					,'<td width="45%" align="left" valign="top"><input type="text" name="state_license" id="state_license" class="regular_input validate[required]" style="width:200px;" maxlength="100" /></td>'
					,'<td width="50%">&nbsp;</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>State License Expiration:</td>'
					,'<td align="left" valign="top"><input type="text" name="state_license_expiration" id="state_license_expiration" class="regular_input validate[required,custom[date]]" style="width:100px;" maxlength="10" /></td>'
					,'<td align="left" valign="top">Date: yyyy-mm-dd</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span>&nbsp; </span>DEA #:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="dea_number" id="dea_number" class="regular_input" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Name appearing on State License / DEA #:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="dea_name" id="dea_name" class="regular_input validate[required]" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span class="required_field">* </span>Primary Office Contact Name:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="primary_contact_name" id="primary_contact_name" class="regular_input validate[required]" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span>&nbsp; </span>Contact Telephone:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="primary_contact_telephone" id="primary_contact_telephone" class="regular_input" style="width:200px;" maxlength="20" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;"><span>&nbsp; </span>Contact Extension:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="primary_contact_extension" id="primary_contact_extension" class="regular_input" style="width:200px;" maxlength="20" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:20px;"></td></tr>'
				,'<tr>'
					,'<td colspan="3">'
						,'<a href="#" onclick="$.buildNewRegShippingForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_back.gif"></a>'
						,'<a href="#" onclick="$.processRegPersonalForm(\'contacts\'); return false;" style="margin-left:5px;"><img src="images/buttons/btn_add_more_contacts.gif"></a>'
						,'<a href="#" onclick="$.processRegPersonalForm(\'billing\'); return false;" style="margin-left:5px;"><img src="images/buttons/btn_next.gif"></a>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:5px;"></td></tr>'
				,'<tr>'
					,'<td colspan="3" align="center">'
						,'<a href="#" onclick="$.closeRegOverlay(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_cancel.gif"></a>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:10px;"></td></tr>'
			,'</table>'
		,'</form>'
	);

	$("#newRegFormDiv").html(personalFormHTML.join(''));
	$.hideRegFormLoading();
	$.initCurveInputs();
	
	$("#newRegPersonalForm").validationEngine({promptPosition: 'centerRight'});
	
	typeof(RegistrationDetails.StateLicense) != 'undefined' ? $("#state_license").val(RegistrationDetails.StateLicense) : $("#state_license").val('');
	typeof(RegistrationDetails.StateLicenseExpiration) != 'undefined' ? $("#state_license_expiration").val(RegistrationDetails.StateLicenseExpiration) : $("#state_license_expiration").val('');
	typeof(RegistrationDetails.DEANumber) != 'undefined' ? $("#dea_number").val(RegistrationDetails.DEANumber) : $("#dea_number").val('');
	typeof(RegistrationDetails.DEAName) != 'undefined' ? $("#dea_name").val(RegistrationDetails.DEAName) : $("#dea_name").val('');
	typeof(RegistrationDetails.PrimaryContactName) != 'undefined' ? $("#primary_contact_name").val(RegistrationDetails.PrimaryContactName) : $("#primary_contact_name").val('');
	typeof(RegistrationDetails.PrimaryContactTelephone) != 'undefined' ? $("#primary_contact_telephone").val(RegistrationDetails.PrimaryContactTelephone) : $("#primary_contact_telephone").val('');
	typeof(RegistrationDetails.PrimaryContactExtension) != 'undefined' ? $("#primary_contact_extension").val(RegistrationDetails.PrimaryContactExtension) : $("#primary_contact_extension").val('');
}

$.processRegPersonalForm = function (nextStep) {
	isValid = $('#newRegPersonalForm').validationEngine({returnIsValid:true, promptPosition: 'centerRight'});
	
	if (isValid) {
		
		RegistrationDetails.StateLicense =  $("#state_license").val();
		RegistrationDetails.StateLicenseExpiration =  $("#state_license_expiration").val();
		RegistrationDetails.DEANumber =  $("#dea_number").val();
		RegistrationDetails.DEAName =  $("#dea_name").val();
		RegistrationDetails.PrimaryContactName =  $("#primary_contact_name").val();
		RegistrationDetails.PrimaryContactTelephone =  $("#primary_contact_telephone").val();
		RegistrationDetails.PrimaryContactExtension =  $("#primary_contact_extension").val();
		
 		if (nextStep == 'contacts') {
		 	$.buildNewRegContactForm();
	 	}
	 	else {
	 		$.buildNewRegBillingForm();
	 	}
	}
}

$.buildNewRegContactForm = function(){
	var contactFormHTML = [];

	$.showRegFormLoading();
	
	contactFormHTML.push(
		'<div style="float:right;"><span class="required_field">* </span>= Required Field</div>'
		,'<div style="clear:both; height:5px;"></div>'
		,'<form id="newRegPersonalForm" method="post" action="index.cfm">'
		,'<div style="width:auto; margin-bottom:10px;" class="standard_bold_text">Contact Information</div>'
		,'<div style="width:auto; margin-bottom:5px;">To maintain the integrity of your customer information, please list all Physicians, Physician Assistants, and Nurse Practitioners in your practice.</div>'
		,'<table cellspacing="0" cellpadding="5" border="0" style="width:100%;">'
			, $.buildRegContactSection('physician','Physician')
			, $.buildRegContactSection('assistant','Physician Assistant')
			, $.buildRegContactSection('practitioner','Nurse Practitioner')
		,'</table>'
		,'</form>'
		,'<div style="width:auto;">'
			,'<a href="#" onclick="$.buildNewRegPersonalForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_back.gif"></a>'
			,'<a href="#" onclick="$.processRegContactForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_next.gif"></a>'
		,'</div>'
		,'<table width="100%" cellpadding="0" cellspacing="0">'
			,'<tr><td colspan="3" style="height:5px;"></td></tr>'
			,'<tr>'
				,'<td colspan="3" align="center">'
					,'<a href="#" onclick="$.closeRegOverlay(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_cancel.gif"></a>'
				,'</td>'
			,'</tr>'
		,'</table>'
	);
			
	$("#newRegFormDiv").html(contactFormHTML.join(''));
	$.hideRegFormLoading();
	$.initCurveInputs();
	
	if (typeof(RegistrationDetails.Contacts) != 'undefined') {
		for (var x = 0; x < RegistrationDetails.Contacts.length; x++) {
			if (typeof(RegistrationDetails.Contacts[x]) != 'undefined') {
				typeof(RegistrationDetails.Contacts[x].Name) != 'undefined' ? $("#contact_name_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val(RegistrationDetails.Contacts[x].Name) : $("#contact_name_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val('');
				typeof(RegistrationDetails.Contacts[x].Specialty) != 'undefined' ? $("#contact_specialty_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val(RegistrationDetails.Contacts[x].Specialty) : $("#contact_specialty_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val('');
				typeof(RegistrationDetails.Contacts[x].LicenseNumber) != 'undefined' ? $("#contact_license_number_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val(RegistrationDetails.Contacts[x].LicenseNumber) : $("#contact_license_number_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val('');
				typeof(RegistrationDetails.Contacts[x].Email) != 'undefined' ? $("#contact_email_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val(RegistrationDetails.Contacts[x].Email) : $("#contact_email_" + RegistrationDetails.Contacts[x].Type + "_" + RegistrationDetails.Contacts[x].Position).val('');
			}
		}
	}
}


$.buildRegContactSection = function(contactType, contactDescription) {
	var contactSectionHTML = [];
	
	contactSectionHTML.push(
		'<tr><td colspan="4" align="left" valign="top">Please enter ' + contactDescription + ' information:</td></tr>'
		,'<tr><td colspan="4" style="height:6px;"></td></tr>'
		,'<tr>'
			,'<td width="25%" align="left" valign="top" style="white-space: nowrap;"><strong>Full Name (First, Last)</strong></td>'
			,'<td width="25%" align="left" valign="top" style="white-space: nowrap;"><strong>Specialty</strong></td>'
			,'<td width="25%" align="left" valign="top" style="white-space: nowrap;"><strong>State License Number</strong></td>'
			,'<td width="25%" align="left" valign="top" style="white-space: nowrap;"><strong>E-mail Address</strong></td>'
		,'</tr>'
	);
	
	for (var x = 0; x < 5; x++) {
		contactSectionHTML.push(
			'<tr>'
				,'<td align="left" valign="top"><input type="text" id="contact_name_' + contactType + '_' + x + '" class="regular_input" style="width:110px;" /></td>'
				,'<td align="left" valign="top"><input type="text" id="contact_specialty_' + contactType + '_' + x + '" class="regular_input" style="width:110px;" /></td>'
				,'<td align="left" valign="top"><input type="text" id="contact_license_number_' + contactType + '_' + x + '" class="regular_input" style="width:110px;" /></td>'
				,'<td align="left" valign="top"><input type="text" id="contact_email_' + contactType + '_' + x + '" class="regular_input" style="width:110px;" /></td>'
			,'</tr>'
			,'<tr><td colspan="4" style="height:3px;"></td></tr>'
		);
	}
	
	contactSectionHTML.push(
		'<tr><td colspan="4" style="height:15px;"></td></tr>'
	);
	
	return contactSectionHTML.join('');
}

$.processRegContactForm = function () {
	
	RegistrationDetails.Contacts = [];
	$.processRegContactSection('physician');
	$.processRegContactSection('assistant');
	$.processRegContactSection('practitioner');
	
	$.buildNewRegBillingForm();
}

$.processRegContactSection = function (contactType) {

	var count = 0;
	for (var x = 0; x < 5; x++) {
		if ($("#contact_name_" + contactType + "_" + x).val() != '') {
			var contact = new Object();
			contact.Name = $("#contact_name_" + contactType + "_" + x).val();
			contact.Specialty = $("#contact_specialty_" + contactType + "_" + x).val();
			contact.LisenseNumber = $("#contact_license_number_" + contactType + "_" + x).val();
			contact.Email = $("#contact_email_" + contactType + "_" + x).val();
			contact.Type = contactType;
			contact.Position = count;
			count++;
			RegistrationDetails.Contacts.push(contact);
		}
	}
}

$.buildNewRegBillingForm = function(){
	var billingFormHTML = [];

	$.showRegFormLoading();
	
	billingFormHTML.push(
		'<div style="float:right;"><span class="required_field">* </span>= Required Field</div>'
		,'<div style="clear:both; height:5px;"></div>'
		,'<div style="width:auto; margin-bottom:10px;" class="standard_bold_text">Billing Information</div>'
		,'<div style="width:auto; margin-bottom:10px;">'
			,'The following states have state sales tax on vaccines:<br />'
			,'GA, HI, IL, KY, LA, MN, SC, and WV.<br />'
			,'If you are state sales tax exempt, please fax the certificate to:<br />'
			,'1-800-295-7808, Attn: New Contract eConnection Customer Representative.'
		,'</div>'
		,'<div style="width:auto;">If invoices should be mailed separately, please indicate address below.</div>'
		,'<form id="newRegBillingForm" method="post" action="index.cfm">'
			,'<table cellspacing="0" cellpadding="5" border="0" style="width:auto;">'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td width="5%" align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Name:</td>'
					,'<td width="45%" align="left" valign="top"><input type="text" name="reg_invoice_name" id="reg_invoice_name" class="regular_input" style="width:200px;" maxlength="100" /></td>'
					,'<td width="50%">&nbsp;</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Address:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_invoice_address" id="reg_invoice_address" class="regular_input" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">City:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_invoice_city" id="reg_invoice_city" class="regular_input" style="width:200px;" maxlength="100" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">State:</td>'
					,'<td align="left" valign="top" colspan="2">'
						, $.buildRegistrationStateDropDown('reg_invoice_state',false)
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Postal Code:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_invoice_postal_code" id="reg_invoice_postal_code" class="regular_input" style="width:50px;" maxlength="10" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Telephone:</td>'
					,'<td align="left" valign="top"><input type="text" name="reg_invoice_phone" id="reg_invoice_phone" class="regular_input" style="width:200px;" maxlength="20" /></td>'
					,'<td align="left" valign="top">(xxx) xxx-xxxx</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Fax:</td>'
					,'<td align="left" valign="top"><input type="text" name="reg_invoice_fax" id="reg_invoice_fax" class="regular_input" style="width:200px;" maxlength="20" /></td>'
					,'<td align="left" valign="top">(xxx) xxx-xxxx</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:20px;"></td></tr>'
				,'<tr><td align="left" valign="top" colspan="3">Is your practice/facility financially responsible for vaccine bills?</td></tr>'
				,'<tr><td align="left" valign="top" colspan="3">'
					,'<input type="radio" id="vaccine_bills" name="vaccine_bills" value="1" checked="checked" onclick="$.showVaccineBilling();" />&nbsp;Yes'
					,'<input type="radio" id="vaccine_bills" name="vaccine_bills" value="0" style="margin-left:10px;" onclick="$.showVaccineBilling();" />&nbsp;No'
				,'</td></tr>'
			,'</table>'
	);
			
	billingFormHTML.push(
		'<div style="margin-top:10px; width:auto; display:none;" id="vaccine_billing_div">'
			,'<table cellspacing="0" cellpadding="5" border="0" style="width:auto;">'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td width="5%" align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Name:</td>'
					,'<td width="45%" align="left" valign="top"><input type="text" name="reg_vaccine_name" id="reg_vaccine_name" class="regular_input" style="width:200px;" maxlength="100"  /></td>'
					,'<td width="50%">&nbsp;</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Address:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_vaccine_address" id="reg_vaccine_address" class="regular_input" style="width:200px;" maxlength="100"  /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">City:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_vaccine_city" id="reg_vaccine_city" class="regular_input" style="width:200px;" maxlength="100"  /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">State:</td>'
					,'<td align="left" valign="top" colspan="2">'
						, $.buildRegistrationStateDropDown('reg_vaccine_state',false)
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Postal Code:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_vaccine_postal_code" id="reg_vaccine_postal_code" class="regular_input" style="width:50px;" maxlength="10"  /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Telephone:</td>'
					,'<td align="left" valign="top"><input type="text" name="reg_vaccine_phone" id="reg_vaccine_phone" class="regular_input" style="width:200px;" maxlength="20"  /></td>'
					,'<td align="left" valign="top">(xxx) xxx-xxxx</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">Fax:</td>'
					,'<td align="left" valign="top"><input type="text" name="reg_vaccine_fax" id="reg_vaccine_fax" class="regular_input" style="width:200px;" maxlength="20"  /></td>'
					,'<td align="left" valign="top">(xxx) xxx-xxxx</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
				,'<tr>'
					,'<td align="left" valign="top" style="white-space: nowrap; vertical-align: top;">ATTN:</td>'
					,'<td align="left" valign="top" colspan="2"><input type="text" name="reg_vaccine_attention" id="reg_vaccine_attention" class="regular_input" style="width:200px;" maxlength="200" /></td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:3px;"></td></tr>'
			,'</table>'
		,'</div>'
		
	);
	
	billingFormHTML.push(
			'<table cellspacing="0" cellpadding="5" border="0" style="width:100%; margin-top:20px;">'
				,'<tr>'
					,'<td colspan="3">'
						,'<a href="#" onclick="$.buildNewRegPersonalForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_back.gif"></a>'
						,'<a href="#" onclick="$.processRegBillingForm(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_finish.gif"></a>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:5px;"></td></tr>'
				,'<tr>'
					,'<td colspan="3" align="center">'
						,'<a href="#" onclick="$.closeRegOverlay(); return false;" style="margin-left:5px;"><img src="images/buttons/btn_cancel.gif"></a>'
					,'</td>'
				,'</tr>'
				,'<tr><td colspan="3" style="height:10px;"></td></tr>'
			,'</table>'
		,'</form>'
	);

	$("#newRegFormDiv").html(billingFormHTML.join(''));
	$.hideRegFormLoading();
	$.initCurveInputs();
	$("#newRegBillingForm").validationEngine({promptPosition: 'centerRight'});
}

$.processRegBillingForm = function () {
	var isValid = $('#newRegBillingForm').validationEngine({returnIsValid:true, promptPosition: 'centerRight'});
	
	if (isValid) {
		$.showRegFormLoading();
		
		RegistrationDetails.InvoiceName = $("#reg_invoice_name").val();
		RegistrationDetails.InvoiceAddress = $("#reg_invoice_address").val();
		RegistrationDetails.InvoiceCity = $("#reg_invoice_city").val();
		RegistrationDetails.InvoiceState = $("#reg_invoice_state").val();
		RegistrationDetails.InvoicePostalCode = $("#reg_invoice_postal_code").val();
		RegistrationDetails.InvoicePhone = $("#reg_invoice_phone").val();
		RegistrationDetails.InvoiceFax = $("#reg_invoice_fax").val();
		RegistrationDetails.VaccineBills = $('input[name=vaccine_bills]:checked').val();
		RegistrationDetails.VaccineName = $("#reg_vaccine_name").val();
		RegistrationDetails.VaccineAddress = $("#reg_vaccine_address").val();
		RegistrationDetails.VaccineCity = $("#reg_vaccine_city").val();
		RegistrationDetails.VaccineState = $("#reg_vaccine_state").val();
		RegistrationDetails.VaccinePostalCode = $("#reg_vaccine_postal_code").val();
		RegistrationDetails.VaccinePhone = $("#reg_vaccine_phone").val();
		RegistrationDetails.VaccineFax = $("#reg_vaccine_fax").val();
		RegistrationDetails.VaccineAttention = $("#reg_vaccine_attention").val();
		
		
		$.postJSON("services/json/UserService.cfc?returnFormat=json&method=sendRegistrationEmail", {
			facilityName: RegistrationDetails.FacilityName,
			shippingAddress: RegistrationDetails.ShippingAddress,
			shippingCity: RegistrationDetails.ShippingCity,
			shippingState: RegistrationDetails.ShippingState,
			shippingPostalCode: RegistrationDetails.ShippingPostalCode,
			attentionLine: RegistrationDetails.AttentionLine,
			deliveryDayFrom: RegistrationDetails.DeliveryDayFrom,
			deliveryDayTo: RegistrationDetails.DeliveryDayTo,
			deliveryTimeFrom: RegistrationDetails.DeliveryTimeFrom,
			deliveryTimeTo: RegistrationDetails.DeliveryTimeTo,
			otherInformation: RegistrationDetails.OtherInformation,
			specialty: RegistrationDetails.Specialty,
			phone: RegistrationDetails.Phone,
			fax: RegistrationDetails.Fax,
			email: RegistrationDetails.Email,
			stateLicense: RegistrationDetails.StateLicense,
			stateLicenseExpiration: RegistrationDetails.StateLicenseExpiration,
			deaNumber: RegistrationDetails.DEANumber,
			deaName: RegistrationDetails.DEAName,
			primaryContactName: RegistrationDetails.PrimaryContactName,
			primaryContactTelephone: RegistrationDetails.PrimaryContactTelephone,
			primaryContactExtension: RegistrationDetails.PrimaryContactExtension,
			contacts: JSON.stringify(RegistrationDetails.Contacts),
			invoiceName: RegistrationDetails.InvoiceName,
			invoiceAddress: RegistrationDetails.InvoiceAddress,
			invoiceCity: RegistrationDetails.InvoiceCity,
			invoiceState: RegistrationDetails.InvoiceState,
			invoicePostalCode: RegistrationDetails.InvoicePostalCode,
			invoicePhone: RegistrationDetails.InvoicePhone,
			invoiceFax: RegistrationDetails.InvoiceFax,
			vaccineBills: RegistrationDetails.VaccineBills,
			vaccineName: RegistrationDetails.VaccineName,
			vaccineAddress: RegistrationDetails.VaccineAddress,
			vaccineCity: RegistrationDetails.VaccineCity,
			vaccineState: RegistrationDetails.VaccineState,
			vaccinePostalCode: RegistrationDetails.VaccinePostalCode,
			vaccinePhone: RegistrationDetails.VaccinePhone,
			vaccineFax: RegistrationDetails.VaccineFax,
			vaccineAttention: RegistrationDetails.VaccineAttention
		}, function(json){
			if (checkJsonError(json)) {
				var isSuccess = json.isSuccess;
				var msgHTML = new Array();
				var errorMessage = 'There was an issue with your registration. Please verify that the information entered is correct.';
				
				msgHTML.push('<div style="width:auto; text-align:center; margin-top:20px;">');
				
				if (isSuccess) {
					msgHTML.push(json.message);
				}
				else {
					msgHTML.push(errorMessage);
				}
				
				msgHTML.push('</div>');
				
				$("#newRegFormDiv").html(msgHTML.join(''));
				$.hideRegFormLoading();
			}
		});
		
	}
}

$.buildRegistrationStateDropDown = function(controlID,validateField) {
	var stateDropDownHTML = [];
	
	var className = "";
	if (validateField) {
		className="validate[required]";
	}
	
	stateDropDownHTML.push(
		'<select name="' + controlID + '" id="' + controlID + '" style="width:150px;" class="' + className + '">'
			,'<option value="">Please Select</option>'
			,'<option value="AL">AL</option>'
			,'<option value="AK">AK</option>'
			,'<option value="AZ">AZ</option>'
			,'<option value="AR">AR</option>'
			,'<option value="CA">CA</option>'
			,'<option value="CO">CO</option>'
			,'<option value="CT">CT</option>'
			,'<option value="DE">DE</option>'
			,'<option value="DC">DC</option>'
			,'<option value="FL">FL</option>'
			,'<option value="GA">GA</option>'
			,'<option value="HI">HI</option>'
			,'<option value="ID">ID</option>'
			,'<option value="IL">IL</option>'
			,'<option value="IN">IN</option>'
			,'<option value="IA">IA</option>'
			,'<option value="KS">KS</option>'
			,'<option value="KY">KY</option>'
			,'<option value="LA">LA</option>'
			,'<option value="ME">ME</option>'
			,'<option value="MD">MD</option>'
			,'<option value="MA">MA</option>'
			,'<option value="MI">MI</option>'
			,'<option value="MN">MN</option>'
			,'<option value="MS">MS</option>'
			,'<option value="MO">MO</option>'
			,'<option value="MT">MT</option>'
			,'<option value="NE">NE</option>'
			,'<option value="NV">NV</option>'
			,'<option value="NH">NH</option>'
			,'<option value="NJ">NJ</option>'
			,'<option value="NM">NM</option>'
			,'<option value="NY">NY</option>'
			,'<option value="NC">NC</option>'
			,'<option value="ND">ND</option>'
			,'<option value="OH">OH</option>'
			,'<option value="OK">OK</option>'
			,'<option value="OR">OR</option>'
			,'<option value="PA">PA</option>'
			,'<option value="RI">RI</option>'
			,'<option value="SC">SC</option>'
			,'<option value="SD">SD</option>'
			,'<option value="TN">TN</option>'
			,'<option value="TX">TX</option>'
			,'<option value="UT">UT</option>'
			,'<option value="VT">VT</option>'
			,'<option value="VA">VA</option>'
			,'<option value="WA">WA</option>'
			,'<option value="WV">WV</option>'
			,'<option value="WI">WI</option>'
			,'<option value="WY">WY</option>'
		,'</select>'
	);
	
	return stateDropDownHTML.join('');
}

$.showVaccineBilling = function () {
	if ($('input[name=vaccine_bills]:checked').val() == '1') {
		$("#vaccine_billing_div").hide();
	}
	else {
		$("#vaccine_billing_div").show();
	}
}

$.showRegFormLoading = function () {
	$("#newRegFormDivLoading").html('<div style="width:auto; text-align:center; font-size:11px;"><img src="images/vsh/animation/rotatingclock-fast.gif" align="center"/></div>');
	$("#newRegFormDiv").hide();
	$("#newRegFormDivLoading").show();
}

$.hideRegFormLoading = function () {
	$("#newRegFormDivLoading").html('');
	$("#newRegFormDivLoading").hide();
	$("#newRegFormDiv").show();
}




