var Submitted=false;

//document.oncontextmenu=new Function("return false");

function checkRegistration(formRef) {
	// Check username and password (where present)
	if (formRef.Username) {
		if ((CheckString(formRef.Username,false)) && (CheckString(formRef.Password,false))) {if (formRef.Password.value!=formRef.ConfirmPassword.value) {alert("Passwords do not match"); formRef.ConfirmPassword.focus(); return false}}
		else {return false}
		}
	else if (formRef.Password!="") {if (formRef.Password.value!=formRef.ConfirmPassword.value) {alert("Passwords do not match"); formRef.ConfirmPassword.focus(); return false}}
	// Check personal details (always present)
	if ((CheckString(formRef.FirstName,false)) && (CheckString(formRef.LastName,false)) && (emailCheck(formRef.EmailAddress.value))) {if (formRef.JobTitle[formRef.JobTitle.selectedIndex].value=="") {alert("Please specify a job title"); formRef.JobTitle.focus(); return false}}
	else {return false}
	// Check company contact details (always present)
	if ((CheckString(formRef.CompanyName,false)) && (CheckString(formRef.StreetAddress,false)) && (CheckString(formRef.City,false)) && (CheckString(formRef.Postcode,false)) && (CheckString(formRef.BusinessPhone,false))) {if (formRef.AddrCountry[formRef.AddrCountry.selectedIndex].value=="") {alert("Please specify a country"); formRef.AddrCountry.focus(); return false}}
	else {return false}
	// Check company contact details (always present except for exhibitor only fields)
	if (formRef.Country[formRef.Country.selectedIndex].value=="") {alert("Please specify where your business is registered"); formRef.Country.focus(); return false}
	if ((formRef.VATnumber.value!="") && (checkVATNumber(formRef.VATnumber.value)==false)) {alert("Please specify a valid VAT (sales tax) registration number beginning\nwith the two letter country code where your company is registered."); formRef.VATnumber.focus(); return false}
	if ((formRef.YearEstablished) && (CheckString(formRef.YearEstablished,false)==false)) {return false}
	// Check confirmations (where present)
	if ((formRef.AcceptTerms) && ((formRef.AcceptTerms.checked==false) || (formRef.PrivacyPolicy.checked==false))) {alert("You must accept our Terms of Use and Privacy Policy"); return false}
	}

function checkVisitorRegistration(formRef) {
	// Check personal details (always present)
	if ((CheckString(formRef.FirstName,false)) && (CheckString(formRef.LastName,false)) && (emailCheck(formRef.EmailAddress.value)) && (CheckString(formRef.CompanyName,false))) {}
	else {return false}
	// Check username and password (where present)
	if (formRef.Username) {
		if ((CheckString(formRef.Username,false)) && (CheckString(formRef.Password,false))) {if (formRef.Password.value!=formRef.ConfirmPassword.value) {alert("Passwords do not match"); formRef.ConfirmPassword.focus(); return false}}
		else {return false}
		}
	else if (formRef.Password!="") {if (formRef.Password.value!=formRef.ConfirmPassword.value) {alert("Passwords do not match"); formRef.ConfirmPassword.focus(); return false}}
	if ((formRef.VATnumber.value!="") && (checkVATNumber(formRef.VATnumber.value)==false)) {alert("Please specify a valid VAT (sales tax) registration number beginning\nwith the two letter country code where your company is registered."); formRef.VATnumber.focus(); return false}
	// Check confirmations (where present)
	if ((formRef.AcceptTerms) && ((formRef.AcceptTerms.checked==false) || (formRef.PrivacyPolicy.checked==false))) {alert("You must accept our Terms of Use and Privacy Policy"); return false}
	}

function checkTicketForm(formRef,thisMonth) {
	if (Submitted==false) {
		if (formRef.CompanyActivity.selectedIndex==0) {alert("Please select a Company Activity"); formRef.CompanyActivity.focus(); return false}
		if ((formRef.YourInterests) && (formRef.YourInterests.selectedIndex==-1)) {alert("Please select Your Interests"); formRef.YourInterests.focus(); return false}
		if (formRef.cctype) {
			if ((CheckString(formRef.FirstName,false)) && (CheckString(formRef.LastName,false)) && (CheckString(formRef.City,false)) && (CheckString(formRef.StreetAddress,false)) && (CheckString(formRef.ccnumber,false)) && (CheckString(formRef.ccsecurity,false))) {
				if (formRef.Country[formRef.Country.selectedIndex].value=="") {alert("Please select a country"); formRef.Country.focus(); return false}
				if ((formRef.ccexpyear.selectedIndex==0) && ((formRef.ccexpmonth.selectedIndex + 1)<thisMonth)) {alert("Your credit card has expired"); formRef.ccexpmonth.focus(); return false}
				Submitted=true;
				}
			else {return false}
			}
		}
	else {alert("Your order has already been processed. Pressing the button twice does not\nallow us to display our usual purchase successful or purchase failed page.\nPlease check your e-mail in a few minutes to see that we have sent you an\norder confirmation. If not, please check the 'Tickets Purchased' section of\nyour 'My Account' page to see whether the purchase was successful."); return false}
	}

function showTicketInfo(EID) {
	if (document.getElementById) {
		for (var i=0; i<ExpoArray.length; i++) {
			if (ExpoArray[i][0]==EID) {
				var today=new Date();
				var thisStart=new Date(ExpoArray[i][1]);
				var thisEnd=new Date(ExpoArray[i][2]);
				document.getElementById("OpeningTimes").innerHTML=ExpoArray[i][1] + " to " + ExpoArray[i][2];
				document.getElementById("AlreadyPurchased").innerHTML=(ExpoArray[i][5]) ? "Yes" : "No";
				document.getElementById("TicketCost").innerHTML=ExpoArray[i][3];
				document.getElementById("TicketValidity").innerHTML=(parseInt((thisEnd-today) / FSintOneDay)<parseInt(ExpoArray[i][4]) ? parseInt((thisEnd-today) / FSintOneDay) : ExpoArray[i][4]) + " days";
				document.TicketForm.StartDate.value=(thisStart<today) ? FSfncDateToString(today) : FSfncDateToString(thisStart);
				if (document.getElementById) {
					if (thisEnd<thisStart) {var tempSwap=thisEnd; thisEnd=thisStart; thisStart=tempSwap}
					if (FSstrBrowser=="Gecko") {document.getElementById("FSdsIcon_StartDate").parentNode.onmousedown=function(event) {FSfncShowDateSelector("document.TicketForm.StartDate",event,true,FSfncDateToString(thisStart),FSfncDateToString(thisEnd),"EN","../../Components/DateSelector/Images/",0,-202,"")}}
					else {document.getElementById("FSdsIcon_StartDate").parentNode.onmousedown=function() {FSfncShowDateSelector("document.TicketForm.StartDate",event,true,FSfncDateToString(thisStart),FSfncDateToString(thisEnd),"EN","../../Components/DateSelector/Images/",0,-202,"")}}
					}
				}
			}
		}
	}

function getTicketPDF(formRef) {window.open('../../Images/Exhibitions/TicketPurchase_' + formRef.ShowID[formRef.ShowID.selectedIndex].value + ".pdf")}

function toggleLocPanel(Index,State,AllowMove,EventRef) {if (document.getElementById) {document.getElementById("LocPanel_" + Index).style.visibility=State ? "visible" : "hidden"}}

function setCounter(CounterID,FieldRef,MaxLength) {
	if (FieldRef.value.length>MaxLength) {FieldRef.value=FieldRef.value.substring(0,MaxLength)} 
	document.getElementById(CounterID).innerHTML=FieldRef.value.length + " of " + MaxLength + " characters"
	}

function setBoothPrice(formRef) {
	if (formRef.ShowListing[2].checked) {var curListingFee=arrListingFee[2]}
	else if (formRef.ShowListing[1].checked) {var curListingFee=arrListingFee[1]}
	else {var curListingFee=arrListingFee[0]}
	if (formRef.IsGold.checked) {curListingFee+=arrListingFee[3]}
	document.getElementById("ListingFee").innerHTML=strCurrency + curListingFee + " +VAT";
	if (formRef.BoothType.selectedIndex==0) {
		var strBoothFee="our sales team will contact you to discuss your requirements";
		var strTotalFee="n/a";
		}
	else {
		var arrBoothDetails=formRef.BoothType[formRef.BoothType.selectedIndex].value.split(":");
		var curBoothFee=parseFloat(arrBoothDetails[1]);
		var strBoothFee=strCurrency + curBoothFee + " +VAT";
		var strTotalFee=strCurrency + (curListingFee + curBoothFee) + " +VAT";
		}
	document.getElementById("BoothFee").innerHTML=strBoothFee;
	document.getElementById("TotalFee").innerHTML=strTotalFee
	}

function checkExhibitForm(formRef) {
	if ((CheckString(formRef.CompanyName,false)) && 
		(CheckString(formRef.BoothName,false)) && 
		(CheckString(formRef.FirstName,false)) && 
		(CheckString(formRef.LastName,false)) && 
		(CheckString(formRef.StreetAddress,false)) && 
		(CheckString(formRef.City,false)) && 
		(CheckString(formRef.Postcode,false)) && 
		(CheckString(formRef.BusinessPhone,false)) && 
		(CheckString(formRef.WebAddress,false)) && 
		(emailCheck(formRef.EmailAddress.value,false))
		) {
		if (formRef.AddrCountry[formRef.AddrCountry.selectedIndex].value=="") {alert("Please select a country"); formRef.AddrCountry.focus(); return false}
		if (formRef.ModesOfTrade.selectedIndex==-1) {alert("Please select a Mode of Trade"); formRef.ModesOfTrade.focus(); return false}
		if ((formRef.MainProduct) && (formRef.MainProduct.selectedIndex==-1)) {alert("Please select a Main Product"); formRef.MainProduct.focus(); return false}
		if ((formRef.AcceptConditions) && (formRef.AcceptConditions.checked==false)) {alert("You must accept our terms and conditions"); return false}
		}
	else {return false}
	}
