	var planOrder = [0,1,2];
	var planTableArray = new Array();
	var sortedPlans = false;
	var currentQuote;

	function Quote(startDate, coverage, zip, dob, ageGroup, gender) {
		this.requestedStartDate = startDate || null;
		this.coverageType = coverage || null;
		this.zipCode = zip || null;
		this.applicantDOB = dob || null;
		this.applicantAgeGroup = ageGroup || null;
		this.applicantGender = gender || null;
		this.plans = {};
		for (var attr in this) {
			if (this[attr] == null) throw new Error("The '" + attr + "' attribute of the Quote object you just instantiated cannot be null!\n");
		}
	}

	Quote.prototype.filterPlans = function(rateData) {
		for (var plans in rateData) {
			for (var plan in rateData[plans]) {
				if (this.applicantAgeGroup == rateData[plans][plan]["age_group"] && 
					this.applicantGender == rateData[plans][plan]["gender"] && 
					this.coverageType == rateData[plans][plan]["coverage_type"]) {
						this.plans[plans] = rateData[plans][plan];
				}
			}
		}
	}

	function loadExternalData(src, type, storage, message, callback) {
		$('#loadingMessage').html(message);
		$('#loadingMessage').dialog('open');
		$.ajax({
			url: src,
			dataType: type,
			success: function(data) {	
				document[storage] = data;
				setTimeout(callback, 500);
			},
			error: function(data) {
				$('#loadingMessage').dialog('close');
				$('#errorMessage').dialog('open');
			}
		});
	}

		$(document).ready(function() {
			if (window.location.search.indexOf("helpmechoose") > 0) helpMeChooseOpen();
			$( "#loadingMessage" ).dialog({ autoOpen: false, modal: true, show: "fade", hide: "fade" });
			$( "#errorMessage" ).dialog({ autoOpen: false, modal: true, show: "fade", hide: "fade" });
			$( "#displayAllQuotesFrame" ).dialog({ 
				autoOpen: false, 
				modal: true, 
				show: "fade", 
				hide: "fade",
				title: "Individual and Family Plan Options",
				draggable: false,
				height: 600,
				width: 800,
				buttons: {
					"Print Quotes" : function () { 
						if ($.browser.msie) {
							document.displayAllQuotesFrame.focus();
							document.displayAllQuotesFrame.print();
						} else {
							window.frames['displayAllQuotesFrame'].print();
						}
						_gaq.push(['_trackEvent', 'Print all Quotes', 'Clicked', 'getaquote.html']);
					}, 
					"Close" : function () { 
						$(this).dialog("close");
					}} 
				});
			$( "#notFoundMessage" ).dialog({ 
				autoOpen: false, 
				modal: true, 
				show: "fade", 
				hide: "fade", 
				buttons: {
					"AskBlue" : function () {
						window.location = "http://ic.jellyvision-conversation.com/IBX/";
					}
					} 
				});	
			$( "#zipMessage" ).dialog({ 
				autoOpen: false, 
				modal: true, 
				title: "Choose your County", 
				show: "fade", 
				hide: "fade", 
				buttons: {
					"Okay" : function () { 
						var selectedCounty = $("input[name='zips']:checked").val();
						if (selectedCounty == "Berks" || selectedCounty == "Lancaster" || selectedCounty == "Lehigh" || selectedCounty == "Northampton") {
							$('#zipMessage').dialog('close');
							$( "#notFoundMessage" ).dialog("open");
						} else {
							$(this).dialog("close");
							displayResults();
						}
					}, 
					"Cancel" : function () { 
						$(this).dialog("close");
					}} 
				});
			$( "#gePlanMessage" ).dialog({ 
				autoOpen: false, 
				modal: true, 
				title: "Guaranteed Enrollment Plans", 
				show: "fade", 
				hide: "fade", 
				buttons: {
					"Learn More" : function () { 
						window.location.pathname = "/plan_information/other_plans.html";
					}, 
					"Cancel" : function () { 
						$(this).dialog("close");
					}} 
				});
			$("button").button();
			if ($.cookie('county')) $("#zipCode").val($.cookie('zipCode'));
			$("input:checkbox, input:radio, input:file, input, #coverageType, #reqDate, #applicant1Gender, #applicant2Gender").uniform();
			$("#secondaryApplicant").hide();
			prepareAvailableDates();
			$("#coverageType").change(coverageTypeHandler);
			$("#getQuoteButton").click(getQuoteHandler);
			$("#helpMeChooseSubmit").click(helpMeChooseClose);
			$("#viewAllQuotes").click(viewAllQuotesHandler);
			$("#applicant1Month, #applicant1Date, #applicant1Year, #applicant2Month, #applicant2Date, #applicant2Year").keyup(function(e) {
				$("#applicant1HiddenDate").val($("#applicant1Month").val() + "/" + $("#applicant1Date").val() + "/" + $("#applicant1Year").val());
				$("#applicant2HiddenDate").val($("#applicant2Month").val() + "/" + $("#applicant2Date").val() + "/" + $("#applicant2Year").val());
			});

			
		});

		var zipRE = /^\d{5}$|^\d{5}-\d{4}$/;

var dateRE = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;

		function validateDemographicsForm() {
			$("#errors").empty();
			$("#reqDateCell, #coverageTypeCell, #applicant1DOBCell, #applicant1GenderCell, #applicant2DOBCell, #applicant2GenderCell").css("background-color", "#e6f4fb");
			bday1 = $("#applicant1HiddenDate").val();
			bday1 = bday1.split("/");
			bday2 = $("#applicant2HiddenDate").val();
			bday2 = bday2.split("/");
			var valid = true;
			if ($("#reqDate").val() == '') {
				$("#errors").append("<li>You must select a Start Date.</li>");
			//	$("#reqDateCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if ($("#coverageType").val() == '') {
				$("#errors").append("<li>You must select a Coverage Type.</li>");
			//	$("#coverageTypeCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if (!zipRE.test($("#zipCode").val())) {
				$("#errors").append("<li>You must enter a valid Zip Code.</li>");
			//	$("#applicant2DOBCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if (!dateRE.test($("#applicant1HiddenDate").val())) {
				$("#errors").append("<li>You must enter a valid DOB for the primary applicant.</li>");
			//	$("#applicant1DOBCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if (getAgeAsOf(new Date(), new Date(bday1[2], bday1[0]-1, bday1[1])) > 65) {
				$("#errors").append("<li>The primary applicant can not be over 65. Visit <a href='http://www.ibxmedicare.com' title='ibxmedicare.com'>ibxmedicare.com</a> to learn more about our Medicare plans.</li>");
			//	$("#applicant1GenderCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if (getAgeAsOf(new Date(), new Date(bday1[2], bday1[0]-1, bday1[1])) < 18) {
				$("#errors").append("<li>The primary applicant must be over 18.</li>");
			//	$("#applicant1GenderCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if ($("#applicant1Gender").val() == '') {
				$("#errors").append("<li>You must select a gender for the primary applicant.</li>");
			//	$("#applicant1GenderCell").css("background-color", "#fcd9d9");
				valid = false;
			}
			if ($("#coverageType").val() == "Individual and Spouse" || $("#coverageType").val() == "Family") {
				if (getAgeAsOf(new Date(), new Date(bday2[2], bday2[0]-1, bday2[1])) > 65) {
					$("#errors").append("<li>The secondary applicant can not be over 65. Visit <a href='http://www.ibxmedicare.com' title='ibxmedicare.com'>ibxmedicare.com</a> to learn more about our Medicare plans.</li>");
				//	$("#applicant1GenderCell").css("background-color", "#fcd9d9");
					valid = false;
				}
				if (getAgeAsOf(new Date(), new Date(bday2[2], bday2[0]-1, bday2[1])) < 18) {
					$("#errors").append("<li>The secondary applicant must be over 18.</li>");
				//	$("#applicant1GenderCell").css("background-color", "#fcd9d9");
					valid = false;
				}
				if (!dateRE.test($("#applicant2HiddenDate").val())) {
					$("#errors").append("<li>You must enter a valid DOB for the secondary applicant.</li>");
			//		$("#applicant2DOBCell").css("background-color", "#fcd9d9");
					valid = false;
				}
				if ($("#applicant2Gender").val() == '' || $("#applicant1Gender").val() == $("#applicant2Gender").val()) {
					$("#errors").append("<li>The gender for the secondary applicant can not be the same as the first.</li>");
			//		$("#applicant2GenderCell").css("background-color", "#fcd9d9");
					valid = false;
				}
			}
			if (valid) {
				$("#errorText_wrapper").hide(); 
			} else {
				$("#errorText_wrapper").show(); 
			}
			return valid;
		}

		function coverageTypeHandler() {
			if ($("#coverageType").val() == "Individual and Spouse" || $("#coverageType").val() == "Family") {
				$("#secondaryApplicantRowOne, #secondaryApplicantRowTwo").fadeIn("fast");
			} else {
				$("#secondaryApplicantRowOne, #secondaryApplicantRowTwo").fadeOut("fast");
			}
		}

		function getQuoteHandler() {
			if (!validateDemographicsForm()) return false;
			$("button").button();
			currentZip = $('#zipCode').val();
			$('#zipMessage').dialog('close');
			$('#zip1').val(null);
			$('#zip2').val(null);
			var day1 = $("#applicant1Date").val();
			var day2 = $("#applicant2Date").val();
			var month1 = $("#applicant1Month").val();
			var month2 = $("#applicant2Month").val();
			if (month1 != "10") month1 = month1.replace('0', '');
			if (month2 != "10") month2 = month2.replace('0', '');
			if (day1 == "01" || day1 == "02" || day1 == "03" || day1 == "04" || day1 == "05" || day1 == "06" || day1 == "07" || day1 == "08" || day1 == "09") day1 = day1.replace('0', '');
			if (day2 == "01" || day2 == "02" || day2 == "03" || day2 == "04" || day2 == "05" || day2 == "06" || day2 == "07" || day2 == "08" || day2 == "09") day2 = day2.replace('0', '');
			var birthday = new Date(parseInt($("#applicant1Year").val()), parseInt(month1) - 1, parseInt(day1));
			var gender = $("#applicant1Gender").val();
			if ($("#coverageType").val() == "Individual and Spouse" || $("#coverageType").val() == "Family") {
				var secondBirthday = new Date(parseInt($("#applicant2Year").val()), parseInt(month2) - 1, parseInt(day2));
				if (birthday > secondBirthday) {
					birthday = secondBirthday;
					gender = $("#applicant2Gender").val();
				} 
			}
			var requestedDate = new Date($("#reqDate").val());
			var ageGroup = getAgeGroup(getAgeAsOf(requestedDate, birthday));
			if (!ageGroup) {
				$("#errorText_wrapper").show(); 
				$("#errors").append("<li>The applicant can not be over 65 as of the requested start date. Visit <a href='http://www.ibxmedicare.com' title='ibxmedicare.com'>ibxmedicare.com</a> to learn more about our Medicare plans.</li>");
				return false;
			}
			currentQuote = new Quote(new Date($("#reqDate").val()), $("#coverageType").val(), $("#zipCode").val(), birthday, ageGroup, gender);
			loadExternalData('/scripts/get_a_quote_data/ibx_individual_zipcodes.js' , 'json', 'zipcodes', 'Checking elegibility...', function(){
				loadExternalData('/scripts/get_a_quote_data/ibx_individual_plan_rates.js', 'json', 'planRateData', 'Loading Plan Rates...', function(){
					loadExternalData('/scripts/get_a_quote_data/ibx_individual_plans.js', 'json', 'planDetailData', 'Loading Plan Details...', function(){
						$('#loadingMessage').dialog('close'); 
						currentQuote.filterPlans(document["planRateData"]);
					 	if (checkZip(document["zipcodes"])) displayResults();
					});
				});
			});
			
		}
		
		function getAgeAsOf(asOfDate, dob) {
			var cy = asOfDate.getFullYear();
			var by = dob.getFullYear();
			var db = new Date(dob);
			db.setFullYear(cy);
			var adj = (asOfDate-db<0) ? 1 : 0;
			return cy - by - adj;
		}

		function prepareAvailableDates() {
			var weekdays = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
			var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
			var variableDate = new Date();
			var tenDaysFromNow = variableDate.getTime() + 86400000 * 10;
			variableDate.setTime(tenDaysFromNow);
			var dateOptionsString = '';
			///////////////////////////////////
			//var notAfter = new Date("7/1/2011"); // Uncomment to cap the Available Dates, Remove after rate changes are in place
			//////////////////////////////////
			for (var i = 0; i < 80; i++) {
				//if (notAfter < variableDate) continue; // Uncomment to cap the Available Dates, Remove after rate changes are in place
				if (variableDate.getDate() == 1 || variableDate.getDate() == 15) {
					var validDay = variableDate.toString();
					dateOptionsString += "<option style='font-size: 1.4em; color: #666;' value='" + validDay + "'>" + weekdays[variableDate.getDay()] + ", " + months[variableDate.getMonth()] + " " + variableDate.getDate() + "</option>";
				}
				var nextDay = variableDate.getTime() + 86400000;
				variableDate.setTime(nextDay);
			}
			$("#reqDateOption").after(dateOptionsString);
		}

		function checkZip(data) {
			var counties = [];
			for (var county in data) {
				for (var zip in data[county]) {
					if ($('#zipCode').val() == data[county][zip]) {
						counties.push(county);
					}
				}
			}

			if (counties.length >= 2) {
				$('#zipMessage').show();
				$('#zip1Label').html(counties[0]);
				$('#zip2Label').html(counties[1]);
				$('#zip1').val(counties[0]);
				$('#zip2').val(counties[1]);
				if ($.cookie('county')  == "Bucks" || $.cookie('county') == "Chester" || $.cookie('county') == "Delaware" || $.cookie('county') == "Montgomery" || $.cookie('county') == "Philadelphia") {
					return true;
				} else {
					$( "#zipMessage" ).dialog("open");
					return false;
				}
			} else  if (counties.length == 0) {
				$( "#notFoundMessage" ).dialog("open");
				return false;
			} else {
				return true;
			}
		}

		function getAgeGroup(age) {
			var ageGroup = undefined;
			switch (age) {
				case (18):
					ageGroup = "18";
					break;
				case 19: case 20: case 21: case 22: case 23: case 24:
					ageGroup = "19-24";
					break;
				case 25: case 26: case 27: case 28: case 29: 
					ageGroup = "25-29";
					break;
				case 30: case 31: case 32: case 33: case 34:
					ageGroup = "30-34";
					break;
				case 35: case 36: case 37: case 38: case 39:
					ageGroup = "35-39";
					break;
				case 40: case 41: case 42: case 43: case 44:
					ageGroup = "40-44";
					break;	
				case 45: case 46: case 47: case 48: case 49:
					ageGroup = "45-49";
					break;			
				case 50: case 51: case 52: case 53: case 54:
					ageGroup = "50-54";
					break;
				case 55: case 56: case 57: case 58: case 59:
					ageGroup = "55-59";
					break;
				case 60: case 61: case 62: case 63: case 64:
					ageGroup = "60-64";
					break;
				default : 
					ageGroup = false;
					break;
			}
			return ageGroup;
		}

		function displayResults() {
			$("#resultsStartDate").html((currentQuote.requestedStartDate.getMonth() + 1) + "/" + currentQuote.requestedStartDate.getDate()  + "/" + currentQuote.requestedStartDate.getFullYear());
			$("#resultsCoverageType").html(currentQuote.coverageType);
			$("#resultsZipCode").html(currentQuote.zipCode);
			$("#resultsApplicantDOB").html((currentQuote.applicantDOB.getMonth() + 1) + "/" + currentQuote.applicantDOB.getDate()  + "/" + currentQuote.applicantDOB.getFullYear());
			$("#resultsGender").html(currentQuote.applicantGender);

			for (plan in currentQuote.plans) {
				var opt = document.createElement("option");
				$(opt).attr("value", plan);
				$(opt).css("font-size", "1.4em");
				$(opt).css("color", "#666");
				$(opt).html(plan);
				if (plan.indexOf('Deductible') > 0) {
					$("#deductablePlanSelector").append(opt);
				}
				if (plan.indexOf('Copay') > 0) {
					$("#copayPlanSelector").append(opt);
				}
				if (plan.indexOf('HSA') > 0) {
					$("#hsaPlanSelector").append(opt);
				}
			}
			planTableArray[0] = $("#plan1").html();
			planTableArray[1] = $("#plan2").html();
			planTableArray[2] = $("#plan3").html();
			orderPlans();
			$("#getAQuotePage1").fadeOut("fast", function() {$("#getAQuotePage2").fadeIn("fast");});
		}

		function helpMeChooseOpen() {
			$("#getAQuotePage1, #getAQuotePage2").fadeOut("fast");
			$("#helpMeChoose").fadeIn("fast");
		}

		function validateHelpMeChoose() {
			var valid = true;
			$("#q1, #q2, #q3, #q4, #q5").css("background-color", "#ffffff");
			if ($("input[name=q1]:checked").val() == undefined) {
				$("#q1").css("background-color", "#fcd9d9");
				valid = false;
			}
			if ($("input[name=q2]:checked").val() == undefined) {
				$("#q2").css("background-color", "#fcd9d9");
				valid = false
			}
			if ($("input[name=q3]:checked").val() == undefined) {
				$("#q3").css("background-color", "#fcd9d9");
				valid = false
			}
			if ($("input[name=q4]:checked").val() == undefined) {
				$("#q4").css("background-color", "#fcd9d9");
				valid = false
			}
			if ($("input[name=q5]:checked").val() == undefined) {
				$("#q5").css("background-color", "#fcd9d9");
				valid = false
			}
			return valid;
		}
		
		function helpMeChooseClose() {
			if (!validateHelpMeChoose()) return false;
			planOrder = [1,0,2]; 
			if ($("input[name=q1]:checked").val() == "true"|| $("input[name=q2]:checked").val() == "true"|| $("input[name=q3]:checked").val() == "true") return $('#gePlanMessage').dialog('open');
			if ($("input[name=q5]:checked").val() == "true") planOrder = [0,2,1];
			if ($("input[name=q4]:checked").val() == "true") planOrder = [2,0,1];
			$("#helpMeChoose").fadeOut("fast", function() {
				if (currentQuote != undefined) {
					$("#getAQuotePage2").fadeIn("fast"); 
					orderPlans();
				} else {
					$("#getAQuotePage1").fadeIn("fast");
				}
			});
			$(".tout").hide();
			sortedPlans = true;
		}
		
		function viewAllQuotesHandler() {
			var tableString = "";
			for (var plan in document["planDetailData"]) {
				tableString += "<tr class='align_center headline blue'><td colspan=2><h2>"+plan+"</h2></td></tr>\n<tr><td><ul>";
			   // console.group(plan);
			    for (detail in document["planDetailData"][plan]) {
			        tempTitle = '';
					if (detail == "plan_name") continue;
					if (detail == "plan_pdf") continue;
			        if (detail.indexOf("_") > 0) {
			            titleWords = detail.split("_");
			            for (var word in titleWords) {
			                n = titleWords[word].charAt(0).toUpperCase();
			                n += titleWords[word].substr(1);
			                tempTitle += n + ' ';
			            }
			        } else {
			            n = detail.charAt(0).toUpperCase();
			            n += detail.substr(1);
			            tempTitle = n;
			        }
					tableString += "<li><span style='font-weight: bold;'>"+tempTitle + "</span> - " + document["planDetailData"][plan][detail] + "</li>";
			        //console.log(tempTitle + " - " + document["planDetailData"][plan][detail]);
			    }
				var quoteAmount = '';
				if (currentQuote.plans[plan].new_rate) {
					var dateArr = currentQuote.plans[plan].new_rate_start_date.split("-");
					if (currentQuote.requestedStartDate > new Date(parseInt(dateArr[2]), parseInt(dateArr[0]) - 1, parseInt(dateArr[1]))) {
						quoteAmount = currentQuote.plans[plan].new_rate;
					} else {
						quoteAmount = currentQuote.plans[plan].amount;
					}
				} else {
					quoteAmount = currentQuote.plans[plan].amount;
				}
				tableString += "</ul></td><td class='emp' style='text-align: center;'>"+"<h3>Estimated Monthly Payment : </h3>\n<h4>" + quoteAmount +"</h4></td></tr>";
			   // console.log("Plan cost : " + currentQuote.plans[plan].amount);
			    //console.groupEnd();
			}
			$("#displayAllQuotesFrame").contents().find("#quotesTable").html(tableString);
			$("#displayAllQuotesFrame").contents().find("#viewAllStartDate").html((currentQuote.requestedStartDate.getMonth() + 1) + "/" + currentQuote.requestedStartDate.getDate()  + "/" + currentQuote.requestedStartDate.getFullYear());
			$("#displayAllQuotesFrame").contents().find("#viewAllCoverageType").html(currentQuote.coverageType);
			$("#displayAllQuotesFrame").contents().find("#viewAllZipCode").html(currentQuote.zipCode);
			$("#displayAllQuotesFrame").contents().find("#viewAllApplicantDOB").html((currentQuote.applicantDOB.getMonth() + 1) + "/" + currentQuote.applicantDOB.getDate()  + "/" + currentQuote.applicantDOB.getFullYear());
			$("#displayAllQuotesFrame").contents().find("#viewAllGender").html(currentQuote.applicantGender);
			$("#displayAllQuotesFrame").css("display", "block");
			$("#displayAllQuotesFrame").dialog('open');
			$("#displayAllQuotesFrame").css("width", "780px");
			_gaq.push(['_trackEvent', 'View all Quotes', 'Clicked', 'getaquote.html']);
		}
		
		function orderPlans() {
			$('#plan1').html(planTableArray[planOrder[0]]);
			$('#plan2').html(planTableArray[planOrder[1]]);
			$('#plan3').html(planTableArray[planOrder[2]]);
			if (sortedPlans) $('#plan1').children('td').first().prepend('<img style="position:relative; float:left; margin:-7px 7px 0 0;" src="/images/icons/burst_best_match.gif" alt="star" /><h6>Best Match</h6><br />');
			$("#deductablePlanSelector, #copayPlanSelector, #hsaPlanSelector").uniform();
			$("#deductablePlanSelector").change(function(e) {
				$("#deductablePlanHighlights, #deductablePlanQuote, #deductablePlanDetails").fadeOut("fast", function() {
					$("#deductablePlanHighlights, #deductablePlanQuote, #deductablePlanDetails").fadeIn("fast");
					$("#deductablePlanHighlights").empty();
					var tempString;
					var tempTitle;
					for (var detail in document["planDetailData"][$("#deductablePlanSelector").val()]) {
						if (detail == "plan_name") continue;
						if (detail == "plan_pdf") {
							$("#deductablePlanDetails").attr('href', document["planDetailData"][$("#deductablePlanSelector").val()]["plan_pdf"]);
							continue;
						}
						tempTitle = '';
						if (detail.indexOf("_") > 0) {
							titleWords = detail.split("_");
							for (var word in titleWords) {
								n = titleWords[word].charAt(0).toUpperCase();
								n += titleWords[word].substr(1);
								tempTitle += n + ' ';
							}
						} else {
							n = detail.charAt(0).toUpperCase();
							n += detail.substr(1);
							tempTitle = n;
						}
						tempString = "<li>" + tempTitle + " - " + document["planDetailData"][$("#deductablePlanSelector").val()][detail] + "</li>\n";
						$("#deductablePlanHighlights").append(tempString);
						
					}
				});
				if (currentQuote.plans[$("#deductablePlanSelector").val()].new_rate) {
					var dateArr = currentQuote.plans[$("#deductablePlanSelector").val()].new_rate_start_date.split("-");
					if (currentQuote.requestedStartDate > new Date(parseInt(dateArr[2]), parseInt(dateArr[0]) - 1, parseInt(dateArr[1]))) {
						$("#deductablePlanCost").html(currentQuote.plans[$("#deductablePlanSelector").val()].new_rate);
					} else {
						$("#deductablePlanCost").html(currentQuote.plans[$("#deductablePlanSelector").val()].amount);
					}
				} else {
					$("#deductablePlanCost").html(currentQuote.plans[$("#deductablePlanSelector").val()].amount);
				}
			});
			$("#copayPlanSelector").change(function() {
				$("#copayPlanHighlights, #copayPlanQuote, #copayPlanDetails").fadeOut("fast", function() {
					$("#copayPlanHighlights, #copayPlanQuote, #copayPlanDetails").fadeIn("fast");
					$("#copayPlanHighlights").empty();
					var tempString;
					var tempTitle;
					for (var detail in document["planDetailData"][$("#copayPlanSelector").val()]) {
						if (detail == "plan_name") continue;
						if (detail == "plan_pdf") {
							$("#copayPlanDetails").attr('href', document["planDetailData"][$("#copayPlanSelector").val()]["plan_pdf"]);
							continue;
						}
						tempTitle = '';
						if (detail.indexOf("_") > 0) {
							titleWords = detail.split("_");
							for (var word in titleWords) {
								n = titleWords[word].charAt(0).toUpperCase();
								n += titleWords[word].substr(1);
								tempTitle += n + ' ';
							}
						} else {
							n = detail.charAt(0).toUpperCase();
							n += detail.substr(1);
							tempTitle = n;
						}
						tempString = "<li>" + tempTitle + " - " + document["planDetailData"][$("#copayPlanSelector").val()][detail] + "</li>\n";
						$("#copayPlanHighlights").append(tempString);
					}
				});
				if (currentQuote.plans[$("#copayPlanSelector").val()].new_rate) {
					var dateArr = currentQuote.plans[$("#copayPlanSelector").val()].new_rate_start_date.split("-");
					if (currentQuote.requestedStartDate > new Date(parseInt(dateArr[2]), parseInt(dateArr[0]) - 1, parseInt(dateArr[1]))) {
						$("#copayPlanCost").html(currentQuote.plans[$("#copayPlanSelector").val()].new_rate);
					} else {
						$("#copayPlanCost").html(currentQuote.plans[$("#copayPlanSelector").val()].amount);
					}
				} else {
					$("#copayPlanCost").html(currentQuote.plans[$("#copayPlanSelector").val()].amount);
				}
			});
			$("#hsaPlanSelector").change(function() {
				$("#hsaPlanHighlights, #hsaPlanQuote, #hsaPlanDetails").fadeOut("fast", function() {
					$("#hsaPlanHighlights, #hsaPlanQuote, #hsaPlanDetails").fadeIn("fast");
					$("#hsaPlanHighlights").empty();
					var tempString;
					var tempTitle;
					for (var detail in document["planDetailData"][$("#hsaPlanSelector").val()]) {
						if (detail == "plan_name") continue;
						if (detail == "plan_pdf") {
							$("#hsaPlanDetails").attr('href', document["planDetailData"][$("#hsaPlanSelector").val()]["plan_pdf"]);
							continue;
						}
						tempTitle = '';
						if (detail.indexOf("_") > 0) {
							titleWords = detail.split("_");
							for (var word in titleWords) {
								n = titleWords[word].charAt(0).toUpperCase();
								n += titleWords[word].substr(1);
								tempTitle += n + ' ';
							}
						} else {
							n = detail.charAt(0).toUpperCase();
							n += detail.substr(1);
							tempTitle = n;
						}
						tempString = "<li>" + tempTitle + " - " + document["planDetailData"][$("#hsaPlanSelector").val()][detail] + "</li>\n";
						$("#hsaPlanHighlights").append(tempString);
					}
					$("#hsaPlanCost").html(currentQuote.plans[$("#hsaPlanSelector").val()].amount);
					if (currentQuote.plans[$("#hsaPlanSelector").val()].new_rate) {
						var dateArr = currentQuote.plans[$("#hsaPlanSelector").val()].new_rate_start_date.split("-");
						if (currentQuote.requestedStartDate > new Date(parseInt(dateArr[2]), parseInt(dateArr[0]) - 1, parseInt(dateArr[1]))) {
							$("#hsaPlanCost").html(currentQuote.plans[$("#hsaPlanSelector").val()].new_rate);
						} else {
							$("#hsaPlanCost").html(currentQuote.plans[$("#hsaPlanSelector").val()].amount);
						}
					} else {
						$("#hsaPlanCost").html(currentQuote.plans[$("#hsaPlanSelector").val()].amount);
					}
				});
			});
		}

