$(document).ready(function () {

    // TransformMediaLinks ****************************************************************************
    if (mediaplayer) TransformMediaLinks();

    // expand / collapse ****************************************************************************************

    $(".collapsablePanels h2, .collapsablePanels h3").click(function () {
        $(this).next(".collapsablePanel").slideToggle(600);
        var cssImage = $(this).css("background-image");

        if (cssImage.indexOf("bullet2.png") != -1) cssImage = cssImage.replace("bullet2.png", "bullet3.png");
        else cssImage = cssImage.replace("bullet3.png", "bullet2.png");

        $(this).css("background-image", cssImage);
        //if (cssImage.indexOf("bullet2.png") != -1) $(this).css("background-image", "url(layout_images/bullet3.png)");
        //else $(this).css("background-image", "layout_images/bullet2.png");

        //alert(imagePath);
    });


    // auto add <a> + popup class to images *********************************************************************
    $(".mid img").each
    (
        function () {
            var elem = $(this);
            if (elem.parent().attr("href") == undefined) {
                var src = elem.attr('src');
                var a = $('<a class="popup" rel="group"/>').attr('href', src);
                $(this).wrap(a);
            }

            //alert( elem.parent().attr("href") );
        }
    );


    //enable custom buttons ******************************************************************************
    $(document).styleButton();


    //enable popup with fancybox *********************************************************************
    $("a.popup").fancybox({
        'transitionIn': 'fade',
        'speedIn': 50,
        'transitionOut': 'fade',
        'speedOut': 100,
        'changeSpeed': 150,
        'titlePosition': 'over',
        'overlayOpacity': '0.5',
        'overlayColor': '#000000',
        'cyclic': true,
        'centerOnScroll': true,
        'titleShow': false
    });


    //remove empty images *************************************************************************
    $("img").each
    (
      function () {
          var elem = $(this);
          if (elem.attr("src") == "") {
              elem.remove();
          }
      }
    );

    //increase/decrease font size  ****************************************************************
    var section = new Array('.mainContent', '.leftContent', '.rightContent');
    section = section.join(',');

    // Reset Font Size
    var originalFontSize = $(section).css('font-size');
    $(".resetFont").click(function () {
        $(section).css('font-size', originalFontSize);
    });

    // Increase Font Size
    $(".increaseFont").click(function () {
        var currentFontSize = $(section).css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 1.2;
        $(section).css('font-size', newFontSize);
        return false;
    });

    // Decrease Font Size
    $(".decreaseFont").click(function () {
        var currentFontSize = $(section).css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 0.8;
        $(section).css('font-size', newFontSize);
        return false;
    });

}
);

function ExpandLocation(location)
{
    $("."+location).slideToggle(600);
}


