
function confermaDel (url) {
  chiediConferma = confirm('Volete eliminare il Post?');
  
  if (chiediConferma == true){
    location.href=(url); //ricarica la pagina
  }

}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function PopupCentrata(theUrl,w,h) {
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open(theUrl,"","scrollbars=1,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }


function changeLocation(menuObj) {
  var i = menuObj.selectedIndex;
  if(i > 0) {
    window.location = menuObj.options[i].value;
  }
}

function confermaDel (url) {
  chiediConferma = confirm('Volete DAVVERO eliminare TUTTA una Lingua');
  
  if (chiediConferma == true){
    location.href=(url); //ricarica la pagina
  }

}

function spedisci() {
	errors = new Array(24);
	errcounter = 0;
	if (!document.form.cname.value) {
		errors[errcounter] = "- Campo obbligatorio \"Nome della ditta\" non riempito.\n"
		errcounter++;
	}
	if (!document.form.email.value) {
		errors[errcounter] = "- Campo obbligatorio \"E-mail\" non riempito.\n"
		errcounter++;
	}
	else {
		field = "document.form.email.value";
		re=/^([\.A-Za-z0-9_-]+)@([a-z0-9-]+(\.[a-z0-9-]+)*)\.([a-z0-9-]+)$/;
		if (!re.test(eval(field))) {
			errors[errcounter] = "- L'indirizzo e-mail non sembra valido.\n"
			errcounter++;
		}
	}
	if (document.form.acc1[1].checked || document.form.acc2[1].checked) {
		errors[errcounter] = "- Informativa sulla privacy non accettata.\n"
		errcounter++;
	}
	if (!controllo_testo(document.form.notes.value)) {
		errors[errcounter] = "- Troppo testo nelle note.\n"
		errcounter++;
	}
	if (errors[0]) {
		var i = 0;
		var errormessages = "Per favore controllare i seguenti errori:\n";
		while (errors[i]) {
			errormessages += errors[i];
			i++;
		}
		alert(errormessages);
	}	
	if (errcounter == 0) {
		document.form.mode.value = "send";
		document.form.submit();
	}
}

function spedisciEng() {
	errors = new Array(24);
	errcounter = 0;
	if (!document.form.cname.value) {
		errors[errcounter] = "- Required field \"Company name\".\n"
		errcounter++;
	}
	if (!document.form.email.value) {
		errors[errcounter] = "- Required field \"E-mail\".\n"
		errcounter++;
	}
	else {
		field = "document.form.email.value";
		re=/^([\.A-Za-z0-9_-]+)@([a-z0-9-]+(\.[a-z0-9-]+)*)\.([a-z0-9-]+)$/;
		if (!re.test(eval(field))) {
			errors[errcounter] = "-E-mail address form is invalid.\n"
			errcounter++;
		}
	}
	if (!controllo_testo(document.form.notes.value)) {
		errors[errcounter] = "- Too much words in the notes.\n"
		errcounter++;
	}
	if (errors[0]) {
		var i = 0;
		var errormessages = "Please check out next errors:\n";
		while (errors[i]) {
			errormessages += errors[i];
			i++;
		}
		alert(errormessages);
	}	
	if (errcounter == 0) {
		document.form.mode.value = "send";
		document.form.submit();
	}
}


function salva() {
	errors = new Array(24);
	errcounter = 0;
	if (!document.form.cname.value) {
		errors[errcounter] = "- Campo obbligatorio \"Nome della ditta\" non riempito.\n"
		errcounter++;
	}
	if (!document.form.email.value) {
		errors[errcounter] = "- Campo obbligatorio \"E-mail\" non riempito.\n"
		errcounter++;
	}
	else {
		field = "document.form.email.value";
		re=/^([\.A-Za-z0-9_-]+)@([a-z0-9-]+(\.[a-z0-9-]+)*)\.([a-z0-9-]+)$/;
		if (!re.test(eval(field))) {
			errors[errcounter] = "- L'indirizzo e-mail non sembra valido.\n"
			errcounter++;
		}
	}
	if (document.form.acc1[1].checked || document.form.acc2[1].checked) {
		errors[errcounter] = "- Informativa sulla privacy non accettata.\n"
		errcounter++;
	}
	if (!controllo_testo(document.form.notes.value)) {
		errors[errcounter] = "- Troppo testo nelle note.\n"
		errcounter++;
	}
	if (errors[0]) {
		var i = 0;
		var errormessages = "Per favore controllare i seguenti errori:\n";
		while (errors[i]) {
			errormessages += errors[i];
			i++;
		}
		alert(errormessages);
	}	
	if (errcounter == 0) {
		document.form.mode.value = "save";
		document.form.submit();
	}
}
function controllo_email() { //v.0.9
	re=/^([\.A-Za-z0-9_-]+)@([a-z0-9-]+(\.[a-z0-9-]+)*)\.([a-z0-9-]+)$/;
	if (!re.test(controllo_email.arguments[0])) {
		return false;
	}
	else return true;
}
function controllo_testo(value) {
	if (value.length > 1800) {
		return false;
	}
	else return true;
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}