function assegnaXMLHttpRequest() {
	var
	 XHR = null,
	 browserUtente = navigator.userAgent.toUpperCase();
	 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")  XHR = new XMLHttpRequest();
	 else if(window.ActiveXObject &&	  browserUtente.indexOf("MSIE 4") < 0){
		  if(browserUtente.indexOf("MSIE 5") < 0)  XHR = new ActiveXObject("Msxml2.XMLHTTP");
		  else   XHR = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 return XHR;
}

function getHTTPObject() {
	var http_object;
	if (!http_object && typeof XMLHttpRequest != 'undefined') {
		try {
			http_object = new XMLHttpRequest();
		}
		catch (e) {
			http_object = false;
		}
	}

	return http_object;
}
function sleep(milliSeconds){
	var startTime = new Date().getTime(); // get the current time
	while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}
function arrow_up(){
	var freccia_div =  document.getElementById("freccia"); 
	freccia_div.innerHTML = '<div id="freccia" style="float:right;"><a href="javascript:collapse1.slideup();arrow_down();"><img src="../images/freccie_up.gif" id="freccia" border="0" style="float:right;margin-top:-1px;" /></a></div>';
}
function arrow_down(){
	var freccia_div =  document.getElementById("freccia"); 
	freccia_div.innerHTML = '<div id="freccia" style="float:right;"><a href="javascript:collapse1.slidedown();arrow_up();"><img src="../images/freccie_down.gif" id="freccia" border="0" style="float:right;margin-top:-1px;" /></a></div>';
}

function cerca_area_timer() {
	setTimeout("cerca_utente();", 400);
}
var stop_cerca = false; 

function stop_cerca_area() {
	stop_cerca = false;
}

function cerca(){
	cerca_area_timer();
	w=window; 
	stop_cerca = true;
	stop_cerca_area();
	setTimeout("stop_cerca_area();", 1000);
	if (w.event){ 
		if (event.keyCode == 13) { 
			event.cancelBubble = true; 
			event.returnValue = true; 
		} 
	} 
}

function cerca_utente(lo_id,content_id,nome) {
	w=window; 
	var pagina = document.getElementById("pagina"); 
	var nome = document.getElementById("nome"); 
	var ris_utenti = document.getElementById("ris_utenti"); 
	if (w.XMLHttpRequest) { 
		ajax = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato = '';
	if(ajax) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link = "";
	ajax.open("post", "index.php" , true);
	ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link += "pag=ut_ric";
	link += "&";
	link += "nome=" + nome.value;
	link += "&";
	link += "pagina=" + pagina.value;
	ajax.send(link);
	ajax.onreadystatechange = function() {
	  if(ajax.readyState === 4) {
		  if(ajax.status == 200){
				risultato = ajax.responseText;
				//alert(risultato);
				ris_utenti.innerHTML = risultato;

			}
			else
			{

		  }
	  }
	}	
}



function nascondi_msg(){
	var result_crea1 =  document.getElementById("result_crea"); 
	result_crea1.style.display = 'none';
}


function initFade() {
	var result_crea1 =  document.getElementById("result_crea"); 
	for (var i=2000;i<5000;i++){
		setTimeout('setOpacity('+i+')',200*i);
	}
	setTimeout('nascondi_msg()',2000);
	return false;
}

function setOpacity(value){
	var result_crea1 =  document.getElementById("result_crea"); 
	result_crea1.style.opacity = value/10;
	result_crea1.style.filter = 'alpha(opacity=' + value + ')';
}

///////////////////////////////////////////////

//////////////////////////////////////////////////

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
	var classes = elem[i].className;
	if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
	alert(retnode);
}; 

function getElementsByClassName(oElm, strTagName, strClassName){
  var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);  
  strClassName = strClassName.replace(/\-/g, "\\-");
  var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
  var oElement;
  for(var i=0; i<arrElements.length; i++){
    oElement = arrElements[i];
    if(oRegExp.test(oElement.className)){
      oElement.style.display="none"
    }
  }  
} 

function upd_esame(u_id,id_appello){
	var esito =  document.getElementById("esito"); 
	var note =  document.getElementById("note"); 
	var sede =  document.getElementById("sede"); 
	/*
	for (i=0;i<document.profili.profilo_select.length;i++){
	if (document.profili.profilo_select[i].checked==true)
		theone=document.profili.profilo_select[i].value;
	}	
	*/
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=upd_esame";
	link1 += "&";
	link1 += "esito=" + esito.value;
	link1 += "&";
	link1 += "note=" + note.value;
	link1 += "&";
	link1 += "sede=" + sede.value;
	link1 += "&";
	link1 += "id_appello=" + id_appello;
	link1 += "&";
	link1 += "u_id=" + u_id;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				//result_crea1.style.display = "block";
				risultato = ajax1.responseText;
				reload();
				//alert(risultato);
				//result_crea1.innerHTML =risultato + '<br /><input type="button" value="ok" onclick="reload()">';
				//setTimeout('window.location.reload();',2000);

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}
function mod_iscr(u_id,corso,anno_accad,field,value){
	document.getElementsByClassName('hide');
	var result_crea1 =  document.getElementById("risultato"); 
	for (i=0;i<document.profili.profilo_select.length;i++){
	if (document.profili.profilo_select[i].checked==true)
		theone=document.profili.profilo_select[i].value;
	}	
	//alert(u_id+corso+anno_accad+field);
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=upd_profilo";
	link1 += "&";
	link1 += "u_id=" + u_id;
	link1 += "&";
	link1 += "corso=" + corso;
	link1 += "&";
	link1 += "anno_accad=" + anno_accad;
	link1 += "&";
	link1 += "field=" + field;
	link1 += "&";
	link1 += "prof=" + theone +';';
	link1 += "&";
	link1 += "value=" + value;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				result_crea1.style.display = "block";
				risultato = ajax1.responseText;
				result_crea1.innerHTML =risultato + '<br /><input type="button" value="ok" onclick="reload()">';
				//setTimeout('window.location.reload();',2000);

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}
function iscrivi_all(u_id,anno,corso,corso_anno){
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_iscri_insegnamenti";
	link1 += "&";
	link1 += "u_id=" + u_id;
	link1 += "&";
	link1 += "corso=" + corso;
	link1 += "&";
	link1 += "anno_accad=" + anno;
	link1 += "&";
	link1 += "corso_anno=" + corso_anno;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				alert(risultato);
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function canc_insegnamento(id_insegnamento){
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "act_canc_insegnamenti.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "&";
	link1 += "id_insegnamento=" + id_insegnamento;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				alert(risultato);
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function add_ins_doc(ins_id){
	//var doc_ins =  document.getElementById("doc_ins"); 
	var gli_ins=new Array();
	for (i=0;i<document.docenti.doc_ins.length;i++){
	if (document.docenti.doc_ins[i].selected==true)
		gli_ins[i]=document.docenti.doc_ins[i].value;
	}	
	//alert(gli_ins);
	
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "act_doc_ins.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "&";
	link1 += "id_ins=" + ins_id;
	var ins_doc=new Array();
	
	for (i=0;i<gli_ins.length;i++){
		if (gli_ins[i]!=undefined){
			link1 += "&";
			link1 += "ins_doc["+i+"]=" + gli_ins[i];
			//ins_doc = gli_ins[i];
		}
	}		
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				alert('I docenti sono stati associati a questo insegnamento');
				window.opener.location.reload();
				window.close();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
	
}

function add_tipo(){
	var cms_tipo_nome =  document.getElementById("cms_tipo_nome"); 
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_add_tipo";
	link1 += "&";
	link1 += "cms_tipo_nome=" + cms_tipo_nome.value;
	
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				//alert(risultato);
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}
function add_cms_iul(){
	var cms_titolo =  document.getElementById("cms_titolo"); 
	var cms_gruppo =  document.getElementById("cms_gruppo"); 
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_add_cms_iul";
	link1 += "&";
	link1 += "cms_gruppo=" + cms_gruppo.value;
	link1 += "&";
	link1 += "cms_titolo=" + cms_titolo.value;
	
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				//alert(risultato);
				document.location.href = "index.php?pag=cms_iul&show=" + cms_gruppo.value;

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}
function canc_tipo(id_tipo){
	if (confirm('desideri veramente cancellare la tipologia n° ' + id_tipo+ '?')){
		var cms_tipo_nome =  document.getElementById("cms_tipo_nome"); 
		w=window; 
		if (w.XMLHttpRequest) { 
			ajax1 = new getHTTPObject(); 
		}
		else if (w.ActiveXObject) { 
			ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		var risultato1 = '';
		if(ajax1) {
			}
			else
			{
			alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
		}
		var link1 = "";
		
		ajax1.open("post", "index.php" , true);
		ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		link1 += "pag=act_canc_tipo";
		link1 += "&";
		link1 += "cms_id_tipo=" + id_tipo;
		
		ajax1.send(link1);
		ajax1.onreadystatechange = function() {
		  if(ajax1.readyState === 4) {
			  if(ajax1.status == 200){
					risultato = ajax1.responseText;
					//alert(risultato);
					window.location.reload();

				}
				else
				{
					alert("Operazione fallita, errore numero " + ajax1.status);
			  }
		  }
		}
	}
	else
	{
		return ;
	}

}


function add_utente(){
	var cms_tipo_nome =  document.getElementById("cms_tipo_nome"); 
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_add_tipo";
	link1 += "&";
	link1 += "cms_tipo_nome=" + cms_tipo_nome.value;
	
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				//alert(risultato);
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}
function canc_utente(id_utente){
	if (confirm('desideri veramente cancellare la tipologia n° ' + id_tipo+ '?')){
		var cms_tipo_nome =  document.getElementById("cms_tipo_nome"); 
		w=window; 
		if (w.XMLHttpRequest) { 
			ajax1 = new getHTTPObject(); 
		}
		else if (w.ActiveXObject) { 
			ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		var risultato1 = '';
		if(ajax1) {
			}
			else
			{
			alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
		}
		var link1 = "";
		
		ajax1.open("post", "index.php" , true);
		ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		link1 += "pag=act_canc_tipo";
		link1 += "&";
		link1 += "cms_id_tipo=" + id_tipo;
		
		ajax1.send(link1);
		ajax1.onreadystatechange = function() {
		  if(ajax1.readyState === 4) {
			  if(ajax1.status == 200){
					risultato = ajax1.responseText;
					//alert(risultato);
					window.location.reload();

				}
				else
				{
					alert("Operazione fallita, errore numero " + ajax1.status);
			  }
		  }
		}
	}
	else
	{
		return ;
	}

}


function iscrivi_this(u_id,ins_id){
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_iscri_insegnamento";
	link1 += "&";
	link1 += "u_id=" + u_id;
	link1 += "&";
	link1 += "ins_id=" + ins_id;
	
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				alert(risultato);
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function disiscrivi_this(u_id,ins_id){
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_disiscri_insegnamento";
	link1 += "&";
	link1 += "u_id=" + u_id;
	link1 += "&";
	link1 += "ins_id=" + ins_id;
	
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				alert(risultato);
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function reload(){
	window.location.reload();
}
function cerca_lo() {
	var newSel = document.getElementById('idx_sel').options[document.getElementById('idx_sel').selectedIndex].text;
	var nome_area1 = document.getElementById("aree"); 
	var id_sottoarea1 = document.getElementById("idx_sel"); 
	//var id_sub_sottoarea = document.getElementById("idx_sub_sel"); 
	var status1 = document.getElementById("idx"); 
	var disp_area1 = document.getElementById("Z"); 
	var sottoarea1 = document.getElementById("Z_sel"); 
	var sottoarea_lo1 = document.getElementById("Z_lo"); 
	var area1 = document.getElementById("area");
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "../index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "action=search_lo";
	link1 += "&";
	link1 += "sub=1";
	link1 += "&";
	link1 += "subaree= " + id_sottoarea1.value;
	link1 += "&";
	link1 += "subaree_name= " + newSel;
	link1 += "&";
	link1 += "status= " + status1.value;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				//sottoarea.style.display = "none";
				sottoarea_lo1.style.display = "block";
				risultato1 = ajax1.responseText;
				sottoarea_lo1.innerHTML = '<div id=\'input_titolo\'><div class=\'wiz\' id=\'titolo_pag\'>'+ risultato1 + '</div></div>\n';
				//alert("Operazione effettuata con successo");
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function save_new_mail() {
	w=window; 
	var mail_subject = document.getElementById("mail_subject"); 
	var mail_text = document.getElementById("mail_text"); 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "salva_mail.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "mail_subject="+mail_subject.value;
	link1 += "&";
	link1 += "mail_text="+mail_text.value;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				window.location.href='index.php?pag=elenco_mail';
				//alert("Operazione effettuata con successo");
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function apri_ditte(url){
	window.open(url, 'ftp', 'toolbar=no,directories=no,menubar=no,width=750px,height=500px,resizable=yes,scrollbars=yes,top=5,left=5');
}
function cache_cms(url,anchor){
	aprichiudi=window.open(url,'crediti', 'status=no,toolbar=no,directories=no,menubar=no,width=1,height=1,left=330,top=30,scrollbars=yes,resizable=yes');
	//document.location.reload('#' + anchor);
	aprichiudi.focus();
	setTimeout("aprichiudi.close();",1500);
}
function dettagli_small(url){
		window.open(url,'dettagli', 'status=no,toolbar=no,directories=no,menubar=no,width=710,height=710,left=30,top=30,scrollbars=yes,resizable=yes');
}
function dettagli_very_small(url){
		window.open(url,'dettagli', 'status=no,toolbar=no,directories=no,menubar=no,width=510,height=510,left=50,top=50,scrollbars=yes,resizable=yes');
}
function dettagli_medio(url){
		window.open(url,'dettagli', 'status=no,toolbar=no,directories=no,menubar=no,width=910,height=810,left=30,top=30,scrollbars=yes,resizable=yes');
}
function dettagli(url){
		window.open(url,'dettagli', 'status=no,toolbar=no,directories=no,menubar=no,width=1010,height=810,left=30,top=30,scrollbars=yes,resizable=yes');
}

function apri_url(url,finestra){
		window.open(url, finestra, 'status=no,toolbar=no,directories=no,menubar=no,width=1010,height=810,left=30,top=30,scrollbars=yes,resizable=yes');
}

function apri_url_medio(url,finestra){
		window.open(url, finestra, 'status=no,toolbar=no,directories=no,menubar=no,width=810,height=610,left=60,top=30,scrollbars=yes,resizable=yes');
}

function return_style(witch_obj) {
	var input_obj = document.getElementById(witch_obj);
	input_obj.style.border = '2px inset #c0c0c0';
	input_obj.style.backgroundColor = '#fff';
	input_obj.style.color = '#000';
}

function change_style(witch_obj) {
	var input_obj = document.getElementById(witch_obj);
	input_obj.style.border = '2px outset #000';
	input_obj.style.backgroundColor = '#EDF3F2';
	input_obj.style.color = '#476444';
}



function aprimap(url){
	window.open(url, 'map', 'toolbar=no,directories=no,menubar=no,width=790,height=590,resizable=yes,scrollbars=yes,top=10,left=30');
}
function apriguida(url){
	window.open(url, 'guida', 'toolbar=no,directories=no,menubar=no,width=800,height=500,resizable=yes,scrollbars=yes,top=10,left=30');
}
function apri(){
	window.open('../preview/img.php?dir=<?echo $lo_id;?>', 'news', 'toolbar=no,directories=no,menubar=no,width=500,height=350,resizable=yes,scrollbars=yes,top=10,left=30');
}
function copy_title(){
	document.mod_content.content_title_menu.value=document.mod_content.content_title.value;
}

function toggleLayer(whichLayer){
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function show(whichLayer){
	if (document.getElementById){
		var style2 = document.getElementById(whichLayer).style;
		style2.display = "block";
	}
	else if (document.all)
	{
		var style2 = document.all[whichLayer].style;
		style2.display =  "block";
	}
	else if (document.layers)
	{
		var style2 = document.layers[whichLayer].style;
		style2.display =  "block";
	}
}
function hide(whichLayer){
	if (document.getElementById){
		var style2 = document.getElementById(whichLayer).style;
		style2.display = "none";
	}
	else if (document.all)
	{
		var style2 = document.all[whichLayer].style;
		style2.display =  "none";
	}
	else if (document.layers)
	{
		var style2 = document.layers[whichLayer].style;
		style2.display =  "none";
	}
}

function vaicollamail(mail_id,email){
	var mail_array = email.split(";");
	for (i=0; i<=mail_array.length; i++) { 
		if (mail_array[i]!=''){
			ajaxmail(mail_id,mail_array[i]);
		}
	}
	alert("I messaggi sono stati inviati.\nControllare il file di log");
}

function canc_mail(mail_id){
	if (confirm('confermi di cancellare il testo della mail n.' + mail_id))	{
		w=window; 
		if (w.XMLHttpRequest) { 
			ajax1 = new getHTTPObject(); 
		}
		else if (w.ActiveXObject) { 
			ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		var risultato1 = '';
		if(ajax1) {
			}
			else
			{
			alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
		}
		var link1 = "";
		
		ajax1.open("post", "canc_mail.php" , true);
		ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		link1 += "mail_id=" + mail_id;
		ajax1.send(link1);
		ajax1.onreadystatechange = function() {
		  if(ajax1.readyState === 4) {
			  if(ajax1.status == 200){
				  alert('la mail è stata resa non visibile');
				window.location.reload();

					//risultato1 = ajax1.responseText;
				}
				else
				{
					alert("Operazione fallita, errore numero " + ajax1.status);
			  }
		  }
		}	
	}
	else
	{
		return false;
	}
}

function coll_video(id_video){
		w=window; 
		if (w.XMLHttpRequest) { 
			ajax1 = new getHTTPObject(); 
		}
		else if (w.ActiveXObject) { 
			ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		var risultato1 = '';
		if(ajax1) {
			}
			else
			{
			alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
		}
		var link1 = "";
		
		ajax1.open("post", "coll_video.php" , true);
		ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		link1 += "id_video=" + id_video;
		ajax1.send(link1);
		ajax1.onreadystatechange = function() {
		  if(ajax1.readyState === 4) {
			  if(ajax1.status == 200){
					risultato1 = ajax1.responseText;
					return risultato1;
					//alert(risultato1);
					//window.location.reload();

				}
				else
				{
					alert("Operazione fallita, errore numero " + ajax1.status);
			  }
		  }
		}	
	}

function ajaxmail(mail_id,mail_addr){
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "prova_mail.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "mail_addr=" + mail_addr;
	link1 += "&";
	link1 += "mail_id=" + mail_id;
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato1 = ajax1.responseText;
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function valida(id_file,valid,tab){
	var imgtochange =document.getElementById('img_'+id_file);
	w=window; 
	if (w.XMLHttpRequest) { 
		ajax1 = new getHTTPObject(); 
	}
	else if (w.ActiveXObject) { 
		ajax1 = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	var risultato1 = '';
	if(ajax1) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link1 = "";
	
	ajax1.open("post", "index.php" , true);
	ajax1.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link1 += "pag=act_valida";
	link1 += "&";
	link1 += "id_file=" + id_file;
	link1 += "&";
	link1 += "validazione=" + valid;
	link1 += "&";
	link1 += "tab=" + tab;
	
	ajax1.send(link1);
	ajax1.onreadystatechange = function() {
	  if(ajax1.readyState === 4) {
		  if(ajax1.status == 200){
				risultato = ajax1.responseText;
				if(valid==1){imgtochange.src='../../images/validato.gif';}else{imgtochange.src='../../images/invalidato.gif';}
				window.location.reload();

			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax1.status);
		  }
	  }
	}	
}

function mod_field(campo){
	show(campo);
	//alert(field);
}

function set_field(u_id,field) {
	var div_field = document.getElementById('div_'+field); 
	var valore = document.getElementById(field); 
	var ajax = assegnaXMLHttpRequest();
	var risultato = '';
	if(ajax) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link = "";
	ajax.open("post", "act_save_field.php" , true);
	ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link += "&";
	link += "field=" + field;
	link += "&";
	link += "u_id=" + u_id;
	link += "&";
	link += "value=" + valore.value;
	ajax.send(link);
	ajax.onreadystatechange = function() {
	  if(ajax.readyState === 4) {
		  if(ajax.status == 200){
				risultato = ajax.responseText;
				div_field.innerHTML = risultato;
				valore.style.display='none';
				alert(risultato);
				//window.location.href='view_cliente.php?id_cliente='+cliente+'&open_div='+n;
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax.status);
		  }
	  }
	}	
}
function getCheckedValue(radioobj) {
	//alert(radioobj);
	for(var i = 0; i < 2; i++) {
		if(eval('document.profilo.'+radioobj+'[i]').checked==true) {
		var	valore = eval('document.profilo.'+radioobj+'[i]').value;
		}
	}
	//alert(valore);
	return  valore;
}
function set_condividi(u_id,field,campo) {
	var valore = document.getElementById(field);
	valore_campo = getCheckedValue(campo);
	var ajax = assegnaXMLHttpRequest();
	var risultato = '';
	if(ajax) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link = "";
	ajax.open("post", "act_save_condividi.php" , true);
	ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link += "&";
	link += "field=" + field;
	link += "&";
	link += "u_id=" + u_id;
	link += "&";
	link += "valore=" + valore_campo;
	ajax.send(link);
	ajax.onreadystatechange = function() {
	  if(ajax.readyState === 4) {
		  if(ajax.status == 200){
				risultato = ajax.responseText;
				alert(risultato);
				reload();
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax.status);
		  }
	  }
	}	
}

function get_alert(testo){
	alert(testo);
}
