jQuery(function() {
	
	// googles prettyprint.. :)
	prettyPrint();
	
	// some functions for scoller on startpage...
	scroller.init('#latest-comments', 200);
	
	jQuery("li.down span").mouseover(function(){	
		scroller.down();
	});
	
	jQuery("li.down span").mouseout(function() {
		scroller.stop();
	});

	jQuery("li.up span").mouseover(function(){
		scroller.up();
	});
	
	jQuery("li.up span").mouseout(function() {
		scroller.stop();
	});
	
});

var scroller = {
	interval: 1000,
	el: "",
	defaultValue: null,
	init: function(element, timeInterval) {
		this.el = element;
		this.interval = timeInterval;
	},
	up: function() {
		scroller.defaultValue = setInterval(function() {			
			var topVal = jQuery(scroller.el).css("top").replace(/[^-\d\.]/g, '');
			var val = (topVal != '' ? parseInt(topVal) : 0);
			
			if(val != 0) {
				jQuery(scroller.el).css("top", (val + 20) + 'px');
			} else {
				clearInterval(scroller.defaultValue); // no more scroll if we reaches zero in top.
			}
			
		}, scroller.interval);
	},
	down: function() {
		
		scroller.defaultValue = setInterval(function() { 
			var topVal = jQuery(scroller.el).css("top").replace(/[^-\d\.]/g, '');
			var val = parseInt(topVal);
			jQuery(scroller.el).css("top", (val - 20) +'px');
		},scroller.interval);	
	},
	stop: function() {				
		if(scroller.defaultValue != null) 
			clearInterval(scroller.defaultValue);
			
		scroller.defaultValue = null;
	}
};
