	function xmlError(e) 
	{//there was an error, show the user
		alert(e);
	}
	var requestGroup;
	var responseGroup;
	var pddlGroup = document.getElementById("ddlGroup");
	//var sPath="http://localhost/Applyajax/JSForApplyAjax/";
	function populateGroup()
	{	
		if (pddlGroup==null)
			pddlGroup = document.getElementById("ddlGroup");
		var ddlReportType = document.getElementById("ddlReportType");
		return SendrequestGroup(ddlReportType.options[ddlReportType.selectedIndex].value);
	}
	function InitializerequestGroup()
	{
		try
		{
			requestGroup = new ActiveXObject("Microsoft.XMLHTTP");//Try creating an XMLHTTP Object
		}
		catch(Ex)
		{
			try
			{
				requestGroup = new ActiveXObject("Microsoft.XMLHTTP");//First failure, try again creating an XMLHTTP Object
			}
			catch(Ex)
			{
				requestGroup = null;//Else assign null to requestGroup
			}
		}
		if(!requestGroup&&typeof XMLHttpRequest != 'undefined')
		{
			requestGroup = new XMLHttpRequest();
		}
	}
	function SendrequestGroup(ID)
	{	
		//status.innerText = "Loading.....";//Set the status to "Loading....."
		InitializerequestGroup();//Call InitializerequestGroup to set requestGroup object
		var url = sAppPath + "/ReportTypE.aspx?SRGCType=3&ReportType="+ID;//Create the url to send the requestGroup to
		//alert (url);
		requestGroup.onreadystatechange = ProcessrequestGroup;//Delegate ProcessrequestGroup to onreadystatechange property so it gets called for every change in readyState value
		requestGroup.open("GET", url, true);//Open a GET requestGroup to the URL
		requestGroup.send(null);//Send the requestGroup with a null body.
	}
	function ProcessrequestGroup()
	{	
		if(requestGroup.readyState == 4)//If the readyState is in the "Ready" State
		{
			//alert(requestGroup.status);
			if(requestGroup.status == 200)//If the returned status code was 200. Everything was OK.
			{
				if(requestGroup.responseText != "")//If responseGroupGroupText is not blank
				{	
					populateListGroup(requestGroup.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(pddlGroup);//Call clearSelect function
					pddlGroup.disabled=true;
					pddlGroup.options[0].text="No Group found";
					pddlGroup.options[0].value="0";
				}
			}
		}
		return true;//return
	}
		function populateListGroup(responseGroup)
		{	
			//alert("InPL");
			pddlGroup.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(responseGroup, xmlError);
			if(xmlDoc.docNode!=null)
			{	
				obRoot = xmlDoc.docNode;
				if(obRoot.getElements().length > 0)//If there are one or more TERRITORIES nodes
				{
					clearSelect(pddlGroup); // set on 18-Sept // this will clear the ddlGroup before fill, every time
					pddlGroup.options.length=0;
					//if(pddlGroup.options[0].text=="No Group found")
					//{
					//	pddlGroup.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(pddlGroup, obRoot.getElements()[i].getAttribute("class_group_id"), textNode);//Call appendToSelect to append the text elements to the PType dropdown	
					}
					//alert(obRoot.getElements().length);
					//if(obRoot.getElements().length>0)
					//	pddlGroup.selectedIndex=1;
				}
				else
				{
					pddlGroup.disabled=true;
					pddlGroup.options[0].text="No Group 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
	}
