
/* FORM CONTROLS */


function privacyValidator(idPush)
	{
	accept = document.getElementById('accept').checked
		if (accept == true)
		{
		document.getElementById(idPush).disabled = false;
		
		}
	
		if (accept == false)
		{
		document.getElementById(idPush).disabled = true;
		
		}
	
	}


function isNotValidEmail(elem) {
	var str = elem.value;
	var re  = /\b[a-z0-9._%-]+@[a-z0-9._%-]+\.[a-z0-9._%-]{2,4}\b/;
	if (!str.match(re))
		return false;
	else
		return true;
}



function formValidator(theForm)
{

  

  if (theForm.dato_email.value == "")
  {
    alert('La mail è obbligatoria');
    theForm.dato_email.focus();
    return (false);
  }
	
	if (!isNotValidEmail(document.forms['formContacts'].elements['dato_email']))
	{
		alert("il formato dell'email non è corretto");
		return false;
	}
	

  if (theForm.dato_note.value == ""  || theForm.dato_note.value == " " )
  {
    alert('Inserire una richiesta informativa');
    theForm.dato_note.focus();
    return (false);
  }
  return (true);
}

function nlValidator(theForm)
{

  

  if (theForm.dato_email.value == "")
  {
    alert('La mail è obbligatoria');
    theForm.dato_email.focus();
    return (false);
  }
	
	if (!isNotValidEmail(document.forms['formNewsletter'].elements['dato_email']))
	{
		alert("il formato dell'email non è corretto");
		return false;
	}
	
  return (true);
}


function showHideContent(s,h, idButton1, idButton2)
{
   document.getElementById(idButton1).className = 'btnActive';
   document.getElementById(idButton2).className = 'btnTab';
   document.getElementById(s).style.display = 'block';
   document.getElementById(h).style.display = 'none';
}


/*### PopUp ###*/

function openpopupWindow(popupURL, width, height) 
  {
     var w = width;
     var h = height;
     var l = Math.floor((screen.width-w)/2);
     var t = Math.floor((screen.height-h)/2);
     popupWindow = window.open(popupURL,"popupWindowDoc","scrollbars=,location=no,toolbar=no,directories=no,status=no,resizable=no,height=" + height + ",width=" + width + ",top=" + t + ",left=" + l); 
  	popupWindow.focus();
  }
