var scroll_id;
var scroll_pscroll = 10;
var scroll_easing  = 10;
var is_apple = ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) ? true : false;

if (is_apple) {
	scroll_pscroll = 150;
	scroll_easing  = 'slow';
}

$(document).ready(function() {
	if (!$('#scrollable') || !$('#scrollup') || !$('#scrolldown')) return;
	function scroll(op) {
		var divOffset = $('#scrollable').offset().top;
		$('#scrollable').animate({scrollTop: op + scroll_pscroll + 'px'}, scroll_easing);
	}
	function scrollup() {
		scroll('-=');
	}
	function scrolldown() {
		scroll('+=');
	}
	if (is_apple) {
		$('#scrollup').click(function() {
			scrollup();
		});
		$('#scrolldown').click(function() {
			scrolldown();
		});
	} else {
		$('#scrollup').mousedown(function() {
			if (scroll_id) clearInterval(scroll_id);
			scroll_id = setInterval(scrollup,50);
		});
		$('#scrollup').mouseup(function() {
			if (scroll_id) clearInterval(scroll_id);
		});
		$('#scrolldown').mousedown(function() {
			if (scroll_id) clearInterval(scroll_id);
			scroll_id = setInterval(scrolldown,50);
		});
		$('#scrolldown').mouseup(function() {
			if (scroll_id) clearInterval(scroll_id);
		});
	}
});

