var RssNew = Class.create();
RssNew.prototype = {
	initialize: function(options) {
		this.options = Object.extend({}, options || {});
		this.judge();
	},
	
	judge: function() {
		var url = document.location.protocol + "//" + window.location.host + "/rssnew.php";
		new Ajax.Request(url, {
			parameters:"url=" + this.options.url + "&day=" + this.options.day,
			onFailure: function(Request) {alert("onFailure")},
			onException: function(Request, ex) {alert(ex.message)},
			onSuccess: (function(rss) {
				return function(Request) {
					rss.show(Request);
				}				
			})(this),
			onComplete: function(){}
		});
	},
	
	show: function(req) {
		if (req.responseText == "true") {
			if (this.options.src) {
				if ($(this.options.id))
					$(this.options.id).src = this.options.src
			} else if (this.options.style) {
				if ($(this.options.id))
					Element.setStyle($(this.options.id), this.options.style);
			} else if (this.options.className) {
				if ($(this.options.id)) {
					var offset = Position.cumulativeOffset($(this.options.id));
					var e = new Element("div", {id:"new_" + this.options.id,className: "new"});
					e.appendChild(document.createTextNode("New"));
					Element.setStyle(e, {left: offset[0] + "px", top:offset[1] + "px"})
					Element.addClassName(e, this.options.className);
					document.body.appendChild(e);
				}
			}
		}
	}
}