var service_contracts = {} /* Namespace */

/* Service Contracts: Help Me Choose Application */
service_contracts.app = {
	
	/****************************
	//APPLICATION:  MODEL
	****************************/	
	model: {
		selectedOptions: [],
		rememberedOptions: [], /* Used in 2 places. *
		/* 	1) On index.html (set in update_option()) to remember a previously selected option so that we can set display:none on a div before setting display:block for the new option.
			2) On pricing.html (set in init()) to provide the opt1 parameter variable for returning to the index.html page via the controller.goBack function.
		*/
		pricingPageOn: false,
		
		plans: window.scsplans, /* Defined in corresponding data file */
		plansByID: window.scsplansByID, /* Defined in corresponding data file */
		
		planOptionsByDeductible: { /* Hash used to hold a list of plan_options within a certain plan_id by deductible */
			addPlan : function(/*Object*/ o) {
				service_contracts.app.model.planOptionsByDeductible = $merge(service_contracts.app.model.planOptionsByDeductible,o);
			}
		},		
		buildPlanOptionsByDeductible: function (/*Object*/o) { /* Receives a plan_option. */
			for (i in o) {
				if ($defined(o[i].deductible)) {
					var option = {};
					option[o[i].deductible] = {};
					option[o[i].deductible][o[i].code] = {};
					option[o[i].deductible][o[i].code].term = o[i].term;
					option[o[i].deductible][o[i].code].miles = o[i].miles;
					service_contracts.app.model.planOptionsByDeductible.addPlan( option );
				}
			}
		},
			
		availableOptions: [],
		sortPlanOptions : function (a,b) { /* Sort option for plan_option objects*/
		
			if (a["term"] != b["term"]) { //If months are unequal, sort highest to lowest on months (term).
				return a["term"] - b["term"];
			} else {
				return a["miles"] - b["miles"]; //If months are equal, sort highest to lowest on years.
			}
		},
		
		
		//The amount totals from the three editable UI components. (Price = SUM(all))  //DO NOT SET DIRECTLY; Use Setter Method
		selectedPlanID:  0, //Added 1/29/2009 | Place to store planID (csc_4_12_40)
		selectedOptionCode: 0, //Added 1/29/2009 | Place to store plan CODE (HHA6100N)
		selectedPlanPrice: 	0, 
		selectedDeductible: 0, 
		selectedSurcharges: 0,
		selectedSurchargeList: [], //A list of the actual IDs of the Surcharges
		setSelectedPlanPrice: function(/* num */ num) {if ($defined(num)) {this.selectedPlanPrice = parseInt(num);}},
		setSelectedDeductible: function(/* num */ num) {if ($defined(num)) {this.selectedDeductible = num;}},
		setSelectedSurcharges: function(/* num */ num) { 
			if ($defined(num)) {if (num != 0) {this.selectedSurcharges += parseInt(num);} else {this.selectedSurcharges = 0;}}
		},
		
		/* These properties alert the view to display the proper instruction above the form fields. */
		fixedDeductible: true, 
		fixedTime: false,
		
		/* These properties store the term/miles parameters if they're passed in, and alert the app */
		term_and_miles_defined: false,
		term_param: 0,
		miles_param: 0
		
	}, //END service_contracts.app.model

		
	/****************************
	//APPLICATION:  VIEW
	****************************/
	view: {

		updateDisplay : function(/*num*/ num) { 	
			if (num == 1) {
				//Turn off a previously selected div
				if ($defined(service_contracts.app.page_div_id_map1[service_contracts.app.model.rememberedOptions[1]])) {
					$(service_contracts.app.page_div_id_map1[service_contracts.app.model.rememberedOptions[1]]).setStyle('display', 'none');	
				}
				//Turn on the appropriate div based on the first selected option.
				$(service_contracts.app.page_div_id_map1[service_contracts.app.model.selectedOptions[1]]).setStyle('display', 'block');
			} else if ( num == 2) { 
				//If pricingPageOn...
				if (service_contracts.app.model.pricingPageOn == true) { //ONLY RUN THESE DISPLAY UPDATES WHEN ON PRICING PAGE					
					this.setTermOptionsHTML(service_contracts.app.controller.buildDurationOptions(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options)); //Build the duration options & populate the HTML
					service_contracts.app.model.buildPlanOptionsByDeductible(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options); //Populate the plan options object
					this.setDeductibleOptionsHTML(service_contracts.app.controller.buildDeductibleOptionString(service_contracts.app.model.planOptionsByDeductible)); //Build the deductible options & populate the html
					this.setSurchargeOptionsHTML(service_contracts.app.controller.buildSurchargeOptionString(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].surcharges)); //Build the deductible options & populate the html			
				
					this.updatePackageTitleSubheader();
					this.updateComparePlanLink();
					this.updateSelectLabelHead();
					this.updateCustomerServiceMessage();
					
					if (service_contracts.app.model.selectedOptionCode != 0) {
						this.updateTerm(service_contracts.app.model.selectedOptionCode);//Set the passed-in term
					} else {
						this.updateTerm(document.time_mileage_deductible_form.time.value);//Set the default term (To cheat the display of price on load)
					}
					this.updateDeductible();
				} else { 
				
					//If pricingPageOn ...isn't...
					//Build the url and redirect
					
					var scsBase = ""; //"/en/service_contracts/help_me_choose/"; 
					var scsAppend = '?opt1='+service_contracts.app.model.selectedOptions[1]+'&opt2='+service_contracts.app.model.selectedOptions[2];
					var scsPURL = "";
					if (service_contracts.app.model.selectedOptions[2].match(/option2c/)) {
						scsPURL = 'pricing_conv.html';	
					} else if ( (service_contracts.app.model.selectedOptions[1] == "opt1f") && ( (service_contracts.app.model.selectedOptions[2] == "option2d") || (service_contracts.app.model.selectedOptions[2] == "option2e"))  ) {
						scsPURL = service_contracts.app.pricing_page_map1[service_contracts.app.model.selectedOptions[2]] + "_cpov680.html";		
					} else {
						scsPURL = service_contracts.app.pricing_page_map1[service_contracts.app.model.selectedOptions[2]] + service_contracts.app.pricing_page_map2[service_contracts.app.model.selectedOptions[1]];						
					}
					
					/* AVAILABLE URLS
						/en/service_contracts/help_me_choose/pricing_max_new.html
						/en/service_contracts/help_me_choose/pricing_added_new.html
						/en/service_contracts/help_me_choose/pricing_max_cpov.html
						/en/service_contracts/help_me_choose/pricing_added_cpov.html
						/en/service_contracts/help_me_choose/pricing_max_cpov680.html
						/en/service_contracts/help_me_choose/pricing_added_cpov680.html
						/en/service_contracts/help_me_choose/pricing_conv.html		
					*/
					
					//confirm('URL: '+scsBase+scsPURL+scsAppend); //Uncomment for testing 
					window.location.href = scsPURL+scsAppend; //Comment for testing
					return false;
					
				}
			}
		},
			
		//set<OPTION>OptionsHTML
		setTermOptionsHTML: function (/*String*/ options ) {$('time_mileage_span').setHTML(options);},
		setDeductibleOptionsHTML: function(/*String*/ options ) {$('deductible_span').setHTML(options);},
		setSurchargeOptionsHTML: function (/*String*/ options) {$('surcharges_check_boxes').setHTML(options);},
			
		//ONCHANGE HANDLERS
		updateTerm: function(/*String*/ plan ) {
			service_contracts.app.model.setSelectedSurcharges('0'); //Reset the surcharges to $0.
			service_contracts.app.model.setSelectedPlanPrice(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options[plan].price); //Set the price
			service_contracts.app.model.selectedOptionCode = service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options[plan].code; //Store the planOptionCode
			this.updatePlanCode(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options[plan].code); //Set the HTML Plan Code
			this.updatePlanType(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_type); //Set the HTML Plan Type
			this.setSurchargeOptionsHTML(service_contracts.app.controller.buildSurchargeOptionString(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].surcharges)); //Update Surcharge HTML (Which will change price)
			//ORDER OF OPERATION
			this.updatePrice();
		},
		updateDeductible: function(/*String*/ update ) {
			service_contracts.app.model.setSelectedDeductible(update);
			this.updatePrice();
		},
		updateSurcharges: function(/*String*/ value, id, group ) {
			if ($defined(group)&&(group != '')) { //If the checkbox has a group, we need to handle the exclusivity of the boxes.			
				var myBoxes = $$('.'+group); //Get our checkbox group.
				for (var x = 0; x < myBoxes.length; x++) {
					if ((myBoxes[x].id != id)&&(myBoxes[x].checked == true)) { //TEST: Grouped box is checked, not equal to the id we just clicked
						//Simply perform the same 3 operations we would if the individual box had been checked!
						service_contracts.app.model.selectedSurchargeList.remove(myBoxes[x].id); //1. Remove the ID from our array
						service_contracts.app.model.setSelectedSurcharges(myBoxes[x].value*-1);	//2. Reduce surcharges by this amount
						myBoxes[x].checked = false; //3. Uncheck the box
					}
				}
			}
			
			if (service_contracts.app.model.selectedSurchargeList.contains(id)) {
				service_contracts.app.model.selectedSurchargeList.remove(id);		
				value *= -1; //To "remove the value"
			} else {
				service_contracts.app.model.selectedSurchargeList.include(id);
			}
			service_contracts.app.model.setSelectedSurcharges(value);
			this.updatePrice();
		},
			
		/* updatePrice: This adjusts the VIEW, not just a calculator */
		updatePrice: function(/* String */ price) { //Pass in preformatted number
			$('est_price').setHTML(this.numberFormat(service_contracts.app.model.selectedPlanPrice + service_contracts.app.model.selectedDeductible + service_contracts.app.model.selectedSurcharges));	
		},
			
		updatePlanCode: function(/* String */ plan_code) {
			if ($defined(plan_code)) {
				$('plan_code').setHTML("Option Code: "+plan_code);
			} 
		},
		
		updatePlanType: function(plan_type) {
			if ($defined(plan_type)) {
				$('plan_code_des').setHTML(plan_type);
			} 
		},
		
		updateComparePlanLink: function() {		
			var cur_loc_str = window.location.toString();
			if (cur_loc_str.indexOf("pricing_conv") == -1) {
				var divID = "";
				var html = "";
				if(cur_loc_str.indexOf("pricing_max") != -1){
					divID = "#max_care";
					html = "<a href='#' id='compare_to' onclick='javascript: service_contracts.app.view.comparePlans(); return false;'>Compare To: ADDED CARE PLUS</a>";
				}else if(cur_loc_str.indexOf("pricing_added") != -1){
					divID = "#added_care";
					html = "<a href='#' id='compare_to' onclick='javascript: service_contracts.app.view.comparePlans(); return false;'>Compare To: MAXIMUM CARE</a>";
				}
				var text = $$(divID+" h1").getText();
				$$(divID+" h1").setHTML(text+"&nbsp;&nbsp;&nbsp;&nbsp;"+html);
			}
		},
					
		updateSelectLabelHead: function() {
			if ((service_contracts.app.model.fixedTime == false) && (service_contracts.app.model.fixedDeductible == true)) {
				$('variable_time_set_deductible').setStyle('display', 'block');
			} else if ((service_contracts.app.model.fixedTime == true) && (service_contracts.app.model.fixedDeductible == true)) {
				$('variable_time_deductible').setStyle('display', 'block');	
			} else if ((service_contracts.app.model.fixedTime == true) && (service_contracts.app.model.fixedDeductible == false)) {
				$('set_time_deductible').setStyle('display', 'block');
			}
		},
			
		updateCustomerServiceMessage: function () {
			if ($defined($('price_disclaimer_b'))) {
				var myHTML = $('price_disclaimer_b').innerHTML;
				if ($defined(brand)) {
					myHTML = myHTML.replace(/dealer/i, brand.substring(0,1).toUpperCase() + brand.substring(1)+" dealer");
				}
				$('price_disclaimer_b').setHTML(myHTML);
			}
		},
			
		updatePackageTitleSubheader: function() {
			var prepend = "";
			if (service_contracts.app.model.rememberedOptions[1] != 'opt1f' ) { prepend = "with a ";}
			$(service_contracts.app.page_div_id_map3_opt2[service_contracts.app.model.rememberedOptions[2]]).setHTML(prepend+service_contracts.app.page_div_id_map3_opt1[service_contracts.app.model.rememberedOptions[1]]);
		},
		
		/* Currency Format Function */
		numberFormat: function(num /*Number*/) {
			num = parseInt(num).toFixed(2);
			num += '';
			x = num.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return "$"+x1+x2;
		},
			
		setCheckedValue: function (radioObj, newValue) {
			if(!$defined(radioObj)) { return; }//If the form object doesn't exist
			var radioLength = radioObj.length; 
			if(radioLength == undefined) {
				radioObj.checked = (radioObj.value == newValue.toString());
				return;
			}
			for(var i = 0; i <= radioLength; i++) {
				if ($defined(radioObj[i])) {
					radioObj[i].checked = false;
					if(radioObj[i].value == newValue.toString()) {
						radioObj[i].checked = true;
					}	
				}
			}
		},
			
		goBack: function() {
			var opt1 = "";
			if ($defined(service_contracts.app.model.rememberedOptions[1])) {
				opt1 = "?opt1="+service_contracts.app.model.rememberedOptions[1];
			}
			window.location.href = "/en/service_contracts/help_me_choose/"+opt1;
		},
			
		comparePlans: function() {
			//buildtheURL
			
			var scsPURLCompare = "";
			var option2 = service_contracts.app.option_conversion_map[service_contracts.app.model.selectedOptions[2]]; //CONVERTED OPTION (Exmpl: option2a becomes option2b)
			var scsAppendCompare = '?opt1='+service_contracts.app.model.selectedOptions[1]+'&opt2='+option2; //PLAN OPTIONS
			
			var planTerm = "&planterm="+service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options[service_contracts.app.model.selectedOptionCode].term;
			var planMiles = "&planmiles="+service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options[service_contracts.app.model.selectedOptionCode].miles;
			
			var surchargeList = ""; //SURCHARGE LIST
			var separator = "_";
			for (var x = 0; x < service_contracts.app.model.selectedSurchargeList.length; x++) { 
				if (x > 0) {surchargeList += separator;} else { surchargeList += "&surchargelist=" };
				surchargeList += service_contracts.app.model.selectedSurchargeList[x];
			}
			//DETERMINE PROPER HTML PAGE
			if ( (service_contracts.app.model.selectedOptions[1] == "opt1f") && ( (service_contracts.app.model.selectedOptions[2] == "option2d") || (service_contracts.app.model.selectedOptions[2] == "option2e"))  ) {
				scsPURLCompare = service_contracts.app.pricing_page_map1[option2]+"_cpov680.html";
			} else {
				scsPURLCompare = service_contracts.app.pricing_page_map1[option2] + service_contracts.app.pricing_page_map2[service_contracts.app.model.selectedOptions[1]];						
			}
									//PAGE			//OPT1&OPT2		//TERM	//MILES		//SURCHARGES
			window.location.href = scsPURLCompare+scsAppendCompare+planTerm+planMiles+surchargeList; //Comment for testing
			return false;
		}
		
	}, //END service_contracts.app.view
	
		

		
		
	/****************************
	//APPLICATION:  CONTROLLER
	****************************/
	controller: {
		
		/* Retain Selected Options (from UI) */
		update_option : function(/*num*/ num, /*string*/ option) { //Sets the option, calls update display for the appropriate selection
			if (parseInt(num) > 0) {
				service_contracts.app.model.selectedOptions[num] = option; /*Examples: selectedOptions[1] = "opt1a"*/
				service_contracts.app.view.updateDisplay(num);	
				service_contracts.app.model.rememberedOptions = service_contracts.app.model.selectedOptions.copy(); //Create a copy; Not a pointer.
			}		
		}, //END update_option
			
		
		
		/* Build HTMLString for time/mileage options (and build deductible plans) */
		buildDurationOptions : function( o /*String*/) {
			if ($defined(o)) {
				var cindex = 0; //Counter for printing options
				
				/* Build array of plan_options, sort on miles */
				service_contracts.app.model.availableOptions = [];
				for (i in o) { service_contracts.app.model.availableOptions.push(o[i]); }
				service_contracts.app.model.availableOptions.sort(service_contracts.app.model.sortPlanOptions);
				
				/* Open the HTMLString for time/mileage options */
				var HTMLString = "<select name='time' id='time_select' onchange='javscript: service_contracts.app.view.updateTerm(this.value); linkTrack(\"content\",\"plan option \"+this.value);'>";
				var lifetimeOption = ""; 
				var selected = ''; //Determine which value is selected when incoming to the page
					
				//Create the lifetime option; Used to append lifetime option at any point in the list
				if ($defined(service_contracts.app.model.availableOptions[0])) { //(service_contracts.app.model.availableOptions.length - 1) (For sort down)
					if (service_contracts.app.model.availableOptions[0]["term"] == 0) {
						if (service_contracts.app.controller.isSelectedDurationOption(service_contracts.app.model.availableOptions[0]["code"], service_contracts.app.model.availableOptions[0]["term"], service_contracts.app.model.availableOptions[0]["miles"]) == true) { selected = 'selected'; } //SET SELECTED?
						lifetimeOption += "<option "+selected+" value='"+service_contracts.app.model.availableOptions[0]["code"]+"'>Lifetime</option>";	
						cindex ++; //increment to 1, so we leave lifetime out of beginning
						//service_contracts.app.model.availableOptions.pop(); //pop off to leave lifetime off the end
					}
				}
				
				//Create the rest of the time/mileage options
				for (var x = cindex; x < service_contracts.app.model.availableOptions.length; x++) { /* Build the time/mileage options */
					var option = "";
					selected = '';
					if ((service_contracts.app.model.availableOptions[x]["term"])==39) { //Display 39-month plans in months
						option += (service_contracts.app.model.availableOptions[x]["term"]);
						option += " Months";
					} else {
						option += ((service_contracts.app.model.availableOptions[x]["term"])/12);
						option += " Years";							
					}
					if (service_contracts.app.controller.isSelectedDurationOption(service_contracts.app.model.availableOptions[x]["code"], service_contracts.app.model.availableOptions[x]["term"], service_contracts.app.model.availableOptions[x]["miles"]) == true) { selected = 'selected'; } //SET SELECTED?
					HTMLString += "<option "+selected+" value='"+service_contracts.app.model.availableOptions[x]["code"]+"'>"+option+" / "+service_contracts.app.model.availableOptions[x]["miles"]+" Miles</option>";	
				}
				
				/* Close the HTMLString time/mileage options */
				HTMLString += lifetimeOption;
				HTMLString += "</select>";
				return HTMLString;
			} 		
			return "<select><option>N/A</option></select>"; //Empty if o is not defined.
		},
		
		isSelectedDurationOption: function(planOptionCode, planOptionTerm, planOptionMiles) {
			if (service_contracts.app.model.term_and_miles_defined && (planOptionTerm == service_contracts.app.model.term_param)  && (planOptionMiles ==  service_contracts.app.model.miles_param) ) { //If we have params, check to see if we match the term/miles
				return true;
			} else if (planOptionCode == service_contracts.app.model.selectedOptionCode) { // If we have a selectedOptionCode, see if we match it
				return true;
			}
			return false;
		},
	
		buildDeductibleOptionString: function(o) {
			/* Pull the deductibles out of the object, and put them in array. Sort them.*/
			if ($defined(o)) {
				var deductibleArray = [];
				for (i in o) {
					if (i >= 0) {
						deductibleArray.push(i);
					}
				}
				deductibleArray.sort();
			}
			/* If the array only contains one element, then present it as a hard-coded option. Otherwise, make it a select option */
			if (deductibleArray.length == 1) {
				service_contracts.app.model.fixedDeductible = true;
				return service_contracts.app.view.numberFormat(deductibleArray[deductibleArray.length - 1]);				
			} else {
				service_contracts.app.model.fixedDeductible = false;
				return "None";
			}
		},
			
			
		buildSurchargeOptionString: function(o) {
			var HTMLString = "";
			var count = 0;
			if ($defined(o)) {
				for (i in o) { //SURCHARGE OPTIONS STRING
					var print = true; //By default, print all surcharges
					var checked = ''; //Turn off the checked string
					if ($defined(o[i].exclude)) { //If this surcharge contains option codes to exclude...
						var pattern = new RegExp(service_contracts.app.model.plansByID[service_contracts.app.model.selectedPlanID].plan_options[document.time_mileage_deductible_form.time.value].code);
						if (o[i].exclude.match(pattern)) {print = false;} //if this option code is excluded, turn off the print.
					}
					//If we have this option in our array, check it by default
					
					if (print == true) {
						//Turn on auto-checked boxes ONLY for printed surcharges (If they're not printed, they can't be unchecked!)
						if (service_contracts.app.model.selectedSurchargeList.contains(o[i].sid)) { 
							checked = 'checked' 
							service_contracts.app.model.setSelectedSurcharges(o[i].price);
						}
						
						count ++;
						var groupKey = "";
						if ($defined(o[i].group)) { //If there is a group, add it to groupKey. We'll use it as a class, and a parameter in updateSurcharges
							groupKey = o[i].group;
						}
						HTMLString += "<p class='cscbox' ><span class='surchargeBox'><input type='checkbox' name='"+o[i].sid+"' id='"+o[i].sid+"'  class='"+groupKey+"' value='"+o[i].price+"' onclick='javascript: service_contracts.app.view.updateSurcharges(this.value, this.id, \""+groupKey+"\"); linkTrack(\"content\",\"surcharge "+o[i].description+" "+o[i].price+"\");' "+checked+" /></span> <span class='surchargeDesc'><label for='"+o[i].sid+"' style='cursor: pointer;'>"+o[i].description+"</label></span></p>"; 
					}
				}
			}
			if (count == 0) { HTMLString += "<p class='cscbox' ><span class='surchargeBox'>&nbsp;</span><span class='surchargeDesc'>No surcharges apply to selected option.</span></p>"; }
			return HTMLString;
		}		
			
	},	//END service_contracts.app.controller


		
	/****************************
	//APPLICATION:  INIT
	****************************/
	init: function() {
		if ((window.location.toString()).match(/help_me_choose\/pricing.*/)) { //PAGE 2
			
			/* Redirect if options are not present */
			var redirect = false;
			if (! (getParameter("opt1").length > 1)) {
				redirect = true;
			} else if (! (getParameter("opt2").length > 1)) {
				redirect = true;
			}
			if (redirect == true) {
				window.location.href = '/en/service_contracts/help_me_choose/';
			}
			
			// PAGE PARAMS
			if (getParameter("opt1").length > 1) {
				service_contracts.app.model.selectedOptions[1] = getParameter("opt1");
				service_contracts.app.model.rememberedOptions = service_contracts.app.model.selectedOptions.copy();
			}
			if (getParameter("opt2").length > 1) {
				service_contracts.app.model.selectedOptions[2] = getParameter("opt2");
				service_contracts.app.model.rememberedOptions = service_contracts.app.model.selectedOptions.copy(); //Create a copy; Not a pointer.
			}
			if (getParameter("optcode").length > 1) {
				service_contracts.app.model.selectedOptionCode = getParameter("optcode");
			} else if ($defined(getParameter("planterm"))&&$defined(getParameter("planmiles"))) {
				service_contracts.app.model.term_and_miles_defined = true;
				service_contracts.app.model.term_param = getParameter("planterm");
				service_contracts.app.model.miles_param = getParameter("planmiles");
			}
			if (getParameter("surchargelist").length > 2) {
				service_contracts.app.model.selectedSurchargeList = getParameter("surchargelist").split("_");
				service_contracts.app.model.selectedSurchargeList.remove("");
				
			}
			service_contracts.app.model.selectedPlanID = scsplans[service_contracts.app.model.selectedOptions[1]][service_contracts.app.model.selectedOptions[2]];
	 
			
			//Enable additional updateDisplay functionality for the pricing page.
			service_contracts.app.model.pricingPageOn = true;
			service_contracts.app.view.updateDisplay(2);

			
			//
			$('back_to_results').addEvent('click', function() {
				service_contracts.app.view.goBack();
				return false;
			});
			
			
		} else if (getParameter('opt1').length > 1) {//PAGE 1 //if an option is provided and NOT on pricing page. 
			service_contracts.app.view.setCheckedValue(document.scsform.opt1,getParameter('opt1'));
			service_contracts.app.controller.update_option(1, getParameter('opt1'));
		}
	},
	

		
	/****************************
	//APPLICATION:  (ADDITIONAL PROPERTIES & MAPS)
	****************************/	
	
	/* BEG PAGE1 OPT2 DIV DISPLAY MAPPINGS */
	/* -----------------------------------*/
	page_div_id_map1 : {//Used to turn on specific div
		opt1a: "within_warranty_life",
		opt1b: "within_warranty_3_36",
		opt1c: "within_warranty_7_70",
		opt1d: "within_warranty_8_80",
		opt1e: "within_warranty_5_100", 
		opt1f: "older_vehicle",
		opt1g: "within_warranty_6_80"
	},

	
		
	/* BEG OPTION CODE TITLE MAPPINGS */
	/* -----------------------------------*/
	page_div_id_map2 : { //Used to write in plan type above option code
		option2a: "Maximum Care",
		option2b: "Added Care Plus",
		option2c: "Convenience Package",
		option2d: "Maximum Care",
		option2e: "Added Care Plus"
	},

	
	
	
	/* BEG SUB HEADER MAPPINGS */
	/* -----------------------------------*/
	page_div_id_map3_opt1 : { //Used to write in sub-header
		opt1a: "Lifetime Powertrain Limited Warranty",
		opt1b: "3-Year / 36,000-Mile Warranty",
		opt1e: "5-Year / 100,000-Mile Powertrain Limited Warranty",
		opt1c: "7-Year / 70,000-Mile Powertrain Limited Warranty",
		opt1d: "8-Year / 80,000-Mile Certified Pre-Owned Powertrain Limited Warranty",
		opt1g: "6-Year / 80,000-Mile Certified Pre-Owned Powertrain Limited Warranty",
		opt1f: "My vehicle is older"
	},
	page_div_id_map3_opt2 : { //Used to write in sub-header
		option2a: "max_care_sub",
		option2b: "added_care_sub",
		option2c: "conv_package_sub",
		option2d: "max_care_sub",
		option2e: "added_care_sub"
	},
	/* -----------------------------------*/
	/* END SUB HEADER MAPPINGS */
	
	
	
	
	/* BEG PRICING PAGE LANDING COMPONENTS */
	/* -----------------------------------*/
	pricing_page_map1 : {//Used as a component to generate pricing landing page. (FOR ORIGINAL | NOT COMPARISON)
		option2a: "pricing_max",
		option2b: "pricing_added",
		//option2c: "pricing_conv" //Handled by logic switch|NO COMPARISON
		option2d: "pricing_max",
		option2e: "pricing_added"
	},
	pricing_page_map2 : {//Used as a component to generate pricing landing page.
		opt1a: "_new.html",
		opt1b: "_new.html",
		opt1c: "_new.html",
		opt1d: "_cpov.html",
		opt1e: "_new.html",
		opt1f: "_cpov.html", //CAN BE EITHER _cpov.html or _cpov680.html (680 case is handled separately in compositionof URL)
		opt1g: "_cpov680.html"
	},
	
	option_conversion_map : { //Used for .app.view.comparePlans() to swap option values
		option2a: "option2b",
		option2b: "option2a",
		//option2c: "pricing_conv"
		option2d: "option2e",
		option2e: "option2d"		
	}
	/* -----------------------------------*/
	/* END PRICING PAGE LANDING COMPONENTS */
	
	
} //END service_contracts.app

//ONLOAD_REGISTER
onload_register('service_contracts.app.init()');