// Funzioni comuni JavaScript

<!-- Funzione per aprire le nuove finestre con ECMAScript accessibile. -->

function apri(uri,nome,mnbar,tlbar,lcbar,drbar,scbar,stbar,rsz,wdt,hgt) {
window.open(uri,nome,"menubar=" + mnbar + ",toolbar=" + tlbar + ",location=" + lcbar + ",directories=" + drbar + ",scrollbars=" + scbar + ",status=" + stbar + ",resizable=" + rsz + ",width=" + wdt + ",height=" + hgt);
}

// Funzione per inserire testo formattato nell'area di testo del messaggio

function txtFormat(tagelem) {
var frase = "";
switch (tagelem) {
case "b":
frase = "in grassetto";
break;
case "i":
frase = "in corsivo";
break;
case "u":
frase = "come sottolineato";
break;
case "s":
frase = "come barrato";
break;
}
var txt = window.prompt("Inserire il testo da formattare " + frase + ".","");
if (txt!="" && txt!=null) document.getElementById("messaggio").value = document.getElementById("messaggio").value + " [" + tagelem.toUpperCase() + "]" + txt + "[/" + tagelem.toUpperCase() + "] ";
}

// Funzione per inserire un'immagine

function img() {
var txt = window.prompt("Inserire l'indirizzo http:// dell'immagine ");
if (txt!="" && txt!=null) document.getElementById("messaggio").value = document.getElementById("messaggio").value + " [IMG]" + txt + "[/IMG] ";
}

// Funzione per inserire gli smilies nell'area di testo del messaggio

function addSmile(smile) {
var faccina = " " + smile;
document.getElementById("messaggio").value += faccina;
}

// Variabile globale e funzione per selezionare/deselezionare tutti i messaggi nella pagina amministrativa

var actv = 0;

function activateAll(txtselect,txtdeselect) {
actv = (actv==0)? 1 : 0;
var f = document.getElementById("modulomsg");
for (i=0; i<f.elements.length; i++) {
if (f.elements[i].type=="checkbox") {
f.elements[i].checked = (actv==1)? true : false;
}
}
if (actv==0) {
var statimg = "on";
var textlink = txtselect;
}
else {
var statimg = "off";
var textlink = txtdeselect;
}
document.getElementById("selezionatutti").innerHTML = document.getElementById("selezionatutti").title = textlink;
document.getElementById("selezionatutti").style.backgroundImage = "url(../images/iconselall" + statimg + ".gif)";
}

// Funzione per confermare l'eliminazione di un messaggio

function conferma(txtconferma) {
var ask = window.confirm(txtconferma);
if (ask) {
document.getElementById("modulomsg").submit();
return true;
}
else {
return false;
}
}