$.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

$.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externalLinks;


//To do after loading HTML
$(document).ready(function(){

// 	$(window).scroll(function() {
// 	  $.clearTimer(scrollTimer);
// 	  $('ul#product_grid_view li').addClass('scrolling');
// 	});
// 	
// 	$('body').mousemove(function() {
// 	  scrollTimer = $.timer(100,function(){
// 		$('ul#product_grid_view li').removeClass('scrolling');
// 	  });
// 	});

	//catch the click on the "return to top" button at the bottom of the page
	$('p.bottom-links a.top').click(function(){
		$('#page').click();
		$.scrollTo( '#page', 1600 );
	});


});

