// JavaScript Document
// Log In Script
function login() {
	window.open( "login.php", "myWindow", "status = 1, width = 300, resizable = 1, scrollbars=1" )
}

// JavaScript Document
// Update profile Script
function profile() {
	window.open( "update_profile.php", "myWindow", "status = 1, width = 300, resizable = 1, scrollbars=1" )
}



// Ajax to load order in new DB table
//Browser Support Code
function add_item(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{ajaxRequest = new XMLHttpRequest();} catch (e){	
//		try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {
//			try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){
				alert("Ajax not supported");
				return false;
//			}
//		}
	}


// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('current_order');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	var tablename = document.getElementById('tablename').value;
	var item_no = document.getElementById('item_no').value;
	var quantity = document.getElementById('quantity').value;

	var addqueryString = "?item_no=" + item_no + "&quantity=" + quantity + "&tablename=" + tablename;
	ajaxRequest.open("GET", "add_item.php" + addqueryString , true);
	ajaxRequest.send(null);

}




// Ajax to load order in new DB table
//Browser Support Code
function display_or(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('view_or');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	var or_no = document.getElementById('or_no').value;

	var addqueryString = "?or_no=" + or_no;
	ajaxRequest.open("GET", "display_or.php" + addqueryString, true);
	ajaxRequest.send(null); 
	http.onreadystatechange = updateNewContent;
}



//Browser Support Code
function close_or(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('close_or');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

	var or_no = document.getElementById('or_no').value;

	var addqueryString = "?or_no=" + or_no;
	ajaxRequest.open("GET", "close_or.php" + addqueryString, true);
	ajaxRequest.send(null); 
	http.onreadystatechange = updateNewContent;
}


// image changer
function changeImage(imageSRC)//here we are running the function, and bringing the image source from the onclick command
{
document.getElementById('changingImage').src=imageSRC;//setting source of main image
}
