	function buildOptionTable(mode) {
		var flop = 0;
		var option_count = 0;
		var addFunction = "";
		var disabletext = "";
		
		if (!mode) {addFunction = "switchFields(\"on\");";}
		//if (!mode) {disabletext = " disabled";}
		selOptions = optionArray.split(',');
		var output = "<table id='OptionTable' class='smalltable' width='100%' border=0 cellspacing=0 cellpadding=0><tbody id='OptionTableBody'>";
		for (var j = 0; j < selOptions.length; j++) {
			selOptions2 = selOptions[j].split(':');
			var checkedtext = "";
			// CHECK IF OPTION IS SELECTED
			curOptions = document.forms['veh_submit'].Options.value.split('|');
			for (var k = 0; k < curOptions.length; k++) {
				if (curOptions[k] == selOptions2[0]) {
					checkedtext = " checked";
				}				
			}
			
			if (flop == 0) output += "<tr onClick='" + addFunction + "'>";
		   	if (selOptions2[0]!='') {
			   	output += "<td width='1%' class='smalltable'><input class='form-fieldshort' type='checkbox' name='Option[]' value='" + selOptions2[0] + "' onClick='updateCRV();" + addFunction + "'" + disabletext + checkedtext + "><td width='49%' height=1 class='smalltable'><font class='blackfootnote'>" + selOptions2[3].replace("@","") + "</td>";
		   		option_count++;
		   	}
		   	if (flop == 1) output += "</tr>";
		   	if (flop == 0) {flop = 1;} else {flop = 0;}
		}

		output += "</tbody></table>";
		if (mode==1) {
			if (option_count) {optionTagDiv.style.display = 'block';} else {optionTagDiv.style.display = 'none';}
			document.getElementById("optionTableDiv").innerHTML = output;			
		} else {
			if (option_count) {optionTagDiv_used.style.display = 'block';optionTagDiv_new.style.display = 'block';} else {optionTagDiv_used.style.display = 'none';optionTagDiv_new.style.display = 'none';}
			if (parseFloat(document.forms['veh_submit'].Residual.value) < 1) {document.getElementById("optionTableDiv_new").innerHTML = output;document.getElementById("optionTableDiv_used").innerHTML = '';} else {document.getElementById("optionTableDiv_used").innerHTML = output;document.getElementById("optionTableDiv_new").innerHTML = '';}
		}
	}

	function updateCRV() {
		var oppaction = false;
		var res_adj = 0;
		var selOptions = ""
		var curOptions = new Array();
		var arrayCount = 0;
		
		selOptions = optionArray.split(',');
		if (document.forms['veh_submit'].elements['Option[]']) {
			for (i=0;i<document.forms['veh_submit'].elements['Option[]'].length;i++)
			{
				for (var j = 0; j < selOptions.length; j++) {
					selOptions2 = selOptions[j].split(':');	
					if (selOptions2[0] == document.forms['veh_submit'].elements['Option[]'][i].value) {
						if (selOptions2[0].indexOf("@") > -1 ) {
							oppaction = true;
						} else {
							oppaction = false;
						}
						
						if (document.forms['veh_submit'].elements['Option[]'][i].checked) {
							curOptions[arrayCount] = selOptions2[0];
							arrayCount++;
						}	
												
						if (selOptions2[2] == "A" && document.forms['veh_submit'].elements['Option[]'][i].checked == 1) {
							res_adj = res_adj + parseInt(selOptions2[1]);
						} else if (selOptions2[2] == "D" && document.forms['veh_submit'].elements['Option[]'][i].checked == 0 && oppaction == false) {
							res_adj = res_adj - parseInt(selOptions2[1]);
						} else if (selOptions2[2] == "D" && document.forms['veh_submit'].elements['Option[]'][i].checked == 1 && oppaction == true) {
							res_adj = res_adj - parseInt(selOptions2[1]);
						}			
					}
				}
			}
		}
		//window.status = optionArray;

		if (document.forms['veh_submit'].RetailValueDisplay) document.forms['veh_submit'].RetailValueDisplay.value = addCommas(parseInt(document.forms['veh_submit'].BaseRetailValue.value) + parseInt(res_adj));
		document.forms['veh_submit'].Options.value = curOptions.join("|");
		
		// IF CAR IS USED OR SELF SOURCE IS CHECKED, ENABLED OPTIONS
		if (document.forms['veh_submit'].VehSource) {
			if (parseFloat(document.forms['veh_submit'].Residual.value) > 1 || document.forms['veh_submit'].VehSource[1].checked) {
				if (document.forms['veh_submit'].elements['Option[]']) {
					for (i=0;i<document.forms['veh_submit'].elements['Option[]'].length;i++) {
						document.forms['veh_submit'].elements['Option[]'][i].disabled=0;
					}
				}			
			}		
		}
	}
	
	function addCommas(nStr)
	{
		nStr += '';
		x = nStr.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;
	}