/* 

	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
	
*/
function ShowMsg( msg ) {
	var div = document.getElementById('DebugMsg');
	div.innerHTML = div.innerHTML + msg;
}


this.easyscroll = function(upBtnId, downBtnId, containerId) {

    // movement speed
    var speed = 5;

    // desired height of the container element (in pixels)
    var height = 220;

    var obj = document.getElementById(containerId);

    obj.up = false;
    obj.down = false;
    obj.fast = false;

    obj.btnUp = document.getElementById(upBtnId);
    obj.btnDown = document.getElementById(downBtnId);

    obj.btnUp.onmouseover = function() {
        obj.interval = setInterval("document.getElementById('" + containerId + "').start()", 50);
        obj.up = true;
        this.className = "over";
    };
    obj.btnUp.onmouseout = function() {
        clearInterval(obj.interval);
        obj.up = false;
        this.className = "";
    };
    obj.btnDown.onmouseover = function() {
        obj.interval = setInterval("document.getElementById('" + containerId + "').start()", 50);
        obj.down = true;
        this.className = "over";
    };
    obj.btnDown.onmouseout = function() {
        clearInterval(obj.interval);
        obj.down = false;
        this.className = "";
    };
    obj.btnUp.onmousedown = obj.btnDown.onmousedown = function() {
        obj.fast = true;
    };
    obj.btnUp.onmouseup = obj.btnDown.onmouseup = function() {
        obj.fast = false;
    };

    obj.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;
            if (newTop > 0) {
                newTop = 0;
                clearInterval(obj.interval);
            }
            obj.style.top = newTop + "px";
        };
        if (obj.up) {
            newTop = (top < 0) ? top + (speed * fast) : top;
            if (newTop > 0) {
                newTop = 0;
                clearInterval(obj.interval);
            }
            obj.style.top = newTop + "px";
        };
    };
    //obj.interval = setInterval("start()", 50);

};


//
// script initiates on page load. 
//

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};