// JScript File
var obj1;
var type;
	function GetLookupData(type1,Errorretrievingdatafromlookup)
	{ 
	  type=type1;
	    if(window.ActiveXObject)
        {    
            try
            {
                obj1 = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e)
            {
                try
                {
	                obj1 = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e1)
                {
	                obj1 = null;
                }
            }
        }  
         else if(window.XMLHttpRequest)
         {
            try
            {
                obj1 = new XMLHttpRequest("Msxml2.XMLHTTP");
            }
            catch(e)
            {
                try
                {
	                obj1 = new XMLHttpRequest("Microsoft.XMLHTTP");
                }
                catch(e1)
                {
	                obj1 = null;
                }
            }
          }
//	 try
//        {
//             obj1 = new XMLHttpRequest();
//        }
//        catch(ex)
//        {
//	        try
//	        {
//		        obj1 = new ActiveXObject("Msxml2.XMLHTTP");
//	        }
//	        catch(e)
//	        {
//		        try
//		        {
//			        obj1 = new ActiveXObject("Microsoft.XMLHTTP");
//		        }
//		        catch(e1)
//		        {
//			        obj1 = null;
//		        }
//	        }
//	    }    
	    if(obj1!=null)
	    {
		    var url1
		    var item1
		    if (type=='1')
		    {
		    item1 = document.getElementById("ctl00_BodyContentPH_ddl_Country").value
		    url1="Lookup_Remote.aspx?type=1&ID=" + item1
		    }
		    if (type=='2')
		    {
		    item1 = document.getElementById("ctl00_BodyContentPH_ddl_State").value
		    url1="Lookup_Remote.aspx?type=2&ID=" + item1
		    }
		    if (type=='3')
		    {
		    item1 = document.getElementById("ctl00_BodyContentPH_ddl_City").value
		    url1="Lookup_Remote.aspx?type=3&ID=" + item1
		    }
		    if (item1!="-Select-")
		    {
		        if(window.ActiveXObject)
                {
		            obj1.onreadystatechange = ProcessResponseLook();
		            obj1.open("POST", url1,  true);
		            obj1.send(null);  
		        } 
		        else if(window.XMLHttpRequest)
                {
                    obj1.open("POST", url1,  false);
                    obj1.send(null); 
                    obj1.onreadystatechange = ProcessResponseLook();
                }  
		    }
	    }
	    return false;
    }
function getTagName1()
{
    if(obj1.responseXML==null)
    {
      return false;
    }
	var dsRoot=obj1.responseXML.documentElement; 
	if (dsRoot != null)
	{
 	    return dsRoot.getElementsByTagName('Title');
 	}
 	else
 	{
 	    return false
 	}
}
function getTagName2()
{
    if(obj1.responseXML==null)
    {
      return false;
    }
    var dsRoot1=obj1.responseXML.documentElement;  
    if (dsRoot1 != null)
    {
        return dsRoot1.getElementsByTagName('ID');
    }
    else
    {
        return false;
    }
}
function ProcessResponseLook()
{
	if(obj1.readyState == 4)
	{
	  	if(obj1.status == 200)
		{
		    var orders = getTagName1()
		    var orders1= getTagName2()
		    if (type==1)
		    {
		        var ddl_Orders = document.getElementById("ctl00_BodyContentPH_ddl_State");
			    for (var count = ddl_Orders.options.length-1;count >0; count--)
		        {
			        ddl_Orders.options[count]= null;
		        }
		        if (document.getElementById("ctl00_BodyContentPH_ddl_City")!=null)
		        {
		            var ddl_Orders1 = document.getElementById("ctl00_BodyContentPH_ddl_City");
			        for (var count = ddl_Orders1.options.length-1;count >0; count--)
		            {
			            ddl_Orders1.options[count]= null;
		            }
		        }    
		    }
		    else if (type==2)
		    {
		        var ddl_Orders = document.getElementById("ctl00_BodyContentPH_ddl_City");
		        for (var count = ddl_Orders.options.length-1;count >0; count--)
		        {
			        ddl_Orders.options[count]= null;
		        }
			}
		    var value1;
		    var text; 
		    var listItem;
		    for (var count =0 ; count < orders.length ; count++)
		    {
			    value1=(orders1[count].textContent || 
			    orders1[count].innerText || orders1[count].text);
			    text = (orders[count].textContent || 
			    orders[count].innerText || orders[count].text);
			    list_Item = new Option(text, value1,  false, false);
			    list_Item.title = text;
			    ddl_Orders.options[ddl_Orders.length] = list_Item;
		    }
		}
		else
		{
			//alert("Error retrieving data from lookup!" );
			alert(Errorretrievingdatafromlookup);
		}
	}
}
