/**
 * @package    Church Resources
 * @subpackage View
 * @author     Stephen Callaghan
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 * @updated    13/07/2011
 */

$(document).ready(function() {  

    //Scroll the menu on mouse move above the #sidebar layer
    $('#arrowdown').click(function(e) {
        // Get Current CSS Top Value 
        var current_top = parseInt($('#menu').css('top'));
     
        // Calculate the heights
        var sidebar_height = parseInt($('#sidebar').height());

        //Calculate the top value
        var top_value = 0 - (sidebar_height - current_top);

        if(top_value > (0 - $('#menu').height()))
        {
          //Animate the #menu by chaging the top value
          $('#menu').animate({top: top_value}, { queue:false, duration:500});
        }
    });

    $('#arrowup').click(function(e) {
        // Get Current CSS Top Value 
        var current_top = parseInt($('#menu').css('top'));
     
        // Calculate the heights
        var sidebar_height = parseInt($('#sidebar').height());

        //Calculate the top value
        
        var top_value = sidebar_height + current_top;

        if(top_value <= 0)
        {
          //Animate the #menu by chaging the top value
          $('#menu').animate({top: top_value}, { queue:false, duration:500});
        }
        else
        {
          $('#menu').animate({top: 0}, {queue:false, duration: 300})
        }
    });
});

