var http = createObject();


function popola_pizzerie(id){
	http.open('GET', 'ajax/ajax_popola_pizzerie.php?prov=' + id, true);
	http.onreadystatechange = function() { mostra("AHAH_pr_ristorante"); };
	http.send(null);
}

function popola_opzioni(id){
	http.open('GET', 'ajax/ajax_popola_opzioni.php?locale=' + id, true);
	http.onreadystatechange = function() { mostra("opzioni"); };
	http.send(null);
}

function popola_dettagli(id, mode){
	http.open('GET', 'ajax/ajax_popola_dettagli.php?locale=' + id + '&mode=' + mode, true);
	http.onreadystatechange = function() { mostra("details"); };
	http.send(null);
}

function form_richiesta(ristorante, StartDate, ora_arrivo, posti){
	http.open('GET', 'ajax/ajax_form_richiesta.php?ristorante=' + ristorante + '&StartDate=' + StartDate + '&ora_arrivo=' + ora_arrivo + '&posti=' + posti, true);
	http.onreadystatechange = function() { mostra("details"); };
	http.send(null);
}

function ajax_conferma(nome, email, tel, ristorante, StartDate, ora_arrivo, posti){
	http.open('GET', 'ajax/ajax_conferma.php?nome=' + nome + '&email=' + email + '&tel=' + tel + '&ristorante=' + ristorante + '&StartDate=' + StartDate + '&ora_arrivo=' + ora_arrivo + '&posti=' + posti, true);
	http.onreadystatechange = function() { mostra("details"); };
	http.send(null);
}

function vota(voto, locale, mode){
	http.open('GET', 'ajax/ajax_vota.php?locale=' + locale + '&mode=' + mode + '&voto=' + voto, true);
	http.onreadystatechange = function() { mostra("vota"); };
	http.send(null);
}

function vota_comm(commento, locale){
        var params = "commento=" + commento + "&locale=" + locale;
	http.open('POST', 'ajax/ajax_vota_comm.php', true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() { mostra("vota"); };
	http.send(params);
}

function mostra(div){
	if(http.readyState < 4){
		document.getElementById(div).innerHTML = "<img src='../prenota/ajax/ajax-loader.gif'>";
	}
	if(http.readyState == 4){
		if(http.status == 200){
        		var R = document.getElementById(div);
        		R.innerHTML = http.responseText;
		}
	}
}



function createObject() {
	var tipo_richiesta;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		tipo_richiesta = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		tipo_richiesta = new XMLHttpRequest();
	}
return tipo_richiesta;
}