// JScript File
var xmlHttp
function GetSubcategory(ctl)
{ 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var url="/bpclfeedback/Ajax/AjaxCategory.aspx?CategoryID="+ctl.value   
    //url=url+"&sid="+Math.random()   
    xmlHttp.onreadystatechange=setSubCategory    
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

//function setSubCategory()
//{ 
//   
//    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete')
//    {         
//      if(xmlHttp.status == 200)
//	  {
//	    var response = xmlHttp.responseText;
//	    var ctlName = document.getElementById('ddlSubcategory_Id');
//	        for(var i=ctlName.options.length-1;i>=0;i--)
//	        {
//			    ctlName.options[i]=null;				
//		    }		
//            document.getElementById('ddlSubcategory_Id').options[0]= new Option('--Select--','0',false,false);	   
//	    if(response.length>0)
//	    {		
//            var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
//	        xmlDoc.async = false;
//	        xmlDoc.loadXML(response);	
//	        var opt;
//	        var Subcategories = xmlDoc.getElementsByTagName("Subcategories"); 
//	        var sCat = Subcategories[0].getElementsByTagName("SubCategory");		        
//	        if(Subcategories.length > 0)
//	        {	        
//	            for(var j=0;j<sCat.length;j++)
//	            {
//	                document.getElementById('ddlSubcategory_Id').options[j+1]= new Option(sCat[j].lastChild.text,sCat[j].firstChild.text,false,false); //content,value
//                }    
//	        }
//	    }
//            
//        
//        
//      }
//    }     
//} 


function setSubCategory()
{     
    var ctlName = document.getElementById('ddlSubcategory_Id') 
     		
 for(var i=ctlName.options.length-1;i>0;i--)
			{
			//alert("dfd")
				ctlName.options[i]=null;				
			}	
    if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete')
    { 
        for(var i = ctlName.length-1;i>0;i--)
        {
            ctlName.options[i] = null;
        }
        var response = xmlHttp.responseText; 
                
                //alert(response)
        if (response!="")
            {  
                var mainList = response.split('#');        
                if(mainList.length > 0)
                {            
                    var cnt;
                    cnt = 0;
                    while(cnt<mainList.length)
                    {
                        var temp = mainList[cnt].split('%');
                        ctlName.options[cnt+1] = new Option(temp[1],temp[0],false,false);
                        cnt++;
                    }
                }    
            }  
                     
    }     
}



function GetXmlHttpObject()
{ 
    try
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        //Try creating an XMLHTTP Object
       // alert(xmlHttp);
    }
    catch(Ex)
    {
        try
        {
	        //First failure, try again creating an XMLHTTP Object
	        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(Ex)
        {
	        xmlHttp = null;
        }
    }
    if(!xmlHttp&&typeof XMLHttpRequest != 'undefined')
    {
        xmlHttp = new XMLHttpRequest();
    }
    return xmlHttp;
//    var objXMLHttp=null
//    if (window.XMLHttpRequest)
//    {
//        objXMLHttp=new XMLHttpRequest()
//    }
//    else if (window.ActiveXObject)
//    {
//        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") 
//    }
//    return objXMLHttp
}



