var rnd = Math.random();
//Global XMLHTTP Request object
var XmlHttp;

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

function getBannerAds(CId, randomNo)
{
	var d = new Date();
	var requestUrl = "ajaxServer.aspx?CId=" + CId + '&session=' + randomNo;
	
	CreateXmlHttp();
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = showPageContent;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

function getFeatureForServiceType(sTypeId, randomNo)
{
	var d = new Date();
	var requestUrl = "ajaxServer.aspx?serviceTypeId=" + sTypeId + '&session=' + randomNo;
	
	CreateXmlHttp();
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = showPageContent;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

function getFilledFeatureForServiceType(sTypeId, sSessionId, randomNo)
{
	var d = new Date();
	var requestUrl = "ajaxServer.aspx?serviceTypeId=" + sTypeId + '&SessionId=' + sSessionId + '&session=' + randomNo;
	
	CreateXmlHttp();
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = showPageContent;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}

//Called when response comes back from server
function showPageContent()
{
	// 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)
		{
			document.getElementById("spnContent").innerHTML = "";
			document.getElementById("spnContent").innerHTML = XmlHttp.responseText; //  XmlHttp.response
			document.getElementById('spnContent').style.display='block';
		}
		else
			alert("There was a problem retrieving data from the server." );
	}
}

function hide()
{
	document.getElementById("spnContent").innerHTML = "";
}



