function NewsTicker(oAppendTo) {
    var oThis = this;
    this.timer = null;
    this.feeds = [];
    this.tickerContainer = document.createElement("div");
    this.ticker = document.createElement("div");
	//this.ticker.className = "newsverticalscroll";

    this.tickerContainer.className = "newsTickerContainer";
    this.ticker.className = "newsTicker";

    this.tickerContainer.onmouseover = function () {
        clearTimeout(oThis.timer);
    };

    this.tickerContainer.onmouseout = function () {
        oThis.tick();
    };

    this.tickerContainer.appendChild(this.ticker);

    var oToAppend = (oAppendTo)?oAppendTo:document.body;
    oToAppend.appendChild(this.tickerContainer);

    this.ticker.style.top = this.tickerContainer.offsetHeight + "px";
	this.ticker.style.left = "0px";
    this.tick();
}
	
	
NewsTicker.prototype.tick = function () {
    var iTickerLength = this.ticker.offsetHeight;
    var oThis = this;

    var doSetTimeout = function() {
        oThis.tick();
    };

    if (this.ticker.innerHTML) {
        if (this.ticker.offsetTop > -iTickerLength) {
            var iNewTop = this.ticker.offsetTop - 1;
            this.ticker.style.top = iNewTop + "px";
        } else {
            this.ticker.style.top = this.tickerContainer.offsetHeight + "px";
        }
    }
    this.timer = setTimeout(doSetTimeout,25);
};
	
NewsTicker.prototype.add = function (sUrl) {
    var feedsLength = this.feeds.length;

    this.feeds[feedsLength] = new NewsTickerFeed(this,sUrl);
};
	
function NewsTickerFeed(oParent,sUrl) {
    this.parent = oParent;
    this.url = sUrl;
    this.container = null;

    this.poll();
}
	
NewsTickerFeed.prototype.poll = function () {
    var oThis = this;

    var oReq = zXmlHttp.createRequest();
	    oReq.onreadystatechange = function () {
		if (oReq.readyState == 4) {
		    if (oReq.status == 200) {
                oThis.populateTicker(oReq.responseText);
            }
        }
    };
		
    var sFullUrl = encodeURI("newsreader.php?url=" + this.url);
		
    oReq.open("GET", sFullUrl, true);
    oReq.send(null);
		
    var doSetTimeout = function () {
        oThis.poll();
    };
		
    setTimeout(doSetTimeout, 900000);
};
	
NewsTickerFeed.prototype.populateTicker = function (sXml) {
    var oParser = new XParser(sXml, true);

    var spanLinkContainer = document.createElement("div");
	spanLinkContainer.className = "rssLinkContainer";

    for (var i = 0; i < oParser.items.length; i++) {
        var item = oParser.items[i];

        var aFeedLink = document.createElement("a");
        aFeedLink.href = item.link.value;
        aFeedLink.target = "_new";
        aFeedLink.className = "newsTicker-feedItem";
        aFeedLink.innerHTML = item.title.value;

        spanLinkContainer.appendChild(aFeedLink);
		
		var dNewsDiv = document.createElement("div");
		var tempDiv = document.createElement("div");
		tempDiv.innerHTML = item.description.value;
		dNewsDiv.className = "rssDescription";
		dNewsDiv.appendChild(tempDiv.firstChild);
		
		spanLinkContainer.appendChild(dNewsDiv);
    }
	  	
    if (!this.container) {
        this.container = document.createElement("div");
        this.container.className = "newsTicker-feedContainer";
        this.parent.ticker.appendChild(this.container);
    } else {
        this.container.removeChild(this.container.firstChild);
    }

    this.container.appendChild(spanLinkContainer);
};