  
    
 function LoadSelectedMMCode(ModelTypeID,mmCode){

		if (mmCode == ''){
            new Ajax.Updater('mmcodediv', '../cfm/vehicleMMCode.cfm?ModelTypeID='+ModelTypeID+'&modelcheck=true',{onComplete:function(){ new Effect.Highlight('mmcodediv');},asynchronous:true, evalScripts:true});
		}else{
            new Ajax.Updater('mmcodedivSearch', '../cfm/vehicleMMCode.cfm?smmcode='+mmCode+'&getcars=true');
            testme();
		}
	}
  
  
   function PopulateHiddenID(aform,afield,aValue)
    {
    	try{
      theField = eval("document."+aform+"."+afield);
    	theField.value = aValue;
      }catch(err){}
    	//alert(theField.value);
    } 


  
 
		
		function submitter() {
			with (document.searchForm) {
				if (Model.value == "") {
					alert('Please choose a model!');
				} else {
					for (i=0;i<makesArr.length;i++) {
						if ( makesArr[i][0] == Makes[Makes.selectedIndex].value) {
							action=makesArr[i][1];
							target=makesArr[i][2];
						}	}
					submit();
				}	}	}
		
		function goTo() {
			with ( document.linkForm ) {
				window.open(externalLinks.options[externalLinks.selectedIndex].value);
			}	}
		//-->
function calculate() {
	with (document.calculatorForm) {
		//validate all fields
		varCalc = true;
		if ((price.value == "")||(isNaN(price.value))) {
			ShowErrorFixError(price,"Please enter a valid price!")
			varCalc = false;
		} else if ((deposit.value == "")||(isNaN(deposit.value))) {
			ShowErrorFixError(deposit,"Please enter a valid deposit!")
			varCalc = false;
		} else if ((interest.value == "")||(isNaN(interest.value))||(interest.value < 1)) {
			ShowErrorFixError(interest,"Please enter a valid interest rate!")
			varCalc = false;
		} else if ((payments.value == "")||(isNaN(payments.value)) || (payments.value > 60)) {
			ShowErrorFixError(payments,"Please enter a valid number of payments!\nA maximum of 60 is allowed",60)
			varCalc = false;
		}
		
		if (varCalc == true) {
			//all values are set, do calculations
			if (interest.value > 1.0) {
	        	varInterest = parseFloat(interest.value)/100.0;
	    	}
			varInterest = parseFloat(varInterest)/12;
			varPow = 1;
			for (i = 0; i < payments.value; i++) {
	        	varPow = varPow * (1 + varInterest);
			}
			tempMonthly = ((parseInt(price.value) - parseInt(deposit.value)) * varPow * varInterest) / (varPow - 1);
			monthly.value = twodec(tempMonthly);
		}
	}
}

function ShowErrorFixError(aObject,aMessage,aDefault)
{
	if (!aDefault) { aDefault=0; }
	 alert(aMessage);
	 aObject.value = aDefault;	
	 aObject.focus();
}

function twodec(value) {
	tempValue = parseInt(value*100)/100;
	return tempValue;
}

function doDeposit(tempDeposit) {
	cons = parseInt(tempDeposit)/100;
	depositAmount1 = parseInt(document.calculatorForm.price.value) * cons;
	document.calculatorForm.deposit.value = Math.round(depositAmount1);
	calculate();
}
function checkDrops() {
  
  theBody = document.getElementById('body');
 
	  if (theBody.getAttribute('dropDown') == 1) {
		try {
		  document.getElementById('DropdownMakes').style.display = 'none';
		  document.getElementById('DropdownSeries').style.display = 'none';
		  document.getElementById('DropdownModels').style.display = 'none';
		  document.getElementById('DropdownDealers').style.display = 'none';
		  theBody.setAttribute('dropDown',0);
		} catch(e){}
	  } else {
		
	  }
  
}

function LoadNewDealerRegion(value){
	
	window.location = "dealerships.cfm?search=1&ipkRegionID=" + value;
	
}


function FromDropDownLink(value){
	vWinCal = window.open(value,'main');
	vWinCal.opener = self;
	
}


