// JavaScript Document
var xmlhttp  = false;
var xmlhttp2 = false;
var count = 0
var t = 0

try {
	xmlhttp  = new ActiveXObject("Msxml2.XMLHTTP");
	xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
	window.status = "You are using Microsoft Internet Explorer";
} catch (e) {
	try {
		xmlhttp  = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		window.status = "Your are using Microsoft Internet Explorer";
	} catch (E) {
		xmlhttp  = false;
		xmlhttp2 = false;
	}
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp  = new XMLHttpRequest();
	xmlhttp2 = new XMLHttpRequest();
	window.status = "You are not using Microsoft Internet Explorer";
}


function ajax_getBooking(serverPage,str) {	
	xmlhttp.open("POST", serverPage, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {			
			document.getElementById("reservation").innerHTML = xmlhttp.responseText
			document.frmBooking.txtname.focus()
		}
	}
	xmlhttp.send(str);	
}

function ajax_backScreen(serverPage,str) {	
	xmlhttp.open("POST", serverPage, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {			
			document.getElementById("reservation").innerHTML = xmlhttp.responseText
			document.frmBooking.cboDiningHour.focus()
		}
	}
	xmlhttp.send(str);	
}

function ajax_submitMailing(serverPage,str) {	
	xmlhttp.open("POST", serverPage, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {						
			
			//alert(xmlhttp.responseText)
			var str
			str = '<input class="mailing_button" onclick="submitMail()" name="btnSubmit" type="button" value="Submit" />'
			
			switch(xmlhttp.responseText){
			case "success":	
				/*var str 
				str  = "<table width='100%' cellpadding='0' cellspacing='0'>"
				str += "<tr height='4px'><td></td></tr>"
				str += "<tr><td><img src='images/mailinglist.jpg' /></td></tr>"
				str += "<tr height='10px'><td></td></tr>"
				str += "<tr><td class='text1'>Thank you for your subscription to our mailing list.</td></tr>"
				str += "<tr><td class='text1'>You should be able to receive any latest news update from us soon.</td></tr>"
				//str += "<tr><td class='text1'><img src='images/smile.gif' /></td></tr>"
				str += "</table>"
				document.getElementById("subscribe").innerHTML = str*/
				alert("Thank you for your subscription to our mailing list.\nYou should be able to receive any latest news update from us soon.")
				document.frmMailingList.txtname.value = ''
				document.frmMailingList.txtemail.value = ''				
				document.getElementById("submitbutton").innerHTML = str				
				
				break
			case "fail":	
				alert("We cannot send your reservation at the moment due to some technical error.")				
				document.getElementById("submitbutton").innerHTML = str		
				break
			}
		}
	}
	xmlhttp.send(str);	
}



function ajax_resetScreen(serverPage) {
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			location.href = "index.php?page=customerservice"
		}
	}
	xmlhttp.send(null);
}

function ajax_ConfirmBooking(serverPage,str) {	

	xmlhttp.open("POST", serverPage, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {					

			switch(xmlhttp.responseText){
			case "success":	
				location.href = "index.php?page=reservationconfirm"
				break
			case "fail":	
				alert("We cannot send your reservation at the moment due to some technical error.")
				break
			}
		}
	}
	xmlhttp.send(str);	
}


