function xmlError(e) 
	{//there was an error, show the user
		alert(e);
	}
	var requestRace;
	var responseRace;
	var pddlRace = document.getElementById("ddlRace");
	//var sPath="http://localhost/Applyajax/JSForApplyAjax/";
	function populateRace(sid,id)
	{	
		if (pddlRace==null)
			pddlRace = document.getElementById("ddlRace");
		var ddlReportType = document.getElementById("ddlReportType");
		if (id=="2")
			return SendRequestRace(ddlReportType.options[ddlReportType.selectedIndex].value,sid);
		else
			return SendRequestRace("0",sid);	
	}
	function InitializeRequestRace()
	{
		try
		{
			requestRace = new ActiveXObject("Microsoft.XMLHTTP");//Try creating an XMLHTTP Object
		}
		catch(Ex)
		{
			try
			{
				requestRace = new ActiveXObject("Microsoft.XMLHTTP");//First failure, try again creating an XMLHTTP Object
			}
			catch(Ex)
			{
				requestRace = null;//Else assign null to request
			}
		}
		if(!requestRace && typeof XMLHttpRequest != 'undefined')
		{
			requestRace = new XMLHttpRequest();
		}
	}
	function SendRequestRace(ID,sid)
	{	
		//status.innerText = "Loading.....";//Set the status to "Loading....."
		InitializeRequestRace();//Call InitializeRequest to set request object
		var url;
		if(ID=="0")		
			url = sAppPath + "/ReportTyPE.aspx?ReportTypeID=LoadRace&SeasonID="+sid;//Create the url to send the request to
		else
			url = sAppPath + "/ReportTyPe.aspx?SRGCType=2&ReportType="+ID+"&SeasonID="+sid;//Create the url to send the request to	
		requestRace.onreadystatechange = ProcessRequestRace;//Delegate ProcessRequest to onreadystatechange property so it gets called for every change in readyState value
		requestRace.open("GET", url, true);//Open a GET request to the URL
		requestRace.send(null);//Send the request with a null body.
	}
	function ProcessRequestRace()
	{	
		if(requestRace.readyState == 4)//If the readyState is in the "Ready" State
		{
			if(requestRace.status == 200)//If the returned status code was 200. Everything was OK.
			{
				if(requestRace.responseText != "")//If responseText is not blank
				{	
					populateListRace(requestRace.responseText);//Call the populateList fucntion
					//status.innerText = "Cities Loaded";//Set the status to "Territories Loaded"
				}
				else
				{
					//status.innerText = "None Found";//Set the status to "None Found"
					clearSelect(pddlRace);//Call clearSelect function
					pddlRace.disabled=true;
					pddlRace.options[0].text="No Race found";
				}
			}
		}
		return true;//return
	}
		function populateListRace(response)
		{	pddlRace.disabled=false;
			var xmlDoc;
			if (navigator.appName.indexOf("Microsoft")>=0)  //Microsoft Case
				xmlDoc=new ActiveXObject("Microsoft.XMLDOM");//Create the XMLDOM object
			else											// Mozilla Case
				xmlDoc = new XMLHttpRequest();
			xmlDoc=new XMLDoc(response, xmlError);
			if(xmlDoc.docNode!=null)
			{	
				obRoot = xmlDoc.docNode;
				if(obRoot.getElements().length > 0)//If there are one or more TERRITORIES nodes
				{
					clearSelect(pddlRace); // set on 18-sept this will clear the ddlSeason before fill, every time
					pddlRace.options.length=0;
					//if(pddlRace.options[0].text=="No Race found")
					//{
					//	pddlRace.options[0].text="Select";
					//}
					//alert(obRoot.getElements().length);
					for (var i = 0; i < obRoot.getElements().length; i++)//Loop through the XML TERRITORIES nodes
					{
						var textNode = document.createTextNode(obRoot.getElements()[i].getText());//Create a TextNode
						appendToSelect(pddlRace, obRoot.getElements()[i].getAttribute("race_id"), textNode);//Call appendToSelect to append the text elements to the PType dropdown	
					}
					//if(obRoot.getElements().length>0)
					//	pddlRace.selectedIndex=1;
				}
				else
				{
					pddlRace.disabled=true;
					pddlRace.options[0].text="No Race found";
				}	
			}
		}
	function appendToSelect(select, value, content)
	{
		var opt;
		opt = document.createElement("option");//Create an Element of type option
		opt.value = value;//Set the option's value
		opt.appendChild(content);//Attach the text content to the option
		select.appendChild(opt);//Append the option to the referenced [PType] select box
	}
	function clearSelect(select)
	{
			select.options.length = 1;//Set the select box's length to 1 so only "--Select--" is availale in the selection on calling this function.
									//You may want to write your own clearSelect logic
	}
