// JavaScript Document
function getMore(val)
{
  if(val!='')
  {
	   document.getElementById('summary').style.display = 'none';
	  document.getElementById('morephotos').style.display = 'none';
	  document.getElementById('specifications').style.display = 'none';
	  document.getElementById('finance').style.display = 'none';
	  document.getElementById('warranty').style.display = 'none';
	  document.getElementById(val).style.display = 'block';
	  
  }
}
// loan calculator
function calculate(chr) {
    // Get the user's input from the form. Assume it is all valid.
    // Convert interest from a percentage to a decimal, and convert from
    // an annual rate to a monthly rate. Convert payment period in years
    // to the number of monthly payments.
	//alert(chr);
  if((document.loandata.principal.value!="")&&(document.loandata.interest.value!="")&&(document.loandata.years.value!=""))
  { 
  	document.getElementById('err').style.display='none'; 
    var principal = document.loandata.principal.value;
    var interest = document.loandata.interest.value / 100 / 12;
    var payments = document.loandata.years.value;
    var charg = (chr * principal)/100;
	var charge_mon = charg / payments ;
	
    // Now compute the monthly payment figure, using esoteric math.
    var x = Math.pow(1 + interest, payments);
    var month = (principal*x*interest)/(x-1);
    var monthly = month+charge_mon;
    // Check that the result is a finite number. If so, display the results
    if (!isNaN(monthly) && 
        (monthly != Number.POSITIVE_INFINITY) &&
        (monthly != Number.NEGATIVE_INFINITY)) {
		 document.loandata.charges.value = round(charg);	
        document.loandata.payment.value = round(monthly);
        document.loandata.total.value = round(monthly * payments);
        document.loandata.totalinterest.value = 
            round((month * payments) - principal);
    }
    // Otherwise, the user's input was probably invalid, so don't
    // display anything.
    else {
        document.loandata.payment.value = "";
        document.loandata.total.value = "";
        document.loandata.totalinterest.value = "";
    }
  }
  else
  {
	document.getElementById('err').style.display='block';  
  }
  return false;	
}

// This simple method rounds a number to two decimal places.
function round(x) {
  return Math.round(x*100)/100;
}


