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 += "- Name\n";
		if (document.getElementById('LastName').value=="") errorField += "- Surname\n";
		if (document.getElementById('Email').value=="") errorField += "- E-mail\n";
		if (document.getElementById('Email2').value=="") errorField += "- Confirm 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 += "- Confirm Password\n";
		if (document.getElementById('Password_Request')) if (document.getElementById('Password_Request').value=="") errorField += "- Secret Question\n";
		if (document.getElementById('Password_Response')) if (document.getElementById('Password_Response').value=="") errorField += "- Response (Secret Question)\n";
		if (document.getElementById('BirtD_D').value=="") errorField += "- Birth Date (DAy)\n";
		if (document.getElementById('BirtD_M').value=="") errorField += "- Birth Date (Month)\n";
		if (document.getElementById('BirtD_Y').value=="") errorField += "- Birth Date (Year)\n";
		if (document.getElementById('Country').value=="") errorField += "- Country\n";
	
	}	
	if (numScheda==1) {
		if (document.getElementById('Address').value=="") errorField += "- Address\n";
		if (document.getElementById('NCiv').value=="") errorField += "- Street n°\n";
		if (document.getElementById('CAP').value=="") errorField += "- Postal Code\n";
		if (document.getElementById('City').value=="") errorField += "- Location\n";
		if (document.getElementById('Regione').value=="") errorField += "- Regione\n";
	
	}	
	
	if (errorField!="") {
		alert("WARNING! Compile these fields:\n\n"+errorField);
	}
		
	if (errorField=="") {
		if (document.getElementById('Email').value!=document.getElementById('Email2').value) {
			alert("WARNING! Confirm E-mail Error");
			errorField = "Email";
		}
	}		
	if (errorField=="") {
		if (document.getElementById('Password')) {
		if (document.getElementById('Password').value!=document.getElementById('Password2').value) {
			alert("WARNING! Confirm Password Error");
			errorField = "Password";
		}
		if (document.getElementById('Password').value.length<6) {
			alert("WARNING! Password too short");
			errorField = "Password";
		}
		}
	}
	if ((errorField=="")&&(numScheda==1)) {
		if (document.getElementById('Privacy1')) {
		if (document.getElementById('Privacy1').checked == false) {
			alert("WARNING! Were not accepted the Conditions of Participation at the program Shop & Fly");
			errorField = "Privacy";
		}
		}
		if (document.getElementById('Privacy2')) {
		if (document.getElementById('Privacy2').value == "") {
			alert("WARNING! They were the statements of consent for participation at the program Shop & Fly");
			errorField = "Privacy";
		}
		}
		if (document.getElementById('Privacy3')) {
		if (document.getElementById('Privacy3').value == "") {
			alert("WARNING! They were the statements of consent for participation at the program Shop & Fly");
			errorField = "Privacy";
		}
		}
	}
	if (errorField=="") {
		OpenCloseTab(numScheda+1)
	}
}

function ConfirmMessage(message,link)	{
	//alert(message);
	if (confirm(message)) location.href = link;
}


