﻿/* 

Easy Scroll v1.0
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
please visit http://cssglobe.com/post/1495/easy-scroll-accessible-content-scroller
	
	
*/

this.easyscroll = function() {

    // id of the container element 
    var id = "event_scroll";

    // navigation buttons text
    var nav = ["", "", ""];

    //	id for each navigation button (OPTIONAL)
    var navId = ["prev", "next", "reset"];

    // movement speed
    var speed = 10;

    // desired height of the container element (in pixels)
    var height = 430;

    //
    // END CONFIG
    // do not edit below this line (unless you want to of course :) )
    //

    var obj = document.getElementById(id);

    obj.up = false;
    obj.down = false;
    obj.fast = true;

    var container = document.createElement("div");
    var parent = obj.parentNode;
    container.id = "easyscroll";
    parent.insertBefore(container, obj);
    parent.removeChild(obj);

    container.style.position = "relative";
    container.style.height = height + "px";
    container.style.overflow = "hidden";
    obj.style.position = "absolute";
    obj.style.top = "0";
    obj.style.left = "0";
    container.appendChild(obj);

    $("a.prev").mouseover(function() {
        obj.up = true;
    });

    $("a.prev").mouseout(function() {
        obj.up = false;
    });

    $("a.next").mouseover(function() {
        obj.down = true;
    });

    $("a.next").mouseout(function() {
        obj.down = false;
    });

    this.start = function() {
        var newTop;
        var objHeight = obj.offsetHeight;
        var top = obj.offsetTop;
        var fast = (obj.fast) ? 2 : 1;
        if (obj.down) {
            newTop = ((objHeight + top) > height) ? top - (speed * fast) : top;
            obj.style.top = newTop + "px";
        };
        if (obj.up) {
            newTop = (top < 0) ? top + (speed * fast) : top;
            obj.style.top = newTop + "px";
        };
    };
    obj.interval = setInterval("start()", 50);

};
