$(document).ready(function(){
/*AddStats select character START*/
    $('#add_stats_selected_char').change(function () {
        //alert(this.value);
        var Character;
        $.post('/ajax/getcharinacc', {'CharName' : this.value}, function(data) {
            Character = JSON.parse(data);
            $('#freest').children('b').html(Character.LevelUpPoint);
            $('#distr').children('b').html('0');
            
            $('.adding-stat-str').html(Character.Strength);
            $('.adding-stat-agi').html(Character.Dexterity);
            $('.adding-stat-vit').html(Character.Vitality);
            $('.adding-stat-ene').html(Character.Energy);
            $('.adding-stat-cmd').html(Character.Leadership);
            
            $('#str').parent().children('.result-point').html(Character.Strength);
            $('#agi').parent().children('.result-point').html(Character.Dexterity);
            $('#vit').parent().children('.result-point').html(Character.Vitality);
            $('#ene').parent().children('.result-point').html(Character.Energy);
            $('#com').parent().children('.result-point').html(Character.Leadership);
            
            $('.raspred-stats').val('0');
            $('.raspred-stats').val('0'); 
            $('.raspred-stats').val('0'); 
            $('.raspred-stats').val('0'); 
            $('.raspred-stats').val('0');
        });

    });

/*AddStats select character END*/
    
/*HideInfo select character START*/
    var Valute0 = $('#valute_id_0 span').html();
    var Valute1 = $('#valute_id_1 span').html();
    var Valute2 = $('#valute_id_2 span').html();
    var Valute3 = $('#valute_id_3 span').html();
    var Valute4 = $('#valute_id_4 span').html();

    $('#count_hour').change(function () {
       var InputHour = $(this).val();
        if (InputHour <= 0) {
            $('#valute_id_0 span').html(Valute0);
            $('#valute_id_1 span').html(Valute1);
            $('#valute_id_2 span').html(Valute2);
            $('#valute_id_3 span').html(Valute3);
            $('#valute_id_4 span').html(Valute4);
            $('#count_hour').val(1);
        } else {
            $('#valute_id_0 span').html(InputHour * Valute0);
            $('#valute_id_1 span').html(InputHour * Valute1);
            $('#valute_id_2 span').html(InputHour * Valute2);
            $('#valute_id_3 span').html(InputHour * Valute3);
            $('#valute_id_4 span').html(InputHour * Valute4);
        }
    });

/*HideInfo select character END*/

/*Buy prem select character START*/
    var Valute0 = $('#buyprem_valute span').html();
    var TypePrem = 1;
    $('#buyprem_level').change(function(){
        TypePrem = $(this).val();
        if (TypePrem == 1) {
            Valute0 = 350;
        } else if(TypePrem == 2) {
            Valute0 = 500;
        } else if(TypePrem == 3) {
            Valute0 = 800;
        }
        $('#buyprem_valute span').html(Valute0);
        $('#count_days').val(7);
    });
    $('#count_days').change(function () {
       var InputDays = $(this).val();
       /* if (InputDays <= 0) {
            $('#buyprem_valute span').html(Valute0);
            $('#count_days').val(7);
        } else {
            $('#buyprem_valute span').html(InputDays * Valute0);
        }*//*
        TypePrem = $(this).val();*/
        if (TypePrem == 1) {
            if (InputDays == 7) {
            Valute0 = 350;
            } else if(InputDays == 14) {
                Valute0 = 550;
            } else if(InputDays == 30) {
                Valute0 = 850;
            }
        } else if(TypePrem == 2) {
            if (InputDays == 7) {
            Valute0 = 500;
            } else if(InputDays == 14) {
                Valute0 = 900;
            } else if(InputDays == 30) {
                Valute0 = 1350;
            }
        } else if(TypePrem == 3) {
            if (InputDays == 7) {
            Valute0 = 800;
            } else if(InputDays == 14) {
                Valute0 = 1350;
            } else if(InputDays == 30) {
                Valute0 = 2000;
            }
        }
        $('#buyprem_valute span').html(Valute0);
    });

/*Buy prem select character END*/
});