function sendEmail(sUser, sDomain)
{
	sSubject = "Contatto da MolinellaWeb.it"
	location.href = 'mailto:' + sUser + '@' + sDomain + '?subject=' + sSubject;
}

function sendEmail2(sUser, sDomain, sSubject)
{
	location.href = 'mailto:' + sUser + '@' + sDomain + '?subject=' + sSubject;
}

function NewWindow(mypage, myname, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable=yes,directories=no,status=no,location=no,toolbar=no';
	win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function validate_form() {
  validity = true; // assume valid
  var msg="";
  if (!check_empty(document.form1.RagSoc.value))
  	{ validity = false; msg=msg+'Inserire Ragione sociale\n'; }
  if (!check_empty(document.form1.Resp.value))
  	{ validity = false; msg=msg+'Inserire Responsabile\n'; }
  if (!check_empty(document.form1.Indirizzo.value))
  	{ validity = false; msg=msg+'Inserire Indirizzo\n'; }
  if (!check_empty(document.form1.CAP.value))
  	{ validity = false; msg=msg+'Inserire CAP\n'; }
  if (!check_empty(document.form1.Localita.value))
  	{ validity = false; msg=msg+'Inserire Localita\'\n'; }
  if (!check_provincia())
  	{ validity = false; msg=msg+'Scegliere la Provincia\n'; }
  if (!check_empty(document.form1.Tel.value))
  	{ validity = false; msg=msg+'Inserire Telefono\n'; }
  if (!check_empty(document.form1.Fax.value))
  	{ validity = false; msg=msg+'Inserire Fax\n'; }
  if (!check_empty(document.form1.web.value) || document.form1.web.value=='http://')
  	{ validity = false; msg=msg+'Inserire Indirizzo Sito Internet\n'; }
  if (!check_empty(document.form1.email.value) || !check_email(document.form1.email.value))
  	{ validity = false; msg=msg+'E-Mail non corretta\n'; }
  if (!check_categoria())
  	{ validity = false; msg=msg+'Scegliere la Categoria\n'; }
  if (!check_accetto())
  	{ validity = false; msg=msg+'Accettare le condizioni\n'; }
  if (!validity)
	alert("I seguenti dati sono mancanti: \n"+msg);
  return validity;
}

function validate_form2() {
  validity = true; // assume valid
  var msg="";
  if (!check_empty(document.form1.Persona.value))
  	{ validity = false; msg=msg+'Inserire Nome e cognome\n'; }
  if (!check_empty(document.form1.Indirizzo.value))
  	{ validity = false; msg=msg+'Inserire Indirizzo\n'; }
  if (!check_empty(document.form1.CAP.value))
  	{ validity = false; msg=msg+'Inserire CAP\n'; }
  if (!check_empty(document.form1.Localita.value))
  	{ validity = false; msg=msg+'Inserire Localita\'\n'; }
  if (!check_provincia())
  	{ validity = false; msg=msg+'Scegliere la Provincia\n'; }
  if (!check_empty(document.form1.Tel.value))
  	{ validity = false; msg=msg+'Inserire Telefono\n'; }
  if (!check_empty(document.form1.email.value) || !check_email(document.form1.email.value))
  	{ validity = false; msg=msg+'E-Mail non corretta\n'; }
  if (!check_accetto())
  	{ validity = false; msg=msg+'Accettare le condizioni\n'; }
  if (!validity)
	alert("I seguenti dati sono mancanti: \n"+msg);
  return validity;
}

function check_email(EMail) {
  if ((EMail == "")
    || (EMail.indexOf ('@') == -1)
    || (EMail.indexOf ('.') == -1))
      return false;
  return true;
}

function check_empty(text) {
	text = stripSpaces(text);
	return (text.length > 2);
}

function stripSpaces(x) {
    return x.replace(/^\W+/,'').replace(/\W+$/,'');
}

function check_provincia() {
	if (document.form1.Prov.options[document.form1.Prov.selectedIndex].value == '')
		return false;
  return true;
}

function check_categoria() {
	if (document.form1.Cat.options[document.form1.Cat.selectedIndex].value == '')
		return false;
  return true;
}

function check_accetto() {
	if (!document.form1.accetto.checked)
		return false;
	return true;
}
