var programPractical = function(completion)
{
    this.name = 'Практичный';
    this.programType = 1;
    this.codeName = 'practical';
    
    this.price = Math.round(completion.price);
    this.completionPrice = Math.round(completion.price);
    this.metallicPrice = completion.CostColorMetalic;
    this.metallicPriceUSD = completion.CostColorMetallicUSD;
    this.completion = completion;
}

extend(programPractical, programStandard);

programPractical.prototype.updateInterestRate = function()
{
    if (this.term < 13)
    {
        if (this.firstPay < 30)
        {
            this.interestRate = 14;
        }
        else if (this.firstPay < 40)
        {
            this.interestRate = 13.5;
        }
        else
        {
            this.interestRate = 10.5;
        }
    }
    else if (this.term < 37)
    {
        if (this.firstPay < 30)
        {
            this.interestRate = 15;
        }
        else if (this.firstPay < 40)
        {
            this.interestRate = 14.5;
        }
        else
        {
            this.interestRate = 13.5;
        }        
    }
    
    else
    {
        if (this.firstPay < 30)
        {
            this.interestRate = 16;
        }
        else if (this.firstPay < 40)
        {
            this.interestRate = 15.5;
        }
        else
        {
            this.interestRate = 14.5;
        }          
    }
}

programPractical.prototype.init = function(startData, programSwitch)
{
    if (typeof programSwitch == 'undefined')
    {
        programSwitch = false;
    }
    this.termMin = 12;
    this.termMax = 60;
    this.firstPayMin = 20;
    this.firstPayMax = 100; 
    this.ltv = 0.8;
    
    $('#CalcCredit input[name=onSumCredit]').attr('disabled', false);
    facade.program.setTerm(36);
    facade.program.setFirstPay(30);
    facade.program.commission = 6000;
    this.insurance = 0;
    
    if (!programSwitch)
    {
        facade.program.currency = 'rub';
        this.USDRate = false;
    }
    
    facade.page.sliderTerm.slider('option', 'disabled', false);
    facade.page.sliderTermInner.slider('option', 'disabled', false);
    facade.page.sliderFirstPay.slider('option', 'disabled', false);
    
    if (!programSwitch)
    {
        $('#currency_selector_rub').attr('checked', true);
        $('.currency_label').html('Руб');
        $('#metallic_off').attr('checked', true);
    }
    
    $('#onSumCredit_off').attr('checked', true);
    $('#CalcCredit input[name=SumCreditCur]').val('').attr('disabled', true);
    $('#CalcCredit input[name=SumCreditRate]').val('').attr('disabled', true);
    $('#LsTerm').hide();
    
    $('#FormExchangeRate').hide();
    $('.program50_field').hide();
    $('.additional_field').hide();
    $('.standard_field').show();
    $('.so_sign').hide();
    $('.disclaimer p').hide();
    $('#so_notice_standart').show();
    $('#so_notice_eco').show();
    
    
    
    $('#TotalIntegCost').val(Math.round(parseFloat(this.price)));
    if ((typeof startData != 'undefined') && startData)
    {
        this.setData(startData);
    }
    facade.program.calc();
    facade.program.bindEvents();
} 
