var HttpReq = null;
var dest_combo = null;

function ajaxComboBox(url, comboBox){
	dest_combo = comboBox;
	
	var indice = document.getElementById('entrega').selectedIndex;
	var sigla = document.getElementById('entrega').options[indice].getAttribute('value');
	
	var estado = document.getElementById('estado').selectedIndex;
	var estadoId = document.getElementById('estado').options[estado].getAttribute('value');
	
	var peso = document.getElementById('peso').selectedIndex;
	var pesoId = document.getElementById('peso').getAttribute('value');
	
	url = url + '?entrega=' + sigla + '&estado=' + estadoId + '&peso=' + pesoId;
	
	if ( pesoId > 30000 ){
		alert ("O Peso Execedeu o limite máximo de 30 kilos")		
	}
	
	if (document.getElementById) { //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) {
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpRequestChange;
			HttpReq.open("GET", url, true);
			HttpReq.send(null);
		} else if (window.ActiveXObject) {
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) {
				HttpReq.onreadystatechange = XMLHttpRequestChange;
				HttpReq.open("GET", url, true);
				HttpReq.send();
			}
		}
	}
}

function validaFrete(){
	if(document.getElementById("valor").value.length == 1 || document.frmCarrinho.opc_atualizar.value != 1){
		alert('                                     ***ATENÇÃO***\n\nVocê deve selecionar o tipo de entrega, o estado e clicar em atualizar!');
		return false;
	}
	return true;
}
function XMLHttpRequestChange() {
	
	if (HttpReq.readyState == 4 && HttpReq.status == 200){
		document.getElementById('valor').value = HttpReq.responseText;
	}
}