function xmlhttpPost_ricerca(strURL,div_result) {
	document.getElementById(div_result).innerHTML = "<img class='loading_ajax' src='/images/ajax-loader.gif' />";
	
    var xmlHttpReq_ricerca = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq_ricerca = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq_ricerca = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq_ricerca.open('POST', strURL, true);
    self.xmlHttpReq_ricerca.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq_ricerca.onreadystatechange = function() {
        if (self.xmlHttpReq_ricerca.readyState == 4) {
            updatepage_ricerca(self.xmlHttpReq_ricerca.responseText,div_result);
        }
    }    		    
	self.xmlHttpReq_ricerca.send(getquerystring());
}


function getquerystring() {
    var form     = document.forms['ricerca_immobile'];
    
	if (document.getElementById('contratto')){ var contratto = form.contratto.value;}
    else if (document.getElementById('val_contratto')){ var contratto = form.val_contratto.value;}

	if (document.getElementById('macro_area')){ var macro_area = form.macro_area.value;}
    else if (document.getElementById('val_macro_area')){ var macro_area = form.val_macro_area.value;}

	if (document.getElementById('tipologia')){ var tipologia = form.tipologia.value;}
    else if (document.getElementById('val_tipologia')){ var tipologia = form.val_tipologia.value;}

	if (document.getElementById('fascia_prezzo')){ var fascia_prezzo = form.fascia_prezzo.value;}
	else if (document.getElementById('val_fascia_prezzo')){ var fascia_prezzo = form.val_fascia_prezzo.value;}
	if(!fascia_prezzo) fascia_prezzo = 'qualsiasi';

	qstr = 'contratto=' + escape(contratto) + '&macro_area=' + escape(macro_area) + '&tipologia=' + escape(tipologia) + '&fascia_prezzo=' + escape(fascia_prezzo);
	//alert (qstr);

	return qstr;
}

function updatepage_ricerca(str,div_result){
    document.getElementById(div_result).innerHTML = str;
	jQuery('#carousel_results').jcarousel();
    
}
