﻿// <![CDATA[
$(function() {
    Cufon.replace('h2');
    Cufon.replace('h3');
    Cufon.replace('h4');

    //Image Preloading
    $("#Highlights  img").lazyload({
        placeholder: "/App_Themes/Default/Images/Common/bc_img_loading.gif",
        effect: "fadeIn"
    });

    /*
    $("#Thumbs  img").lazyload({
        placeholder: "/App_Themes/Default/Images/Common/bc_img_tloading.gif",
        effect: "fadeIn"
    });
    */

    //Line Adjustments
    $("#Line").width($("#Container").width());
    var lineDiff = $("#Container").width() - $("#Line #LeftLine").width();
    if (lineDiff > 0)
        $("#Line #RightLine").width(lineDiff);

    //Gordinha Body Adjustments
    $("#GordinhaBody").width($("#Container").width());
    var lineDiff = $("#Container").width() - $("#GordinhaBody #LeftGordinhaBody").width();
    if (lineDiff > 0)
        $("#GordinhaBody #RightGordinhaBody").width(lineDiff);

    //Google Maps
    if (GBrowserIsCompatible()) {
        var hoMap = new GMap2(document.getElementById("GMap"));
        hoMap.setCenter(new GLatLng(25.072529, 55.144479), 15);
    }

    //Tweets
    $("#Tweets").slideDown("slow");

    //Scroll
    //Anchor
    $("#Thumbs li a").click(
                    function() {

                        $("#Thumbs li a").removeClass("On");
                        $("#Thumbs li a").addClass("Off");
                        $(this).addClass("On");

                        jQuery.easing.bounceout = function(p, n, firstNum, delta, duration) {
                            if ((n /= duration) < (1 / 2.75)) {
                                return delta * (7.5625 * n * n) + firstNum;
                            } else if (n < (2 / 2.75)) {
                                return delta * (7.5625 * (n -= (1.5 / 2.75)) * n + .75) + firstNum;
                            } else if (n < (2.5 / 2.75)) {
                                return delta * (7.5625 * (n -= (2.25 / 2.75)) * n + .9375) + firstNum;
                            } else {
                                return delta * (7.5625 * (n -= (2.625 / 2.75)) * n + .984375) + firstNum;
                            }
                        };

                        jQuery.easing.bouncein = function(x, t, b, c, d) {
                            return c - jQuery.easing['bounceout'](x, d - t, 0, c, d) + b;
                        };


                        $("html, body").animate({ scrollLeft: $('#' + $(this).attr("rel")).offset().left }, 5000).animate({ scrollLeft: $('#' + $(this).attr("rel")).offset().left - ((screen.width - 1002) / 2) }, 2000, "bounceout");

                    }
                );

    //Thumbs
    menuXloc = parseInt($("#Thumbs").css("left").substring(0, $("#Thumbs").css("left").indexOf("px")));
    $(window).scroll(function() {
        offset = menuXloc + $(document).scrollLeft() - 487 < 487 ? 487 + "px" : menuXloc + $(document).scrollLeft() - 487 + "px";
        $("#Thumbs").animate({ left: offset }, { duration: 5000, queue: false });
    });
});

window.onunload = function() {
    GUnload();
}
// ]]>