		
		//We have to set this in the ASPx code because we can not easily resolve the application root
		//var sReaderUrl = location.protocol + '//' + location.hostname + "/FeedReader.aspx";
		//var WordCount = 50;
		
		/**************************************************************************************/
		/*                                          No need to edit anything below this comment                                        */
		/**************************************************************************************/
		var	DisplayTagName = new Array();
		var UrlArray = new Array();
		var LogoArray = new Array();
		var	WordCountArray = new Array();
		var	LogoArray = new Array();
		var iPos = 0;
		var sOutputControlName = "";
		var sOutputPrefix = "";
		var sOutputPostfix = "";
		var sOutputReaderUrl = "";
		var iOutputDisplayFormat = 0;
		var xmlHttp;
		var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
		var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
		var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
		//netscape, safari, mozilla behave the same??? 
		var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0; 
		
		/**************************************************************************************/
		function getFeed( sReaderUrl, sDisplayTagName, sFeedUrl, iWordCount, sLogo, sPrefix, sPostfix, iDisplayFormat ) {
			var sQueryString = "?url=" + sFeedUrl + "&iCount=" + iWordCount + "&logo=" + sLogo + "&iDisplayFormat=" + iDisplayFormat;

			//alert('getFeed called, sDisplayTagName: ' + sDisplayTagName + ', sFeedUrl: ' + sFeedUrl);
			
			// Must save these for use by stateChangeHandler
			sOutputControlName = sDisplayTagName;
			sOutputPrefix = sPrefix;
			sOutputPostfix = sPostfix;
			sOutputReaderUrl = sReaderUrl;
			iOutputDisplayFormat = iDisplayFormat;
			
			xmlHttp = GetXmlHttpObject(stateChangeHandler); 
		     
			//Send the xmlHttp get to the specified url 
			xmlHttp_Get( xmlHttp, sReaderUrl + sQueryString);
		} 

		/**************************************************************************************/
		function getFeeds ( sReaderUrl, arrDisplayTagName, arrFeedUrlArray, arrWordCountArray, arrLogoArray, sPrefix, sPostfix, iDisplayFormat ) {
			
			DisplayTagName = arrDisplayTagName;
			UrlArray = arrFeedUrlArray;
			WordCountArray = arrWordCountArray;
			LogoArray = arrLogoArray;
					
			iPos = arrFeedUrlArray.length - 1;
			//Get the first feed - nb stateChangeHandler will get the rest
			getFeed(sReaderUrl, DisplayTagName[iPos], UrlArray[iPos], WordCountArray[iPos], LogoArray[iPos], sPrefix, sPostfix, iDisplayFormat);
		} 

		/**************************************************************************************/
		//stateChangeHandler will fire when the state has changed, i.e. data is received back 
		// This is non-blocking (asynchronous) 
		function stateChangeHandler() 
		{ 
			//alert("stateChangeHandler called");
			
			//readyState of 4 or 'complete' represents that data has been returned 
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){ 
				//alert("stateChangeHandler called and COMPLETE");
	
				//Gather the results from the callback 
				var str = xmlHttp.responseText; 

				var parentElement = document.getElementById( sOutputControlName );
				//alert(sOutputControlName);
				if (parentElement == null ) {
					//alert('No parentElement');
					/** Attach onto another body element if there is no control name defined. **/
					//parentElement = document.getElementById("container");
				}

				try {
					//alert('Try');
					//Populate the innerHTML of the dynamically created div with response results 
					var wrappingDiv = document.createElement('div');
					wrappingDiv.innerHTML = sOutputPrefix + str + sOutputPostfix;
					parentElement.appendChild( wrappingDiv );
				}
				catch (e){
					/* Attempt to deliver some results still by attaching onto the body tag */
					/* This does work, but not required
					alert(e.message);
					var wrappingDiv = document.createElement('div');
					wrappingDiv.innerHTML = sOutputPrefix + str + sOutputPostfix;
					parentElement = document.getElementsByTagName("body")[0];
					parentElement.appendChild( wrappingDiv );
					*/
				}
			
				//Get the next feed if multi-feeds
				if (iPos > 0) {
					iPos -=1;
					//alert('Calling getFeed num: ' + iPos + ' - ' + DisplayTagName[iPos]);
					getFeed( sOutputReaderUrl, DisplayTagName[iPos], UrlArray[iPos], WordCountArray[iPos], LogoArray[iPos], sOutputPrefix, sOutputPostfix, iOutputDisplayFormat);
				}

			} 
		}

		/**************************************************************************************/
		// XMLHttp send GET request 
		function xmlHttp_Get(xmlhttp, url) { 
			xmlhttp.open('GET', url, true); 
			xmlhttp.send(null); 
		}

		/**************************************************************************************/
		function GetXmlHttpObject(handler) { 
			var objXmlHttp = null;    //Holds the local xmlHTTP object instance 

			//Depending on the browser, try to create the xmlHttp object 
			if (is_ie){ 
				//The object to create depends on version of IE 
				//If it isn't ie5, then default to the Msxml2.XMLHTTP object 
				var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
	             
				//Attempt to create the object 
				try{ 
					objXmlHttp = new ActiveXObject(strObjName); 
					objXmlHttp.onreadystatechange = handler; 
				} 
				catch(e){ 
				//Object creation errored 
				//Error not required
					//alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); 
					return; 
				} 
			} 
			else if (is_opera){ 
				//Opera has some issues with xmlHttp object functionality 
				//Error not required
				//alert('Opera detected. The page may not behave as expected.'); 
				return; 
			} 
			else{ 
				// Mozilla | Netscape | Safari 
				/*
				try {
					netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
				} catch (e) {
					alert("Permission UniversalBrowserRead denied.");
				}
				*/
				objXmlHttp = new XMLHttpRequest(); 
				objXmlHttp.onload = handler; 
				objXmlHttp.onerror = handler; 
			} 
	         
			//Return the instantiated object 
			return objXmlHttp; 
		} 

