// --------------------------------------------------------------------ENGINE AJAX---------------------------------------------------------------------- //
function ajax(id,url,after,param){
	var tmp;
	var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	var method=(id==0?"GET":"POST"); 
	
	//fix pt no-cache
	param+='&date='+new Date().getTime();

	if (x){
		x.onreadystatechange = function(){
				if (x.readyState == 4 && x.status == 200)	eval(after+'(x.responseText);');
				}
		if (id==0){
				x.open(method, url+'?'+param, true);
				x.send(null);
				}
			else{
				x.open(method, url, true);
				x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				x.send(param);
				}
		}
}

function noResponse(tmp){
return false;
}
// -------------------------------------------------------------------SFARSIT ENGINE AJAX----------------------------------------------------------------//

function populate(pas,e){
//id=client/awb
ajax(1,'clienti_form_awb_populate.php','populateResp','pas='+pas+'&id='+e.value);
if (pas=='dest') document.getElementById('destNew').value=0;
}

function populateResp(tmp){
var tmp2;
var fields=tmp.split("\n");
for (i in fields){
    tmp2=fields[i].split("=");
    document.formAwb[tmp2[0]].value=tmp2[1];
    } 
}

