function ajaxEval(file){
	var xmlObj = null;
	if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return;
	}
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			eval(xmlObj.responseText);
		}
	}
	xmlObj.open ('GET', file+'&amp;_frameset=true', true);
	xmlObj.send ('');
}

function ajaxRead(file, sendto){
	var xmlObj = null;
	if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return;
	}
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			sendto.innerHTML=xmlObj.responseText;
		}
	}
	xmlObj.open ('GET', file+'&amp;_frameset=true', true);
	xmlObj.send ('');
}

function ajaxReadAdd(file, sendto){
	var xmlObj = null;
	if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return;
	}
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			sendto.innerHTML+=xmlObj.responseText;
		}
	}
	xmlObj.open ('GET', file, true);
	xmlObj.send ('');
}


var http_request = false;
function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	return true;
}

function alertContents() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			result = http_request.responseText;
			document.getElementById('userLogin').innerHTML = result;
		} else {
			alert('There was a problem with the request.');
		}
	}
}

function validEmail(email){
	if(email.indexOf("@") + "" == "-1" || email.indexOf(".") + "" == "-1" || email.value == "") return false;
	return true;
}

function getAjaxResponse(file){
	var xmlObj = null;
	if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return;
	}
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			return(xmlObj.responseText);
		}
	}
	xmlObj.open ('GET', file, true);
	xmlObj.send ('');
}

function venueDescription(v,t){
	target = document.getElementById(t);
	target.style.display = '';
	ajaxRead('/ajax?action=seatDescription&seat='+v+'&amp;_frameset=true',target);
}

function ajaxDiscountInfo(formType){
	var html = '';
	
	var total = 0;
	var pageTotal = 0;
	var url='/ajax?action=discountInfo&id='+document.getElementById('bookingId').value + "&formType=" + formType;
	var totaltickets = 0;
	
	switch (formType)
	{
		case 'ticket':
			var wrapper = document.getElementById('seatsValues');
			var inputs = wrapper.getElementsByTagName('input');
			
			for(var i = 0; i < inputs.length; i++) { 
				if(Math.floor(inputs[i].value) > 0)	{
				
					totaltickets=Math.floor(inputs[i].value);
					
					url+='&seatName='+tickets[inputs[i].id.substr(5)][0];
					url+='&seatId='+ inputs[i].id.substr(5);
					url+='&seatPrice='+tickets[inputs[i].id.substr(5)][1];
					url+='&tickets='+totaltickets;
					
					pageTotal+=Math.floor(inputs[i].value)*parseFloat(tickets[inputs[i].id.substr(5)][1]);
					
					bookingFee = totaltickets * parseFloat(document.getElementById('bookingFeeValue').value);
					pageTotal += bookingFee;
	
					break;
				}			
			}
	
			var offerCode=document.getElementById('offerCode');
			
			if (offerCode)
			{
				url+='&offerCode='+offerCode.value;
			}
			
			
			break;
		default:
			var wrapper = document.getElementById('allProducts');
			var inputs = wrapper.getElementsByTagName('input');
	
			for(var i = 0; i < inputs.length; i++) { 
				if(inputs[i].type == 'text'){
					if(Math.floor(inputs[i].value) > 0){
						url+='&'+inputs[i].id.substr(1)+'='+inputs[i].value;
						pageTotal += Math.floor(inputs[i].value)*parseFloat(options[inputs[i].id.substr(1)][1]);
					}
				}
			}
			break;
	}
	
	var xmlObj = null;
	if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
	} else if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return;
	}
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			
			try
			{
				eval(xmlObj.responseText);
			}
			catch(err)
			{
				document.getElementById('discountDiv').style.display='none';
				
				var temp1=parseFloat(document.getElementById('hiddenTotal').value);
				var temp2=parseFloat(document.getElementById('discountCalc').value);
				
				document.getElementById('totalNumber').innerHTML = '&pound;'+number_format((temp1+temp2),2);

				return;
			}
			
			var html = '';
			var total = parseFloat(document.getElementById('discountCalc').value) + pageTotal;
			var discountTotal = 0;
				
			for (i=0;i<disArray.length;i++)
			{	
				html += '<tr valign="top"><td>'+disArray[i][0]+'</td><td class="alignRight">-&pound;'+number_format(parseFloat(disArray[i][1]),2)+'</td></tr>\n';
				
				discountTotal += parseFloat(disArray[i][1]);
			} 
									
			total -= discountTotal;

			if(html.length > 0){
		
				document.getElementById('discountDiv').style.display='block';
				document.getElementById('discountDiv').innerHTML = '<h4>Discounts</h4><div class="break"></div><table cellspacing="0" cellpadding="0" border="0" id="discountTable">'+html+'</table>';

			} else {
		
				document.getElementById('discountDiv').innerHTML = html;
				document.getElementById('discountDiv').style.display='none';
			}
			
			document.getElementById('totalNumber').innerHTML = '&pound;'+number_format(total,2);
		}
	}
	xmlObj.open ('GET', url, true);
	xmlObj.send ('');
}