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 = "
";
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['form1'].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['form1'].elements['Option[]']) {
for (i=0;i -1 ) {
oppaction = true;
} else {
oppaction = false;
}
if (document.forms['form1'].elements['Option[]'][i].checked) {
curOptions[arrayCount] = document.forms['form1'].elements['Option[]'][i].value;
arrayCount++;
}
if (selOptions2[2] == "A" && document.forms['form1'].elements['Option[]'][i].checked == 1) {
res_adj = res_adj + parseInt(selOptions2[1]);
} else if (selOptions2[2] == "D" && document.forms['form1'].elements['Option[]'][i].checked == 0 && oppaction == false) {
res_adj = res_adj - parseInt(selOptions2[1]);
} else if (selOptions2[2] == "D" && document.forms['form1'].elements['Option[]'][i].checked == 1 && oppaction == true) {
res_adj = res_adj - parseInt(selOptions2[1]);
}
}
}
}
}
//window.status = optionArray;
if (document.forms['form1'].RetailValueDisplay) {
document.forms['form1'].RetailValueDisplay.value = addCommas(parseInt(document.forms['form1'].BaseRetailValue.value) + parseInt(res_adj));
//alert(addCommas(parseInt(res_adj)));
}
//document.forms['form1'].Options.value = curOptions.join("|");
}
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;
}