﻿Date.prototype.getDayOfYear = function () {
    return Math.ceil((this - new Date(this.getFullYear(), 0, 1)) / 86400000);
};

Date.prototype.getHistoricalDay = function () {
    return Math.ceil(this.getTime() / 86400000);
};

Date.prototype.substractDay = function (date) {
    return this.getHistoricalDay() - date.getHistoricalDay();
};

Date.prototype.isSameDay = function (date) {
    return (this.getFullYear() == date.getFullYear()) && (this.getMonth() == date.getMonth()) && (this.getDate() == date.getDate());
}

Date.prototype.isSameOrEarlierDay = function (date) {
    return this.isSameDay(date) || date.getTime() > this.getTime();
}

Date.prototype.isSameOrNewerDay = function (date) {
    return this.isSameDay(date) || date.getTime() < this.getTime();
}

Date.prototype.toHourMinuteString = function () {
    return ((this.getHours() < 10) ? ("0" + this.getHours()) : this.getHours()) +
    ":" +
    ((this.getMinutes() < 10) ? ("0" + this.getMinutes()) : this.getMinutes());
}

String.prototype.shortIfLonger = function (maxlength, dashstr) {
    if (this.length <= maxlength) return this.toString();

    return this.substring(0, maxlength - dashstr.length) + dashstr;
}

var SwIP = new function () {
    this.wB = null;
    this.wBP = null;
    this.wP = null;
    this.url = null;
    this.settings = null;
    this.gallery = null;
    this.current = null;

    this.Show = function (e, url, settings) {
        SwIP.url = url;
        SwIP.settings = settings;
        if (!SwIP.wB) SwIP.wB = SwIP.CreateBlockerPopupElement();
        if (!SwIP.wBP) SwIP.wBP = SwIP.CreateProgressElement();
        if (!SwIP.wP) SwIP.wP = SwIP.CreateImgPopupElement();

        SwIP.ShowBlocker();
        SwIP.ShowProgress();
        SwIP.ShowPopup();

        e = e || window.event;
        e.cancelBubble = true;
        e.returnValue = false;
        if (e.stopPropagation) e.stopPropagation();
        if (e.preventDefault) e.preventDefault();
    }

    this.ShowGallery = function (e, gallery, current) {
        SwIP.gallery = gallery;
        SwIP.current = current;
        SwIP.Show(e, gallery[current].url, gallery[current].settings);
    }

    this.CreateBlockerPopupElement = function () {
        var wBlocker = document.createElement("div");
        wBlocker.style.display = "none";
        wBlocker.style.position = "absolute";
        wBlocker.style.zIndex = "100";
        wBlocker.style.opacity = "0.5";
        wBlocker.style.filter = "filter: alpha(opacity=50)";
        wBlocker.style.backgroundColor = "black";
        // wBlocker.style.backgroundImage = "url(img/progressbar.gif)";
        wBlocker.style.backgroundPosition = "center center";
        wBlocker.style.backgroundRepeat = "no-repeat";
        wBlocker.onclick = SwIP.Hide;
        document.body.appendChild(wBlocker);

        return wBlocker;
    }

    this.CreateProgressElement = function () {
        var wProgress = document.createElement("img");
        wProgress.style.display = "none";
        wProgress.style.position = "absolute";
        wProgress.style.zIndex = "101";
        wProgress.src = "img/progressbar.gif";
        document.body.appendChild(wProgress);

        return wProgress;
    }

    this.CreateImgPopupElement = function () {
        var wPopup = document.createElement("div");
        wPopup.id = "swi_popup";
        wPopup.style.position = "fixed";
        wPopup.style.zIndex = "102";
        if (SwIP.gallery) wPopup.onclick = SwIP.Next;
        else wPopup.onclick = SwIP.Hide;
        document.body.appendChild(wPopup);

        return wPopup;
    }

    this.ShowBlocker = function () {
        SwIP.wB.style.left = "0px";
        SwIP.wB.style.top = "0px";
        SwIP.wB.style.width = document.body.clientWidth + "px";
        SwIP.wB.style.height = document.body.clientHeight + "px";
        SwIP.wB.style.display = "block";
    }

    this.ShowProgress = function () {
        SwIP.wBP.style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth / 2) - 122) + "px";
        SwIP.wBP.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight / 2) - 8) + "px";
        //SwIP.wBP.style.width=document.documentElement.clientWidth + "px";
        //SwIP.wBP.style.height=document.documentElement.clientHeight + "px";
        SwIP.wBP.style.display = "block";
    }

    this.ShowPopup = function () {
        SwIP.wP.style.visibility = "hidden";
        SwIP.wP.style.display = "block";
        SwIP.wP.style.left = ((document.viewport.getWidth() / 2) - (SwIP.wP.offsetWidth / 2)) + "px"; //((document.viewport.getScrollOffsets().left + (document.viewport.getWidth() / 2)) - (SwIP.wP.offsetWidth / 2)) + "px";
        SwIP.wP.style.top = ((document.viewport.getHeight() / 2) - (SwIP.wP.offsetHeight / 2)) + "px"; //((document.viewport.getScrollOffsets().top + (document.viewport.getHeight() / 2)) - (SwIP.wP.offsetHeight / 2)) + "px";
        SwIP.wP.style.width = "1px";
        SwIP.wP.style.height = "1px";
        SwIP.wP.style.overflow = "hidden";
        SwIP.wP.style.zIndex = 101;
        //if(SwIP.settings && SwIP.settings.border) SwIP.wP.style.border = SwIP.settings.border;
        var innerHTML = "";
        if (SwIP.settings && SwIP.settings.showTitleBar) {
            innerHTML += "<div id=\"swi_topbar\"><div" + (SwIP.settings.border ? " style=\"margin-left: " + SwIP.settings.borderSize + "px; margin-right: " + SwIP.settings.borderSize + "px\"" : "") + ">";
            if (SwIP.settings.titlePosition == "top") innerHTML += "<div id=\"swi_title\">" + SwIP.settings.title + "</div>"
            if (SwIP.settings.descriptionPosition == "top") innerHTML += "<div id=\"swi_description\">" + SwIP.settings.description + "</div>";
            innerHTML += "</div></div>";
        }

        if (SwIP.settings) {
            innerHTML += "<div id=\"swi_divimg\" " + (SwIP.settings.border ? "style=\"border: " + SwIP.settings.border + "\"" : "") + "><img id=\"swi_img\" src=\"" + SwIP.url + "\" onload=\"SwIP.Recalc();\" style=\"cursor: pointer;\" /></div>";
        } else {
            innerHTML += "<div id=\"swi_divimg\"><img id=\"swi_img\" src=\"" + SwIP.url + "\" onload=\"SwIP.Recalc();\" style=\"cursor: pointer;\" /></div>";
        }

        if (SwIP.settings && SwIP.settings.showBottomBar) {
            innerHTML += "<div id=\"swi_bottombar\"><div" + (SwIP.settings.border ? " style=\"margin-left: " + SwIP.settings.borderSize + "px; margin-right: " + SwIP.settings.borderSize + "px;\"" : "") + ">";
            if ((SwIP.settings.titlePosition == "bottom") || (!SwIP.settings.titlePosition)) innerHTML += "<div id=\"swi_title\">" + SwIP.settings.title + "</div>"
            if ((SwIP.settings.descriptionPosition == "bottom") || (!SwIP.settings.descriptionPosition)) innerHTML += "<div id=\"swi_description\">" + SwIP.settings.description + "</div>";
            innerHTML += "</div></div>";
        }
        SwIP.wP.innerHTML = innerHTML;
    }

    this.Recalc = function (recursed) {
        var elm = document.getElementById('swi_img');
        var divimg = document.getElementById('swi_divimg');
        var topbar = document.getElementById('swi_topbar');
        var bottombar = document.getElementById('swi_bottombar');
        var topbarheight = 0;
        var bottombarheight = 0;
        var bordersize = 0;
        if (topbar) topbarheight = topbar.offsetHeight;
        if (bottombar) bottombarheight = bottombar.offsetHeight;
        if (SwIP.settings && SwIP.settings.borderSize) bordersize += SwIP.settings.borderSize;
        var winw = document.documentElement.clientWidth - topbarheight - bottombarheight - (bordersize * 2) - 50;
        var winh = document.documentElement.clientHeight - (bordersize * 2) - 50;
        if (elm.width > winw) {
            elm.height = elm.height / (elm.width / (winw - 50));
            elm.width = winw - 50;
        }
        if (elm.height > winh) {
            elm.width = elm.width / (elm.height / (winh - 50));
            elm.height = winh - 20;
        }
        SwIP.wP.style.width = (elm.width + (bordersize * 2)) + "px";
        SwIP.wP.style.height = (elm.height + topbarheight + bottombarheight + (bordersize * 2)) + "px";
        SwIP.wP.style.left = ((document.viewport.getWidth() / 2) - (SwIP.wP.offsetWidth / 2)) + "px"; //((document.viewport.getScrollOffsets().left + (document.viewport.getWidth() / 2)) - (SwIP.wP.offsetWidth / 2)) + "px";
        SwIP.wP.style.top = ((document.viewport.getHeight() / 2) - (SwIP.wP.offsetHeight / 2)) + "px"; //((document.viewport.getScrollOffsets().top + (document.viewport.getHeight() / 2)) - (SwIP.wP.offsetHeight / 2)) + "px";
        if (bottombar && !recursed) SwIP.Recalc(true);
        SwIP.wP.style.visibility = 'visible';
        this.wBP.style.display = "none";
    }

    this.Hide = function () {
        SwIP.wP.style.display = "none";
        SwIP.wBP.style.display = "none";
        SwIP.wB.style.display = "none";
    }

    this.Next = function (e) {
        SwIP.Hide();
        if (SwIP.current < SwIP.gallery.length - 1) {
            SwIP.current++;
            SwIP.Show(e, SwIP.gallery[SwIP.current].url, SwIP.gallery[SwIP.current].settings);
        }
    }
}

var SwPL = new function () {
    this.wB = null;
    this.wP = null;
    this.plid = null;
    this.noclose = false;
    this.type = 'popup';

    this.Show = function (e, plid, type, noclose) {
        if (noclose) this.noclose = noclose;
        if (type) this.type = type;
        SwPL.plid = plid;
        if (!SwPL.wB) SwPL.wB = SwPL.CreateBlockerElement();
        if (!SwPL.wP) SwPL.wP = SwPL.CreatePopupElement();

        SwPL.ShowBlocker();

        e = e || window.event;
        e.cancelBubble = true;
        e.returnValue = false;
        if (SwPL.type == "popup") SwPL.ShowPopup();
        if (SwPL.type == "async") SwPL.LoadPopup();

        return false;
    }

    this.CreateBlockerElement = function () {
        var wBlocker = document.createElement("div");
        wBlocker.style.display = "none";
        wBlocker.style.position = "absolute";
        wBlocker.style.zIndex = "90";
        wBlocker.style.opacity = "0.5";
        wBlocker.style.filter = "filter: alpha(opacity=50)";
        wBlocker.style.backgroundColor = "black";
        wBlocker.style.backgroundPosition = "center center";
        wBlocker.style.backgroundRepeat = "no-repeat";
        wBlocker.onclick = SwPL.Hide;
        document.body.appendChild(wBlocker);

        return wBlocker;
    }

    this.CreatePopupElement = function () {
        var wPopup = document.createElement("div");
        wPopup.style.position = "absolute";
        wPopup.style.zIndex = "101";
        if (!SwPL.noclose) wPopup.onclick = SwPL.Hide;
        if (SwPL.type == 'formpopup') document.getElementById('aspnetForm').appendChild(wPopup);
        else document.body.appendChild(wPopup);

        return wPopup;
    }

    this.ShowBlocker = function () {
        SwPL.wB.style.left = document.documentElement.scrollLeft + "px";
        SwPL.wB.style.top = document.documentElement.scrollTop + "px";
        SwPL.wB.style.width = document.documentElement.clientWidth + "px";
        SwPL.wB.style.height = document.documentElement.clientHeight + "px";
        SwPL.wB.style.display = "block";
    }

    this.ShowPopup = function () {
        SwPL.wP.innerHTML = document.getElementById(SwPL.plid).innerHTML;
        SwPL.wP.style.display = "block";
        SwPL.wP.style.left = ((document.documentElement.scrollLeft + (document.documentElement.clientWidth / 2)) - (SwPL.wP.offsetWidth / 2)) + "px";
        SwPL.wP.style.top = ((document.documentElement.scrollTop + (document.documentElement.clientHeight / 2)) - (SwPL.wP.offsetHeight / 2)) + "px";
        SwPL.wP.style.overflow = "hidden";
        SwPL.wP.style.zIndex = 91;
    }

    this.LoadPopup = function () {
        SwPL.wP.innerHTML = "<div style=\"background-color: white;\"><img src=\"/img/progressbar.gif\" /></div>";

        new Ajax.Request("/shared/sharedhtml.aspx?text=" + encodeURIComponent(SwPL.plid),
        {
            onSuccess: function (resp) {
                SwPL.UpdateAsyncPopup(resp);
            },
            onFailure: function (resp) {
                SwPL.Hide();
            }
        });

        SwPL.wP.style.display = "block";
        SwPL.wP.style.left = ((document.documentElement.scrollLeft + (document.documentElement.clientWidth / 2)) - (SwPL.wP.offsetWidth / 2)) + "px";
        SwPL.wP.style.top = ((document.documentElement.scrollTop + (document.documentElement.clientHeight / 2)) - (SwPL.wP.offsetHeight / 2)) + "px";
        SwPL.wP.style.overflow = "hidden";
        SwPL.wP.style.zIndex = 91;
    }

    this.UpdateAsyncPopup = function (resp) {
        SwPL.wP.innerHTML = resp.responseText;
        SwPL.wP.style.left = ((document.documentElement.scrollLeft + (document.documentElement.clientWidth / 2)) - (SwPL.wP.offsetWidth / 2)) + "px";
        SwPL.wP.style.top = ((document.documentElement.scrollTop + (document.documentElement.clientHeight / 2)) - (SwPL.wP.offsetHeight / 2)) + "px";
    }

    this.Hide = function () {
        SwPL.wP.style.display = "none";
        SwPL.wB.style.display = "none";
    }
}

var Bubble = Class.create({
    initialize: function (targetElement, settings) {
        this._targetElement = targetElement;
        this._htmlContent = settings.htmlContent;
        this._width = settings.width;
        this._height = settings.height;
        this._arrow = settings.arrow;
        this._leftOffset = settings.leftOffset || 6;
    },

    createBubble: function () {
        var be = new Element("div", { "class": "speedyweb-bubble" });
        this._bubbleElement = be;

        var inner = "<div class=\"speedyweb-bubble-envelope\"><div class=\"speedyweb-bubble-top-left\"></div><div class=\"speedyweb-bubble-top-right\"></div><div class=\"speedyweb-bubble-bottom-left\"></div><div class=\"speedyweb-bubble-bottom-right\"></div><div class=\"speedyweb-bubble-top\"></div><div class=\"speedyweb-bubble-bottom\"></div><div class=\"speedyweb-bubble-right\"></div><div class=\"speedyweb-bubble-left\"></div><div class=\"speedyweb-bubble-content\">" + this._htmlContent + "</div><div class=\"speedyweb-bubble-arrow-left\"></div><div class=\"speedyweb-bubble-arrow-right\"></div><div class=\"speedyweb-bubble-arrow-top\"></div><div class=\"speedyweb-bubble-arrow-bottom\"></div></div>";

        document.body.appendChild(be);

        be.update(inner);

        be.style.width = (this._width + 44) + "px";
        be.style.height = (this._height + 44) + "px";

        be.select("div.speedyweb-bubble-envelope")[0].setStyle({ width: (this._width + 44) + "px", height: (this._height + 44) + "px" });
        be.select("div.speedyweb-bubble-content")[0].setStyle({ width: this._width + "px", height: this._height + "px" });
        be.select("div.speedyweb-bubble-top-right")[0].setStyle({ left: (this._width + 22) + "px" });
        be.select("div.speedyweb-bubble-bottom-left")[0].setStyle({ top: (this._height + 22) + "px" });
        be.select("div.speedyweb-bubble-bottom-right")[0].setStyle({ top: (this._height + 22) + "px", left: (this._width + 22) + "px" });

        be.select("div.speedyweb-bubble-top")[0].setStyle({ width: this._width + "px" });
        be.select("div.speedyweb-bubble-left")[0].setStyle({ height: this._height + "px" });
        be.select("div.speedyweb-bubble-right")[0].setStyle({ left: (this._width + 22) + "px", height: this._height + "px" });
        be.select("div.speedyweb-bubble-bottom")[0].setStyle({ top: (this._height + 22) + "px", width: this._width + "px" });

        switch (this._arrow) {
            case "left":
                be.select("div.speedyweb-bubble-arrow-left")[0].setStyle({ top: (((this._height + 44) / 2) - 14) + "px", display: "block" });
                be.style.top = (this._targetElement.cumulativeOffset().top - ((this._height + 44) / 2) + (this._targetElement.offsetHeight / 2)) + "px";
                be.style.left = (this._targetElement.cumulativeOffset().left + this._targetElement.offsetWidth + this._leftOffset) + "px";
                break;
        }
    },

    activate: function (event) {
        this.createBubble();
        this._bubbleElement.style.display = 'block';
    },

    deactivate: function (event) {
        this._bubbleElement.style.display = 'none';
        this._bubbleElement.remove();
    },

    setContent: function (content) {
        this._htmlContent = content;
        if (this._bubbleElement) this._bubbleElement.select("div.speedyweb-bubble-content")[0].update(content);
    }
});

var FormBubble = Class.create({
    _dimsRegex: /speedyweb-bubble-dim-(\d+)-(\d+)/i,

    initialize: function (element) {
        var contentElm = $(element.id + "_help");
        var htmlContent = contentElm.innerHTML;
        var dims = this._dimsRegex.exec(contentElm.className);
        this._bubble = new Bubble(element, { "width": parseInt(dims[1]), "height": parseInt(dims[2]), "arrow": "left", "htmlContent": htmlContent });
        $(element).observe("focus", this._bubble.activate.bindAsEventListener(this._bubble));
        $(element).observe("blur", this._bubble.deactivate.bindAsEventListener(this._bubble));
    }
});

var HoverBubble = Class.create({
    _dimsRegex: /speedyweb-bubble-dim-(\d+)-(\d+)/i,

    initialize: function (element) {
        var contentElm = $(element.id + "_help");
        var htmlContent = contentElm.innerHTML;
        var dims = this._dimsRegex.exec(contentElm.className);
        this._bubble = new Bubble(element, { "width": parseInt(dims[1]), "height": parseInt(dims[2]), "arrow": "left", "htmlContent": htmlContent });
        $(element).observe("mouseover", this._bubble.activate.bindAsEventListener(this._bubble));
        $(element).observe("mouseout", this._bubble.deactivate.bindAsEventListener(this._bubble));
    }
});

document.observe("dom:loaded", function () {
    $$("input.formbubble", "textarea.formbubble").each(function (element) {
        element.formbubble = new FormBubble(element);
    });

    $$(".hoverbubble").each(function (element) {
        element.hoverbubble = new HoverBubble(element);
    });
});

// Progress preloading
var progressImage = new Image();
progressImage.src = "img/progressbar.gif";

// Copy protection
function InitCopyProtection() {
    if (!document.getElementsByTagName('body')[0]) {
        window.setTimeout(InitCopyProtection, 100);
        return;
    }
    document.onkeydown = function (ev) {
        var e = ev || event;
        if (e.ctrlKey && (e.keyCode == '67')) {
            document.getElementsByTagName('body')[0].innerHTML = '<h1>This page is copy protected!!!</h1>';
            e.returnValue = false;
            window.clipboardData.setData('text', 'No copy!');
            return false;
        }
    }
    var body = document.getElementsByTagName('body')[0];
    body.onselectstart = function (ev) {
        var e = ev || event;
        e.returnValue = false;
        return false;
    };
    body.onmousedown = function (ev) {
        var e = ev || event;
        e.returnValue = false;
        return false;
    };
    body.onmouseup = function (ev) {
        var e = ev || event;
        e.returnValue = false;
        return false;
    };
    body.oncontextmenu = function (ev) {
        var e = ev || event;
        var elm = e.target || e.srcElement;
        if (elm.tagName != 'IMG') {
            e.returnValue = false;
            return false;
        }
    };
}

var SpeedyPopup = Class.create({
    initialize: function (popupLinkElement) {
        this._popupType = "iframe";

        if (popupLinkElement != null) {
            this._linkElement = popupLinkElement;
            if (this._linkElement.href.toString()[0] == "#") {
                this._popupType = "inline";
                this._settings = unescape(this._linkElement.href.toString().substring(1)).evalJSON();
                this._popupTarget = this._settings.inlineId;
            } else {
                this._settings = unescape(this._linkElement.href.toString().split('#')[1]).evalJSON();
                this._popupTarget = this._linkElement.href.toString().split('#')[0];
            }

            this._linkElement.observe("click", (function (event) {
                Event.stop(event);
                this.show();
            }).bindAsEventListener(this));
        }
    },

    createBlocker: function () {
        this._blockerElement = new Element("div", { "class": "speedy-popup-blocker" });
        document.body.appendChild(this._blockerElement);
        this._blockerElement.setStyle({ "position": "absolute", "z-index": 1000, "top": "0px", "left": "0px", "width": "100%", "height": "100%", "backgroundColor": "black", "opacity": 0.5, "filter": "filter: alpha(opacity=50)" });
        this._blockerElement.observe("click", this.hide.bindAsEventListener(this));
    },

    createPopup: function () {
        this._popupElement = new Element("div", { "class": "speedy-popup-window" });
        document.body.appendChild(this._popupElement);
        this._popupElement.setStyle({ "width": this._settings.width, "height": this._settings.height, "position": "absolute", "z-index": 1001 });
        if (this._popupType == "inline") this._popupElement.update($(this._popupTarget).innerHTML);
        else this._popupElement.update("<IFRAME SRC=\"" + this._popupTarget + "\" WIDTH=\"" + this._settings.width + "px\" HEIGHT=\"" + this._settings.height + "px\" FRAMEBORDER=\"0\" />");
        this._popupElement.observe("click", function (event) {
            Event.stop(event);
        });
    },

    show: function () {
        this.createBlocker();
        this.createPopup();
        this._popupElement.setStyle({ "left": ((document.documentElement.scrollLeft + (document.documentElement.clientWidth / 2)) - (this._popupElement.offsetWidth / 2)) + "px" });
        this._popupElement.setStyle({ "top": ((document.documentElement.scrollTop + (document.documentElement.clientHeight / 2)) - (this._popupElement.offsetHeight / 2)) + "px" });
        document.currentSpeedyPopup = this;
    },

    hide: function () {
        this._popupElement.remove();
        this._blockerElement.remove();
        document.currentSpeedyPopup = null;
    }
});

document.observe("dom:loaded", function () {
    $$("a.popuplink").each(function (elm) {
        elm.speedyPopup = new SpeedyPopup(elm);
    });
});

var AutoSpeedyPopup = Class.create({
    initialize: function (url, settings) {
        document.observe("dom:loaded", (function () {
            this._speedyPopup = new SpeedyPopup(null);
            this._speedyPopup._popupTarget = url;
            this._speedyPopup._settings = settings;
            this._speedyPopup.show();
        }).bind(this));
    }
});


var Tabs = Class.create({
    initialize: function (tabs) {
        this._tabs = [];
        this._active = null;
        tabs.select(".tab").each((function (elm) {
            var tab = {
                tab: elm,
                placeholder: $(elm.id + "_placeholder"),
                manager: this
            }
            if (tab.tab.hasClassName("active")) this._active = tab;
            this._tabs.push(tab);
            tab.tab.observe("click", this.switchTab.bindAsEventListener(this, tab));
            elm.tab = tab;
        }).bind(this));

        if (this._active != null) this.switchTab(null, this._active);
    },

    switchTab: function (event, tab) {
        this._tabs.each((function (ttab) {
            if (ttab != tab) {
                ttab.placeholder.style.display = "none";
                ttab.tab.removeClassName("active");
            }
        }).bind(this));
        tab.placeholder.style.display = "block";
        tab.tab.addClassName("active");
        this._active = tab;
        if (event) Event.stop(event);
    }
});

document.observe("dom:loaded", function () {
    $$("div.tabs").each(function (elm) {
        elm.Tabs = new Tabs(elm);
    });
});

var RollLine = Class.create({
    initialize: function (element) {
        this.mainElement = element;
        this.isRollEffect = element.hasClassName("rolleffect");
        this.ulElement = element.select("ul")[0];
        this.currentIndex = 0;
        this.liElements = this.ulElement.select("li");
        this.liCount = this.liElements.length;
        this.rollTimerId = window.setTimeout(this.rollTimer.bind(this), 5000);
    },

    rollTimer: function () {
        this.currentIndex++;
        if (this.currentIndex >= this.liCount) {
            this.currentIndex = 0;
            if (this.isRollEffect) {
                new Effect.Move(this.ulElement, { x: 0, y: 0, mode: 'absolute' });
            } else {
                this.ulElement.style.top = "0px";
            }
            this.rollTimerId = window.setTimeout(this.rollTimer.bind(this), 8000);
        } else {
            if (this.isRollEffect) {
                new Effect.Move(this.ulElement, { x: 0, y: -this.liElements[this.currentIndex].clientHeight, mode: 'relative' });
            } else {
                this.ulElement.style.top = (this.ulElement.clientTop - this.liElements[this.currentIndex].clientHeight) + "px";
            }
            this.rollTimerId = window.setTimeout(this.rollTimer.bind(this), 5000);
        }
    }
});

document.observe("dom:loaded", function () {
    $$("div.rollline").each(function (elm) {
        elm.RollLine = new RollLine(elm);
    });
});


//InitCopyProtection();
//document.body.onselectstart = function { alert('Co to delas?'); }
