    /*----------------------------------------------------------------
    Description   :- function to open a new window
    Programmer    :- SDYA
    Last Modified :- 10/NOV/2008
    -------------------------------------------------------------------*/
   	function OpenWindow(url)
	{
       nw = open(url,'new','height=450,width=550,scrollbars=yes,resizable=1');
	   nw.focus();
	}

/*********************************************************************************************
	functions for calculator
**********************************************************************************************/
	/*function addtrade() {
		if (document.forms.loanCalc.trade.selectedIndex == 1) {
			document.getElementById("test").style.display = 'block';
		} else {
			document.getElementById("test").style.display = 'none';
		}
	}*/
	function display_div(){
		if(document.frm_loan.sel_trade.selectedIndex == 1)
			document.getElementById('div_trade').style.display = "block";
		else
			document.getElementById('div_trade').style.display = "none";
	}
	function checkNumber(input, min, max, msg) {       
	  msg = msg + " field has invalid data: " + input.value;         
	  var str = input.value;        
	   for (var i = 0; i < str.length; i++) {           
			var ch = str.substring(i, i + 1)            
			if ((ch < "0" || "9" < ch) && ch != '.') {                
				alert(msg);                
			  return false;             
			}        
		}        
		var num = 0 + str         
		if (num < min || max < num) {            
			 alert(msg + " not in range [" + min + ".." + max + "]");            
			 return false;         
		}         
		input.value = str;         
		return true;     
	}      
	function computeField(input) {   
		if (input.value != null && input.value.length != 0)             
			input.value = "" + eval(input.value);         
			computeForm(input.form);    
	 }     
	  function computeForm(form) {         
			if (form.txt_downpay.value == null || form.txt_downpay.value.length == 0)             
				form.txt_downpay.value = 0;        
			 if (form.txt_owed.value == null || form.txt_owed.value.length == 0)             
				form.txt_owed.value = 0;         
			if (form.txt_tradevalue.value == null || form.txt_tradevalue.value.length == 0)             
				form.txt_tradevalue.value = 0;        
			 if ((form.sel_term.value == null || form.sel_term.value.length == 0) || (form.txt_rate.value == null || form.txt_rate.value.length == 0) || (form.txt_price.value == null || form.txt_price.value.length == 0)) {         
				 return;         
			}         
			if (!checkNumber(form.sel_term, 1, 480, "# of payments") || !checkNumber(form.txt_rate, .001, 99, "Interest") ||             !checkNumber(form.txt_price, 100, 10000000, "Price") || !checkNumber(form.txt_owed, 0, 10000000, "Owed on Trade") ||             !checkNumber(form.txt_tradevalue, 0, 10000000, "Trade Value") || !checkNumber(form.txt_downpay, 0, form.txt_price.value, "Down payment")) {            
					 form.txt_loan.value = "Invalid";            
					 return;         
			}         
			 var i = form.txt_rate.value;                 
			 if (i > .001) {            
				i = i / 100.0;            // form.interest.value = i;       
			  }       
				i /= 12;          
				var pow = 1;         
				for (var j = 0; j < form.sel_term.value; j++)            
					 pow = pow * (1 + i);         
				form.txt_loan.value = Math.ceil(((form.txt_price.value - form.txt_downpay.value - (form.txt_tradevalue.value - form.txt_owed.value)) * pow * i) / (pow - 1))     
		}      

   	function OpenPrintWindow(url)
	{
       nw = open(url,'new','height=570,width=550,scrollbars=yes,resizable=1');
	   nw.focus();
	}
//to submit the form
	function submit_form(selval){
		var act = selval.selectedIndex;
		if(act == 1)
			window.location = "ford.php?process=showpage&id=25";
		else if(act == 2)
			window.location = "ford.php?process=showpage&id=24";
	}

//------------------created from 28-jan-2009---------------------