function rssObj(domainF, localfile, numHead, classN, targetDiv, rootJsDir) {
this.origRem = domainF;
this.rem = this.origRem.replace(/\:/g, 'RRZZ');
this.rem = this.rem.replace(/\//g, 'QQRR');
this.rem = this.rem.replace(/\./g, 'ZZXX');
this.origRem = this.origRem.split("//");
this.origRem = this.origRem[1];
this.origRem = this.origRem.split("/");
this.origRem = this.origRem[0];
this.loc = localfile;
this.numH = numHead;
this.classN = classN;
this.targetDiv = targetDiv;
this.xmlObj = false;
if (window.XMLHttpRequest) { this.xmlObj = new XMLHttpRequest(); } // other browsers
if (window.ActiveXObject) { this.xmlObj = new ActiveXObject("Microsoft.XMLHTTP"); } // ie
this.reqUrl = rootJsDir + 'cacheServeFeed.php';
this.params = 'remote=' + encodeURI(this.rem) + "&local=" + encodeURI(this.loc);
this.build = makeRequest;
}


function makeRequest() {
	this.xmlObj.open("POST", this.reqUrl, true);
	this.xmlObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.xmlObj.setRequestHeader("Content-length", this.params.length);
	this.xmlObj.setRequestHeader("Connection", "close");
	var temp1 = this.classN; var temp2 = this.targetDiv; var temp3 = this.numH; var temp4 = this.xmlObj; var temp5 = this.origRem;
	this.xmlObj.onreadystatechange = function() { rssReturn(temp1, temp2, temp3, temp4, temp5); };
	this.xmlObj.send(this.params); 
}
var x=0;

function rssReturn(classN, targetDiv, numHeadlines, xmlObj, origRem) {
	if (xmlObj.readyState==4) {
		// if data is valid
		if ((xmlObj.responseText.indexOf('Invalid') == -1) || (origRem.indexOf("feedburner") != -1)) 
		{ 	
			// Parsing RSS
			var node = xmlObj.responseXML.documentElement; 
			
			// Get Channel information
			 var channel = node.getElementsByTagName('channel').item(0);
			 
			 // var title = channel.getElementsByTagName('title').item(0).firstChild.data;
			// var link = channel.getElementsByTagName('link').item(0).firstChild.data;
			
			content = '<ul>';
			// content = '<div class="channeltitle"><a href="'+link+'">'+title+'</a></div><ul>';
		
			// Browse items
			var items = channel.getElementsByTagName('item');
			for (var n=0; n < numHeadlines; n++)
			{
				
				var itemTitle = items[n].getElementsByTagName('title').item(0).firstChild.data;
				var itemLink = items[n].getElementsByTagName('link').item(0).firstChild.data;
				try 
				{ 
					var itemPubDate = '<font color=gray>['+items[n].getElementsByTagName('pubDate').item(0).firstChild.data+'] ';
				} 
				catch (e) 
				{ 
					var itemPubDate = '';
				}
				content += '<li class="' + classN + '"><a href="'+itemLink+'">'+itemTitle+'</a></li>';
			}
			
			content += '</ul>';
			// Display the result
			document.getElementById(targetDiv).innerHTML = content;

			// Tell the reader the everything is done
			// document.getElementById("status").innerHTML = "Done.";
			
		}
		else {
			alert('error loading rss');
			// Tell the reader that there was error requesting data
			// document.getElementById("status").innerHTML = "<div class=error>Error requesting data.<div>";
		}
	}
}
