// JavaScript Document

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function dataita() {
      document.write("<object type='application/x-shockwave-flash' data='DataIta.swf' width='170' height='45' id='dataita'> ");
      document.write("<param name='movie' value='DataIta.swf' /> ");
      document.write("<param name='quality' value='high' /><param name='wmode' value='transparent' /> ");
      document.write("</object> ");
}

function mostrasanto(datasanto) {
      document.write("<iframe src='http://www.acor3.it/public/test/santo.asp?data=" + datasanto + "' frameborder='0' id='boxsanto' style='font-size:10px;background-color:#ff6600'></iframe>");
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Auto scroll
function flvS3(v1){//v1.0
var v2=MM_findObj(v1),v3=0,v4=0,v5=0,v6=0;if (!v2){this.x=this.y=this.h=this.w=0;return;}var v7=(document.layers)?v2:v2.style;v3=v7.left;v4=v7.top;if ((v3==""||v4=="")&&document.all&&!window.opera){if (v3==""){v3=v2.offsetLeft;}if (v4==""){v4=v2.offsetTop;}}if (v2.offsetHeight){v5=v2.offsetHeight;v6=v2.offsetWidth;}else if (document.layers){v5=v7.clip.height;v6=v7.clip.width;}this.x=parseInt(v3);this.y=parseInt(v4);this.h=parseInt(v5);this.w=parseInt(v6);}

function flvS8(v1,v2,v3){//v1.0
var v4=(document.layers)?v1:v1.style;var v5=flvS5();eval("v4.left='"+v2+v5+"'");eval("v4.top='"+v3+v5+"'");}

function flvS5(){//v1.0
var v1=((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1)&&(!window.opera))?"px":"";return v1;}

//scroll News
function flvXAS1(){
var v1=arguments,v2=v1.length,v3='MainScrollingNews',v4='SlaveScrollingNews';var v5=MM_findObj(v3),v6=MM_findObj(v4);if (!v5){return;}if (v5.XAS1!=null){clearTimeout(v5.XAS1);}var v7=(v2>0)?parseInt(v1[0]):1;if (v7){var v8=(v2>1)?parseInt(v1[1]):1,v9=(v2>2)?parseInt(v1[2]):50,v10=(v2>3)?parseInt(v1[3]):1;var v11=new flvS3(v3),v12=new flvS3(v4);var v13=v12.x,v14=v12.y,v15=0,v16=0;if (v10==1){var v17=-1*v12.h;v15=v12.x;if (v14>=v17){v16=v12.y-v8;}else {v16=v11.h;}}else {var v18=-1*v12.w;v16=v12.y;if (v13>=v18){v15=v12.x-v8;}else {v15=v11.w;}}flvS8(v6,v15,v16);v5.XAS1=setTimeout("flvXAS1("+v7+","+v8+","+v9+","+v10+")",v9);}}

//scroll Messaggi
function flvXAS2(){
var v1=arguments,v2=v1.length,v3='MainScrollingMex',v4='SlaveScrollingMex';var v5=MM_findObj(v3),v6=MM_findObj(v4);if (!v5){return;}if (v5.XAS1!=null){clearTimeout(v5.XAS1);}var v7=(v2>0)?parseInt(v1[0]):1;if (v7){var v8=(v2>1)?parseInt(v1[1]):1,v9=(v2>2)?parseInt(v1[2]):50,v10=(v2>3)?parseInt(v1[3]):1;var v11=new flvS3(v3),v12=new flvS3(v4);var v13=v12.x,v14=v12.y,v15=0,v16=0;if (v10==1){var v17=-1*v12.h;v15=v12.x;if (v14>=v17){v16=v12.y-v8;}else {v16=v11.h;}}else {var v18=-1*v12.w;v16=v12.y;if (v13>=v18){v15=v12.x-v8;}else {v15=v11.w;}}flvS8(v6,v15,v16);v5.XAS1=setTimeout("flvXAS2("+v7+","+v8+","+v9+","+v10+")",v9);}}

//funzione blankizza
function blankizza() { 
	for (var i=0; i<document.links.length; i++)
		if (document.links[i].className=="blankwin") {
			document.links[i].target="_blank";
		} 
}


function validateadesione(Form1){
var dtCh= "/";
var minYear=1928;
var maxYear=2111;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Formato data non corretto : dd/mm/aaaaa")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Inserire mese valido")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Inserire giorno valido")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Digitare un anno in formato AAAA compreso tra "+minYear+" e "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Vi preghiamo di inserire una data valida")
		return false
	}
return true
}


	var dt=document.Form1.Data
	if (dt.value!="") {
		if (isDate(dt.value)==false){
		dt.focus()
		return false
		}
	}
	
	//CAMPI VUOTI
	
	
	Form1.Cognome.value=Form1.Cognome.value.replace(/^\s*|\s(?=\s)|\s*$/g, "");
    if (Form1.Cognome.value==''){
	alert("Si prega di inserire il Cognome.");
	Form1.Cognome.focus();
	return false;
    };
	Form1.Nome.value=Form1.Nome.value.replace(/^\s*|\s(?=\s)|\s*$/g, "");
    if (Form1.Nome.value==''){
	alert("Si prega di inserire il Nome.");
	Form1.Cognome.focus();
	return false;
    };
	 
   checkEmail =  Form1.Email.value
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))){
	alert("Si prega un indirizzo di posta elettronica valido.");
	Form1.Email.select();
	return false;
	} 
	
	Form1.Provincia.value=Form1.Provincia.value.replace(/^\s*|\s(?=\s)|\s*$/g, "");
    if (Form1.Provincia.value==''){
	alert("Si prega di selezionare una Provincia.");
	Form1.Provincia.focus();
	return false;
    };
	
    if (!Form1.privacy.checked){
	alert("Impossibile continuare senza fornire il consenso al trattamento dei datipersonali.");
	return false;
    };
}
