//xmlhttp.js
//Function to create an XMLHttp Object.
function getxmlhttp (){
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 to process an XMLHttpRequest.
function processajax (serverPage, obj, getOrPost, str){
	//Get an XMLHttpRequest object for use.
	xmlhttp = getxmlhttp ();
	xmlhttp.open("GET", "agregar_sugerencia.php?"+str,true);
	document.getElementById("mensaje").style.display="block";
	document.getElementById("mensaje").innerHTML="Enviado Datos, espere";
	xmlhttp.send(null);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById("mensaje").style.display="block";
			document.getElementById("mensaje").innerHTML="Su mensaje ha sido enviado con &eacute;xito";
			document.getElementById("contenido").style.display="none";
			document.getElementById("mensaje").innerHTML=xmlhttp.responseText;
			// obj.innetHTML = xmlhttp.responseText;
		}else{
			document.getElementById("mensaje").innerHTML="Enviando los Datos......";	
		}
	}
}

function tablaPrecioEncomienda(){
	varOrigen = window.document.frmBuscaPrecioEncomienda.txtOrigen.value;
	varDestino = window.document.frmBuscaPrecioEncomienda.txtDestino.value;
	varPeso = window.document.frmBuscaPrecioEncomienda.txtPeso.value;
	varValor = window.document.frmBuscaPrecioEncomienda.txtValor.value;
	varModo = window.document.frmBuscaPrecioEncomienda.cboModo.value;
	
	if((varPeso != "")&&(varValor != "")){
		xmlHttp=getxmlhttp();
		
		var url="tablaPrecioEncomienda.php";
		url = url + "?origen="+varOrigen;
		url = url + "&destino="+varDestino;
		url = url + "&peso="+varPeso;
		url = url + "&valor="+varValor;
		url = url + "&modo="+varModo;
		xmlHttp.onreadystatechange=stateChangedPrecio;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	else{
		alert("Los campos 'Peso aprox.' y 'Valor declarado' no pueden estar vacios");
	}
}

function stateChangedPrecio() { 
	if (xmlHttp.readyState==4){
		document.getElementById("resultadoPrecios").innerHTML=xmlHttp.responseText;
	}
}