function makethisImgMain( imgSrc ,imageSequence ,imgDesc ) {
	setMainImageSize( imageSequence )
	document.getElementById('IMG_mainimage').src = imgSrc
	document.getElementById('LB_PrimaryImg_Desc').innerHTML = imgDesc
}
function setMainImageSize( imageSequence ) {
	//if (imageSizeAry) {
	document.getElementById('IMG_mainimage').width = imageSizeAry[imageSequence][0]
	document.getElementById('IMG_mainimage').height = imageSizeAry[imageSequence][1]
	//}
}
function makeMainImgMain() {
	setMainImageSize(0)
	document.getElementById('IMG_mainimage').src = mainImgSrc
	document.getElementById('LB_PrimaryImg_Desc').innerHTML = mainImageDes
}
function TR_Options_handler( mode ) {
	document.getElementById('htmTR_Accessories').style.display = "none"
	document.getElementById('htmTR_Exterior').style.display = "none"
	document.getElementById('htmTR_Interior').style.display = "none"
	document.getElementById('htmTR_Mechanical').style.display = "none"
	document.getElementById('htmTR_Saftey').style.display = "none"
	
	document.getElementById('TD_OptionsToptab_E').className = "specification_0"
	document.getElementById('TD_OptionsToptab_I').className = "specification_0"
	document.getElementById('TD_OptionsToptab_M').className = "specification_0"
	document.getElementById('TD_OptionsToptab_S').className = "specification_0"
	document.getElementById('TD_OptionsToptab_A').className = "specification_0"
	
	if ( mode == "E" ) { 
		document.getElementById('htmTR_Exterior').style.display = "block" 
		document.getElementById('TD_OptionsToptab_E').className = "specification_1"
	}
		else if ( mode == "I" ) { 
			document.getElementById('htmTR_Interior').style.display = "block"  
			document.getElementById('TD_OptionsToptab_I').className = "specification_1"
		}
		else if ( mode == "M" ) {  
			document.getElementById('htmTR_Mechanical').style.display = "block"  
			document.getElementById('TD_OptionsToptab_M').className = "specification_1"
		}
		else if ( mode == "S" ) {  
			document.getElementById('htmTR_Saftey').style.display = "block"  
			document.getElementById('TD_OptionsToptab_S').className = "specification_1"
		}
		else if ( mode == "A" ) {  
			document.getElementById('htmTR_Accessories').style.display = "block"  
			document.getElementById('TD_OptionsToptab_A').className = "specification_1"
		}
}
function validateAPR()
{
    var apr = $('txtAPR').value;
    if(apr >= 30) {$('txtAPR').value = apr.substring(0,apr.length-1);}
    calcEstimatedPmts();
}
function calcAmountFinanced()
{
    var amt = $('txtPurchasePrice').value - $('txtDownpayment').value - $('txtTradeValue').value;
    $('txtAmountFinanced').innerHTML = (amt > 0) ? formatNum(amt) : '0.00';
    calcEstimatedPmts();
}
function calcDownPayment()
{
    $('txtDownpayment').value = decRound($('txtPurchasePrice').value * $('hdnDownpaymentPercentage').value);
}
function calcEstimatedPmts()
{
    var apr = $('txtAPR').value;
    var term = $('htmSelect_LoanTerm').value;
    var famt = $('txtAmountFinanced').innerText || $('txtAmountFinanced').textContent;
    famt = famt.replace(/,/g,'');
    var p = 0;
    var varR = 0;
    var rN = 0;
    if(famt > 0)
    {
        varR = apr / 100 / 12;
        if(apr == 0)
        {
            p = famt / term;
        }
        else
        {
            rN = Math.pow((1 + varR), term);
            p = (famt * varR * rN) / (rN - 1);
        }
    }
    $('htmSpan_EstimatedPayments').innerHTML = '$' + formatNum(p);
}