function xmlError(e) 
	{//there was an error, show the user
		alert(e);
	}
	var requestClass;
	var responseClass;
	var pddlClass = document.getElementById("ddlClass");
	//var sPath="http://localhost/Applyajax/JSForApplyAjax/";
	function populateClass(RaceID,GroupID,SeasonID,ID)
	{	//alert(ID);
		if (pddlClass==null)
			pddlClass = document.getElementById("ddlClass");
		var ddlReportType = document.getElementById("ddlReportType");
		if (ID!="0")
			{//return SendRequestClass(ddlReportType.options[ddlReportType.selectedIndex].value,RaceID,GroupID,SeasonID);
			return SendRequestClass(ID,RaceID,GroupID,SeasonID);
			}
		else
			return SendRequestClass("0",RaceID,GroupID,SeasonID);	
	}
	function InitializeRequestClass()
	{
		try
		{
			requestClass = new ActiveXObject("Microsoft.XMLHTTP");//Try creating an XMLHTTP Object
		}
		catch(Ex)
		{
			try
			{
				requestClass = new ActiveXObject("Microsoft.XMLHTTP");//First failure, try again creating an XMLHTTP Object
			}
			catch(Ex)
			{
				requestClass = null;//Else assign null to request
			}
		}
		if(!requestClass && typeof XMLHttpRequest != 'undefined')
		{
			requestClass = new XMLHttpRequest();
		}
	}
	function SendRequestClass(ID,RaceID,GroupID,SeasonID)
	{	
		//status.innerText = "Loading.....";//Set the status to "Loading....."
		InitializeRequestClass();//Call InitializeRequest to set request object
		var url;
		if(ID=="0")		
			//Create the url to send the request to
			url = sAppPath + "/ReportType.aspx?ReportTypeID=LoadClass&RaceID="+RaceID+"&GroupID="+GroupID+"&SeasonID="+SeasonID;  
		else
			url = sAppPath + "/ReportType.aspx?SRGCType=4&ReportType=" + ID + "&RaceID=" + RaceID + "&GroupID=" + GroupID + "&SeasonID=" + SeasonID;	
		requestClass.onreadystatechange = ProcessRequestClass;//Delegate ProcessRequest to onreadystatechange property so it gets called for every change in readyState value
		requestClass.open("GET", url, true);//Open a GET request to the URL
		requestClass.send(null);//Send the request with a null body.
	}
	function ProcessRequestClass()
	{	
		if(requestClass.readyState == 4)//If the readyState is in the "Ready" State
		{
			if(requestClass.status == 200)//If the returned status code was 200. Everything was OK.
			{
				if(requestClass.responseText != "")//If responseText is not blank
				{	
					populateListClass(requestClass.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(pddlClass);//Call clearSelect function
					pddlClass.disabled=true;
					pddlClass.options[0].text="No Class found";
				}
			}
		}
		return true;//return
	}
		function populateListClass(response)
		{	
			pddlClass.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(pddlClass); //set on 19-sept // this will clear the ddlSeason before fill, every time
					pddlClass.options.length=0;
					//if(pddlClass.options[0].text=="No Class found")
					//{
					//	pddlClass.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(pddlClass, obRoot.getElements()[i].getAttribute("class_id"), textNode);//Call appendToSelect to append the text elements to the PType dropdown	
					}
					//if(obRoot.getElements().length>0)
					//	pddlClass.selectedIndex=1;
				}
				else
				{
					pddlClass.disabled=true;
					pddlClass.options[0].text="No Class 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
	}
