	// Webalistic.net Booking Popup Script
	var listConn = new XHConn();
	var listUpdate = function (oXML) { document.getElementById('listPopUp').innerHTML = oXML.responseText; }
	var debug = false;
	
	function subPopUp(id) {
		var popupBox = document.getElementById('listPopUp');
		if (listConn) {
			if (popupBox) {
				listConn.connect("mod/list/list.php", "POST", "form=1&group=" + id, listUpdate);
				popupBox.style.display = 'block';
				
				getScreenXY();
				var x = posx;
				var y = posy;	
				var ypos=y-230;
				popupBox.style.top=ypos + 'px';
				popupBox.style.left=x + 'px';
				document.getElementById('frame').onclick = listPopUpHide;
			}
		}
	}
	
	function listPopUpHide () {
		document.getElementById('listPopUp').style.display = 'none';
	}
	
	function listSend(id) {
		var popupBox = document.getElementById('listPopUp');
		if (listConn) {
			if (popupBox) {
				if(listPopUpValidate()){	
					var pars = "send=1&group=" + id + "&name=" + encodeURIComponent(document.getElementById('listName').value) + "&email=" + encodeURIComponent(document.getElementById('listEmail').value) + '&phone=' + encodeURIComponent(document.getElementById('listPhone').value) + '&company=' + encodeURIComponent(document.getElementById('listCompany').value) + '&add1=' + encodeURIComponent(document.getElementById('listAdd1').value) + '&add2=' + encodeURIComponent(document.getElementById('listAdd2').value) + '&city=' + encodeURIComponent(document.getElementById('listCity').value) + '&postcode=' + encodeURIComponent(document.getElementById('listPostcode').value);
					popupBox.innerHTML = '<img src="/cms/theme/img/loading.small.gif" />';
					listConn.connect("mod/list/list.php", "POST", pars, listUpdate);
				}
			}
			else {
				emailPopUpError ('Unable to find mail group popup');	
			}
		}
		else {
			emailPopUpError ('No javascript - use a newer browser?');	
		}
	}
	
	function listPopUpValidate() {
		validForm = true;
		firstError = null;
		if(!document.getElementById('listName').value){
			writeError(document.getElementById('listName'), "*");
		}
		if(!document.getElementById('listEmail').value){
			writeError(document.getElementById('listEmail'), "*");
		}
		if(!validForm){
			errorMessage = document.getElementById('listErrorMess')
			errorMessage.innerHTML="*Please fill in your contact details.";
			errorMessage.className += 'listErrorMess';
		}
		if (firstError)
			firstError.focus();
		return validForm;
	}
	
	function writeError(obj,message) {
		validForm = false;
		if (obj.hasError) return;
			obj.className += ' listPopUpError';
			obj.onchange = removeError;
			var sp = document.createElement('span');
			sp.className = 'listError';
			sp.appendChild(document.createTextNode(message));
			obj.parentNode.appendChild(sp);
			obj.hasError = sp;
		if (!firstError)
			firstError = obj;
	}
	
	function removeError() {
		this.className = this.className.substring(0,this.className.lastIndexOf(' '));
		this.parentNode.removeChild(this.hasError);
		this.hasError = null;
		this.onchange = null;
		errorMessage = document.getElementById('listErrorMess')
		errorMessage.innerHTML="";
		errorMessage.className = errorMessage.className.substring(0,errorMessage.className.lastIndexOf(' '));
	}
	
	function emailPopUpError (mess) {
		if (debug) {
			alert (mess);	
		}
	}	
	
	