function openwin(theURL,ampl,alt) {
  window.open(theURL,'carrega','width='+ampl+',height='+alt+',status=yes');
}
function nouAjax(){ 
	var xmlhttp=false; 
	try	{ 
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}catch(e){ 
		try	{ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		}catch(E){ 
			xmlhttp=false; 
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}

function carregapreus(){
	var valor=document.getElementById("idregi").options[document.getElementById("idregi").selectedIndex].value;
	
	if(valor==0){
		combo=document.getElementById("idpreu");
		//combo.length=1;
		combo.length=0;
		//var nova=document.createElement("option"); 
		//nova.value=0; 
		//nova.innerHTML="<%=tgen(17,hl)%>";
		//combo.appendChild(nova);	
		combo.disabled=true;
	}else{
		ajax=nouAjax();
		ajax.open("GET", "include/actcerca.asp?tippre="+valor, true);
		ajax.onreadystatechange=function(){ 
			if (ajax.readyState==1){
				//mentre carrega...
				combo=document.getElementById("idpreu");
				combo.length=0;
				//var nova=document.createElement("option"); 
				//nova.value=0; 
				//nova.innerHTML="<%=tgen(18,hl)%>";
				//combo.appendChild(nova); 
				combo.disabled=true;	
			}
			if (ajax.readyState==4){ 
				document.getElementById("segon").innerHTML=ajax.responseText;
			} 
		}
		ajax.send(null);
	}
}
