//Checks For A Click
var global_counter;
setInterval("refresh_floorplan()", 10000);
function refresh_floorplan() {
	replace_content('/pages/exhibiting/floorplan/floorplan_right.php?ajax=on', 'floorplan_right_ajax');
}

// Removes Element
function removeElement(el) {
	el.parentNode.removeChild(el);
}

//Unreserves A Stand
function unreserve_stand(stand_id) {
	//Unreserve Stand
	var xmlhttp=null;
	xmlhttp=getxmlhttp();
	var stand_id = String(stand_id);
	var url = "/pages/exhibiting/floorplan/sql_functions/unreserve_stand.php?ajax=on&stand_id=" + stand_id;
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			response = xmlhttp.responseText;
			var value = response;
			//Now need to refresh actual stand
			var replace_stand_div = "stand_" + stand_id;
			var replace_stand_url = "/pages/exhibiting/floorplan/sql_functions/draw_floorplan.php?ajax=on&stand_id=" + stand_id;
			replace_content(replace_stand_url, replace_stand_div);
			replace_content('/pages/exhibiting/floorplan/shopping_cart.php?ajax=on', 'side_cart_replaceable');
			}
		}
	xmlhttp.send(null)
}

//Reserves A Stand
function reserve_stand(stand_id) {
	var xmlhttp=null;
	xmlhttp=getxmlhttp();
	var stand_id = String(stand_id);
	var url = "/pages/exhibiting/floorplan/sql_functions/reserve_stand.php?ajax=on&stand_id=" + stand_id;
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			response = xmlhttp.responseText;
			var value = response;
			if (value==0) {
			alert("Unfortunately this stand has now been reserved by another user!");
			//Replace Whole Floorplan?
			replace_content('/pages/exhibiting/floorplan/floorplan_right.php?ajax=on', 'floorplan_right_ajax');
			}
			//Now need to refresh actual stand
			var replace_stand_div = "stand_" + stand_id;
			var replace_stand_url = "/pages/exhibiting/floorplan/sql_functions/draw_floorplan.php?ajax=on&stand_id=" + stand_id;
			replace_content(replace_stand_url, replace_stand_div);
			replace_content('/pages/exhibiting/floorplan/shopping_cart.php?ajax=on', 'side_cart_replaceable');
			}
		}
	xmlhttp.send(null)
}

//Confirms Booking
function confirm_stand() {
	replace_content('/pages/exhibiting/floorplan/shopping_cart.php?ajax=on&form_action=confirm', 'side_cart_replaceable');
	replace_content('/pages/exhibiting/floorplan/floorplan_right.php?ajax=on', 'floorplan_right_ajax');
}

//Activated LiveValidation
function check_cart() {
	var form_stand_type = new LiveValidation('form_stand_type');
	form_stand_type.add(Validate.Exclusion, { within: ['Please Select'], failureMessage: "Please select a stand type!"});
}

function cancel_stands() {
	var xmlhttp=null;
	xmlhttp=getxmlhttp();
	var stand_id = String(stand_id);
	var url = "/pages/exhibiting/floorplan/sql_functions/cancel_stands.php?ajax=on";
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			response = xmlhttp.responseText;
			var value = response;
			//Now need to refresh actual stand
			replace_content('/pages/exhibiting/floorplan/shopping_cart.php?ajax=on', 'side_cart_replaceable');
			replace_content('/pages/exhibiting/floorplan/floorplan_right.php?ajax=on', 'floorplan_right_ajax');	
			}
		}
	xmlhttp.send(null)
}
