var xmlHttp;
function stateChanged(){
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){/*alert(xmlHttp.responseText);*/eval(xmlHttp.responseText);}
}

function GetXmlHttpObject(){ 
	var objXMLHttp=null;
	if(window.XMLHttpRequest){objXMLHttp=new XMLHttpRequest();}
	else if(window.ActiveXObject){objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	return objXMLHttp;
}

function calculaFrete(cep,peso,valorTotal){
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){alert('Seu navegador não tem suporte à tecnologia Ajax.');return false;}
	
	var url='includes/ajax/ajax.php?acao=calculaFrete&cep='+cep+'&peso='+peso+'&valorTotal='+valorTotal;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function saveInSession(){
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){alert('Seu navegador não tem suporte à tecnologia Ajax.');return false;}
	
	var url='includes/ajax/ajax.php?acao=saveInSession&forma_pagamento='+($('#formaPagamento')[0].value)+'&parcelamento='+($('#parcelamento')[0].value);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
