/**
* BVF Javascript
* Author: Phil Rowley
* Email: webmaster@britishvolkswagenfestival.co.uk
* URL: www.britishvolkswagenfestival.co.uk
* Version: 1
**/

	<!-- ajax - xml http post -->
	function xmlHttpPost(targetURL, queryString , functionNotReady, functionErr, functionSuccess, booSync) {
		
		<!-- define variables -->
		var xmlHttpReq = false;
		var self = this;
		
		<!-- optional argument -->
		if (typeof booSync == 'undefined') {
			
			<!-- set default -->
			var booSync = false;
		}

		<!-- create new functions to be called upon AJAX post busy, errored or completed -->
		if (typeof functionNotReady != 'undefined') {
			
			var fNotReady = new Function(functionNotReady);
		}

		if (typeof functionErr != 'undefined') {
			
			var fErr = new Function(functionErr);
		}
		
		if (typeof functionSuccess != 'undefined') {
			
			var fSuccess = new Function(functionSuccess);
		}
				
		// check for mozilla / safari / ie
		if (window.XMLHttpRequest) {
			
			// mozilla / safari
			self.xmlHttpReq = new XMLHttpRequest();
			
		} else if (window.ActiveXObject) {
			
			// ie
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
	
		<!-- open post request -->
		self.xmlHttpReq.open('POST', targetURL, booSync);
		
		<!-- set headers -->
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
		<!-- set time out to catch server problems = 30 seconds -->	
		var requestTimer = setTimeout(function() { self.xmlHttpReq.abort(); }, 120000); 
     
		<!-- check for state change -->
		self.xmlHttpReq.onreadystatechange = function() {
			
			<!-- check for ready state change -->
			if (self.xmlHttpReq.readyState != 4) {
			
				<!-- update page -->
				fNotReady();
				
				<!-- continue checking -->
				return;
			}
			
			<!-- clear time out timer -->
			clearTimeout(requestTimer); 
				
			<!-- update page -->
			if (self.xmlHttpReq.status != 200) {
			
				<!-- inform user to problem -->
				fErr();
				
			} else {
				
				<!-- inform user of success -->
				fSuccess();
				
			}
		}
			
		<!-- post query string -->
		self.xmlHttpReq.send(queryString);
	}
	
	<!-- check club members password -->
	function checkClubMemberPassword(intClubID, strPassword) {
		
		<!-- check for club camping association -->
		if (intClubID != "-1" && intClubID != "[unspecified]" && intClubID != "" && strPassword != "none" && strPassword != "") {
			 	
			<!-- add variables to url -->
			var urlString = "intClubID=" + intClubID + 
						  "&strPassword=" + strPassword;
			
			<!-- ajax -->
			xmlHttpPost('/uploads/bvf/actions/sp_checkClubMemberPassword.php', urlString, '', 'alert(\'A problem was encountered at the server!\\n\\n\' + self.xmlHttpReq.responseText);', 'processClubMemberPassword(self.xmlHttpReq.responseText);');	
		}
	}
	
	<!-- process club member password result -->
	function processClubMemberPassword(strResponse) {

		<!-- check response -->
		if (strResponse != '') {
			
			alert('Please check your club password!\n\nThe password you supplied does not match the password set by your chosen club.  Please contact your club representative for the correct password.');
		}
	}