var XmlHttpObj;
function CreateXmlHttpObj()
{
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpObj = new XMLHttpRequest();
	}
}
function ListOnChange(var1,var2) 
{
    var selectedContinent = document.getElementById(var1).options[document.getElementById(var1).selectedIndex].value;
    var requestUrl;
		if(var2 == "marka")
		{
		requestUrl = "http://www.arzumetal.com.tr/xml_marka.asp?p="+selectedContinent+"";
		}else{
		var selectedContinent2 = document.getElementById('kat').options[document.getElementById('kat').selectedIndex].value;
		requestUrl = "http://www.arzumetal.com.tr/xml_urun.asp?k="+selectedContinent2+"&p=" + selectedContinent+"";
		}
	CreateXmlHttpObj();
	if(XmlHttpObj)
	{
		if(var2 == "marka")
		{
		XmlHttpObj.onreadystatechange = StateChangeHandler;
		}else{
		XmlHttpObj.onreadystatechange = StateChangeHandler2;
		}
		XmlHttpObj.open("GET", requestUrl,  true);
		XmlHttpObj.send(null);		
	}
}
function StateChangeHandler()
{
	if(XmlHttpObj.readyState == 4)
	{
		if(XmlHttpObj.status == 200)
		{			
			PopulateList(XmlHttpObj.responseXML.documentElement,"marka");
		}
		else
		{
			alert("Hata oluştu: "  + XmlHttpObj.status);
		}
	}
}
function StateChangeHandler2()
{
	if(XmlHttpObj.readyState == 4)
	{
		if(XmlHttpObj.status == 200)
		{			
			PopulateList(XmlHttpObj.responseXML.documentElement,"urun");
		}
		else
		{
			alert("Hata oluştu: "  + XmlHttpObj.status);
		}
	}
}
function PopulateList(countryNode,var1)
{
if (var1 != "urun"){
	s = document.getElementById('urun');
	while (s.hasChildNodes())
	s.removeChild(s.childNodes[0]);
	
	var opt = document.createElement("option");
	document.getElementById("urun").options.add(opt);
	opt.text = "--Marka Seç--";
	opt.value = "0";
}

    var countryList = document.getElementById(var1);
	for (var count = countryList.options.length-1; count >-1; count--)
	{
		countryList.options[count] = null;
	}
	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	for (var count = 0; count < countryNodes.length; count++)
	{
   		textValue = GetInnerText(countryNodes[count]);
		idValue = countryNodes[count].getAttribute("id");
		optionItem = new Option( textValue, idValue,  false, false);
		countryList.options[countryList.length] = optionItem;
	}
}
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}