﻿

//*************************************************
//call rss 
//*************************************************
/*
This function is replaced for a dynamic version
in the code behind.
var XmlHttp;
function fncGetRssStream(id,target){
	XmlHttp = CreateXmlHttp();
	fncGetRssStreamII(id,target,XmlHttp)
}
*/
function fncGetRssStreamII(id,target,oXmlHttp){

	// URL to get states for a given country
	
	var requestUrl = AjaxServerPageName + "?id=" + encodeURIComponent(id)+'&target='+encodeURIComponent(target);
	//XmlHttp = CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(oXmlHttp)
	{
		//Setting the event handler for the response
		//XmlHttp.onreadystatechange = HandleResponse;
		DynamicHandleResponse(oXmlHttp);
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		oXmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		oXmlHttp.send(null);		
	}
}




//*************************************************
//Writing content to the page
//*************************************************
function WriteContent(sText)
{
	document.getElementById(sText.substring(0,5)).innerHTML=sText.substring(5,32000);
}


//*************************************************
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
//*************************************************
function CreateXmlHttp()
{
var oXMLHTTP
	//Creating object of XMLHTTP in IE
	try
	{
		oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
		
	}
	catch(e)
	{
		try
		{
			oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			oXMLHTTP = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!oXMLHTTP && typeof oXMLHTTP != "undefined") 
	{
		oXMLHTTP = new XMLHttpRequest();
	}
	return oXMLHTTP;
}

//*************************************************
//Called when response comes back from server
//*************************************************
//this is now created dynamically in code as these 2 lines
//function HandleResponse" & sID & "(){if(XmlHttp.readyState == 4)	{if(XmlHttp.status == 200){var sText = XmlHttp.responseText;document.getElementById(sText.substring(0,5)).innerHTML=sText.substring(5,32000);}else{alert("There was a problem retrieving data from the server." );}}}
//function DynamicHandleResponse(oXmlHttp){XmlHttp.onreadystatechange = HandleResponse" & sID & ";}

/*
here is the old funcion 
just uncomment for restopen
*/
/*
function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			WriteContent(XmlHttp.responseText);
			//WriteContent(XmlHttp.responseXML);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
*/