		/* GLOBAL VARS */
		// form objects
		var mostimptObj;
		var descyouObj;
		var howmanyObj;
		var howlongObj;
		var serviceObj;
		var descyou2Obj;
		
		/* assign the form feilds to object variables */
		function init() 
		{
			mostimptObj = document.forms['lorb'].mostimpt;
			descyouObj = document.forms['lorb'].descyou;
			howmanyObj = document.forms['lorb'].howmany;
			howlongObj = document.forms['lorb'].howlong;
			serviceObj = document.forms['lorb'].service;
			descyou2Obj = document.forms['lorb'].descyou2;
			contentdivObj = getRef("contentdiv");
		}
		
		// get a reference to the object (used for divs)
		function getRef(id) {
			return (document.getElementById ? document.getElementById(id) : document.all[id]);
		}
		
		function testUserInput()
		{
		
			if( !getChecked(mostimptObj) ) {
				alert("Please make a selection for question number 1.");
				return 0;
			}
			
			if( !getChecked(descyouObj) ) {
				alert("Please make a selection for question number 2.");
				return 0;
			}
			
			if( !getChecked(howmanyObj) ) {
				alert("Please make a selection for question number 3.");
				return 0;
			}
			
			if( !getChecked(descyou2Obj) ) {
				alert("Please make a selection for question number 4.");
				return 0;
			}

			if( !getChecked(howlongObj) ) {
				alert("Please make a selection for question number 5.");
				return 0;
			}
			
			if( !getChecked(serviceObj) ) {
				alert("Please make a selection for question number 6.");
				return 0;
			}
			
			
			/* all tests have passed */
			return 1;
		}
		
		
		/* returns the value of the selected radio button */
		function getChecked(obj) 
		{
			var flag;
			for(var x=0; x<obj.length; x++){
				if(obj[x].checked) {
					return obj[x].value;
					break;
				}
				/* the following test will only be performed if no selection is made */
				if(x==2){return false;}
			}
		}
		
		/* main logic checks and result calculation */
		function calculate(arg) 
		{
			
			var intlease=0, intbuy=0;	// used to hold the totals
			var scoreArray = new Array(6); // used to hold all results
			var strMsg = ""; // message displayed to the user
			contentdivObj.innerHTML = strMsg;  // reset message div
			
			/* verify user data before proceeding */		
			if( !testUserInput() )
				return;
		
			scoreArray[0] = getChecked(mostimptObj); // Question 1
			scoreArray[1] = getChecked(descyouObj);  // Question 2
			scoreArray[2] = getChecked(howmanyObj);  // Question 3
			scoreArray[3] = getChecked(howlongObj);  // Question 4
			scoreArray[4] = getChecked(serviceObj);  // Question 5
			scoreArray[5] = getChecked(descyou2Obj); // Question 6
		
			/* iterate through the array and tally the results */
			for(var x=0; x<scoreArray.length; x++){
				if(scoreArray[x].substring(0,2)=='ls') {
					intlease++;
				} else if(scoreArray[x].substring(0,2)=='by') {
					intbuy++;
				}
			}
		
			/* for testing: display scores */
			// alert("lease: " + intlease + "\nbuy: " + intbuy);
		
			if(intlease > intbuy){ // lease customer
			
				strMsg += "<strong>GMAC SMARTLEASE</strong><br />Based on your answers you may want to consider leasing your next vehicle. <br /><br />";
				
				if ( getChecked(descyouObj)=="by" ) {
					strMsg += "While leasing seems to be your best fit, we currently only offer monthly payment schedules on our leases.<br /><br />";
				}
				if ( getChecked(howmanyObj)=="by" || getChecked(howmanyObj)=="ls2" ) {
					strMsg += "While leasing seems to suit you best, you will need to purchase extra kilometres with your lease agreement. Please consult your <a href=\"http://apps.gm.ca/app/GMCanada/DealerLocatorSearch.do?nav=0&cta=blank&lang=en\">local GM Dealer</a> or call our Customer Service Centre (1-800-616-4622) for details.<br /><br />";
				}
				if ( getChecked(howlongObj)=="by" || getChecked(howlongObj)=="ls2") {
					strMsg += "Your answers indicate you may drive a vehicle beyond the standard warranty period. You may wish to consider purchasing the General Motors Protection Plan (GMPP). It protects you from potentially costly repairs and associated expenses occurring outside your vehicle's warranty period. See your <a href=\"http://apps.gm.ca/app/GMCanada/DealerLocatorSearch.do?nav=0&cta=blank&lang=en\">local GM Dealer</a> for more information on this program.<br /><br />";
				}
				if ( getChecked(descyou2Obj)=="by" ) {
					strMsg += "Although leasing seems like the best option for you, leased vehicles cannot be modified.<br /><br />";
				}
				if ( getChecked(serviceObj)=="by" ) {
					strMsg += "Remember that GM Goodwrench Service technicians know your GM vehicle best. Goodwrench has the factory-trained technicians, diagnostic equipment, GM-approved parts and competitive pricing to treat your GM vehicle Right. On time.";
				}
				
				strMsg += "<br /><br /><a href=\"/gm/english/services/gmac/leasing/overview\">Learn more about leasing with GMAC.</a>";
				
				
			} else { // buy customer
			
				strMsg += "<strong>GMAC Purchase Financing</strong><br />Based on your answers you may want to consider buying your next vehicle.<br /><br />";

				if ( getChecked(howlongObj)=="by" || getChecked(howlongObj)=="ls2") {
					strMsg += "Your answers indicate you may drive a vehicle beyond the standard warranty period. You may wish to consider purchasing the General Motors Protection Plan (GMPP). It protects you from potentially costly repairs and associated expenses occurring outside your vehicle's warranty period. See your <a href=\"http://apps.gm.ca/app/GMCanada/DealerLocatorSearch.do?nav=0&cta=blank&lang=en\">local GM Dealer</a> for more information on this program.<br /><br />";
				}
				
				strMsg += "<a href=\"/gm/english/services/gmac/commercial/finance-introduction \">Learn more about purchase financing with GMAC.</a>";
			
			}
			
			/* print the message to the screen */
			contentdivObj.innerHTML = strMsg;

			/* jump to the output */
			location.href = "#output";			
		
		}

		/* clears all form values */
		function reset()
		{
			document.forms['lorb'].reset();
			contentdivObj.innerHTML = "";
		}