
function insertAfter(parent, node, referenceNode) {
    parent.insertBefore(node, referenceNode.nextSibling);
}

this.ScrollBlogroll1 = function () {
    var id = "blogroll";
    var nav = ["R", "U", "D"];
    var navId = ["btnReset", "btnUp", "btnDown"];
    var speed = 5;
    var height = 100;
    var topNav = document.getElementById("topNavBlogRol");
    if (topNav != null) {
        var obj = document.getElementById(id);
        if (obj != null) {
            obj.up = false;
            obj.down = false;
            obj.fast = false;

            var container = document.createElement("div");
            var parent = obj.parentNode;
            container.id = "BlogRollNavScroll";
            parent.insertBefore(container, obj);
            parent.removeChild(obj);

            var hght = document.getElementById("hght");

            if (hght == null) {

                hght = height;
            }
            else {
                hght = hght.innerHTML;
            }

            container.style.position = "relative";
            container.style.height = hght + "px";
            container.style.overflow = "hidden";

            obj.style.position = "relative";
            obj.style.top = "0";
            obj.style.left = "0";
            container.appendChild(obj);

            var btns = new Array();
            var ul = document.createElement("ul");
            ul.id = "BlogRollNavUl";
            for (var i = 0; i < nav.length; i++) {
                var li = document.createElement("li");

                if (i == 0) {
                    li.innerHTML = "<a href='#' title='Back to Top'><img  src='/themes/IRunAtServer/img/slice3.png'  alt='Back to Top'  /></a>";

                }
                else if (i == 1) {
                    li.innerHTML = "<a href='#' title='Scroll Up'><img src='/themes/IRunAtServer/img/slice1.png' alt='Scroll Up'  /></a>";
                }
                else {
                    li.innerHTML = "<a href='#' title='Scroll Down'><img  src='/themes/IRunAtServer/img/slice2.png' alt='Scroll Down'   /></a>";
                }

                li.id = navId[i];
                btns.push(li);
                ul.appendChild(li);
            };


            topNav.appendChild(ul);

            btns[1].onmouseover = function () {
                obj.up = true;
                this.className = "over";
            };
            btns[1].onmouseout = function () {
                obj.up = false;
                this.className = "";
            };
            btns[2].onmouseover = function () {
                obj.down = true;
                this.className = "over";
            };
            btns[2].onmouseout = function () {
                obj.down = false;
                this.className = "";
            };
            btns[1].onmousedown = btns[2].onmousedown = function () {
                obj.fast = true;
            };
            btns[1].onmouseup = btns[2].onmouseup = function () {
                obj.fast = false;
            };
            btns[0].onmouseover = function () {
                this.className = "over";
            };
            btns[0].onmouseout = function () {
                this.className = "";
            };
            btns[0].onclick = function () {
                obj.style.top = "0px";
            };

            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);
        }
    }

};

this.ScrollBlogroll2 = function () {
    var id = "blogroll2";
    var nav = ["R", "U", "D"];
    var navId = ["btnReset", "btnUp", "btnDown"];
    var speed = 5;
    var height = 100;
    var topNav = document.getElementById("topNavBlogRol2");
    if (topNav != null) {
        var obj = document.getElementById(id);
        if (obj != null) {
            obj.up = false;
            obj.down = false;
            obj.fast = false;

            var container = document.createElement("div");
            var parent = obj.parentNode;
            container.id = "BlogRoll2NavScroll";
            parent.insertBefore(container, obj);
            parent.removeChild(obj);

            var hght = document.getElementById("hght");

            if (hght == null) {

                hght = height;
            }
            else {
                hght = hght.innerHTML;
            }

            container.style.position = "relative";
            container.style.height = hght + "px";
            container.style.overflow = "hidden";

            obj.style.position = "relative";
            obj.style.top = "0";
            obj.style.left = "0";
            container.appendChild(obj);

            var btns = new Array();
            var ul = document.createElement("ul");
            ul.id = "BlogRoll2NavUl";
            for (var i = 0; i < nav.length; i++) {
                var li = document.createElement("li");

                if (i == 0) {
                    li.innerHTML = "<a href='#' title='Back to Top'><img  src='/themes/IRunAtServer/img/slice3.png'  alt='Back to Top'  /></a>";

                }
                else if (i == 1) {
                    li.innerHTML = "<a href='#' title='Scroll Up'><img src='/themes/IRunAtServer/img/slice1.png' alt='Scroll Up'  /></a>";
                }
                else {
                    li.innerHTML = "<a href='#' title='Scroll Down'><img  src='/themes/IRunAtServer/img/slice2.png' alt='Scroll Down'   /></a>";
                }

                li.id = navId[i];
                btns.push(li);
                ul.appendChild(li);
            };


            topNav.appendChild(ul);

            btns[1].onmouseover = function () {
                obj.up = true;
                this.className = "over";
            };
            btns[1].onmouseout = function () {
                obj.up = false;
                this.className = "";
            };
            btns[2].onmouseover = function () {
                obj.down = true;
                this.className = "over";
            };
            btns[2].onmouseout = function () {
                obj.down = false;
                this.className = "";
            };
            btns[1].onmousedown = btns[2].onmousedown = function () {
                obj.fast = true;
            };
            btns[1].onmouseup = btns[2].onmouseup = function () {
                obj.fast = false;
            };
            btns[0].onmouseover = function () {
                this.className = "over";
            };
            btns[0].onmouseout = function () {
                this.className = "";
            };
            btns[0].onclick = function () {
                obj.style.top = "0px";
            };

            this.start3 = 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("start3()", 50);
        }
    }

};



this.ScrollLinkedList = function () {
    var id = "linkedList";
    var nav = ["R", "U", "D"];
    var navId = ["btnReset", "btnUp", "btnDown"];
    var speed = 5;
    var height = 100;
    var topNav = document.getElementById("topNavLinkedList");
    if (topNav != null) {
        var obj1 = document.getElementById(id);
        if (obj1 != null) {
            obj1.up = false;
            obj1.down = false;
            obj1.fast = false;

            var container = document.createElement("div");
            var parent = obj1.parentNode;
            container.id = "BlogRollNavScroll";
            parent.insertBefore(container, obj1);
            parent.removeChild(obj1);

            var hght = document.getElementById("hghtLinkedList");

            if (hght == null) {

                hght = height;
            }
            else {
                hght = hght.innerHTML;
            }

            container.style.position = "relative";
            container.style.height = hght + "px";
            container.style.overflow = "hidden";

            obj1.style.position = "relative";
            obj1.style.top = "0";
            obj1.style.left = "0";
            container.appendChild(obj1);

            var btns = new Array();
            var ul = document.createElement("ul");
            ul.id = "BlogRollNavUl";
            for (var i = 0; i < nav.length; i++) {
                var li = document.createElement("li");

                if (i == 0) {
                    li.innerHTML = "<a href='#' title='Back to Top'><img  src='/themes/IRunAtServer/img/slice3.png'  alt='Back to Top'  /></a>";

                }
                else if (i == 1) {
                    li.innerHTML = "<a href='#' title='Scroll Up'><img src='/themes/IRunAtServer/img/slice1.png' alt='Scroll Up'  /></a>";
                }
                else {
                    li.innerHTML = "<a href='#' title='Scroll Down'><img  src='/themes/IRunAtServer/img/slice2.png' alt='Scroll Down'   /></a>";
                }

                li.id = navId[i];
                btns.push(li);
                ul.appendChild(li);
            };


            topNav.appendChild(ul);

            btns[1].onmouseover = function () {
                obj1.up = true;
                this.className = "over";
            };
            btns[1].onmouseout = function () {
                obj1.up = false;
                this.className = "";
            };
            btns[2].onmouseover = function () {
                obj1.down = true;
                this.className = "over";
            };
            btns[2].onmouseout = function () {
                obj1.down = false;
                this.className = "";
            };
            btns[1].onmousedown = btns[2].onmousedown = function () {
                obj1.fast = true;
            };
            btns[1].onmouseup = btns[2].onmouseup = function () {
                obj1.fast = false;
            };
            btns[0].onmouseover = function () {
                this.className = "over";
            };
            btns[0].onmouseout = function () {
                this.className = "";
            };
            btns[0].onclick = function () {
                obj1.style.top = "0px";
            };

            this.start1 = function () {
                var newTop;
                var objHeight = obj1.offsetHeight;
                var top = obj1.offsetTop;
                var fast = (obj1.fast) ? 2 : 1;
                if (obj1.down) {
                    newTop = ((objHeight + top) > height) ? top - (speed * fast) : top;
                    obj1.style.top = newTop + "px";
                };
                if (obj1.up) {
                    newTop = (top < 0) ? top + (speed * fast) : top;
                    obj1.style.top = newTop + "px";
                };
            };

            obj1.interval = setInterval("start1()", 100);
        }
    }

};









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);
	};
};
addEvent(window, "load", ScrollBlogroll1);
addEvent(window, "load", ScrollLinkedList);
addEvent(window, "load", ScrollBlogroll2);
