<?php
/**
* @package linea21\plugins\l21_gotoTop
* @author $Author$ - Simon Georget <simon@linea21.com>
* @version $Id$ 
* @access public
* @license http://opensource.org/licenses/gpl-3.0.html
*/

global $plug;

// we define the element ID, by default 'scrollToTop'
$element_id = 'scrollToTop';

// we load css file
headerAddCSS($plug->getVar('relative_url') .'css/style.css');


// We prepare the JS content to embed
$js = "   
		
					$(window).scroll(function() {
        		  if($(window).scrollTop() == 0){
        		    $('#".$element_id."').fadeOut('fast');
        		  } else {
        		    if($('#".$element_id."').length == 0){
        		      $('body').append('<div id=\"".$element_id."\"><a href=\"#\"><span>"._t('gotoTop','to-top')."<\/span><\/a><\/div>');
        		      
        		      $('#".$element_id." a').click(function(){
        		  			$('html, body').animate({ scrollTop: '0'}, 500);
	    							return false;
        					});
        		    }
        		    $('#".$element_id."').fadeIn('fast');
        		  }
        		});
        ";

footerAddInlineJS($js);

?>