function xmlhttpPost2(strURL) {
	var Elemento = document.getElementsByName('Centrale');
	
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
        	
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring2() {
   // var form     = document.forms['f1'];
   // var word = form.word.value;
   qstr = "pippo";
   //w=' + escape(word);  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage2(str){
    document.getElementById('Centrale').innerHTML = str;
}

function TornaIndietro(URLString,paramName,param)
{
    var location = document.location.href;
	var positem = location.indexOf(param);
		if (positem != -1) {
			var lunghezza=param.length;
			var paraValue = location.substring(positem + lunghezza+1);
    var URLCambia=URLString+"?"+paramName+"="+paraValue;
    xmlhttpPost(URLCambia);
    }
}

function xmlhttpPostForPagingByPolymedia(strURL,id2Change) 
{
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			updatepage(self.xmlHttpReq.responseText,id2Change);
		}
	}
	self.xmlHttpReq.send(getquerystring());
}

function xmlhttpPost(strURL,id2Change,idSelected) 
{
	;
	
	if (idSelected!=null)
	{
		var indexSelected = document.getElementById(idSelected).options.selectedIndex;
		strURL=strURL+document.getElementById(idSelected).options[indexSelected].value;
	}
	
	
	
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			
			updatepage(self.xmlHttpReq.responseText,id2Change);
		}
	}
	self.xmlHttpReq.send(getquerystring());
}
		
function getquerystring() 
{
   // var form     = document.forms['f1'];
		   // var word = form.word.value;
	qstr = "pippo";
		   //w=' + escape(word);  // NOTE: no '?' before querystring
	return qstr;
}
		
function updatepage(str,id2Change)
{
	document.getElementById(id2Change).innerHTML = str;
	
	if(document.getElementById('table2order')) 
	{
		initTable('table2order')
    scorriPagina('0');
	}	

}


function xmlhttpPostForSorting(strURL,id2Change,idTabella) 
{
	//strURL='../'+strURL;
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			updatepage(self.xmlHttpReq.responseText,id2Change);
		}
	}
	self.xmlHttpReq.send(getquerystring());
}

function xmlhttpPostForSortingByPolymedia(strURL,id2Change) 
{
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			updatepage(self.xmlHttpReq.responseText,id2Change);
		}
	}
	self.xmlHttpReq.send(getquerystring());
}

function xmlhttpPostForDettaglioCertificate(strURL,id2Change) 
{
	var loc = document.location.toString();
	var pos = loc.lastIndexOf('_');
	var id = loc.substring(pos+1,loc.lastIndexOf('.'));
	strURL='../'+strURL+id;
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			updatepage(self.xmlHttpReq.responseText,id2Change);
		}
	}
	self.xmlHttpReq.send(getquerystring());
}

function xmlhttpPostForRedirect(strURL,id2Change) 
{
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('get', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			var risposta = self.xmlHttpReq.responseText.toString();
			//alert(risposta);
			if(risposta.substring(13,risposta.length).length==0)
			{
				if(strURL.indexOf('ordine=asc')>=0)
				{
					document.getElementById('succ').innerHTML = "<div>Successivo</div><div><img src=\"../img/forw.gif\" alt=\"Successivo\" width=\"11\" height=\"11\"/></div>";

				}
				else if(strURL.indexOf('ordine=dec')>=0)
				{
					document.getElementById('prev').innerHTML = "<div><img src=\"../img/back.gif\" alt=\"Precedente\" width=\"11\" height=\"11\"/></div><div>Precedente</div>";

				}
			}
			else
			{
				//var id = risposta.substring(risposta.indexOf('id:')+3,risposta.length);
				//document.location='Certificate_'+id+'.jsp';
				//document.location='Dettaglio_Certificate.jsp?'+risposta;
				var URL='certificateHomePage.jsp?'+risposta;
				//alert(URL);
				document.location.href=URL;
				//caricaBanner(URL,'Centrale');
			}
		}
	}
	self.xmlHttpReq.send(getquerystring());
}


function caricaBanner(strURL,idDocumento) {
       new Ajax.Request(strURL,{
               method: 'get',
               contentType:'application/x-www-form-urlencoded',
               onSuccess: function(response) {
                       updatepage(response.responseText,idDocumento);
       }});

}


function caricaBannerPrezziold(strURL,idDocumento) {
       alert("passo");
       new Ajax.Request(strURL,{
               method: 'get',
               contentType:'application/x-www-form-urlencoded',
               onSuccess: function(response) {
                       updatepage(response.responseText,idDocumento);
       }});

}

function caricaBannerPrezzi(strURL,idDocumento) {

       new Ajax.Updater(
 { success: idDocumento },
 strURL,
 { evalScripts: true }
);
       
       
     //  new Ajax.Updater({ success: idDocumento, failure: 'notice' }, strURL, {   parameters: { evalScripts: 'true' } }); 
       //new Ajax.Request(strURL,{
         //      method: 'get',
           //    contentType:'application/x-www-form-urlencoded',
             //  onSuccess: function(response) {
               //        updatepage(response.responseText,idDocumento);
      // }});

}


/*function caricaBanner(strURL,idDocumento) {
	var Elemento = document.getElementsByName('idDocumento');
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
        
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        
    }
    
    self.xmlHttpReq.open('GET', strURL, false);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,idDocumento);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}*/

/*function settaTipoligaPolymedia()
{
	
	var indexSelected = document.getElementById('selTipo').options.selectedIndex;
	var indexSelectedSotto = document.getElementById('selDue').options.selectedIndex;
	if (indexSelected==0)
	{
	alert("Scegliere la tipologia");
	}
	else
	{
		if (indexSelectedSotto==0)
		{
		alert("Scegliere il Sottostante");
		}
	else
	{
	    var scelta=document.getElementById('selTipo').options[indexSelected].value;
	       var sottostante=document.getElementById('selDue').options[indexSelectedSotto].value;
	    var tipPoly=scelta.substring(scelta.indexOf('-')+1,scelta.length);
	    var tipDB=scelta.substring(0,scelta.indexOf('-'));
	 	
	   var URLRicerca=document.TipoSottostante.action+"?PolyPage="+document.getElementById("PolyPage").value;
	       URLRicerca=URLRicerca+"&idNodo="+document.getElementById("idNodo").value;
	       URLRicerca=URLRicerca+"&idSelectVoce="+document.getElementById("idSelectVoce").value;
	       URLRicerca=URLRicerca+"&idtip="+document.getElementById("idtip").value;
 	       URLRicerca=URLRicerca+"&idTipDB="+scelta;
 	       URLRicerca=URLRicerca+"&id_tipoTab="+tipPoly;
	       URLRicerca=URLRicerca+"&idTipologiaDB="+tipDB;
	       URLRicerca=URLRicerca+"&idSottostante="+sottostante;
	      alert(URLRicerca);
	       document.location=URLRicerca;	
		
	
      }
}


}*/
function settaTipoligaPolymedia()
{
	//alert(document.getElementById("idNodo").value);
	
	var indexSelected = document.getElementById('selTipo').options.selectedIndex;
	var indexSelectedSotto = document.getElementById('selDue').options.selectedIndex;
	if (indexSelected==0)
	{
	alert("Scegliere la tipologia");
	}
	else
	{
		if (indexSelectedSotto==0)
		{
		alert("Scegliere il Sottostante");
		}
	else
	{
	    var scelta=document.getElementById('selTipo').options[indexSelected].value;
	       var sottostante=document.getElementById('selDue').options[indexSelectedSotto].value;
	      var IsinCode=document.getElementById('IsinCode').value;
 
	    var tipPoly=scelta.substring(scelta.indexOf('-')+1,scelta.length);
	    var tipDB=scelta.substring(0,scelta.indexOf('-'));
	    
	 	
	   var URLRicerca="TabelleGeneralizzate.jsp?PolyPage="+document.getElementById("PolyPage").value;
	       URLRicerca=URLRicerca+"&idNodo="+document.getElementById("idNodo").value;
	       URLRicerca=URLRicerca+"&idSelectVoce="+document.getElementById("idSelectVoce").value;
	       URLRicerca=URLRicerca+"&idtip="+document.getElementById("idtip").value;
 	       URLRicerca=URLRicerca+"&idTipDB="+scelta;
 	       URLRicerca=URLRicerca+"&id_tipoTab="+tipPoly;
	       URLRicerca=URLRicerca+"&idTipologiaDB="+tipDB;
	       URLRicerca=URLRicerca+"&idSottostante="+sottostante;
	      //URLRicerca=URLRicerca+"&isin="+IsinCode;
	  // alert(URLRicerca);
	       document.location=URLRicerca;	
	       
		
	
      }
}
}
function redirectTiplogiacodiceIsin(isincode,tipologia,isinpassato)
{
	

	 	
	   var URLRicerca="TabelleIsin.jsp?PolyPage=PP_Ricerca";
	       URLRicerca=URLRicerca+"&isin="+isincode;
	       URLRicerca=URLRicerca+"&tipologia="+tipologia;
	       URLRicerca=URLRicerca+"&isinPassato="+isinpassato;
	       URLRicerca=URLRicerca+"&idTipologiaDB="+tipologia;
	       
	       
	     
	       document.location=URLRicerca;	
		


}

function xmlhttpPostSottostante(strURL,id2Change,idSelected) 
{
	
	if (idSelected!=null)
	{
		var indexSelected = document.getElementById(idSelected).options.selectedIndex;
		var scelta=document.getElementById(idSelected).options[indexSelected].value;
		scelta=scelta.substring(0,scelta.indexOf('-'));
		strURL=strURL+scelta;
	}
	
	
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			updatepage(self.xmlHttpReq.responseText,id2Change);
		}
	}
	self.xmlHttpReq.send(getquerystring());
}

function VerificaCodiceIsin()
{
	var IsinInserito=document.getElementById("IsinCode").value;
	if(IsinInserito.length<7)
	{
	alert("Attenzione! Il numero minimo di caratteri da inserire per la ricerca è 7");
	}
	else
	{
		
		var URLRicerca="DefaultSenzaSpalla.jsp?PolyPage="+document.getElementById("PolyPageIsin").value;
	  URLRicerca=URLRicerca+"&idNodo="+document.getElementById("idNodoIsin").value;
		URLRicerca=URLRicerca+"&idSelectVoce="+document.getElementById("idSelectVoceIsin").value;
		URLRicerca=URLRicerca+"&idtip="+document.getElementById("idtipIsin").value;
		URLRicerca=URLRicerca+"&Isin="+document.getElementById("IsinCode").value;
		
	 document.location=URLRicerca;
	}
}

function  SETTAcomboTipologieSottostanti(ID,sottostante )
	{
		 var obj = document.getElementById('selTipo');
                if (obj)
            {
                for(var index=0; index<obj.options.length; index++)
                {
                    if (obj.options[index].value==ID)
                    {
                        obj.selectedIndex = index;
                       
                        xmlhttpPostSottostante('comboSottostanteDB.jsp?tipologia=','combo','selTipo',sottostante)
                        
                         
                     }	
	        }
	   }
}

function xmlhttpPostSottostante(strURL,id2Change,idSelected,sottostante) 
{

	if (idSelected!=null)
	{
		var indexSelected = document.getElementById(idSelected).options.selectedIndex;
		var scelta=document.getElementById(idSelected).options[indexSelected].value;
		scelta=scelta.substring(0,scelta.indexOf('-'));
		strURL=strURL+scelta;
	}
	
	
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
	     self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
	     self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if (self.xmlHttpReq.readyState == 4) 
		{
			updatepage(self.xmlHttpReq.responseText,id2Change);
			var obj2 = document.getElementById('selDue');
                         if (obj2)
           		 {
	       			 for(var index=0; index<obj2.options.length; index++)
	       			 {
	          		  if (obj2.options[index].value==sottostante)
	                          {
	                            obj2.selectedIndex = index;
	                            break;
	                          } 
                                }
                          }
		}
	}
	self.xmlHttpReq.send(getquerystring());
	
}

function InviaMail2()
{
	var URLDoc=document.location.href;
	
	//Esempio costruzione Body
	//body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph
	//Use "%0A" for a new line, use "%0A%0A" for a new line preceded by a blank line
	var body="Inserire un tuo commento non modificando l'URL riportato sotto%0A%0A"+encodeURIComponent(URLDoc);
	
	 document.location.href("mailto:inserisci la mail di un tuo amico?subject=Segnalazione Pagina Gestielle&body="+body);
}

function InviaMail()
{
	var URLDoc=document.location.href;
	
	//Esempio costruzione Body
	//body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph
	//Use "%0A" for a new line, use "%0A%0A" for a new line preceded by a blank line
	var body=" %0A%0A"+encodeURIComponent(URLDoc);
	
	 document.location.href("mailto:?subject= &body="+body);
}
function  vaiSingolo(codiceIsin)
	{
			var URL="certificateHomePage.jsp?isin="+codiceIsin;
			document.location.href=URL;
	

	}
