$(document).ready(function() {
    
    var clip = null;
    var clip = new ZeroClipboard.Client();
    clip.setHandCursor( true );
    var aj = $('#ajax table');
    
    aj.css('opacity', 0).load('/home/get_gn_html', function(){
        $('#ajax-loader').fadeOut('fast');
        $(this).animate({opacity:1}, 2000);
    });
    
    // Refresh button's functionality
    $('#refresh').live('click', function() {
         //console.log("Refresh action called: "+this);
         $('#ajax-loader').fadeIn('fast');
         $(this).attr("disabled", "true");
         clip.hide();
         aj.animate({opacity:'0.1'}, 150);
         aj.load('home/get_gn_html', function() {
             //console.log("Content refreshed: "+this);
             $('#ajax-loader').fadeOut('fast');
             clip.destroy();
             $(this).animate({opacity:1}, 300);
             $('#refresh').removeAttr('disabled');
         });
    });
         
    $('#gn').live('mouseover', function() {
         clip.glue(this); // Element that triggers
         var txt = $.trim($(this).text());
         //console.log("Mouse over: "+txt);
         clip.setText(txt);
    });

});
