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=no, location=no, toolbar=no, directories=no, status=no, resizable=no, height=" + height + ",width=" + width + ",top=" + t + ",left=" + l);
  popupWindow.focus();
}

function closePopUp()
{
  opener.location.reload(true);
  window.parent.focus();
  window.close(); 
}

function submitForm()
{
  window.document.forms[0].submit();
}

function writeArrow(leftPos){	
	document.write('<div class="arrow" id="arrow" style="left:'+leftPos+'px;"></div>');
	}	
	
function writeLine(widthline,posline,direction){
	if(direction == 0){
		document.write('<div class="whiteline" id="line1" style="width:'+ widthline +'px;left:'+ posline +'px"></div>');
		}
	else{
		document.write('<div class="whiteline" id="line1" style="width:'+ widthline +'px;right:'+ posline +'px"></div>');
	}			
			
	}	
	
function validateEmail(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 checkMail(){
  if(document.forms['frmSend'].elements['confirmdati'].checked){			
    if(validateEmail(document.forms['frmSend'].elements['phmail'])){
      document.forms['frmSend'].submit();
      }
    else{
        alert("Controllare la mail inserita");
        return false;
      }	
    }
  else{
    alert("Accettare le condizioni sulla provacy");
    return false;
    }
}