$(function(){
    $("div.menu ul li a").bind("mouseenter mouseleave", function(){
        $(this).parent().toggleClass("menu-hover");
    });

});

function showCalendar(){
    $('#calendar').fullCalendar({
        editable: true,
        aspectRatio: 5.25,
        weekMode: 'liquid',
        events: function(start, end, callback) {

            // do some asynchronous ajax
            $.getJSON("/get_ugc_events_for_calendar",
            {
                start: start.getTime(),
                end: end.getTime()
            },
            function(result) {
                callback(result);
            });
        },
        firstDay: 1,
        eventRender: false,
        buttonText: {
            prev: '&nbsp;<img src="/images/swich1.gif" />&nbsp;',
            next: '&nbsp;<img src="/images/swich2.gif" />&nbsp;'
        },
        disableDragging: true,
        dayNamesShort: ['Su','Mo','Tu','We','Th','Fr','Sa']
    });
    $('.fc-button-today').hide();
}

function load_scrollable_overlay() {
    $(".scrollable").scrollable({
        size: 2,
        clickable: false
    }).find("a.asset_with_title").tooltip({
        tip: '#tooltip'
    })
    if($("#scrollable div.scrollable").length){
        $(".scrollable a.lightbox-image").overlay({

            // each trigger uses the same overlay with id "gallery"
            target: '#gallery',

            // optional exposing effect with custom color
            expose: '#111'

        // gallery plugin
        }).gallery({

            // do not use the same disabled class name as scrollable
            disabledClass: 'inactive'
        });
    }

    $("a[rel]").each(function(i) {

        $(this).overlay({

            onBeforeLoad: function() {
                // grab wrapper element inside content
                var wrap = this.getContent().find(".contentWrap");

                // load the page specified in the trigger
                wrap.load(this.getTrigger().attr("href"));
            }
        });
    });

}

function load_main_image_overlay(){
    if($("#main_image a").length){
        $("#main_image a").overlay({

            // each trigger uses the same overlay with the id "gallery"
            target: '#main_gallery',

            // optional exposing effect
            expose: '#f1f1f1'

        // let the gallery plugin do its magic!
        }).gallery({

            // the plugin accepts its own set of configuration options
            speed: 800
        });
    }
    $("a[rel]").each(function(i) {

        $(this).overlay({

            onBeforeLoad: function() {
                // grab wrapper element inside content
                var wrap = this.getContent().find(".contentWrap");

                // load the page specified in the trigger
                wrap.load(this.getTrigger().attr("href"));
            }
        });
    });
    $("a.powered-by-help").tooltip({
        tip: '.powered-by-tooltip',
        position: 'center right'
    });

}