/**
 * Developed by Aspire Systems
 * @authour : Mukul Das
 */
function customerTypeChange(){
    var customer_type = $('#customer_type').val();
    
    for (var i = 1; i <= total_customer; i++) {
        $('#accordionCustomer' + i).hide();
        if (i == customer_type) {
            $('#accordionCustomer' + i).show();
        }
    }
}

function changeOption(customer_type, question_id, affect_question, depent_question){
    $option_val = $('#cust_q_option_' + customer_type + question_id).val();
    if (1 == $option_val) {
        $('#discount_amount_' + customer_type + question_id).val($('#max_discount_amount_' + customer_type + question_id).val());
        if (!isNaN(parseInt(affect_question, 10))) {
            $('#cust_q_option_' + customer_type + affect_question).val("1");
            $('#discount_amount_' + customer_type + affect_question).val($('#max_discount_amount_' + customer_type + affect_question).val());
        }
    }
    else {
        $('#discount_amount_' + customer_type + question_id).val($('#min_discount_amount_' + customer_type + question_id).val());
        if (!isNaN(parseInt(depent_question, 10))) {
            $('#cust_q_option_' + customer_type + depent_question).val("0");
            $('#discount_amount_' + customer_type + depent_question).val($('#min_discount_amount_' + customer_type + depent_question).val());
        }
    }
    totalAmount(customer_type);
}

function totalAmount(customer_type){	
	var total_question=$('#total_question_'+customer_type).val();	
	var total_amount=0;
	
	for(var i=1;i<=total_question;i++){
		if($('#discount_amount_'+customer_type+i).val()){			
		total_amount=parseFloat(total_amount+parseFloat($('#discount_amount_'+customer_type+i).val()));
		}
	}	
	
	var standard_price=parseFloat($('#standard_price').val());
	var customer_discount_amount=parseFloat($('#customer_discount_amount_'+customer_type).val());
	main_price=standard_price-customer_discount_amount-total_amount;	
	$('#total_amount_'+customer_type).html(main_price.toFixed(2));
}
