// JavaScript Document





var thefrm, thisFormName, valid;
valid = true;
var errors = '';
var errMsg;
	// form scripts ehre
	
	
		function makeRequest() {
        var httpRequest;

		url = '../lib/validate_captcha.asp?captchaValue=' + document.frmForm.strCAPTCHA.value;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
        } else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!httpRequest) {
            alert('There was a problem submitting your form, this could be due to your browser.');
        }
		
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
		// set the asch value to false to wait for the response before carrying on
        httpRequest.open('GET', url, true);
        httpRequest.send(null);
		
        //function below deals with results...
    }
	

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 


	
    function alertContents(httpRequest) {

		if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
				if (httpRequest.responseText != "true")
				{
					// wrong or some problem
					errors += "Please check the numbers you entered in the text box.";
				}
				
				//now, did we have errors from captcha or other fields?
				if (errors != "")
				{
				    alert('There was a problem with your details.\n\n' + errors);
				    errors = "";
				}
				else
				{
				    // ok!
					document.frmForm.action = "default.asp?page=" + getURLParam('page') + "_1";
				    document.frmForm.submit();
				}
				
            } else {
                alert('There was a problem verifying your submission, please try again later.');
            }
		}

    }
	
	
	
	
	
	
	function validateBookingForm()
	{

			if (document.frmForm.txtFilm.value == '')
				{
					errors = errors + "You must supply the Film Title\n";
					valid = false;
				}
				
			if (document.frmForm.ddlDay.value == '' || document.frmForm.ddlMonth.value == '' || document.frmForm.ddlYear.value == '')
				{
					errors = errors + "You must a correct date\n";
					valid = false;
				}
				
			if (document.frmForm.ddlHour.value == '' || document.frmForm.ddlMinute.value == '')
				{
					errors = errors + "You must a correct time\n";
					valid = false;
				}
				
			if (document.frmForm.txtNoSeats.value == '')
				{
					errors = errors + "You must supply the Number of Seats\n";
					valid = false;
				}
				else
				{
					if (IsNumeric(document.frmForm.txtNoSeats.value))
					{
						errors = errors + "You must supply a valid Number of Seats\n";
						valid = false;
					}
				}
				
			if (document.frmForm.txtName.value == '')
				{
					errors = errors + "You must supply your Name\n";
					valid = false;
				}
			


			if (document.frmForm.txtTelephone.value == '')
				{
					errors = errors + "You must supply a Contact Telephone Number\n";
					valid = false;
				}


		// check the captcha thing
		if (document.frmForm.strCAPTCHA.value == '')
			{
				errors = errors + "You must enter the Validation Code.\n";
				valid = false;
				alert('There was a problem with your details.\n\n' + errors);
				    errors = "";
			}
			else
			{
				// captcha does stuff shen its finished
				makeRequest(thefrm)

			}


		
	}
	
	
		function IsNumeric(sText)
		{
		   var ValidChars = "0123456789.";
		   var IsNumber=false;
		   var Char;
		
		 
		   for (i = 0; i < sText.length && IsNumber == false; i++) 
			  { 
			  Char = sText.charAt(i); 
			  if (ValidChars.indexOf(Char) == -1) 
				 {
				 IsNumber = true;
				 }
			  }
		   return IsNumber;
		   
		}
	
	
	
	
	
	function validateElectronicBooking()
	{

			if (document.frmForm.txtFilm.value == '')
				{
					errors = errors + "You must supply the Film Title\n";
					valid = false;
				}
				
			if (document.frmForm.ddlDay.value == '' || document.frmForm.ddlMonth.value == '' || document.frmForm.ddlYear.value == '')
				{
					errors = errors + "You must a correct date\n";
					valid = false;
				}
				
			if (document.frmForm.ddlHour.value == '' || document.frmForm.ddlMinute.value == '')
				{
					errors = errors + "You must a correct time\n";
					valid = false;
				}
				
			if (document.frmForm.txtNoStudents.value == '')
				{
					errors = errors + "You must supply the Number of Students\n";
					valid = false;
								}
				else
				{
					if (IsNumeric(document.frmForm.txtNoStudents.value))
					{
						errors = errors + "You must supply a valid Number of Students\n";
						valid = false;
					}
				}
				
			if (document.frmForm.txtNoStaff.value == '')
				{
					errors = errors + "You must supply the Number of Staff\n";
					valid = false;
								}
				else
				{
					if (IsNumeric(document.frmForm.txtNoStaff.value))
					{
						errors = errors + "You must supply a valid Number of Staff\n";
						valid = false;
					}
				}
			
			
			if (document.frmForm.txtName.value == '')
				{
					errors = errors + "You must fill in your Name\n";
					valid = false;
				}
			
			
			if (document.frmForm.txtEmail.value == '')
				{
					errors = errors + "You must fill in your Email Address\n";
					valid = false;
				}
			else
				{
					var x = document.frmForm.txtEmail.value;
					var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					if (filter.test(x))
						{
							valid = true;
							
							if (!document.frmForm.txtEmail.value == document.frmForm.txtEmailConfirm.value)
								{
									errors = errors + "Your emails must match\n";
									valid = false;
								}
						}
						else
						{
							valid = false;
							errors = errors + "You must fill in a valid Email Address\n";
						}

						
				}


		// check the captcha thing
		if (valid)
			{
				document.frmForm.submit();
			}
			else
			{
				// captcha does stuff shen its finished
				valid = false;
				alert('There was a problem with your details.\n\n' + errors);
				    errors = "";

			}


		
	}
		
	
	
	
	
	
	
	
	
	function validateNewsletter()
	{


			if (document.frmForm.txtEmail.value == '')
				{
					errors = errors + "You must fill in your Email Address\n";
					valid = false;
				}
			else
				{
					var x = document.frmForm.txtEmail.value;
					var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					if (filter.test(x))
						{
							valid = true;
							
							if (!document.frmForm.txtEmail.value == document.frmForm.txtEmailConfirm.value)
								{
									errors = errors + "Your emails must match\n";
									valid = false;
								}
						}
						else
						{
							valid = false;
							errors = errors + "You must fill in a valid Email Address\n";
						}

						
				}
				
				
			if (document.frmForm.ddlInfo.value == '')
				{
					errors = errors + "You must supply a Location\n";
					valid = false;
				}


		// check the captcha thing
		if (document.frmForm.strCAPTCHA.value == '')
			{
				errors = errors + "You must enter the Validation Code.\n";
				valid = false;
				alert('There was a problem with your details.\n\n' + errors);
				    errors = "";
			}
			else
			{
				// captcha does stuff shen its finished
				makeRequest(thefrm)

			}


		
	}	
	
	
	
	
	
	
	
	function validateMailingList()
	{
			
			var found_it = false;
			for (var i=0; i<document.frmForm.radSubscribeList.length; i++)
			{
				if (document.frmForm.radSubscribeList[i].checked)  {
				
					found_it = true;
				
				}
			}
			
			if (!found_it)
				{
					errors = errors + "You must select a Screening\n";
					valid = false;
				}
			

			if (document.frmForm.txtEmail.value == '')
				{
					errors = errors + "You must fill in your Email Address\n";
					valid = false;
				}
			else
				{
					var x = document.frmForm.txtEmail.value;
					var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					if (filter.test(x))
						{
							valid = true;
							
							if (!document.frmForm.txtEmail.value == document.frmForm.txtCofirmEmail.value)
								{
									errors = errors + "Your emails must match\n";
									valid = false;
								}
						}
						else
						{
						valid = false;
						errors = errors + "You must fill in a valid Email Address\n";
						}
				}



		// check the captcha thing
		if (document.frmForm.strCAPTCHA.value == '')
			{
				errors = errors + "You must enter the Validation Code.\n";
				valid = false;
				alert('There was a problem with your details.\n\n' + errors);
				    errors = "";
			}
			else
			{
				// captcha does stuff shen its finished
				makeRequest(thefrm)

			}


		
	}	
	
	
	
	
	
	
	
		
	function validateContactUsForm()
	{

	        if (document.frmForm.ddlNature.value == '') {
	            errors = errors + "You must choose the nature of your enquiry\n";
	            valid = false;
	        }
	    
			if (document.frmForm.txtName.value == '')
				{
					errors = errors + "You must supply your Name\n";
					valid = false;
				}
				
			if (document.frmForm.txtDayTel.value == '')
				{
					errors = errors + "You must supply a Contact Telephone Number\n";
					valid = false;
				}
				
		
			if (document.frmForm.txtEmail.value == '')
				{
					errors = errors + "You must fill in your Email Address\n";
					valid = false;
				}
			else
				{
					var x = document.frmForm.txtEmail.value;
					var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					if (filter.test(x))
						{
							valid = true;
						}
						else
						{
						valid = false;
						errors = errors + "You must fill in a valid Email Address\n";
						}
				}
				
				
			if (document.frmForm.txtEnquiry.value == '')
				{
					errors = errors + "You must supply an Enquiry\n";
					valid = false;
				}


		// check the captcha thing
		if (document.frmForm.strCAPTCHA.value == '')
			{
				errors = errors + "You must enter the Validation Code.\n";
				valid = false;
				alert('There was a problem with your details.\n\n' + errors);
				    errors = "";
			}
			else
			{
				// captcha does stuff shen its finished
				makeRequest(thefrm)

			}


		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	