
; /* Start:/style/js/custom/calculator.summary-deposits.js*/
var calculatorDeposits = {
    depositCalculatorList:false,
    isChoosenCapitalization:false,
    isChoosenDebitTransaction:false,
    isUseAddDeposits:false,
    currentCurrency:false,
    summaryMinDepositAmountList:false,
    summaryContribMinAmountList:false,
    summaryDepositPeriodSliderData:false,

    currentAddDepositsTimes:false,
    currentAddDepositsCount:false,

    init: function(){

        calculatorDeposits.getData();

        // обработка событий связанных с изменениями доп. взносами
        if ( $('#contribAmount').length ){
            calculatorDeposits.isUseAddDeposits = true;
            calculatorDeposits.changeContribPeriodsInit();
            calculatorDeposits.changeContribAmountInit();
        }


        calculatorDeposits.changeTypeTabInit();

        calculatorDeposits.chooseCurrencyInit();
        calculatorDeposits.changeDepositAmountInit();

        // обработка событий связанных с изменениями срока вклада
        calculatorDeposits.changeDepositPeriodInit();

        calculatorDeposits.choosenCapitalizationInit();

        calculatorDeposits.slidersInit();

        calculatorDeposits.compareActionInit();
        calculatorDeposits.showCompareTableInit();






    },
    getData:function(){
        $.post('/ajax/get-data.php', {'type': 'calculator.summary-deposits'},
            function( response ){
                if ( response.status == 'ok' ){
                    var calcParams = response.calc_params;
                    calculatorDeposits.depositCalculatorList = calcParams.depositCalculatorList;
                    calculatorDeposits.summaryMinDepositAmountList = calcParams.summaryMinDepositAmountList;
                    calculatorDeposits.summaryContribMinAmountList = calcParams.summaryContribMinAmountList;
                    calculatorDeposits.summaryDepositPeriodSliderData = calcParams.summaryDepositPeriodSliderData;

                    $("#currencyList").change();

                }else{
                    console.log( 'error from getCalcData :' + response.message );
                }
            });
    },
    changeTypeTabInit:function(){

        $('#summaryDepositContainer').find('.tab_control>div').unbind();
        $('#summaryDepositContainer').find('.tab_control>div').on('click', function(){
            if ($(this).hasClass('sand')){
                return false;
            } else {
                $(this).addClass('sand').siblings('div').removeClass('sand');
                $.post('/ajax/get-data.php', {'type': 'calculator.summary-deposits', 'depositType': $(this).attr('type') },
                    function( responseHtml ){
                        $('#summaryDepositTable').html( responseHtml );
                        $("#currencyList").change();
                        calculatorDeposits.requestActionInit();
                    })
            };
        });
    },
    changeDepositAmountInit:function(){
        $('#depositAmount').change(function(){
            calculatorDeposits.calculate();
        });

    },
    changeDepositPeriodInit:function(){
        $('#depositDays').change(function(){
            var contribAmount = str_replace(' ', '',  $('#contribAmount').val() );
            contribAmount = parseInt( contribAmount );
            if ( calculatorDeposits.isUseAddDeposits && parseInt( contribAmount ) ){
                $('#addContribPeriodList').change();
                return false;
            }

            calculatorDeposits.calculate();

        });

    },
    initDefaultJsActions:function(){
        // открываем форму для заявки
        $('.show').unbind();
        $('.show').on('click', function(){
            $(this).toggleClass('disabled').siblings('.hidden').slideToggle(400);
        });

        //реализация вкладок
        $('.tab_control>div').unbind();
        $('.tab_control>div').on('click', function(){
            if ($(this).hasClass('sand')){
                return false;
            } else {
                $(this).addClass('sand').siblings('div').removeClass('sand');
                $('.tab_content>.tab', $(this).parents('.wrapper_tabs')).removeClass('active').eq($(this).index()).addClass('active');
            };
        });

        //закрытие всплывающих окон
        $('.close').unbind();
        $('.close').click(function(){
            if (ie){
                $('#overlay').hide();
                $(this).parents('.pop_up, .pop_up_block').hide();
            } else {
                $('#overlay').fadeOut(300);
                $(this).parents('.pop_up, .pop_up_block').fadeOut(300);
            };
        });
        $('#overlay').unbind();
        $('#overlay').click(function(){
            if (ie){
                $(this).siblings('.pop_up').hide();
                $('#overlay').hide();
            } else {
                $(this).siblings('.pop_up').fadeOut(300);
                $('#overlay').fadeOut(300);
            };
        });

        //нестандартный селект
        var i =0;
        $('select').each(function(){
            if ( $(this).parents('.wrapper_select').length ) {
                return;
            }
            $(this).wrap('<div class="wrapper_select '+ $(this).attr('class') +'"></div>').after('<div class="arrow"></div><div class="select"></div><ul></ul>');
            $('option', this).each(function(){
                if ($(this).attr('selected')=='selected'){
                    $(this).parents('select').siblings('.select').html($(this).html());
                };
                $(this).parents('select').siblings('ul').append('<li>'+$(this).html()+'</li>');
            });
            $(this).hide().parents('.wrapper_select').css('z-index', (999-i));
            i++;
        });

        $('.wrapper_select').unbind();
        $('.wrapper_select').on('click', function(){
            $(this).toggleClass('active');
            var obj = $(this);
            $(document).click(function(event) {
                if ($(event.target).closest(obj).length) return;
                if ($(event.target).closest(obj).length) return;
                obj.removeClass('active');
                event.stopPropagation();
            });
        });

        $('.wrapper_select ul li').unbind();
        $('.wrapper_select ul li').on('click', function(){
            var index=$(this).index();

            $('.select', $(this).parents('.wrapper_select')).html($(this).html());

            $('select option', $(this).parents('.wrapper_select')).removeAttr('selected').eq(index).attr('selected','selected').change();
        });

        //нестандартный радиобаттон
        $('.wrapper_radio').each(function(){
            $(this).children('input:radio').css('display','none');
            $(this).children('input:radio').after('<div class="radio"></div>');
            if ($(this).children('input:radio').attr('checked')=='checked') {
                $(this).addClass('checked');
            };
        });

        $('.wrapper_radio').unbind();
        $('.wrapper_radio').click(function(){
            $(this).siblings('.wrapper_radio').children('input:radio').removeAttr('checked');
            $(this).children('input:radio').attr('checked','checked').change();
            $(this).siblings('.wrapper_radio').removeClass('checked');
            $(this).addClass('checked');
        });

        //нестандартный чекбокс
        $('.wrapper_checkbox').each(function(){
            $(this).children('input:checkbox').css('display','none');
            $(this).children('input:checkbox').after('<div class="checkbox"></div>');
            if ($(this).children('input:checkbox').attr('checked')=='checked') {
                $(this).addClass('checked');
            };
        });
        $('.wrapper_checkbox').unbind();
        $('.wrapper_checkbox').click(function(){
            $(this).toggleClass('checked');
            if ($(this).hasClass('checked')){
                $(this).children('input:checkbox').attr('checked','checked').change();
            } else {
                $(this).children('input:checkbox').removeAttr('checked').change();
            };
        });
    },
    showDepositDetailInit:function(){
        $('[id^="depositDetail_"]').click(function(){




            var data = $(this).attr('id').split('_');
            var depositId = data[1];
            $.post('/ajax/deposits/detail.php', {'depositId': depositId },
                function( responseHtml ){
                    $('#pop_deposit').html( responseHtml );
                    //открытие заявки на вклад

                    centerAndOpenPopUp();
                    if (ie){
                        $('#pop_deposit').show();
                    } else {
                        $('#pop_deposit').fadeIn(300);
                    };

                    calculatorDeposits.initDefaultJsActions();

                    // переключение валют в Тарифах
                    $('[id^="tariffsCurrency_"]').change(function(){
                        var data = $(this).attr('id').split('_');
                        var currencyCode = data[1];

                        $('[id^="tariffsTable_"]').hide();
                        $('#tariffsTable_' + currencyCode).show();
                    });

                    requestDeposit.init();



                });
        });
    },

    choosenCapitalizationInit:function(){

        $('#isUseCapitalization').unbind();
        $('#isUseCapitalization').change(function(){
            calculatorDeposits.isChoosenCapitalization = ($(this).attr("checked")=="checked");

            calculatorDeposits.calculate();


        });
    },

    chooseCurrencyInit:function(){
        $("#currencyList").unbind();
        $("#currencyList").change(function(){

            calculatorDeposits.currentCurrency = $(this).val();

            $('.scroller.auto').attr( 'min', calculatorDeposits.summaryMinDepositAmountList[ $(this).val() ] );


            if ( $('#contribAmount').length ){
                var contribMinAmount = calculatorDeposits.summaryContribMinAmountList[ $(this).val() ];
                $('#contribAmount').attr( 'min', contribMinAmount );
            }

            calculatorDeposits.slidersInit();
            calculatorDeposits.calculate();
        });


    },

    changeContribPeriodsInit:function(){
        $('#addContribPeriodList').change(function(){
            calculatorDeposits.calculate();

        });
    },

    changeContribAmountInit:function(){

        $('#contribAmount').change(function(){

            var contribAmount = str_replace(' ', '',  $(this).val() );
            contribAmount = parseInt( contribAmount );

            if ( parseInt( contribAmount ) > 0 && parseInt( contribAmount ) < parseInt( $('#contribAmount').attr('min') ) ){
                $('.error_message').html( 'Мин. сумма взноса - '+ $('#contribAmount').attr('min')  +' ' +  calculatorDeposits.currentCurrency  ).show();
                $('#contribAmount').parents('.wrapper_input').addClass('field_error');
                return false;
            }else{
                $('.error_message').hide();
                $('#contribAmount').parents('.wrapper_input').removeClass('field_error');
            }

            calculatorDeposits.calculate();




        });
    },

    calculate:function(){

        calculatorDeposits.clearLockedDeposits();

        var currentCurrency = calculatorDeposits.currentCurrency.toString().toUpperCase();

        var currentDepositDays = str_replace(' ', '',  $('#depositDays').val() );
        currentDepositDays = parseInt( currentDepositDays );

        var currentDepositAmount = str_replace(' ', '',  $('#depositAmount').val() );
        currentDepositAmount = parseInt( currentDepositAmount );

        var contribAmount = 0;
        if ( $('#contribAmount').length ){
            contribAmount = str_replace(' ', '',  $('#contribAmount').val() );
            contribAmount = parseInt( contribAmount );
        }

        var doneDepositList = new Array();
        var lockDepositList = new Array();

        var depositCalculatorList = calculatorDeposits.depositCalculatorList;

        for ( depositId in depositCalculatorList ){
            var depositCalculator = depositCalculatorList[depositId];
            // проверяем используются ли во вкладе выбранная валюта

            if ( !in_array( currentCurrency, depositCalculator['depositCurrencyList'] ) ){
                lockDepositList.push( depositId );
                continue;
            }

            // проверяем используются ли во вкладе указанный период
            var depositDataList = depositCalculator['depositDataList'][ currentCurrency ];
            var depositPeriodList = depositDataList['depositPeriodList'];

            if ( depositPeriodList[0] > currentDepositDays || depositPeriodList[ depositPeriodList.length - 1 ] < currentDepositDays ){
                lockDepositList.push( depositId );
                continue;
            }

            // проверяем используются ли во вкладе доп. взносы
            if ( parseInt( contribAmount ) > 0 && !depositCalculator['isUseAddContrib'] ){
                lockDepositList.push( depositId );
                continue;
            }

            // проверяем используются ли во вкладе капитализация
            if ( calculatorDeposits.isChoosenCapitalization && !depositCalculator['isUseCapitalization'] ){
                lockDepositList.push( depositId );
                continue;
            }



            doneDepositList.push( depositId );

        }

        var summaryDepositsResults = {};
        if ( doneDepositList.length ){
            for ( index in doneDepositList ){

                var depositId = doneDepositList[ index ];
                // получаем процентную ставку
                var depositRate = calculatorDeposits.getDepositeRate( depositId );
                // если false значит недостаточно размера вклада
                if ( !depositRate ){

                    lockDepositList.push( depositId );
                    continue;
                }


                summaryDepositsResults[ depositId ] = {};
                summaryDepositsResults[ depositId ]['depositRate'] = depositRate;

                var depositCalculator = depositCalculatorList[depositId];

                // делаем расчет общей доходности и доходности по каждому отфильтрованному вкладу

                var yearDays = parseInt( calculatorDeposits.getDaysInYear() );
                var formulaCountDays = 31;//parseInt( depositCalculator['formulaCountDays'] );

                var totalIncome = 0;
                var income = 0;

                if ( calculatorDeposits.isUseAddDeposits && parseInt( contribAmount  ) ){ // при доп. взносах
                    var monthCount = currentDepositDays / 30;
                    monthCount = Math.floor( monthCount );

                    var contribAmount = parseInt( contribAmount );

                    var currentAddDepositsTimes = parseInt( $("#addContribPeriodList option:selected").index() ) + 1;

                    var addDepositsCount = currentDepositDays / ( 30 * currentAddDepositsTimes );
                    var addDepositsCount = Math.floor( addDepositsCount );
                    addDepositsCount = !addDepositsCount ? 1 : addDepositsCount;
                    if ( !addDepositsCount ){
                        console.log('incorrect currentAddDepositsCount');
                        return false;
                    }
                    var amount = currentDepositAmount;
                    var totalPercentIncome = 0;

                    var tmpAddDepositCount = 0;
                    for ( i = 1; i <= monthCount; i++ ){

                        if ( i != 1 && ( (i - 2) % currentAddDepositsTimes ) == 0 && tmpAddDepositCount < addDepositsCount ){
                            amount += contribAmount;
                            tmpAddDepositCount++;
                        }
                        totalPercentIncome += amount  * ( depositRate / 100 ) / yearDays * formulaCountDays;
                    }

                    totalIncome = currentDepositAmount + contribAmount * addDepositsCount + totalPercentIncome;
                    income = totalPercentIncome;

                }else{ // расчет обычных процентов
                    income = currentDepositAmount * ( depositRate / 100 ) / yearDays * currentDepositDays;
                    totalIncome = currentDepositAmount + income;
                }

                summaryDepositsResults[ depositId ]['totalIncome'] = totalIncome;// number_format( totalIncome, 2, '.', ' ' ) + ' ' + currentCurrency.toUpperCase();
                summaryDepositsResults[ depositId ]['income'] = income;// number_format( income, 0, '', ' ' ) + ' ' + currentCurrency.toUpperCase();
            }
        }

        calculatorDeposits.showLockedDeposits( lockDepositList );
        calculatorDeposits.showSummaryDepositsResults( summaryDepositsResults );

    }, 
    getDepositeRate:function( depositId ){

        var depositId = parseInt( depositId );
        var depositCalculatorList = calculatorDeposits.depositCalculatorList


        if ( typeof depositCalculatorList[ depositId ] === 'undefined' ){
            console.log( 'Not found depositCalculatorList' );
            return false;
        }

        var depositDataList = depositCalculatorList[ depositId ]['depositDataList'];
        if ( typeof depositDataList[ calculatorDeposits.currentCurrency ] === 'undefined' ){
            console.log( 'Not found depositPeriodRates' );
            return false;
        }

        var depositPeriodRates = depositDataList[ calculatorDeposits.currentCurrency ]['depositPeriodRates'];

        var depositRate = false;

        var depositDays = str_replace(' ', '',  $('#depositDays').val() );
        depositDays = parseInt( depositDays );
        var depositAmount = str_replace(' ', '',  $('#depositAmount').val() );
        depositAmount = parseInt( depositAmount );

        var addDepositCount = 0;
        var depositItemRate = false;

        for( period in depositPeriodRates ){

            if ( period.indexOf('-') > -1 ){

                var daysPeriod = period.split('-');

                if ( depositDays >= parseInt( daysPeriod[0] ) && depositDays <= parseInt( daysPeriod[1] ) ){
                    depositItemRate = depositPeriodRates[period];
                    break;
                }
            }else{

                if ( parseInt( depositDays ) >= parseInt( period ) ){

                    depositItemRate = depositPeriodRates[period];
                    break;
                }
            }
        }

        if ( !depositItemRate ){
            console.log( 'Not found depositPeriodRates' );
            return false;
        }
        for ( i in depositItemRate ){
            var ratItem = depositItemRate[i];
            for ( minAmount in ratItem ){
                if ( parseInt( depositAmount ) >=  parseInt( minAmount ) ){
                    if ( depositRate && depositRate > parseFloat( ratItem[minAmount] ) ){
                        continue;
                    }
                    depositRate = parseFloat( ratItem[minAmount] );
                }
            }

        }

        return depositRate;

    },

    showSummaryDepositsResults:function( summaryDepositsResults ){

        var currentCurrency = calculatorDeposits.currentCurrency;
        var depositByIncomeList = {};
        for( depositId in summaryDepositsResults ){
            var depositResults = summaryDepositsResults[ depositId ];

            var income = depositResults['income'];


            $('#rate_' + depositId ).html( '<div>' + depositResults['depositRate'] + '%</div>' );

            $('#income_' + depositId ).html( '<div>' + number_format( depositResults['income'], 0, '', ' ' ) + ' ' + currentCurrency.toUpperCase() + '</div>' );
            $('#totalIncome_' + depositId ).html( '<div>' + number_format( depositResults['totalIncome'], 2, '.', ' ' ) + ' ' + currentCurrency.toUpperCase() + '</div>' );

            depositByIncomeList[ parseFloat( income ) + parseFloat( depositId / 10000 )   ] = depositId;

        }

        depositByIncomeList = ksort( depositByIncomeList, 'SORT_NUMERIC' );

        for ( income in depositByIncomeList ){
            var depositId = depositByIncomeList[income];
            var depositHtmlTr = $('#deposit_' + depositId).html();
            var trClone = $('#deposit_' + depositId).clone();
            $('#deposit_' + depositId).remove();


            $('.table_compare').find('tr').eq(0).after(trClone);
        }
        calculatorDeposits.compareActionInit();
        calculatorDeposits.showDepositDetailInit();
        calculatorDeposits.requestActionInit();
    },
    requestActionInit:function(){
        $('[id^="requestAction_"]').click(function(){
            var data = $(this).attr('id').split('_');
            var depositId = data[1];

            $('#depositDetail_' + depositId).click();
            setTimeout(function(){ $('#showSubmitFormButton').click() }, 1000);
        });
    },

    compareActionInit:function(){
        $('[id^="compareAction_"]').unbind();
        $('[id^="compareAction_"]').click(function(){
            var data = $(this).attr('id').split('_');
            var depositId = data[1];

            $('#compareListContainer').append('<li class="inline" id="compareDeposit_'+ depositId +'"><img src="/style/images/icons/icon_close_min.png" alt="" class="close" id="delCompareDeposit_'+ depositId +'">'+ $('#deposit_' + depositId).find('.title').html() +'</li>');

            $('#compareButtonContainer_' + depositId).html('<div class="button inline" id="requestAction_'+ depositId +'" >Оформить</div>');

            $('#compareSummarryContainer').show();
            $('#clearCompareList').show();
            if ( $('#compareListContainer li').length >= 2 ) {

                $('#showCompareTable').show();
                calculatorDeposits.showCompareTableInit();
            }
            calculatorDeposits.compareListActionsInit();
        });
    },
    showCompareTableInit:function(){
        $('#showCompareTable').unbind();
        $('#showCompareTable').click(function(){

            if ( $('#compareListContainer li').length < 2 ) {
                return false;
            }

            $('#pop_comparision .table_comparision').html('');
            $('#pop_comparision .table_comparision').append('<tr><td>Название вклада</td><td>Ставка</td><td>Доход</td><td>Итоговая сумма</td></tr>');
            $('#compareListContainer li').each(function(){
                var data = $(this).attr('id').split('_');
                var depositId = data[1];

                if ( $('#summaryDepositTable').find('[id="deposit_'+ depositId +'"]').length ) {
                    var $depositTr = $('#summaryDepositTable').find('[id="deposit_'+ depositId +'"]');
                    $depositTr = $depositTr.clone();
                    $depositTr.find('.hidden').remove();
                    $depositTr.find('span').after('<br>');
                    $('#pop_comparision .table_comparision').append( $depositTr );

                }
            });
            $('#pop_comparision .table_comparision').find('[id^="deposit_"]').click(function(){
                $('#pop_comparision .close').click();

                var data = $(this).attr('id').split('_');
                $('#summaryDepositTable').find('#depositDetail_' + data[1]).click();

            });
            centerAndOpenPopUp();
            $('#pop_comparision').show();
        });

    },
    compareListActionsInit:function(){

        $('#clearCompareList').unbind();
        $('#clearCompareList').click(function(){
            $('#compareListContainer li').each(function(){
                $(this).find('.close').click();

            });
            $('#showCompareTable').hide();
        });

        $('#compareListContainer .close').unbind();
        $('#compareListContainer .close').click(function(){
            var data = $(this).attr('id').split('_');
            var depositId = data[1];

            $('#compareButtonContainer_' + depositId).html('<div class="button inline" id="requestAction_'+ depositId +'" >Оформить</div> или <span id="compareAction_'+ depositId +'">Сравнить</span>');

            $(this).parent().remove();
            if ( $('#compareListContainer li').length < 2 ) {
                $('#showCompareTable').hide();
            }
            if ( $('#compareListContainer li').length < 1 ) {
                $('#clearCompareList').hide();
            }
            calculatorDeposits.compareActionInit();
        });


    },
    clearLockedDeposits:function(){
        $('tr.disabled').removeClass('disabled');

    },
    showLockedDeposits:function( lockDepositList ){

        for( index in lockDepositList ){
            var depositId = lockDepositList[ index ];


            if ( !$('#summaryDepositTable').find('#deposit_' + depositId).length ){
                continue;
            }


            $('#summaryDepositTable').find('#deposit_' + depositId).addClass('disabled');

        }

    },

    getDaysInYear: function() {
        var output=0;
        var data=new Date();
        var year=data.getFullYear();
        for(var x=1;x<13;x++) {
            output+=daysInMonth(x, year);
        }

        function daysInMonth(iMonth, iYear)
        {
            return 32 - new Date(iYear, iMonth, 32).getDate();
        }
        return output;
    },
    slidersInit:function(){
        var minDepositAmount = parseInt( $('.scroller.auto').attr('min') );

        $('#minDepAmountTitle').html( number_format( minDepositAmount, 0, '', ' ' ) );
        $('#maxDepAmountTitle').html( number_format( minDepositAmount * 1000 / 2, 0, '', ' ' ) );

        //инициализация и настройки ползунка покупки авто
        $('.scroller.auto').each(function(){
            var val_2 = $('input:text', $(this).parents('.wrapper_scroller'));
            $(this).slider({
                range: 'min',
                max: minDepositAmount * 1000 / 2,
                step: minDepositAmount / 10 ,
                min: minDepositAmount,
                value: minDepositAmount * 5,

                slide: function( event, ui ) {
                    val_2.val(accounting.formatNumber(ui.value,0,' ')).change();
                }
            });
            val_2.val(accounting.formatNumber($(this).slider('value'),0,' '));
        });

        //инициализация и настройки ползунка сроков кредита со шкалой






        $('.scroller.term_scale').each(function(){
            var val_2 = $('input:text', $(this).parents('.wrapper_scroller'));
            $(this).slider({
                min: parseInt($('.scroller.term_scale').attr('min')),
                max: parseInt( $('.scroller.term_scale').attr('max') ),
                step: 1,
                value: parseInt($('.scroller.term_scale').attr('min')),
                slide: function( event, ui ) {
                    var dayCount = parseInt( ui.value );
                    var monthCount = Math.floor( dayCount / 30 );

                    $('#formateCreditTerm').html( monthCount + ' мес.' );

                    val_2.val(accounting.formatNumber(ui.value,0,' ')).change();
                }
            });
            val_2.val(accounting.formatNumber($(this).slider('value'),0,' '));
        });








    },
    rand : function ( min, max ) {	// Generate a random integer
        //
        // +   original by: Leslie Hoare

        if( max ) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        } else {
            return Math.floor(Math.random() * (min + 1));
        }
    }




};
$(function(){
    calculatorDeposits.init();
});

/* End */
;
; /* Start:/style/js/custom/request.deposit.js*/
var requestDeposit = {
    isSend: null,
    init: function(){

        requestDeposit.submitInit();
        requestDeposit.coincRegLiveInit();


    },
    coincRegLiveInit: function(){
        $('#coincRegLive').unbind();
        $('#coincRegLive').click(function(){
            $('#regRegion').val( $('#liveRegion').val());
            $('#regRegion').parents('.wrapper_select').find('div.select').html( $('#liveRegion').val() );
        });
    },
    submitInit:function(){
        $('#depositRequestForm').unbind();
        $('#depositRequestForm').bind('submit', function(e) {

            requestValidator.formId = 'depositRequestForm';
            requestValidator.validateForm();

            var birthDate = $('#birthDay').val() + '.' + $('#birthMonth').val() + '.' + $('#birthYear').val();
            if ( !validate_date( birthDate ) ){
                $('#birthDay').parent().addClass('field_error');
                $('#birthYear').parent().addClass('field_error');

                return false;
            }else{

                $('#birthDay').parent().removeClass('field_error');
                $('#birthYear').parent().removeClass('field_error');

            }

            if ( $('.field_error').length ){
                return false;
            }

            if ( $('#agreePersonalData').attr('checked') != 'checked' ) {
                alert('Необходимо дать согласие на обработку персональных данных.');
                return false;
            }
            if ( null !== requestDeposit.isSend ){
                return false;
            }
            e.preventDefault();
            function responseHandler( data ){
                if(data.status == 'ok'){
                    $('.close').click();
                    $('#pop_success h1').html('Заявка на Вклад');
                    $('#pop_success .box_success').find('img').after('<h2>Ваша заявка успешно отправлена.</h2><p>В ближайшее время с вами свяжется сотрудник банка</p>');
                    if (ie){
                        $('#pop_success').show();
                    } else {
                        $('#pop_success').fadeIn(300);
                    };
                    setTimeout(function(){ window.location.reload(); }, 2000);
                } else {
                    $('#errorContainer').html( data.message ).show();
                    requestDeposit.isSend = null;

                }
            }
            requestDeposit.isSend = $(this).ajaxSubmit({
                type: 'POST',
                dataType: 'json',
                target:    '/ajax/request/deposit.php',
                url:    '/ajax/request/deposit.php',
                success:    responseHandler
            });
        });
    }
};
$(function(){
    requestDeposit.init();
});

/* End */
;; /* /style/js/custom/calculator.summary-deposits.js*/
; /* /style/js/custom/request.deposit.js*/
