/* ---- =CUFON --*/

Cufon.replace(['h1', 'h2', '.heading-prices-sub', '.cycle-heading', '.postcard-heading', '.feature-btn', '.fonty', '.heading-prices', '.heading-prices-price', '#form-main legend'], {
    hover: true, fontFamily: 'Champagne & Limousines'
});

Cufon.replace(['h3', 'h4', '#nav-sub a', 'blockquote'], {
    hover: true, fontFamily: 'Champagne & Limousines Bold'
});

Cufon.replace(['#nav-main a', '.btn', '.btn-top'], {
    hover: true, fontFamily: 'Champagne & Limousines Bold'
});
/* ---- =JQUERY --*/

$(function () {

    /* ---- BOXES homepage --*/

$('#boxes').masonry({
  itemSelector: '.box'
});

    /* ---- =fancybox --*/

    $('.cycle')
    .after('<div class="cycle-nav">')
    .cycle({
        fx: 'fade',
        speed: 500,
        timeout: 5000,
        pager: '.cycle-nav'
    });

    $('#gallery')
    .cycle({
        fx: 'scrollLeft',
        speed: 500,
        timeout: 0,
        easing: 'easeOutExpo',
        next: '.btn-next',
        prev: '.btn-prev',
        after: onAfter,
        startingSlide: 1
    });

    $(".related").click(function () {
        $("#gallery li:first a").trigger("click");
    });

    /* ---- =MASONRY --*/

    $('#postcards, #nav-footer').masonry({
        singleMode: true,
        itemSelector: '.postcard-item, .nav-footer-item'
    });

    /* ---- =HOVERS --*/

    $(".feature-btn, .cycle a, .cycle-bot a, #postcard-flow a, .block-brown").hover(function () {
        $(this).stop().animate({ opacity: 0.85 }, 250);
    }, function () {
        $(this).stop().animate({ opacity: 1.0 }, 250);
    });

    $(".postcard-info, .postcard-tall-content").hover(function () {
        $(this).children(".postcard-images").stop().animate({ opacity: 0.85 }, 250);
    }, function () {
        $(this).children(".postcard-images").stop().animate({ opacity: 1.0 }, 250);
    });

    $("#nav-aside-pics a").hover(function () {
        $(this).children("#nav-aside-pics img").stop().animate({ opacity: 0.85 }, 250);
    }, function () {
        $(this).children("#nav-aside-pics img").stop().animate({ opacity: 1.0 }, 250);
    });

    $("#gallery a").hover(function () {
        $(this).children(".mag").not(':animated').fadeIn(250);
    }, function () {
        $(this).children(".mag").fadeOut(250);
    });

    $(".block-brown").hover(function () {
        $(this).next(".prices-hover").not(':animated').fadeIn(250);
    }, function () {
        $(this).next(".prices-hover").fadeOut(250);
    });

    /* ---- =SELECTORS --*/

    $("#nav-sub li:first").addClass("nav-sub-first");
    $("#nav-tabs li:first").addClass("nav-tabs-first");
    $("#nav-main li:last, .list-inline li:nth-child(4)").addClass("nav-main-last");
    $("#postcards li:nth-child(2n), #nav-aside-pics li:nth-child(2n), .nav-social li:last").addClass("mr0");
    $("#docs li:last").addClass("mb0");
    $("#form-main fieldset:last").addClass("fs-last");
    $(".aside-feature-mid blockquote:last").next("p").addClass("mb0");

    /* ---- =FANCYBOX --*/

    $("a[rel=gallery]").cycle({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'overlayOpacity': 0.8,
        'padding': 10,
        'speedIn': 750,
        'speedOut': 250,
        'overlayColor': '#000000',
        'titlePosition': 'inside'
    });


    /* ---- =FAQS --*/
    $("ul.faq li a").click(function () {

        $(this).toggleClass("on");
        $(this).next("div.answer").slideToggle(250);
        return false;

    });

    $(".facebook").click(function () {
        var t = document.title;
        window.open("http://www.facebook.com/sharer.php?u=" + encodeURIComponent($(this).attr("href")) + "&t=" + encodeURIComponent(t), "sharer", "toolbar=0,status=0,width=626,height=436");
        return false;
    });

    $(".share").click(function () {
        var t = document.title;
        window.open($(this).attr("href"), "sharer", "toolbar=0,status=0,width=800,height=370");
        return false;
    });

});

function onAfter(curr, next, opts) {
    $("#gallery-bot .current").text(zeroPad(opts.currSlide + 1, 2));
    $("#gallery-bot .total").text(zeroPad(opts.slideCount, 2));
}

function zeroPad(num, count) {
    var numZeropad = num + '';
    while (numZeropad.length < count) {
        numZeropad = "0" + numZeropad;
    }
    return numZeropad;
}

