var modell;
function selectBrand(){
	document.carsearch.modell.disabled=false;
	if(document.carsearch.marke.value == "alle Marken"){
		document.carsearch.modell.disabled=false;
		//var inner = '<option value="alle Modelle">alle Modelle</option>';
		//select_innerHTML(document.carsearch.modell,inner);
		getData(document.carsearch.marke.value);
	} else {
		var marke = document.carsearch.marke.value;
		modell = document.carsearch.modell.value;
		getData(marke);	
	}
}

var xmlhttp;

//http request starten
function getData(marke) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="typo3conf/ext/pv_modix/pi1/getSelectData.php";
	//alert("?kategorie="+kategorie+"&preis="+preis+"&wohnflaeche="+wohnflaeche);
	url=url+"?marke="+marke;
    url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function stateChanged() {
	if (xmlhttp.readyState==4){
		//document.carsearch.modell.innerHTML =xmlhttp.responseText;
		select_innerHTML(document.carsearch.modell,xmlhttp.responseText);
	}
}
function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		return new XMLHttpRequest();
  	}
	if (window.ActiveXObject) {
  		// code for IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
  	}
	return null;
}


function select_innerHTML(objeto, innerHTML){
	objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){
		innerHTML = "<option>" + innerHTML + "</option>"	
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  		var spantemp = selTemp.childNodes[i];
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
			if(document.all){ //IE
				objeto.add(opt)
			}else{
				objeto.appendChild(opt)
			}       
		   //getting attributes
		   for(var j=0; j<spantemp.attributes.length ; j++){
			var attrName = spantemp.attributes[j].nodeName;
			var attrVal = spantemp.attributes[j].nodeValue;
			if(attrVal){
			 try{
			  opt.setAttribute(attrName,attrVal);
			  opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
			 }catch(e){}
			}
		   }
		   //getting styles
		   if(spantemp.style){
			for(var y in spantemp.style){
			 try{opt.style[y] = spantemp.style[y];}catch(e){}
			}
		   }
		   //value and text
		   opt.value = spantemp.getAttribute("value")
		   opt.text = spantemp.innerHTML
		   //IE
		   opt.selected = spantemp.getAttribute('selected');
		   opt.className = spantemp.className;
	  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}