

$(document).ready(function(){

    /*
     * Observamos el evento "scroll" en la ventana
     * Si la posición del scroll (scrollTop) es mayor de cero, mostramos el elemento ".goUp",
     * Si no, ocultamos el elemento
     **/
    $(window).scroll(function(){ 
	if ($(window).scrollTop() > 0){
	    $('.goUp').fadeIn();
	} else {
	    $('.goUp').fadeOut();
	}
    });

    /*
     * Al hacer click en el elemento ".goUp", volvemos arriba con una animación.
     * Comprobamos si el navegador es webkit (Chrome y Safari) ya que no funcionan con 'html'
     * Es importante comprobar que body y html no están animados.
     **/
    $('.goUp').click(function(){
	if ($.browser.webkit){
	    $('body:not(:animated)').animate({scrollTop:0},'slow');
	} else {
	    $('html:not(:animated)').animate({scrollTop:0},'slow');
	}

    });
});
