// alias to jQuery library, function noConflict release control of the $ variable 
// to whichever library first implemented it
var $j = jQuery.noConflict();

/***************************************
    BLOG CUFON SETTINGS
****************************************/

function setupAdditionalCufonFontReplacement()
{
    Cufon.replace(".articlesLastTitle", {fontWeight: 700});
    Cufon.replace(".articlesItemWrapper .title", {fontWeight: 400});
} // end of function setupAdditionalCufonFontReplacement

function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}

function toggleThis(show, subShow) {
    if (show != "#Collaborations") {
        $j('#Collaborations').hide(500);
    }

    if (show != "#Product") {
        $j('#Product').hide(500);
    }

    if (show != "#Media") {
        $j('#Media').hide(500);
    }

    if (show != "#Upcoming") {
        $j('#Upcoming').hide(500);
    }
    if (show != "#About") {
        $j('#About').hide(500);
    }

    $j(subShow).show(500);
    //$j(show).show(500);
    $j('#showAll').show(500);
}

/***************************************
    MAIN CODE - CALL THEN PAGE LOADED
****************************************/
       
// binding action to event onload page
$j(document).ready(
    function() {
        // common.js
        setupGlobal();
        setupCommunityButtons();
        setupToolTipText();
        setupSearchBox();
        setupCufonFontReplacement();
        setupSideBarMiniSlider();
        setupMultiImageLightBox();
        setupSidebarTabsPanel();
        setupLoadingAsynchronousImages();
        setupToolTipImagePreview();
        setupTextLabelImagePreview();
        // this file
        setupAdditionalCufonFontReplacement();

        var varResource = gup('resource');

        if (varResource == "Collaborations") {
            toggleThis('#Collaborations', '#subCollaborations');
        };

        if (varResource == "Product") {
            toggleThis('#Product', '#subProduct');
        };

        if (varResource == "Media") {
            toggleThis('#Media', '#subMedia');
        };
        
        if (varResource == "Upcoming") {
            toggleThis('#Upcoming', '#subUpcoming');
        };

        if (varResource == "About") {
            toggleThis('#About', '#subAbout');
        };
        
        


        $j("#toggleCollaborations").click(
            function() {
                toggleThis('#Collaborations', '#subCollaborations');
            }
        );

        $j("#toggleProduct").click(
            function() {
                toggleThis('#Product', '#subProduct');
            }
        );

        $j("#toggleMedia").click(
            function() {
                toggleThis('#Media', '#subMedia');
            }
        );

        $j("#toggleUpcoming").click(
            function() {
                toggleThis('#Upcoming', '#subUpcoming');
            }
        );

        $j("#toggleAbout").click(
            function() {
                toggleThis('#About', '#subAbout');
            }
        );

        $j("#showAll").click(
            function() {
                $j('#showAll').hide(500);

                $j('#Collaborations').show(500);
                $j('#Product').show(500);
                $j('#Media').show(500);
                $j('#Upcoming').show(500);
                $j('#About').show(500);

                $j('#subCollaborations').hide(500);
                $j('#subProduct').hide(500);
                $j('#subMedia').hide(500);
                $j('#subUpcoming').hide(500);
                $j('#subAbout').hide(500);

            }
        );

    }
);
