function view(param)
{
	window.open('view.php?id='+param,'Annuncio'+param,'scrollbars=yes,resizable=no,width=1000,height=700,status=no,location=no,toolbar=no');
}
function foto_admin(param)
{
	window.open('../foto.php?id='+param,'FotoAdmin'+param,'scrollbars=yes,resizable=yes,width=500,height=500,status=no,location=no,toolbar=no');
}
function foto(param,num)
{
	window.open('foto.php?foto='+param,'Foto'+num,'scrollbars=yes,resizable=yes,width=500,height=500,status=no,location=no,toolbar=no');
}
function foto_home(param)
{
	window.open('/foto.php?id='+param,'FotoHome'+param,'scrollbars=yes,resizable=yes,width=680,height=680,status=no,location=no,toolbar=no');
}
function stampa(id)
{
	window.open('stampa_cron_cliente.php?id_cli='+id,'StampaCron'+id,'scrollbars=yes,resizable=no,width=550,height=450,status=no,location=no,toolbar=no');
}
function stampa_download(id)
{
	window.open('stampa_cron_download.php?id_cli='+id,'StampaCron'+id,'scrollbars=yes,resizable=no,width=550,height=450,status=no,location=no,toolbar=no');
}

function mostra_barra()
{
	document.getElementById("attesa").style.visibility = "visible";
}


// accetta una stringa di testo non html da mostrare
function mostraAttesa(testo) {

  // variabili di funzione
  var
    // totale dei puntini mostrati
    puntini = 0,

    // elemento contenente il testo
    // oppure il nodo testuale all'interno
    // dello stesso elemento
    testoIntrattenimento = prendiElementoDaId("testo-temporaneo"),

    // funzione per aggiungere puntini al testo scelto
    animaTesto = function() {

      // stringa locale contenente i vari puntini
      var testoAggiunto = "";

      // ciclo per aggiungere i puntini
      for(var a = 0; a < puntini; a++)
        testoAggiunto += ".";

      // assegnazione del nuovo testo al nodo
      // comprensivo dei puntini
      testoIntrattenimento.nodeValue = testo + testoAggiunto;

      // controllo sul totale puntini
      // se inferiori a 4
      if(puntini < 4)
        // si aggiunge un altro punto
        puntini++;
      
      // altrimenti si ricomincia da nessun punto
      else
        puntini = 0;

      // richiamo alla stessa funzione con intervallo non
      // inferiore ai 250 millisecondi
      setTimeout(animaTesto, 300);
    };

  // verifica della precedente assegnazione
  // del nodo testuale all'interno dell'elemento
  if(testoIntrattenimento.firstChild) {

    // in questo caso è necesario riassegnare
    // la funzione al fine di eliminare l'intervallo
    // successivo ...
    animaTesto = function(){};

    // ... per poi eliminare il nodo precedentemente aggiunto
    testoIntrattenimento.removeChild(testoIntrattenimento.firstChild);
  }
  else {
    // nodo inesistente, è necessario crearlo
    // con il testo predefinito ...
    testoIntrattenimento = document.createTextNode(testo);

    // ... ed assegnarlo all'elemento
    prendiElementoDaId("testo-temporaneo").appendChild(testoIntrattenimento);

    // per poter richiamare la funzione
    animaTesto();
  };
}; 
		function prendiElementoDaId(id_elemento) {
			var elemento;
			if(document.getElementById)
				elemento = document.getElementById(id_elemento);
			else
				elemento = document.all[id_elemento];
			return elemento;
		};
	
	// funzione per assegnare un oggetto XMLHttpRequest
		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;
		};
		
		var readyState = {
			INATTIVO:	0,
			INIZIALIZZATO:	1,
			RICHIESTA:	2,
			RISPOSTA:	3,
			COMPLETATO:	4
		};

		var statusText = new Array();
		statusText[100] = "Continue";
		statusText[101] = "Switching Protocols";
		statusText[200] = "OK";
		statusText[201] = "Created";
		statusText[202] = "Accepted";
		statusText[203] = "Non-Authoritative Information";
		statusText[204] = "No Content";
		statusText[205] = "Reset Content";
		statusText[206] = "Partial Content";
		statusText[300] = "Multiple Choices";
		statusText[301] = "Moved Permanently";
		statusText[302] = "Found";
		statusText[303] = "See Other";
		statusText[304] = "Not Modified";
		statusText[305] = "Use Proxy";
		statusText[306] = "(unused, but reserved)";
		statusText[307] = "Temporary Redirect";
		statusText[400] = "Bad Request";
		statusText[401] = "Unauthorized";
		statusText[402] = "Payment Required";
		statusText[403] = "Forbidden";
		statusText[404] = "Not Found";
		statusText[405] = "Method Not Allowed";
		statusText[406] = "Not Acceptable";
		statusText[407] = "Proxy Authentication Required";
		statusText[408] = "Request Timeout";
		statusText[409] = "Conflict";
		statusText[410] = "Gone";
		statusText[411] = "Length Required";
		statusText[412] = "Precondition Failed";
		statusText[413] = "Request Entity Too Large";
		statusText[414] = "Request-URI Too Long";
		statusText[415] = "Unsupported Media Type";
		statusText[416] = "Requested Range Not Satisfiable";
		statusText[417] = "Expectation Failed";
		statusText[500] = "Internal Server Error";
		statusText[501] = "Not Implemented";
		statusText[502] = "Bad Gateway";
		statusText[503] = "Service Unavailable";
		statusText[504] = "Gateway Timeout";
		statusText[505] = "HTTP Version Not Supported";
		statusText[509] = "Bandwidth Limit Exceeded";

var risposta = false;
var liveSearchReq;
function cerca(cartella) 
{	var strRes; 
	var file = document.getElementById("fil_upd").value;
	
	parti = file.split("\\");
	
//	alert("file : "+file+ " --- "+parti.length);
	var url = "cerca_file.php?file="+cartella+parti[parti.length-1];
//	alert("URL : "+url);
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        liveSearchReq = new XMLHttpRequest();
        liveSearchReq.onreadystatechange = ricevi; 
        liveSearchReq.open("GET",url,true);
        liveSearchReq.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
        if (liveSearchReq) {
           liveSearchReq.onreadystatechange = ricevi; 
            liveSearchReq.open("GET",url,true);
            liveSearchReq.send();
        }
    }	
}
function ricevi() 
{      	
	if (liveSearchReq.readyState == 4) {	   
		strRes=liveSearchReq.responseText;
//		alert("strRes "+ strRes)
		if(strRes=="si")
		{
			alert("IMPOSSIBILE CARICARE IL FILE!!\nAttenzione esiste già un file con lo stesso nome!!!");
			document.formfile.boot_post.disabled=false; 
		}
		else
		{
			mostraAttesa('caricamento file');
			document.formfile.submit();
		}
		
	}
}

function confronta(cartella)
{
	cerca(cartella);
}

function salva() { 
if (document.all) { 
	document.execCommand("SaveAs");  
}else{ 
	alert('Con il tuo Browser non funziona.'); 
} 
} 
