// JavaScript Document

//reset tag
function betterMo() {
	if (confirm("Sei sicuro di voler azzerare i campi?")) {
		document.modulo.reset();
		}
}
// fine

//funzione campi obbligatori
	function checkform(which){
		var pass=true
		if (document.images){
		for (i=0;i<which.length;i++){
		var tempobj=which.elements[i]
		if (tempobj.name.substring(0,4)=="form"){
		if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
		pass=false
		break
		}
		}
		}
		}
		if (!pass){
		alert("Attenzione, tutti i campi sono obbligatori. Clicca su OK per continuare.")
		return false
		}
		else
		return true
	}
// fine

//funzione per  aggiungere i tag grassetto, sottolineato e corsivo
function AddMessageCode(code, promptText, InsertText) {

	if (code != "") {
			insertCode = prompt(promptText + "\n<" + code + ">xxx</" + code + ">", InsertText);
				if ((insertCode != null) && (insertCode != "")){
					document.modulo.form_testo.value += "<" + code + ">" + insertCode + "</" + code + ">";
				}
	}
				
	document.modulo.form_testo.focus();
}
// fine

//funzione conta caratteri
function conta(){
		var lenMax=350
		var strlength=document.modulo.form_testo.value.length
		total = eval("350")
		char = eval(document.modulo.form_testo.value.length)
		left = eval(total - char)
		if (left <= "-1")
	{
		var dif = eval(char - 350)
		var value = document.modulo.form_testo.value.substr(0,char-dif);
		document.modulo.form_testo.value = value;
		var left = "0"
	}
	document.modulo.quanti.value=left
}
// fine

// funzione per aggiungere gli smile al messaggio
function AddSmile(code) {	
		document.modulo.form_testo.value += code + " ";
		document.modulo.form_testo.focus();
}
// fine

// funzione per aprire finestra pop un
function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}
// fine

// capcha
function reloadCAPTCHA() {
	document.getElementById('CAPTCHA').src='/CAPTCHA/CAPTCHA_image.asp?'+Date();
}
// scambio id
function scambio(id){
	 if (document.getElementById){
    		if(document.getElementById(id).style.display == 'none'){
      			document.getElementById(id).style.display = 'block';
    		} else {
      			document.getElementById(id).style.display = 'none';
    		}
  	}
}
//-->