function user_createRequestObject() { 

	var ro;
  
	try  {    // Firefox, Opera 8.0+, Safari    
			ro=new XMLHttpRequest();    
		}
  catch (e)
    {    // Internet Explorer    
			try
      {      ro=new ActiveXObject("Msxml2.XMLHTTP");      }
    catch (e)
      {      try
        {        ro=new ActiveXObject("Microsoft.XMLHTTP");        }
      catch (e)
        {        alert("Aggiorna il tuo browser! Impossibile visualizzare i contenuti!");        
				return false;        
				}
			}
		}

	return ro;
}


var http = user_createRequestObject(); 

var taginput = '';

// ritorno la lista delle province
function sndReqProvince(id_nazione, id_provincia, div) { 
	taginput = div;
	http.open('get', '/include/html_inc/ajaxpage/province.php?idnaz='+id_nazione+'&idprov='+id_provincia, true);
	http.onreadystatechange = handleResponse; 
	http.send(null); 
} 

// funzioni tags
function TagAggiungiNuovo(tag, valore, sezione, id, sess) { 
	taginput = tag;


	var collegam = '/include/html_inc/ajaxpage/tags_aggiungi.php?sezione='+sezione+'&contenuto='+id+'&valore='+valore+'&sess='+sess;
	http.open('get', collegam, false);
	http.onreadystatechange = handleResponse; 
	http.send(null); 
} 

function TagElimina(id, sess) { 
	taginput = '';
	var collegam = '/include/html_inc/ajaxpage/tags_elimina.php?tag_id='+id+'&sess='+sess;

	http.open('get', collegam, false);
	http.onreadystatechange = handleResponse; 
	http.send(null); 
} 

function sndReqTagsLista(div, sezione, contenuto, sess, prop, user) {
	taginput = div;
	http.open('get', '/include/html_inc/ajaxpage/tags_lista.php?sezione='+sezione+'&contenuto='+contenuto+'&sess='+sess+'&prop_id='+prop+'&user_id='+user, true);
	http.onreadystatechange = handleResponse; 
	http.send(null); 	
}

function handleResponse() { 
    if(http.readyState == 4){ 
        var response = http.responseText; 
				if (taginput != '') {
					document.getElementById(taginput).style.display = 'block';
					document.getElementById(taginput).innerHTML = response;
				}
				//hideLoading();
    } else {
				//showLoading();
		}
} 

function addToBookmark(){
    var url = location.href;
    var pageName = document.title;

    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(pageName, url, "");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, pageName); }
    else if(window.opera && window.print) { // Opera Hotlist
        return true; }

    //return false;
}

