$(function(){ neatUpHtml(); idfyCurrentPage(); });
function neatUpHtml(){
	$('input[type=text],input[type=password]').addClass('text');
	$.each( $('ul'), function(){
		$(this).find('li:first').addClass('first');
		$(this).find('li:last').addClass('last');
	});
}
function idfyCurrentPage(){
	var location = window.location+'';
	var locationArr = location.split('/');
	$('input[type=button], input[type=submit], input[type=reset]').hover(function(){ $(this).addClass('hover'); },function(){ $(this).removeClass('hover'); });
	$('a, input[type=button], input[type=submit], input[type=reset]').focus(function(){ $(this).addClass('focus'); }).blur(function(){ $(this).removeClass('focus'); });
	$('a[href="'+location+'"]').addClass('current');
	$('a[href="'+locationArr[locationArr.length-1]+'"]').addClass('current');
}


$(document).ready(function() {         
$('#btn').click(function() {
    
    //2 year lease
    var price = parseInt($('#txtFirst').val())
    var first_price1_2yr=price*0.0522;
    var first_price2_2yr= first_price1_2yr.toFixed(2); 
    $('#first_payment_2yr').html(first_price2_2yr);
    
    var weekly_payment_2yr=(first_price2_2yr)*12/52;
    var weekly_payment1_2yr= weekly_payment_2yr.toFixed(2); 
    $('#weekly_payment_2yr').html(weekly_payment1_2yr);
    $('#monthly_payment_2yr').html(first_price2_2yr);
    
    var total_cost_2yr= first_price2_2yr*24;
    var total_cost1_2yr= total_cost_2yr.toFixed(2);
    $('#total_cost_2yr').html(total_cost1_2yr);
    var tax_relief_2yr=(total_cost1_2yr/100)*21;
    var tax_relief1_2yr= tax_relief_2yr.toFixed(2);
    $('#tax_relief_2yr').html(tax_relief1_2yr);
    
    var net_cost_2yr= (total_cost1_2yr)-(tax_relief1_2yr);
    var net_cost1_2yr= net_cost_2yr.toFixed(2);
    $('#net_cost_2yr').html(net_cost1_2yr);
    //3 year lease
   
    var first_price1_3yr=price*0.0355;
    var first_price2_3yr= first_price1_3yr.toFixed(2); 
    $('#first_payment_3yr').html(first_price2_3yr);
    
    var weekly_payment_3yr=(first_price2_3yr)*12/52;
    var weekly_payment1_3yr= weekly_payment_3yr.toFixed(2); 
    $('#weekly_payment_3yr').html(weekly_payment1_3yr);
    $('#monthly_payment_3yr').html(first_price2_3yr);
    
    var total_cost_3yr= first_price2_3yr*36;
    var total_cost1_3yr= total_cost_3yr.toFixed(2);
    $('#total_cost_3yr').html(total_cost1_3yr);
    
    var tax_relief_3yr=(total_cost1_3yr/100)*21;
    var tax_relief1_3yr= tax_relief_3yr.toFixed(2);
    $('#tax_relief_3yr').html(tax_relief1_3yr);
    
    var net_cost_3yr= (total_cost1_3yr)-(tax_relief1_3yr);
    var net_cost1_3yr= net_cost_3yr.toFixed(2);
    $('#net_cost_3yr').html(net_cost1_3yr);
    
  //4 year lease
    
    var first_price1_4yr=price*0.0289;
    var first_price2_4yr= first_price1_4yr.toFixed(2); 
    $('#first_payment_4yr').html(first_price2_4yr);
    
    var weekly_payment_4yr=(first_price2_4yr)*12/52;
    var weekly_payment1_4yr= weekly_payment_4yr.toFixed(2); 
    $('#weekly_payment_4yr').html(weekly_payment1_4yr);
    $('#monthly_payment_4yr').html(first_price2_4yr);
    
    var total_cost_4yr= first_price2_4yr*48;
    var total_cost1_4yr= total_cost_4yr.toFixed(2);
    $('#total_cost_4yr').html(total_cost1_4yr);
    
    var tax_relief_4yr=(total_cost1_4yr/100)*21;
    var tax_relief1_4yr= tax_relief_4yr.toFixed(2);
    $('#tax_relief_4yr').html(tax_relief1_4yr);
    
    var net_cost_4yr= (total_cost1_4yr)-(tax_relief1_4yr);
    var net_cost1_4yr= net_cost_4yr.toFixed(2);
    $('#net_cost_4yr').html(net_cost1_4yr);
    
 //5 year lease
    
    var first_price1_5yr=price*0.0241;
    var first_price2_5yr= first_price1_5yr.toFixed(2); 
    $('#first_payment_5yr').html(first_price2_5yr);
    
    var weekly_payment_5yr=(first_price2_5yr)*12/52;
    var weekly_payment1_5yr= weekly_payment_5yr.toFixed(2); 
    $('#weekly_payment_5yr').html(weekly_payment1_5yr);
    $('#monthly_payment_5yr').html(first_price2_5yr);
    
    var total_cost_5yr= first_price2_5yr*60;
    var total_cost1_5yr= total_cost_5yr.toFixed(2);
    $('#total_cost_5yr').html(total_cost1_5yr);
    
    var tax_relief_5yr=(total_cost1_5yr/100)*21;
    var tax_relief1_5yr= tax_relief_5yr.toFixed(2);
    $('#tax_relief_5yr').html(tax_relief1_5yr);
    
    var net_cost_5yr= (total_cost1_5yr)-(tax_relief1_5yr);
    var net_cost1_5yr= net_cost_5yr.toFixed(2);
    $('#net_cost_5yr').html(net_cost1_5yr);
});
});  
