function addOption(selectbox,text,value )
{	
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;	
	selectbox.options.add(optn);
}

function handleHttpResponsePortales() { 
    if (http.readyState == 4) { 
       if (http.status == 200) { 
          if (http.responseText.indexOf('invalid') == -1) {
             // Armamos un array, usando la coma para separar elementos			 
             results = http.responseText.split(","); 
			 
			 var mensaje = document.getElementById("form_circulacion");
			 //mensaje.numero.options.length = 0;
			 //addOption(mensaje.numero,"Portal","0")
			 //mensaje.calle.value = "";			
			 for(i=0; i < results.length - 1; i++) 
			 {				 
				//Build our element string.  This is cleaner using the DOM, but
				//IE doesn't support dynamically added attributes.	
				addOption(mensaje.numero,results[i],i+1)
					//mensaje.numero.options = results[i];
			 }	            
          }
       }
    }
}

function portales() {       
	var mensaje = document.getElementById("form_circulacion");
	mensaje.numero.options.length = 0;
	addOption(mensaje.numero,"Portal","0")

	var valor = document.getElementById("form_circulacion").calle.tag
	if (valor != "")
	{		  
	   var url = "/circuweb/Asp/portales.asp?codcalle="+ valor;
		   
	   http = getHTTPObject();	  
	   http.open("GET", url, false);	   
	   http.onreadystatechange = handleHttpResponsePortales;
	   enProceso = true;
	   http.send(null);
	}
}

function getHTTPObject() {
    var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}
