jQuery.noConflict();

 (function($j) {

    TBWA = {

        settings: {
            },

        init: function() {

            var self = this;
            //self.initExternalLinks();
            self.webFont();
            self.isLoaded();
            self.gMap();
            self.pagination();
            self.workRollovers();

        },

        isLoaded: function() {

            var self = this;

            $j(window).load(function() {
                $j('body').removeClass("js-loading");
            });


        },

        initExternalLinks: function() {

            $j('a[rel="external"], a[rel="nofollow"]').click(function() {
                this.target = "_blank";
            });

        },

        webFont: function() {
        	Cufon.replace(".copy h1", {
                fontSize: "24px",
                fontWeight: "bold"
            });
            Cufon.replace(".copy-container h1", {
                fontSize: "80px"
            });
            Cufon.replace(".contact-details h3", {
                fontSize: "18px",
                fontWeight: "bold"
            });
            Cufon.replace(".contact-details .org", {
                fontSize: "18px",
                fontWeight: "bold"
            });
            Cufon.replace(".about p", {
                fontSize: "16px"
            });
            Cufon.replace(".client-list li", {
                fontSize: "16px"
            });
            Cufon.now();

        },

        gMap: function() {

            if ($j('#Gmap').length) {

                $j('#Gmap').hide();

                $j('#OpenGmap').click(function(e) {
                    $j('#Gmap').fadeIn();
                    e.preventDefault();
                    return false;
                });

                $j('#CloseGmap').click(function() {
                    $j('#Gmap').fadeOut();
                    return false;
                });
            }

        },

        pagination: function() {

            if ($j('#NavSecondary').length) {

                $j('#NavSecondary a span').fadeOut(0);

                $j('#NavSecondary a').mouseenter(function() {
                    $j('span', this).stop(true, true).fadeIn(150);
                });

                $j('#NavSecondary a').mouseleave(function() {
                    $j('span', this).stop(true, true).fadeOut(150);
                });


            }

        },

        workRollovers: function() {

            /* Rollover animation */
            var container = '.link-img-container';

            $j(container).each(function() {
                $j(this).children().animate({
                    opacity: 0
                },
                0);
            });

            $j(container).mouseenter(function() {
                $j(this).children().stop(true, true).animate({
                    opacity: 1
                },
                250);
            });

            $j(container).mouseleave(function() {
                $j(this).children().animate({
                    opacity: 0
                },
                250);
            });
        }
    };

    $j().ready(function() {
        TBWA.init();
    });

})(jQuery);

