$(document).ready(function () {
    $(function () {
        $(window).scroll(function () {
            if ($(this).scrollTop() != 0) {
                $('#toTop').fadeIn()
            } else {
                $('#toTop').fadeOut()
            }
        });
        $('#toTop').click(function () {
            $('body,html').animate({
                scrollTop: 0
            }, 500)
        })
    });
    $(window).load(function () {
        $('#status').fadeOut();
        $('#preloader').delay(350).fadeOut('slow');
        $('body').delay(350).css({
            overflow: 'visible'
        })
    });
    $('.btn-responsive-menu').click(function () {
        $('#top-nav').slideToggle(400)
    });
    $('a.bt_more').click(function () {
        $('html, body').animate({
            scrollTop: $($(this).attr('href')).offset().top
        }, 500);
        return false
    });
    $('input, textarea').placeholder();
    $('.stretchMe').anystretch();
    if (window.innerWidth < 500) {
        $('button.forward, button.backword').click(function () {
            $('html, body').animate({
                scrollTop: 215
            }, 'slow');
            return false
        })
    }
    if (window.innerWidth < 340) {
        $('button.forward, button.backword').click(function () {
            $('html, body').animate({
                scrollTop: 280
            }, 'slow');
            return false
        })
    }
    jQuery(function (e) {
//        e('form#wrapped').attr('action', 'survey/review_send');
        e('#review_container').wizard({
            stepsWrapper: '#wrapped',
            submit: '.submit',
            beforeSelect: function (t, n) {
                /*if (e('input#website').val().length != 0) {
                    return false
                }*/
                if (!n.isMovingForward) return true;
                var r = e(this).wizard('state').step.find(':input');
                return !r.length || !!r.valid()
            }
        }).validate({
            errorPlacement: function (e, t) {
                if (t.is(':radio') || t.is(':checkbox')) {
                    e.insertBefore(t.next())
                } else {
                    e.insertAfter(t)
                }
            },
        });
        e('#progressbar').progressbar();
        e('#review_container').wizard({
            afterSelect: function (t, n) {
                e('#progressbar').progressbar('value', n.percentComplete);
                e('#location').text('(' + n.stepsComplete + '/' + n.stepsPossible + ')')
            }
        })
    })

});
$('.count').each(function () {
    $(this).prop('Counter', 0).animate({
        Counter: $(this).text()
    }, {
        duration: 2000,
        easing: 'swing',
        step: function (e) {
            $(this).text(Math.ceil(e))
        }
    })
});
$('#quote-carousel').carousel({
    pause: true,
    interval: 8000
});
$('.latest-tweets').each(function () {
    $(this).tweet({
        username: $(this).data('username'),
        join_text: 'auto',
        avatar_size: 0,
        count: $(this).data('number'),
        auto_join_text_default: ' we said,',
        auto_join_text_ed: ' we',
        auto_join_text_ing: ' we were',
        auto_join_text_reply: ' we replied to',
        auto_join_text_url: '',
        loading_text: ' loading tweets...',
        modpath: './twitter/'
    })
});
$('.latest-tweets').find('ul').addClass('slider');
if ($().bxSlider) {
    var $this = $('.latest-tweets');
    $('.latest-tweets .slider').bxSlider({
        mode: $this.data('mode') != 'undefined' ? $this.data('mode')  : 'horizontal',
        speed: $this.data('speed') != 'undefined' ? $this.data('speed')  : 2000,
        controls: $this.data('controls') != 'undefined' != 'undefined' ? $this.data('controls')  : true,
        nextSelector: $this.data('nextselector') != 'undefined' ? $this.data('nextselector')  : '',
        prevSelector: $this.data('prevselector') != 'undefined' ? $this.data('prevselector')  : '',
        pager: $this.data('pager') != 'undefined' ? $this.data('pager')  : true,
        pagerSelector: $this.data('pagerselector') != 'undefined' ? $this.data('pagerselector')  : '',
        pagerCustom: $this.data('pagercustom') != 'undefined' ? $this.data('pagercustom')  : '',
        auto: $this.data('auto') != 'undefined' ? $this.data('auto')  : true,
        autoHover: $this.data('autoHover') != 'undefined' ? $this.data('autoHover')  : true,
        adaptiveHeight: $this.data('adaptiveheight') != 'undefined' ? $this.data('adaptiveheight')  : true,
        useCSS: $this.data('useCSS') != 'undefined' ? $this.data('useCSS')  : false,
        nextText: '<i class="icon-angle-right">',
        prevText: '<i class="icon-angle-left">',
        preloadImages: 'all',
        responsive: true
    })
}
