
var shownevent="eventdetails";
function showeventdetail(detailLYR) {
document.getElementById(shownevent).style.visibility = "hidden";
document.getElementById(detailLYR).style.visibility = "visible";
shownevent=detailLYR;
}

function position(e) {
	if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
	 positionx = e.pageX;
	 positiony = e.pageY;
    }
    else { // Modif proposé par TeDeum, merci à  lui
    if(document.documentElement.clientWidth>0) {
		positionx=event.x+document.documentElement.scrollLeft;
		positiony=event.y+document.documentElement.scrollTop;
	   } else {
		positionx=event.x+document.body.scrollLeft;
		positiony=event.y+document.body.scrollTop;
      }
    }
}

document.onmousemove = position;

function showpersondetail(pid) {
    if(window.XMLHttpRequest) // FIREFOX
          XhrObj = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          XhrObj = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
   
   //définition de l'endroit d'affichage:
	var filename = "person.php?pid="+pid;
	var content = document.getElementById("zone_detail");
	
	XhrObj.open("GET", filename, true);
	
	//Ok pour la page cible
	XhrObj.onreadystatechange = function()
	{
	if (XhrObj.readyState == 4 && XhrObj.status == 200)
	content.innerHTML = XhrObj.responseText;
	content.style.left = positionx+"px";
	content.style.top = positiony+"px";
	content.style.visibility = "visible";
	content.style.zIndex = "4";
	} 
	XhrObj.send(null);
}//fin fonction SendData

function closedetails() {
	var content = document.getElementById("zone_detail");
	content.innerHTML = "";
	content.style.visibility = "hidden";
	content.style.zIndex = "0";
}

function calculatefee() {

for (var i=0; i<3; i++) {
	if (document.registrationform.fee[i].checked) {
		regfee = document.registrationform.fee[i].value;
		}
	}

var galafee = 0;
for (var j=0; j<2; j++) {
	if (document.registrationform.gala[j].checked) {
		galafee = document.registrationform.gala[j].value;
		}
	}


if (document.registrationform.accfee.checked) {
	accfee = document.registrationform.accfee.value;
	} else {
	accfee = 0;
	}

if (document.registrationform.arrivaltransfer.checked) {
	arrtrans = document.registrationform.arrivaltransfer.value;
	} else {
	arrtrans = 0;
	}

if (document.registrationform.departuretransfer.checked) {
	deptrans = document.registrationform.departuretransfer.value;
	} else {
	deptrans = 0;
	}



if (document.registrationform.hotel.checked) {
	hotelfee = 0;
	} else {
	hotelfee = 270;
	}

var totaldue = document.registrationform.totaldue;

totaldue.value = ((arrtrans*1)+(deptrans*1)+(regfee*1)+(galafee*1)+(accfee*1)+(hotelfee*1));
}

function autocheck() {
	if (document.registrationform.acclastname.value!='') {
	document.registrationform.accfee.checked=true;
	calculatefee();
	} else {
	document.registrationform.accfee.checked=false;
	calculatefee();
	}
}

function validateregform() {
regLNv=document.registrationform.lastname.value;
regPRv=document.registrationform.profession.value;
regADv=document.registrationform.address.value;
regCIv=document.registrationform.city.value;
regZIv=document.registrationform.zip.value;
regCNv=document.registrationform.country.value;
regEMv=document.registrationform.mail.value;
regALNv=document.registrationform.acclastname.value;
regAFEv=document.registrationform.accfee.value;
reg1STv=document.registrationform.stchoice.value;
regARRv=document.registrationform.arrival.value;
regDEPv=document.registrationform.departure.value;
regNBNv=document.registrationform.nbnights.value;


if (regLNv=='') {
	alert('Your name is a required field. Please try again.');
	return false;
	}
if (regPRv=='') {
	alert('Your profession is a required field. Please try again.');
	return false;
	}
if (regADv=='') {
	alert('Your address is a required field. Please try again.');
	return false;
	}
if (regCIv=='') {
	alert('Your city is a required field. Please try again.');
	return false;
	}
if (regZIv=='') {
	alert('Your ZIP code is a required field. Please try again.');
	return false;
	}	
if (regCNv=='') {
	alert('Your country is a required field. Please try again.');
	return false;
	}
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if ( !(filter.test(regEMv)) ) {
	alert('Your email address is a required field. Please try again.');
	return false;
	}
	
	
if (regALNv=='') {
	if (document.registrationform.accfee.checked) {
		alert('Please provide the name of your accompanying person');
		return false;
		}
	}
	
if (regALNv!='') {
	if (!document.registrationform.accfee.checked) {
		alert('Please make sure you checked "accompanying person" in part 1: registration fees, or empty the accompanying person name field');
		return false;
		}
	}	
	

if (!(document.registrationform.hotel.checked)) {
	if (reg1STv=='') {
		alert('You should select at least 1 hotel. Please try again.');
		return false;
		}
	if (regARRv=='') {
		alert('Your date of arrival is a required field. Please try again.');
		return false;
		}
	if (regDEPv=='') {
		alert('Your date of departure is a required field. Please try again.');
		return false;
		}
	if (regNBNv=='') {
		alert('The number of nights is a required field. Please try again.');
		return false;
		}
}

if (!(document.registrationform.payment[0].checked || document.registrationform.payment[1].checked || document.registrationform.payment[2].checked)) {
	alert('Payment option is a required field. Please try again.');
	return false;
	}

if (!(document.registrationform.terms.checked)) {
	alert('Your must accept terms and conditions before sending this form. Please try again.');
	return false;
	}

}