var xmlhttp;

try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

	
var ajax = {
	//ajax busca ouvintes qualidade
	carrega_tipo : function(valor) { 
		//document.getElementById('price').innerHTML = "Recalculando...";
		
		param = "&action=tipo&valor="+valor.value;
		xmlhttp.open("POST", "carrega_ouvinte.php", true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		
		xmlhttp.onreadystatechange = function(){
				//document.getElementById('price').innerHTML = "Recalculando...";
				if(xmlhttp.readyState == 4) { 
					if(xmlhttp.status == 200){ 
						document.getElementById('tpouviente').innerHTML = xmlhttp.responseText;
					}else{ //Não encotra os dados
						document.getElementById('tpouviente').innerHTML = "Erro: returned status code " + xmlhttp.status + " " + xmlhttp.statusText;
					}
				}
			}
			xmlhttp.send(param);
	}, 
	carrega_preco : function() { 
		//document.getElementById('price').innerHTML = "Recalculando...";
		
		param = "&ouvintes="+document.frmcontato.ouvintes.value+"&tipo="+document.frmcontato.tipo.value+"&qualidade="+document.frmcontato.qualidade.value;
		xmlhttp.open("POST", "carrega_ouvinte.php", true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		
		xmlhttp.onreadystatechange = function(){
				//document.getElementById('price').innerHTML = "Recalculando...";
				if(xmlhttp.readyState == 4) { 
					if(xmlhttp.status == 200){ 
						document.getElementById('tp_preco').innerHTML = xmlhttp.responseText;
					}else{ //Não encotra os dados
						document.getElementById('tp_preco').innerHTML = "Erro: returned status code " + xmlhttp.status + " " + xmlhttp.statusText;
					}
				}
			}
			xmlhttp.send(param);
	} 
	
}