// JavaScript Document

// Created 02/08/2008 for the Discount Codes



	function targetDiv() {

		if (req.readyState == 4) { // Complete

			  if (req.status == 200) { // OK response

				  document.getElementById("response_discount").innerHTML = req.responseText;

			  } else {

				alert("Problem: " + req.statusText);

			  }

		}

	} 





	function check_discount(cal) {

		// check that the discount the user has provided matches a discount in the database

		// taken from http://www.webdeveloper.com/forum/showthread.php?t=72954

		//alert("test 10");

		document.getElementById("response_discount").innerHTML = "Please wait whilst we check the code...";

		discount_code = document.frmTickets.discount.value;

		

		url = "http://www.dickensworld.co.uk/media/php/check_discount.php?code="+discount_code;

		//alert("test 20");

		

		if (window.XMLHttpRequest) { // Non-IE browsers

			req = new XMLHttpRequest();

			req.onreadystatechange = targetDiv;

			//alert("test 30");

			

			try {

				req.open("GET", url, true);

			} catch (e) {

				alert(e);

				//alert("test 40");

			}

			req.send(null);

		} else if (window.ActiveXObject) { // IE

			req = new ActiveXObject("Microsoft.XMLHTTP");

			if (req) {

				req.onreadystatechange = targetDiv;

				req.open("GET", url, true);

				req.send();

			}

		}



	};

	
