// application wide javascript
$(function() {
    // window load
    $('.porta-label label, .top-search-box label').inFieldLabels();

    $('.qty-sold').FontEffect({
        outline:true,
        outlineWeight: 2,
        outlineColor1: '#9ca9b3'
    })

    if ($('#slideshow .single-slide').length) {
        $('#slideshow').cycle({
            fx:      'fade',
            timeout:  5000,
            prev:    '#prev',
            next:    '#next',
            after:     onAfter
        });
    }

    if ($('.tools-slider').length) {
        $('.tools-slider').cycle({
            fx:      'scrollHorz',
            timeout:  0,
            prev:    '#prev-tools',
            next:    '#next-tools'
        });
    }

    function onAfter(curr, next, opts) {
        if (opts.slideCount > 1) {
            var caption = (opts.currSlide + 1) + ' of ' + opts.slideCount;
            $('#caption').html(caption);
        }
    }

    $('.image-with-caption').hover(function() {
        var $el = $(this), h = 17;
		$el.find('.porta-overlay').animate({top:(100 - h)}, 100);
        $el.find('.green-bg').animate({backgroundColor: '#00a94f'}, 100);
        $el.find('.pink-bg').animate({backgroundColor: '#eb4498'}, 100);
        $el.find('.purple-bg').animate({backgroundColor: '#8d288f'}, 100);
        $el.find('.red-bg').animate({backgroundColor: '#e51a40'}, 100);
        $el.find('.blue-bg').animate({backgroundColor: '#005BAA'}, 100);
    }, function() {
        $(this).find('.porta-overlay').animate({top: 135}, 100);
        $(this).find('.overlay-bg').animate({backgroundColor:'#000'}, 100);
    });

    $('.porta-nav').hover(function() {
        $(this).find('.dropdown').slideDown('fast');
    }, function() {
        $(this).find('.dropdown').slideUp('fast');
    });

    $('.single-cookie').hover(function() {
        $(this).find('a').not('.selected').animate({bottom: 10}, 0,
            function() {
            }).animate({paddingBottom: 16}, 0,
            function() {
            }).animate({paddingTop: 70}, 100);
    }, function() {
        $(this).find('a').not('.selected, .two-lines').animate({bottom: 21}, 0,
            function() {
            }).animate({paddingBottom: 0}, 0,
            function() {
            }).animate({paddingTop: 0}, 100);
        $(this).find('a.two-lines').not('.selected').animate({bottom: 21}, 0,
            function() {
            }).animate({paddingBottom: 0}, 0,
            function() {
            }).animate({paddingTop: 0}, 100);
    });

    $('.single-cookie').click(function() {
        window.location = $(this).find('a').attr('href');
    });

    Cufon.replace('.find-out-box span, .slide-info h5, section h3, section h4, .porta-countdown span, .bottom-widgets h5, section .girls-menu-1 h2.menu-title, section .girls-menu-2 h2.menu-title, section .families-menu-1 h2.menu-title, section .families-menu-2 h2.menu-title, section .volunteers-menu-1 h2.menu-title, section .volunteers-menu-2 h2.menu-title, section h1, section .cookies-menu-1 h2.menu-title, .top-quality span, .cookies .cookie-name, .cookies .cookie-motto', { fontFamily: 'OmnesBold' });
    Cufon.replace('.cookies-menu-1 h2.menu-title i', { fontFamily: 'OmnesBoldItalic' });
    Cufon.replace('.normal-button span, .cookies-menu-1 ul li a, .module a, .girls-menu-1 ul li a, .girls-menu-2 ul li a, .families-menu-1 ul li a, .volunteers-menu-1 ul li a, .volunteers-menu-2 ul li a, .data-box .order-now, .bottom-widgets .see-all-news, header .top-sections li a, .image-with-caption .porta-overlay a span', { fontFamily: 'PTSansBold', hover: true });
});

