function rssOBJ(a,b,c,d,e) {
    this.link = a;
    this.divContent = b;
    this.num2display = c;
    this.attributes = d;
    this.targetRef = e;
    try{
		var xmlhttp=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
			   	//xmlhttp = false;
			   	try{
			   		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.6.0");
			   	}catch(e){
			   		try{
				   		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
				   	}catch(e){
				   		xmlhttp = false;
				   	}
			   	}
			}
		}
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			try {
				xmlhttp = new XMLHttpRequest();
			} catch (e) {
				xmlhttp=false;
			}
		}
		if (!xmlhttp && window.createRequest) {
			try {
				xmlhttp = window.createRequest();
			} catch (e) {
				xmlhttp=false;
			}
		}
		//init xmlhttp object
		//netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead")
		var contents = this;
		xmlhttp.open("GET",this.link,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				contents.rssContent = xmlhttp.responseText;
				drawXML(contents);
			}
		}
		xmlhttp.send(null);
	}catch(err){
		alert("ERROR : " + err);
	}
}
function extractRSS(x,y){
	try{
		var _tagcontents = String(y);
		var _extractedContents = new Array();
		//var look_for_tag = new RegExp(x);
		var look_for_tag = new RegExp('<'+x+'[^><]*>|<.'+x+'[^><]*>','g')
		var result = _tagcontents.match(look_for_tag);
		var xmlPointer = new Number();
		var _endtag = "</" + x + ">";
		var tmptag2search = "<" + x + ">";
		if (result != null) {
			for(z=0;z<=result.length;z++){
				if(result[z]){
					//turn string into an array so that I can split out the contents
					if(result[z]!=_endtag){
						var _extractedtag = result[z];
						if(tmptag2search == _extractedtag){
							//parse through form document and extract the proper data
							xmlPointer++;
							var _tagcontent = _tagcontents.split(_extractedtag);
							var _tmpTitle = new String();
							var tag2split = _tagcontent[xmlPointer];
							var tagContents = tag2split.split(_endtag);
							var _tagObj = new Object();
							_tagObj.starttag = result[z];
							_tagObj.contents = tagContents[0];
							_tagObj.endtag = _endtag;
							//increment values
							_extractedContents.push(_tagObj);
						}
					}
				}
			}
		}
		return _extractedContents;
	}catch(e){
		alert(e);
	}
}
function drawXML(x){
	_channelArr = extractRSS('channel',x.rssContent);
	_itemArr = extractRSS('item',x.rssContent);
	//draw out element
	//display number of rss numbers
	//draw out item div
	var newdiv = document.createElement("div");
	//alert("ITEM NODE COUNT : " + _itemArr.length);
	if(x.num2display<=_itemArr.length){
		if(x.num2display==0){
			x.num2display=_itemArr.length;
		}else{
			x.num2display=x.num2display-1;
		}
	}else{
		x.num2display=_itemArr.length;
	}
	for(a=0;a<=x.num2display;a++){
		//define content
		if(_itemArr[a]){
			//1-02-08
			//extract cdata from fields
			titleARR = extractRSS('title',_itemArr[a].contents);
			linkARR = extractRSS('link',_itemArr[a].contents);
			descripARR = extractRSS('description',_itemArr[a].contents);
			pubdateARR = extractRSS('pubDate',_itemArr[a].contents);
			//end define content
			var uldiv = document.createElement("ul");
			var lidiv = document.createElement("li");
			//grab information from node, such as; text, link, description
			var look_for_link = new RegExp("link");
			/*if(linkARR[0]){
				var titleanchordiv = document.createElement("a");
				var thickboxlinkSTR = new String();
				thickboxlinkSTR = stripChars(linkARR[0].contents);
				titleanchordiv.setAttribute('href',thickboxlinkSTR);
				titleanchordiv.setAttribute('target',x.targetRef);
				titleanchordiv.setAttribute('class','thickbox');
				titleanchordiv.setAttribute('className','thickbox');
			}*/
			var emnode = document.createElement("em");
			var look_for_pubdate = new RegExp("pubDate");
			if(x.attributes.match(look_for_pubdate)!=null){
				if(pubdateARR[0]){
					var formatpubdate = " (" + stripChars(pubdateARR[0].contents) + ")";
				}else{
					var formatpubdate = "";
				}
			}else{
				var formatpubdate = "";
			}
			//attach nodes to ul element
			var look_for_title = new RegExp("title");
			if(x.attributes.match(look_for_title)!=null){
				if(linkARR[0]){
					var linktmp = String(stripChars(linkARR[0].contents));
					var alink = document.createElement("a");
					//define text to go in text mode
					//1-2-09
					//check to see if any cdata stuff has snuck in
					var aSTR = stripChars(titleARR[0].contents) + " " + stripChars(formatpubdate);
					anchortext = document.createTextNode(aSTR);
					var href = new String();
					if(x.targetRef!="_self"){
						href = "javascript:showPopup('" + linktmp + "');";
	        			alink.setAttribute("href",href);
	        		}else{
	        			href = linktmp;
	        			alink.setAttribute("href",href);
	        			alink.setAttribute("target",'_self');
	        		}
					alink.appendChild(anchortext);
					var titleText = document.createElement("div");
					titleText.appendChild(alink);
					lidiv.appendChild(titleText);
				}else{
					lidiv.appendChild(titleText);
				}
			}else{
				var titleText = document.createTextNode("");
				lidiv.appendChild(titleText);
			}
			var look_for_description = new RegExp("description");
			if(x.attributes.match(look_for_description)!=null){
				if(descripARR[0]){
					var descriptionText = document.createElement("div");
					var descriptSTR = stripChars(descripARR[0].contents);
					descriptSTR = descriptSTR.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");
					descriptionText.innerHTML = descriptSTR;
					lidiv.appendChild(descriptionText);
				}
			}
			uldiv.appendChild(lidiv);
			newdiv.appendChild(uldiv);
		}
	}
	var container = document.getElementById(x.divContent);
	if(container!=null){
		if(container.childNodes.length==0){
			container.appendChild(newdiv);
		}
	}
}
function stripChars(x){
	var perfectString = new String();
	var titlecdatastrip = x;
	titlestrip = titlecdatastrip.split("<![CDATA[");
	if(titlestrip.length!=1){
		var titlestrip2 = titlestrip[1];
		titlestrip3 = titlestrip2.split("]]>");
		perfectString = titlestrip3[0];
	}else{
		perfectString = x;
	}
	return perfectString;
}
function showPopup(url){
	var disp_setting="toolbar=yes,status=yes, location=no,directories=yes,menubar=yes,"; 
	disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
	window.open(url,"popupwin",disp_setting);
}
