﻿/* cps undergrad home page */

$(function() {
    $("#plcContent1, #plcSideContent1 > a, #plcSideContent2 > a, #plcSideContent2 div.storieswrapper").shadow();
    // set up scrolling div
    var activeElement = document.activeElement
    if ($(activeElement).attr("class") != "edit-mode") {
        $("div.storieswrapper.scrolling .storieslistcontainer").jScrollPane({ scrollbarWidth: 0, scrollbarMargin: 0, animateInterval: 40, maintainPosition: false });
        // scroll with up arrow
        scrollDiv("div.storieswrapper.scrolling .ScrollControls img:eq(0)", "div.storieswrapper.scrolling .storieslistcontainer", -15);
        // scroll with down arrow
        scrollDiv("div.storieswrapper.scrolling .ScrollControls img:eq(1)", "div.storieswrapper.scrolling .storieslistcontainer", 15);
    }
    $("#plcSideContent2 div.shadow-container:first").css("margin-left", "-10px");
});

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");
		});
	}
}