// JavaScript Document
function XMLHTTPObject()
{
	var xmlhttp; 

	if (window.ActiveXObject) 
	{
		// Instantiate the latest Microsoft ActiveX Objects
		if (_XML_ActiveX)
		{
			xmlhttp = new ActiveXObject(_XML_ActiveX);
		
		}
		else
		{ 
			// loops through the various versions of XMLHTTP to ensure we're using the latest
			var versions = ["MSXML2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0"];			

			for (var i = 0; i < versions.length ; i++) 
			{ 
				try
				{
					// Try and create the ActiveXObject for Internet Explorer, if it doesn't work, try again.
					xmlhttp = new ActiveXObject(versions[i]); 
						
					if (xmlhttp) 
					{ 
						var _XML_ActiveX = versions[i];
						break;
					}
				}
				catch (e)
				{
					// TRAP
				};
			}
			;
		}			
	}// Well if there is no ActiveXObject available it must be firefox, opera, or something else

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		try 
		{ 
			xmlhttp = new XMLHttpRequest(); 
		} 
		catch (e) 
		{
			xmlhttp = false; 
		}
	}
	
	return xmlhttp;
}

function processRequest(contentId,httpRequest,refreshContentOnFunction,parameterForRefresh)
{ 
	
	if (httpRequest.readyState == 4) 
	{ 
		if(httpRequest.status == 200)
		{ 
			results = httpRequest.responseText; // http.responseXML; which will lead to an XML based response, if we were to have some XML output from a server file
			var para = document.getElementById(contentId); //or whatever ID you gave your element. 			
			para.innerHTML = results; 		
			if (refreshContentOnFunction != "null")
			{		
				refreshContent(refreshContentOnFunction,parameterForRefresh);	
							
			}
			
		}
		else 
		{ 
			var results = "Sorry, there was an error finding the server-side file. Please contact support."; 
			var para = document.getElementById(contentId); 
			para.innerHTML = results; 
		}
		
	}	

	
}

function populateNews(state) {
var httpRequest=null;
//alert(state);
	var refreshContent = "null";
	var result = true;
	var fields = new Array();
	params = "?state="+state;
	//alert(params);
	httpRequest = XMLHTTPObject();	
	
	var varContentUrl = "getstateNews.php"+params;				
	var contentId ="statenews";				
	var para = document.getElementById(contentId);
	var delhinews=document.getElementById("delhistatenews");
	var moreNewsSection=document.getElementById("moreNewsSection");
	if(state!='Delhi')
	{
		para.style.display='inline';
		delhinews.style.display='none';
		moreNewsSection.style.display='none';
	}
	else
	{
		
		delhinews.style.display='inline';
		para.style.display='none';
		moreNewsSection.style.display='inline';
	}
	//para.innerHTML = "<span class=LabelHeading><img src='../resources/images/loading.gif'></span>"; 
	httpRequest.open("GET", varContentUrl, true); 
	httpRequest.onreadystatechange = function () {processRequest(contentId,httpRequest,refreshContent,""); } ;
	//httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	httpRequest.send(null);

}
