function ads_price(ads_id){
	
	var ads_price;
	var number_of_months;
	
	ads_price = $('#ads_price_'+ads_id).val();
	
	$('#selected_price').val(ads_price);
	
	number_of_months = $('#number_of_months').val();
	
	if(number_of_months != ''){
		calculate_price(number_of_months);
	}
}

function calculate_price(number_of_months){
	//var number_of_months;
	var ads_price;
	var discounted_price = 0;
	var discount = 0;
	var total_price = 0;
	var total_amount = 0;
	
	//number_of_months = obj.value;
	ads_price = $('#selected_price').val();
	
	if(ads_price != '' && ads_price > 0){
		if(number_of_months == 2){
			discount = 2;
			discounted_price = (ads_price-(ads_price * 0.02));
		} else if(number_of_months == 3){
			discount = 4;
			discounted_price = (ads_price-(ads_price * 0.04));
		} else if(number_of_months == 4){
			discount = 6;
			discounted_price = (ads_price-(ads_price * 0.06));
		} else if(number_of_months == 5){
			discount = 8;
			discounted_price = (ads_price-(ads_price * 0.08));
		} else if(number_of_months == 6){
			discount = 10;
			discounted_price = (ads_price-(ads_price * 0.10));
		} else {
			discounted_price = ads_price;
		}
		
		total_price = number_of_months * ads_price;
		total_amount = number_of_months * discounted_price;
		
		$('#total_price').val(total_price.toFixed(2));
		$('#discount').val(discount);
		$('#total_amount').val(total_amount.toFixed(2));
	} else {
		alert('Please select type of ads.');
	}
}