function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function page_Over(idImage,message) {	
	if (document.getElementById(idImage)) {
		myImage = document.getElementById(idImage).src;
		document.getElementById(idImage).src = myImage.replace('.gif','Over.gif');
		document.getElementById('pageMessage').innerHTML = message;
	}
}

function page_Out(idImage,message) {
	if (document.getElementById(idImage)) {
		myImage = document.getElementById(idImage).src;
		document.getElementById(idImage).src = myImage.replace('Over.gif','.gif');
		document.getElementById('pageMessage').innerHTML = message;
	}
}

	var TabSelected=0;
	var TabLimit=20;

	function OpenCloseTab(me){

		TabSelected=me;
		for (i=0;i<=20;i++) {

			if (i!=me) {
				if (document.getElementById('Tab' + i)!='undefined' ) {
					document.getElementById('Tab' + i).style.visibility="hidden";
					document.getElementById('Tab' + i).style.display="none";
					document.getElementById('Tab' + i).style.height="0px";			
					document.getElementById('TabCapSX' + i).src="template/img_struct/tabPartSX.gif";
					document.getElementById('TabCapDX' + i).src="template/img_struct/tabPartDX.gif";
					document.getElementById('TabCapBg' + i).style.backgroundImage="url(template/img_struct/tabBgr.gif)";
					document.getElementById('TabCapBg' + i).style.fontWeight="normal";
					document.getElementById('TabCapBg' + i).style.fontColor="#333333";
				}
			} else {
			
				if (document.getElementById('Tab' + i)!='undefined') document.getElementById('Tab' + me).style.visibility="visible";
				if (document.getElementById('Tab' + i)!='undefined') document.getElementById('Tab' + me).style.display="";
				if (document.getElementById('Tab' + i)!='undefined') document.getElementById('Tab' + me).style.height="auto";
				if (document.getElementById('TabCapSX' + i)!='undefined') document.getElementById('TabCapSX' + i).src="template/img_struct/tabPartSXOver.gif";
				if (document.getElementById('TabCapDX' + i)!='undefined') document.getElementById('TabCapDX' + i).src="template/img_struct/tabPartDXOver.gif";
				if (document.getElementById('TabCapBg' + i)!='undefined') document.getElementById('TabCapBg' + i).style.backgroundImage="url(template/img_struct/tabBgrOver.gif)";
				if (document.getElementById('TabCapBg' + i)!='undefined') document.getElementById('TabCapBg' + i).style.fontWeight="bold";
				if (document.getElementById('TabCapBg' + i)!='undefined') document.getElementById('TabCapBg' + i).style.fontColor="#000000";
	
			}
		}
	}
	
	function OnTab(i) {
		if (i!=TabSelected) {
			if (document.getElementById('Tab' + i)!='undefined' ) {
				document.getElementById('TabCapSX' + i).src="template/img_struct/tabPartSXOn.gif";
				document.getElementById('TabCapDX' + i).src="template/img_struct/tabPartDXOn.gif";
				document.getElementById('TabCapBg' + i).style.backgroundImage="url(template/img_struct/tabBgrOn.gif)";		
			}
		}
	}
	
	function OffTab(i) {
		if (i!=TabSelected) {
			if (document.getElementById('Tab' + i)!='undefined' ) {
				document.getElementById('TabCapSX' + i).src="template/img_struct/tabPartSX.gif";
				document.getElementById('TabCapDX' + i).src="template/img_struct/tabPartDX.gif";
				document.getElementById('TabCapBg' + i).style.backgroundImage="url(template/img_struct/tabBgr.gif)";		
			}
		}
	}
	
function ControlScheda(numScheda) {

	errorField = "";
	if (numScheda==0) {
		if (document.getElementById('Name').value=="") errorField += "- Nome\n";
		if (document.getElementById('LastName').value=="") errorField += "- Cognome\n";
		if (document.getElementById('Email').value=="") errorField += "- E-mail\n";
		if (document.getElementById('Email2').value=="") errorField += "- Conferma E-mail\n";
		if (document.getElementById('Password')) if (document.getElementById('Password').value=="") errorField += "- Password\n";
		if (document.getElementById('Password')) if (document.getElementById('Password2').value=="") errorField += "- Conferma Password\n";
		if (document.getElementById('Password_Request')) if (document.getElementById('Password_Request').value=="") errorField += "- Domanda segreta\n";
		if (document.getElementById('Password_Response')) if (document.getElementById('Password_Response').value=="") errorField += "- Risposta (a Domanda segreta)\n";
		if (document.getElementById('BirtD_D').value=="") errorField += "- Data di nascita (Giorno)\n";
		if (document.getElementById('BirtD_M').value=="") errorField += "- Data di nascita (Mese)\n";
		if (document.getElementById('BirtD_Y').value=="") errorField += "- Data di nascita (Anno)\n";
		if (document.getElementById('Country').value=="") errorField += "- Nazione\n";
	
	}	
	if (numScheda==1) {
		if (document.getElementById('Address').value=="") errorField += "- Indirizzo\n";
		if (document.getElementById('NCiv').value=="") errorField += "- N° Civico\n";
		if (document.getElementById('CAP').value=="") errorField += "- CAP\n";
		if (document.getElementById('City').value=="") errorField += "- Cittą\n";
		if (document.getElementById('Regione').value=="") errorField += "- Regione\n";
	
	}	
	
	if (errorField!="") {
		alert("ATTENZIONE! Non sono stati compilati i seguenti campi:\n\n"+errorField);
	}
		
	if (errorField=="") {
		if (document.getElementById('Email').value!=document.getElementById('Email2').value) {
			alert("ATTENZIONE! La Conferma Email non corrisponde all'Email inserita");
			errorField = "Email";
		}
	}		
	if (errorField=="") {
		if (document.getElementById('Password')) {
		if (document.getElementById('Password').value!=document.getElementById('Password2').value) {
			alert("ATTENZIONE! La Conferma Password non corrisponde alla Password inserita");
			errorField = "Password";
		}
		if (document.getElementById('Password').value.length<6) {
			alert("ATTENZIONE! La Password deve essere di almeno 6 caratteri");
			errorField = "Password";
		}
		}
	}
	if ((errorField=="")&&(numScheda==1)) {
		if (document.getElementById('Privacy1')) {
		if (document.getElementById('Privacy1').checked == false) {
			alert("ATTENZIONE! Non sono state accettate le Condizioni Generali di partecipazione al programma Shop & Fly");
			errorField = "Privacy";
		}
		}
		if (document.getElementById('Privacy2')) {
		if (document.getElementById('Privacy2').value != "Y") {
			alert("ATTENZIONE! Non sono state accettate le Dichiarazioni di consenso per la partecipazione al programma Shop & Fly");
			errorField = "Privacy";
		}
		}
		if (document.getElementById('Privacy3')) {
		if (document.getElementById('Privacy3').value != "Y") {
			alert("ATTENZIONE! Non sono state accettate le Dichiarazioni di consenso per la partecipazione al programma Shop & Fly");
			errorField = "Privacy";
		}
		}
	}
	if (errorField=="") {
		OpenCloseTab(numScheda+1)
	}
}

function ConfirmMessage(message,link)	{
	//alert(message);
	if (confirm(message)) location.href = link;
}

function ConfirmMessageFormAlitalia(message)	{
	//alert(message);
	if (confirm(message)) {
		document.getElementById('Form_MilleMiglia').submit();
	}
}

