var ro = null;
var http = null;
var response = null;
var quali = null;
var update = null;
function collassa(){

setTimeout('collapse2.slideit()',1000);
}
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}

	return ro;
}

var http = createRequestObject();

/*
function creaPaginaHome(param){
	http.open('get', 'new/inc/paginaHome.asp?azione='+param);
	http.onreadystatechange = handleResponse;
	http.send(null);

}
*/


function ultimi(){
	http.open('get', 'new/inc/ultimi_iscritti.asp?pippo='+Math.random());
	http.onreadystatechange = handleResponse;
	http.send(null);

}


function creaPaginaPersonale(){

	http.open('get', 'new/ajax/paginaPersonale.asp?pippo='+Math.random());
	http.onreadystatechange = handleResponse;
	http.send(null);
	
}
function creaPaginaPersonaleInfo(info){

	http.open('get', 'new/ajax/paginaPersonaleInfo.asp?pippo='+Math.random()+'&info_id='+info);
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function creaPaginaContattaUtente(info){

	http.open('get', 'new/ajax/paginaContattaUtente.asp?pippo='+Math.random()+'&info_id='+info);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function scrivi_contatti(utente){

	http.open('get', 'new/ajax/contattiUtente.asp?pippo='+Math.random()+'&utente='+utente);
	http.onreadystatechange = handleResponse;
	http.send(null);
	
}
function chiudiConversazione(mittente){
	http.open('get', 'new/ajax/chiudiChatPvt.asp?pippo='+Math.random()+'&mittente='+mittente);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function cancellaAvviso(mittente){
	http.open('get', 'new/ajax/chiudiChatPvt.asp?pippo='+Math.random()+'&mittenteAvviso='+mittente);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function ripristinoSessione(){
	http.open('get', 'new/ajax/ripristinoSessione.asp?pippo='+Math.random());
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function msgRicevuti(quali){
	http.open('get', 'new/ajax/msg-Ricevuti.asp?pippo='+Math.random()+'&quali='+quali);
	http.onreadystatechange = handleResponse;
	http.send(null);

}
function leggiMsg(id_msn,id_div,id_mi){
	http.open('get', 'new/ajax/msg-Leggi.asp?pippo='+Math.random()+'&id_msn='+id_msn+'&id_div='+id_div+'&id_mi='+id_mi);
	http.onreadystatechange = handleResponse;
	http.send(null);

}
function rispondiMsg(id_msn,id_mi){
	http.open('get', 'new/ajax/msg-Rispondi.asp?pippo='+Math.random()+'&id_msn='+id_msn+'&id_mi='+id_mi);
	http.onreadystatechange = handleResponse;
	http.send(null);
	setTimeout(function(){document.editore.testo_email.focus();},2000);
	}

	

function eliminaMsg(id_msn){
	http.open('get', 'new/ajax/msg-Elimina.asp?pippo='+Math.random()+'&id_msn='+id_msn);
	http.onreadystatechange = handleResponse;
	http.send(null);
	
setTimeout('msgRicevuti(\'tutti\')',4000);
}
function formUploadImg(quali){
	http.open('get', 'new/ajax/formUploadImg.asp?pippo='+Math.random()+'&provenienza='+quali);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function fotoUtente(id_u){
	http.open('get', 'new/ajax/foto-Utente.asp?pippo='+Math.random()+'&id_u='+id_u);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function fotoGrande(id_immagini,titoloAlbum,idUtente){
	http.open('get', 'new/ajax/foto-Grande.asp?pippo='+Math.random()+'&id_immagini='+id_immagini);
	http.onreadystatechange = handleResponse;
	http.send(null);

}
function fotoRacolta(idUtente,titoloAlbum){
	http.open('get', 'new/ajax/foto-Racolta.asp?pippo='+Math.random()+'&id_u='+idUtente+'&album='+titoloAlbum);
	http.onreadystatechange = handleResponse;
	http.send(null);
	
	
}
function ricerca(termine_ricerca,sessoRicerca,eta,regione,provincia,citta){
	http.open('get', 'new/ajax/ricerca.asp?pippo='+Math.random()+'&termine_ricerca='+termine_ricerca+'&sessoRicerca='+sessoRicerca+'&eta='+eta+'&regione='+regione+'&provincia='+provincia+'&citta='+citta);
	http.onreadystatechange = handleResponse;
	http.send(null);
	document.getElementById('lastSearch').innerHTML = "<a href=\"javascript:attivaRicerca();ricerca(\'"+termine_ricerca+'\',\''+sessoRicerca+'\',\''+eta+'\',\''+regione+'\',\''+provincia+'\',\''+citta+"\');collassa();\">ultima ricerca</a>";
	
	document.getElementById('IEsesso').value="";
	document.getElementById('IEprovincia').value="";
	document.getElementById('sessoRicerca').options[0].selected=true;
	document.getElementById('eta').options[0].selected=true;
	document.getElementById('regione').options[0].selected=true;
	document.getElementById('provincia').options[0].selected=true;
	document.getElementById('citta').value="";
	collapse2.slideit();
}
function formAjaxCAnnuncio(){
setTimeout('leggiAnnunci()',1000);

	http.open('get', 'new/ajax/form_CreaAnnuncio.asp?pippo='+Math.random());
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function leggiAnnunci(){

	http.open('get', 'new/ajax/annunci-leggi.asp?pippo='+Math.random());
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function annunciModifica(){

	http.open('get', 'new/ajax/annunci-modifica.asp?pippo='+Math.random());
	http.onreadystatechange = handleResponse;
	http.send(null);



}
function controllaAnnuncio(n,risposta){

	http.open('get', 'new/ajax/annunci-controlla.asp?pippo='+Math.random()+"&n="+n+"&risposta="+risposta);
	http.onreadystatechange = handleResponse;
	http.send(null);



}

	function handleResponse() {
	if(http.readyState == 4){
	
		var response = http.responseText;
		var update = new Array();
		if(response.indexOf('|' != -1)) {
		
			update = response.split('|');
			document.getElementById(update[0]).innerHTML = update[1];
			
		}
	}
}

