// JavaScript Document
function showDivDettaglioModulo(webpath,ritorno,div) {
	
	// ottengo i px dello scroll per aprire il dettaglio al posto giusto	
	var offset = 0;
	offset = window.pageYOffset || document.documentElement.scrollTop;
	var offset = offset+ "px";

	var elem = document.getElementById(div) ;
	if (elem.style.display == 'none') {
	
						
		var ajaxObj = new ClassAJAX();	
		ajaxObj.setExecute(false) ;
		ajaxObj.setReturn(true) ;
		ajaxObj.setLoading(true) ;
		ajaxObj.runAJAX(ritorno) ;
		
		var html = "" ;
		var htmlOld = "" ;
			
		myInterval = window.setInterval(
		function() { 
			
			htmlOld = html ;
			html = ajaxObj.getHtml() ;
			
			if (html != false) {
				
				if (htmlOld == html) {
					
					window.clearInterval(myInterval);
					//var scrTop = window.pageYOffset || document.documentElement.scrollTop;
					elem.style.top=offset;
					elem.style.display = 'block';
					elem.style.zIndex= '999999';
					elem.innerHTML = html ;
					
					
					
					/*******************************************************
					* appiccio la patina sotto a tutto
					*******************************************************/
					var xWithScroll ;
					var yWithScroll ;
					if (window.innerHeight && window.scrollMaxY) {// Firefox
						yWithScroll = window.innerHeight + window.scrollMaxY;
						xWithScroll = window.innerWidth + window.scrollMaxX;
					} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
						yWithScroll = document.body.scrollHeight;
						xWithScroll = document.body.scrollWidth;
					} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
						yWithScroll = document.body.offsetHeight;
						xWithScroll = document.body.offsetWidth;
				  	}
					/*var overlay = document.getElementById('overlay') ;
					overlay.style.height = yWithScroll.toString() + 'px' ;
					overlay.style.display = '' ;
					overlay.style.backgroundImage="url("+webpath+"/griglia.gif)" ;
					overlay.style.zIndex = '1000' ;
				*/
					
					try{
						
						if(document.getElementById('cancella_doc').value==1){
							setTimeout("closeDettaglioModulo('risultato');location.href='gestione-documenti.php';",2000);	
						
						}
					}catch(e){}
					
					try{
						
						if(document.getElementById('cancella_cat').value==1){
							setTimeout("closeDettaglioModulo('risultato');location.href='gestione-categorie.php';",2000);	
						
						}
					}catch(e){}
					
					try{
						
						if(document.getElementById('cancella_foto').value==1){
							setTimeout("closeDettaglioModulo('risultato');location.href='gestione-foto.php';",2000);	
						
						}
					}catch(e){}
					
					try{
						
						if(document.getElementById('cancella_ind').value==1){
							setTimeout("closeDettaglioModulo('risultato');location.href='gestione-indirizzi.php';",2000);	
						
						}
					}catch(e){}
					
					
					
					
				}
				
			} 
		} 
		,1) ; 
	}
	
}

function closeDettaglioModulo(div) {
	
	var elem = document.getElementById(div) ;
	elem.style.display = 'none' ;
	
	var overlay = document.getElementById('patina') ;
	overlay.style.display = 'none' ;
}

function closeDettaglioModuloSenzaOverlay(div) {
	
	var elem = document.getElementById(div) ;
	elem.style.display = 'none' ;
	
}

function show(id){

	var div = document.getElementById(id);

	if(div.style.display=='none')div.style.display='';else div.style.display='none';
	
}

var url = "select.php";

var what = "SetLinguaggi(req.responseText)";

var what2 = "SetLinguaggi2(req.responseText)";

var what3 = "SetLinguaggi3(req.responseText)";





function InviaDati(data)

{

  // istanziamo l'oggetto XMLHttpRequest

  if (window.XMLHttpRequest) 

  {

    req = new XMLHttpRequest();

    req.onreadystatechange = PocessaDati;

    req.open('POST', url, true);

    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    req.send(data);
  }

  // controlliamo la versione di ActiveX

  else if (window.ActiveXObject) 

  {

    req = new ActiveXObject('Microsoft.XMLHTTP')

    if (req)

    {

      req.onreadystatechange = PocessaDati;

      req.open('POST', url, true);

      req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

      req.send(data);

    }

  }

}



function InviaDati1(data)

{

  // istanziamo l'oggetto XMLHttpRequest

  if (window.XMLHttpRequest) 

  {

    req = new XMLHttpRequest();

    req.onreadystatechange = PocessaDati2;

    req.open('POST', url, true);

    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    req.send(data);

  }

  // controlliamo la versione di ActiveX

  else if (window.ActiveXObject) 

  {

    req = new ActiveXObject('Microsoft.XMLHTTP')

    if (req)

    {

      req.onreadystatechange = PocessaDati2;

      req.open('POST', url, true);

      req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

      req.send(data);

    }

  }

}





function PocessaDati()

{
  // monitoriamo lo stato dell'invio

  if (req.readyState == 4)

  {
  
    // restituiamo lo stato della richiesta

    if (req.status == 200) 

    {

      eval(what);

    }else{

      alert('Problema nella gestione dei dati: ' +

      req.responseText);

    }

  }

}



function PocessaDati2()

{;

  // monitoriamo lo stato dell'invio

  if (req.readyState == 4)

  {

    // restituiamo lo stato della richiesta

    if (req.status == 200) 

    {

      eval(what2);

    }else{

      alert('Problema nella gestione dei dati: ' +

      req.responseText);

    }

  }

}





function GetLinguaggi(Categoria)

{
  InviaDati("regione="+Categoria);

}



function GetLinguaggi2(Categoria)

{

  InviaDati1("provincia="+Categoria);

}



 

function SetLinguaggi(Linguaggi)

{

  var linguaggioBox = document.getElementById("provincia");

  linguaggioBox.options.length = 0;

  if(Linguaggi != "")

  {

    var arrLinguaggi = Linguaggi.split(",");
	
	
	 linguaggioBox.options[linguaggioBox.options.length] = 

     new Option("Seleziona...","");

    for(i = 0; i < arrLinguaggi.length; i++)

    {
	
	
      if(arrLinguaggi[i] != "")

      {

        linguaggioBox.options[linguaggioBox.options.length] = 

        new Option(arrLinguaggi[i], arrLinguaggi[i]);

      }

    }

  }

}

function SetLinguaggi2(Linguaggi)

{



  var linguaggioBox1 = document.getElementById("comu");

  linguaggioBox1.options.length = 0;

  if(Linguaggi != "")

  {
	
	
    var arrLinguaggi = Linguaggi.split(",");
	
linguaggioBox1.options[linguaggioBox1.options.length] = new Option('Seleziona...', '0');
    for(i = 0; i < arrLinguaggi.length; i++)

    {

      if(arrLinguaggi[i] != "")

      {	

		linguaggioBox1.options[linguaggioBox1.options.length] = new Option(arrLinguaggi[i], arrLinguaggi[i]);

      }

    }

  }

}
