// Make the XMLHttpRequest object  
var http = createRequestObject();

function createRequestObject() 
{
	// PURPOSE: Creates AJAX interface object
	
	var req;  
	
	if(window.XMLHttpRequest)
	{  
		// Firefox, Safari, Opera...  
		req = new XMLHttpRequest();  
	} 
	else if(window.ActiveXObject) 
	{  
		// Internet Explorer 5+  
		req = new ActiveXObject("Microsoft.XMLHTTP");  
	} 
	else 
		xDT.alert('An AJAX capable browser is required to operate this site');  
	
	return req;  
}  

function changeKitchen(img, item)
{
	// 'index.php?page=showroom&img=k1&item=bt'
	
	http.open("GET", "./changeKitchen.php?img=" + img + "&item=" + item, true);
	http.onreadystatechange = displayKitchen;
	http.send(null);	
}

function changeSwab(swab)
{
	// 'index.php?page=showroom&img=k1&item=bt'
	http.open("GET", "./changeKitchen.php?swab=" + swab, true);
	http.onreadystatechange = displaySwab;
	http.send(null);	
}

function changeColor(row, col)
{
	ctrl = document.getElementById("colorSelection"); // UPDATE ajaxList container 
	if(ctrl != null)
		ctrl.style.display = "none";
	else
		alert('ctrl is null');
			
	// 'index.php?page=showroom&img=k1&item=bt'
	http.open("GET", "./changeKitchen.php?row=" + row + "&col=" + col, true);
	http.onreadystatechange = displayColor;
	http.send(null);	
}

function performAction(action)
{
	// 'index.php?page=showroom&img=k1&item=bt'
	http.open("GET", "./changeKitchen.php?action=" + action, true);
	http.onreadystatechange = displayKitchen;
	http.send(null);	
}

function displayKitchen()
{
	if(http.readyState == 4 && http.status == 200)
	{  
		// Text returned FROM the PHP script  
		var response = http.responseText;  
		//alert(response);
		if(response) 
		{
			
//			ctrl = document.getElementById("virtKitchen"); // UPDATE ajaxList container 
ctrl=document.getElementById("abhi");
			if(ctrl != null)
			
			
				ctrl.src = '';//response;
		ctrl.src =response
		}
		
	}  
}

function displaySwab()
{
	if(http.readyState == 4 && http.status == 200)
	{  
		// Text returned FROM the PHP script  
		var response = http.responseText;  
		if(response != "hide") 
		{
			ctrl = document.getElementById("colorSheet"); // UPDATE ajaxList container 
			if(ctrl != null)
			{
				ctrl.innerHTML = response;
				ctrl.style.display = "block";
			}
		}
		else
		{
			ctrl = document.getElementById("colorSheet"); // UPDATE ajaxList container 
			if(ctrl != null)
				ctrl.style.display = "none";
		}
			
	}  
}

function displayColor()
{
	if(http.readyState == 4 && http.status == 200)
	{  
		// Text returned FROM the PHP script  
		var response = http.responseText;  
		if(response) 
		{
			ctrl = document.getElementById("colorSelection"); // UPDATE ajaxList container 
			if(ctrl != null)
			{
				ctrl.style.backgroundColor = response;
				ctrl.style.display = "block";
			}
		}
	}
}
