$(document).ready(function() {

    $colors = [];
    $colors['mainnav'] = "#ffffff";
    $colors['mainnav_active'] = "#b13025";

    jQuery("#statbarStatDetails").hide();
    jQuery("#statbarMemoCanvas").hide();

    // open and close the memo text field in status bar
    $(".statbarMemo").bind('click', memoClick);

    // open and close the skill overview panel in status bar
    $("#statbarSkillAverage").bind('click', skillClick);

    // link mouseover handlers
    $("a.mainnav_active").bind('hover', mmActive_in, mmActive_out);
    $("a.mainnav").bind('hover', mm_in, mm_out);
    $("a.copyright").bind('hover', c_in, c_out);


    // tooltips - normal images (class: .w_tooltip)
    $(".w_tooltip").tooltip({
        effect:'fade',
        position: 'none',
        mousetracking: true,
        offset: [15,15],
        useBaloon: false,
        tipClass: 'tooltip',
        opacity: 1,
        fadeInSpeed: 500,
        fadeOutSpeed: 0,
        layout: '<table id="tt_layout" border="0">' +
                '<tr>' +
                '<td class="corner_t_l"> </td>' +
                '<td class="border_t"> </td>' +
                '<td class="corner_t_r"> </td>' +
                '</tr>' +
                '<tr>' +
                '<td class="border_l"> </td>' +
                '<td><div class="tooltip-inner"></div></td>' +
                '<td class="border_r"></td>' +
                '</tr>' +
                '<td class="corner_b_l"> </td>' +
                '<td class="border_b"> </td>' +
                '<td class="corner_b_r"> </td>' +
                '</table>'
        });

//    $('a.lightbox').lightBox();

});


/****************************************************************
*
*      HANDLER FUNCTIONS!
*
* open and close the memo text field in status bar
*
*/
function memoClick(event) {
    event.preventDefault();
    if(jQuery("#statbarMemoCanvas").is(":visible")) {
        jQuery("#statbarMemoCanvas").animate({
            opacity: 0,
            height:'toggle'
            }, 100, function() {
        });
    } else {
        jQuery("#statbarMemoCanvas").animate({
            opacity: 1,
            height:'toggle'
            }, 100, function() {
        });
    }
}

// open and close the skill overview panel in status bar
function skillClick(event) {
    event.preventDefault();
    jQuery("#statbarStatDetails").css("left", jQuery("#statbarSkillAverage").offset().left+15);

    if(jQuery("#statbarStatDetails").is(":visible")) {
        jQuery("#statbarStatDetails").animate({
            opacity: 0,
            height:'toggle'
            }, 100, function() {
        });
    } else {
        jQuery("#statbarStatDetails").animate({
            opacity: 1,
            height:'toggle'
            }, 100, function() {
        });
    }
}

function mmActive_in(event)
{
    event.preventDefault();
    $(this).stop().animate();
    $(this).animate({
        color:"#e76257"
    }, "slow");
}

function mmActive_out(event)
{
    event.preventDefault();
    $(this).stop().animate();
    $(this).animate({
        color: $colors[$(this).attr("class")]
    }, "slow");
}

function mm_in(event)
{
    event.preventDefault();
    $(this).stop().animate();
    $(this).animate({
        color:"#e76257"
    }, "slow");
}
function mm_out(event)
{
    event.preventDefault();
    $(this).stop().animate();
    $(this).animate({
        color: $colors[$(this).attr("class")]
    }, "slow");
}


// copyright line (bottom) mouseover handlers
function c_in(event)
{
    event.preventDefault();
    $(this).stop().animate();
    $(this).animate({
        color:"#ffffff"
    }, "fast");
}

function c_out(event)
{
    event.preventDefault();
    $(this).stop().animate();
    $(this).animate({
        color:"#555555"
    }, "fast");
}





/*
function saveMemoText()
{
    $.post("ac/ac.memo.php",
    {
        text:  $('#memo').attr('value'),
        userId: '{userid}'
    }, function(data)
    {
        return(NULL);
    });
}

function removeNewFlag(elem)
{

    u_id = {userid};
    a_id = elem;

    $.post("ac/script.removeACMPNewFlag.php",
    {
        user_id: u_id,
        acmp_id: a_id
    },
    function(data)
    {
        return(NULL);
    });
}
*/

function sendDesktopNotification(subject, message)
{
    $.jwNotify({
        image: 'img/MG_logo_notification.gif',
        title: subject,
        body: message,
        timeout:10000
    });
}




