function scroll_to(id){
    $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}


$(document).ready(function() {
    
    $('#slide').cycle({
        fx:         'fade',
        timeout:    4000,
        pager:      '#slide_nav', 
        pagerEvent: 'click',
        pause:      1
    });
    
    // remove pager if only one element
    $('#slide_nav').ready(function() {
        var num_items = $('#slide_nav a').length;
        if (num_items <= 1) {
            $('#slide_nav').hide ();
        }
    });
    
    
    
    $('img.pulse').hoverpulse({
        size: 40,  // number of pixels to pulse element (in each direction)
        speed: 400 // speed of the animation 
    });
    
    // replace on mouseover
    $('#logo').hover(function () {
        this.src = 'assets/images/logo_on.gif';
    }, function () {
        this.src = 'assets/images/logo.gif';
    });
    
    $('#london_address').click(function() {
        $('#london_map').toggle('slow', function() {
            // Animation complete.
            scroll_to ('london_map');
        });
    });
    
    $('#northeast_address').click(function() {
        $('#northeast_map').toggle('slow', function() {
            // Animation complete.
            scroll_to ('northeast_map');
        });
    });
    
});
