// JavaScript Document

var xmlHttp;

function getSocken(id)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request");
 		return;
 	}
	
	var url="includes/sockenlista.php";
	url=url+"?id="+id;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedLandskap;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getOrt(id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request");
 		return;
 	}
	
	var url="includes/ortlista.php";
	url=url+"?id="+id;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedSocken;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function stateChangedLandskap() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{	 
 		//document.getElementById("socken").innerHTML=xmlHttp.responseText;
		//document.getElementById("ort").innerHTML="<option value=\"0\" selected=\"selected\"></option>";
		document.getElementById("socken_div").innerHTML = "<select name=\"socken\" id=\"socken\" onchange=\"getOrt(this.value)\">" + xmlHttp.responseText + "</select>";
		document.getElementById("ort_div").innerHTML = "<select name=\"ort\" id=\"ort\"><option value=\"0\" selected=\"selected\"></option></select>";
 	} 
}

function stateChangedSocken() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{	 
 		//document.getElementById("ort").innerHTML=xmlHttp.responseText;
		document.getElementById("ort_div").innerHTML = "<select class=\"dd\" name=\"ort\" id=\"ort\">" + xmlHttp.responseText + "</select>";
 	} 
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
 	{
 		// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 	}
	catch (e)
 	{
 		//Internet Explorer
 		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
 		catch (e)
  		{
  			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
 	}
	return xmlHttp;
}
