$(document).ready(function() {    

    // Set global(-ish :P) vars
    var mouseX = 0;
    var mouseY = 0;
    
    // Store mouse input
    $().mousemove( function(e) {   
        mouseX = e.pageX;   
        mouseY = e.pageY;        
        
        /*
        window.Processing.data.epageX = mouseX;
        window.Processing.data.epageY = mouseY;
        */
                        
        mouseTrack();                   
    });
    
    // Cool Mouse tracking canvas stuff
    function mouseTrack(){        
        $('canvas#mouseTrack').css({top: mouseY-50, left: mouseX-50});
                 
    }        
    
    
    // Slight Page Transparency
    // Removed to improve rendering speed on slower machines
    //$('#page').css({opacity:'0.3'});
    
    // Show/Hide Sections With Whizzy Green Line
    $('div.hide').prev().click(function(){elem=$(this).next();        
        elem.css({borderBottom:'1px solid #aaff00'});
        elem.slideToggle(350, function(){
            elem.css({borderBottom:'none'});
        });
        return false;
    });
    
    // View Source 
    $("div.source-window").draggable();
    $('div.mini-canv > a').click(function(){
        $(this).next().fadeIn();
        return false;
    });
    $('div.source-window a.close').click(function(){
        $(this).parent().fadeOut();
        return false;
    });                                  
        
    // Pretty Tables    
    //$("tr:odd").livequery(function(){ $(this).each(function(intIndex){$(this).addClass("odd"); }); });
    $('table').livequery(function(){
        $("tr:odd").each(function(intIndex){$(this).addClass("odd");});
        $("tr:even").each(function(intIndex){$(this).addClass("even"); });    
        $("tr:odd, tr:even").hover(function(){ $(this).addClass("hover");},function(){ $(this).removeClass("hover");});        
        $("th").each(function(intIndex){        
            $(this).hover(function(){
                bumpIndex=intIndex+1;         
                $(this).addClass("hover");
                $(this).parent().parent().children("tr").children("td:nth-child("+bumpIndex+")").addClass("highlight");  
            },function(){            
                bumpIndex=intIndex+1;
                $(this).removeClass("hover");         
                $(this).parent().parent().children("tr").children("td:nth-child("+bumpIndex+")").removeClass("highlight");
            });
        });
        $("td").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");})
        $("td:contains('Broken')").addClass("broken");
        $("td:contains('Additional')").addClass("additional");
    });
    
        
            
    

    
});























