

function ingrandisci_img(immagine)
	{
	popupImage = window.open('','','toolbar=0,location=no,directories=0,menuBar=0,scrollbars=0,resizable=0,top=10,left=50');
	popupImage.document.open();
	popupImage.document.write("<img src='" + immagine + "' name='imageTest' onLoad='if(this.height>640) this.height=640; window.resizeTo(document.imageTest.width+30,document.imageTest.height+100);'>");
	popupImage.document.close()
	};

function pulisci(id){
   document.getElementById(id).value="";
}

function controlla(id){
   var p=document.getElementById(id);
   if(p.value=="")
   		{
			 p.focus();
			 alert("Devi inserire il " + id + "!");
		}
}

function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','left=100,top=100,width=400')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<TITLE>Print Page</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write(str)
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

function printStr(str){
newwin=window.open('','printwin','left=100,top=100,width=500')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<TITLE>Anteprima di Stampa</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write(str)
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

function ShowMenu(URL, WinTitle, WinWidth, WinHeight, WinLeft, WinTop){
	attr = "resizable=no,width=" + WinWidth + ",height=" + WinHeight + ",screenX=" + WinLeft + ",screenY=" + WinTop + ",left=" + WinLeft + ",top=" + WinTop + "";
	msgWindow=open(URL, WinTitle, attr);
	if (msgWindow.opener == null) msgWindow.opener = self;
}

function ShowHide(id){
 if(document.getElementById){
  var el=document.getElementById(id);
  el.style.display = (el.style.display=="block") ? "none" : "block";
 }
} 



// faccio il preload dell'immagine utilizzata per l'effetto rollover
var staron = new Image(); staron.src = ".//css//star-on.gif";

// Definisco la funzione per la votazione che verrā lanciata
// all'evento onclick su una delle 5 stelle
function star_vota(QT)
{
  // Creo una variabile con l'output da restituire al momento del voto
  var star_output = '<span class="output">Hai votato ' + QT + ' stelle!</span>';
  // Cambio dinamicamente il contenuto del DIV contenitore con il messaggio di
  // conferma di votazione avvenuta
  document.getElementById('STAR_RATING').innerHTML = star_output;
}

// Definisco la funzione per "accendere" dinamicamente le stelle
// unico argomento č il numero di stelle da accendere
function star_accendi(QT)
{
  // verifico che esistano i DIV delle stelle
  // se il DIV non esiste significa che si č giā votato
  if (document.getElementById('star_1'))
  {
    // Ciclo tutte e 5 i DIV contenenti le stelle
    for (i=1; i<=5; i++)
    {
      // se il div č minore o uguale del numero di stelle da accendere
      // imposto dinamicamente la classe su "on"
      if (i<=QT) document.getElementById('star_' + i).className = 'on';
      // in caso contrario spengo la stella...
      else document.getElementById('star_' + i).className = '';
    }
  }
}

// Questa č la funzione che produce l'output.
// richiede come unico argomento il numero di stelle che si vuole accendere
// di default (possiamo in questo, ad esempio, modo mostrare il voto ottenuto
// nelle precedenti votazioni)
function star(QT,ID,LOC)
{
  // stampo il codice HTML che produce le stelle
  document.write('<div id="STAR_RATING" onmouseout="star_accendi(' + QT + ')"">');
  document.write('<a id="star_1" href="?loc=' + LOC + '&id='+ID+'&star=1#voto" onmouseover="star_accendi(0); star_accendi(1)" ALT="Voto 1" TITLE="Voto 1"></a>');
  document.write('<a id="star_2" href="?loc=' + LOC + '&id='+ID+'&star=2#voto" onmouseover="star_accendi(0); star_accendi(2)" ALT="Voto 2" TITLE="Voto 2"></a>');
  document.write('<a id="star_3" href="?loc=' + LOC + '&id=' + ID +'&star=3#voto" onmouseover="star_accendi(0); star_accendi(3)" ALT="Voto 3" TITLE="Voto 3"></a>');
  document.write('<a id="star_4" href="?loc=' + LOC + '&id='+ ID + '&star=4#voto" onmouseover="star_accendi(0); star_accendi(4)" ALT="Voto 4" TITLE="Voto 4"></a>');
  document.write('<a id="star_5" href="?loc=' + LOC + '&id=' + ID + '&star=5#voto"  onmouseover="star_accendi(0); star_accendi(5)" ALT="Voto 5" TITLE="Voto 5"></a>');
  document.write('</div>');
  // accendo le stelle definite in argomento
  star_accendi(QT);
}

function ShowHide(id){
 if(document.getElementById){
  var el=document.getElementById(id);
  el.style.display = (el.style.display=="block") ? "none" : "block";
 }
} 

