function Reader()
{
	this.feeds = null;
	this.start = 0;
	this.num_items = 0;
	this.update_seconds=0;
	this.scroll_seconds=0;
	this.cpc_id = 0;
}
function Reader(feed_ids,feed_urls,update_seconds,scroll_seconds,cpcid)
{
	this.feeds = feed_ids;
	this.feed_urls = feed_urls;
	this.start = 0;
	this.num_items = 0;
	this.update_seconds = update_seconds;
	this.scroll_seconds = scroll_seconds;
	this.cpc_id = cpcid;
}
Reader.prototype.OpenFeed=OpenFeed;
Reader.prototype.Prev=Prev;
Reader.prototype.Next=Next;
Reader.prototype.subscribe=subscribe;

function Prev()
{
	with(this)
	{
		if(this.start>0)
		{
			var drop = this.start+this.num_items-1;
			drop = "item"+this.current_feed+"_"+drop;
			document.getElementById(drop).style.display="none";
			this.start--;
			document.getElementById("item"+this.current_feed+"_"+this.start).style.display="block";
			//bust out the div thingy;
		}
		else
		{}
	}
}
function Next()
{
	with(this)
	{
		try
		{
			var next = this.start+this.num_items;
			var add = "item" + this.current_feed + "_" + next;
			var drop = "item" + this.current_feed + "_"+this.start;
			//alert(add + "\n" + drop);
			document.getElementById(add).style.display="block";
			document.getElementById(drop).style.display="none";
			//try opening the next div, catch error and kill other code
			//if no error then close top div, advance start item;
			this.start = this.start+1;
		}
		catch(e){}
	}
}
function subscribe()
{
	with(this)
	{
		location.href=this.current_feed_url;
	}
}
function OpenFeed(feed_id,starto,limito)
{
	with(this)
	{
		this.num_items = limito;
		this.start = starto;
		try
		{
			//alert(this.cpc_id);
			for(i=1;i<this.feeds.length;i++)
			{
				var divo = "feed" + this.cpc_id + "_" + this.feeds[i];
				var tabo = "tab" + this.cpc_id + "_" + this.feeds[i];
				var diso = "none";
				var classo = "";
				if(this.feeds[i]==feed_id)
				{
					this.current_feed=feed_id;
					this.current_feed_url=this.feed_urls[i];
					diso = "block";
					classo = "active";
				}
				document.getElementById(divo).style.display=diso;
				document.getElementById(tabo).className=classo;
			}
		}
		catch(e){}

		var ajax = true;
		var xmlHttp;
		try
		{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					ajax=false;
				}
			}
		}
		var cpc_id;
		try
		{
			xmlHttp.cpc_id = this.cpc_id;
		}
		catch(e){cpc_id = this.cpc_id;}
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				var reply = xmlHttp.responseText;
				try
				{
					document.getElementById("feed" + xmlHttp.cpc_id + "_" + feed_id).innerHTML = reply;
				}
				catch(e)
				{
					document.getElementById("feed" + cpc_id + "_" + feed_id).innerHTML = reply;
				}
			}
		}
		if(ajax)
		{
				xmlHttp.open("GET","/rssAjax.aspx?id=" + feed_id + "&first=" + starto + "&limit=" + limito,true);
				//alert("/rssAjax.aspx?id=" + feed_id + "&first=" + starto + "&limit=" + limito);
				xmlHttp.send(null);
		}
	}
}