﻿$(function() {
	// set up scrolling div
	$("div.meltwaternewswrapper.scrolling .newslistcontainer").jScrollPane({ scrollbarWidth: 0, scrollbarMargin: 0, animateInterval: 40, maintainPosition: false });
	// scroll with up arrow
	scrollDiv("div.meltwaternewswrapper.scrolling .ScrollControls img:eq(0)", "div.meltwaternewswrapper.scrolling .newslistcontainer", -15);
	// scroll with down arrow
	scrollDiv("div.meltwaternewswrapper.scrolling .ScrollControls img:eq(1)", "div.meltwaternewswrapper.scrolling .newslistcontainer", 15);
});

function scrollDiv(trigger, div, verticalpixels) {
	var t;
	$(trigger).unbind();
	if ($(div).siblings(".jScrollPaneTrack").length > 0) {
		$(trigger).mouseover(function() {
			t = setInterval(function() {
				$(div)[0].scrollBy(verticalpixels);
			}, 100);
			$(trigger).addClass("hover");
		}).mouseout(function() {
			clearInterval(t);
			$(trigger).removeClass("hover");
		});
	}
}