function createXmlHttpRequestObject() 
{  
	var xmlHttp;
	if(window.ActiveXObject)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) 
		{
			xmlHttp = false;
		}
	}
	else
	{
		try 
		{
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) 
		{
			xmlHttp = false;
		}
	}
	if (!xmlHttp)
		alert("Error creating the XMLHttpRequest object.");
	else 
		return xmlHttp;
}
xmlHttp = createXmlHttpRequestObject();
var xmlHttpProduct;
//var xmlHttpCancel;

function ProductImage(id)
{
	//alert(id);
	var size = document.getElementById("size_"+id).value;
	var quantity = document.getElementById("quantity_"+id).value;
	var text = document.getElementById("text_"+id).value;
	var postcart = document.getElementById("postcard_text_"+id).value;
	var price = document.getElementById("price_"+id).value;
	xmlHttpProduct = createXmlHttpRequestObject();
	if (xmlHttpProduct.readyState == 4 || xmlHttpProduct.readyState == 0)
	{
		//alert(id);
		//xmlHttpInbox.open("GET", "message_inbox.php?search=" + query + "&page=" + page, true);
		xmlHttpProduct.open("GET", 'product_image.php?id='+id+'&size='+size+'&quantity='+quantity+'&text='+text+'&postcart='+postcart+'&price='+price, true);
		xmlHttpProduct.onreadystatechange = ProductResult;
		xmlHttpProduct.send(null);
	}		
}
function ProductResult()
{
	  //alert(id);
	if (xmlHttpProduct.readyState == 4) 
	{
		if (xmlHttpProduct.status == 200) 
		{
			
			//alert(document.getElementById("productimage").innerHTML);
			//document.getElementById("cate_id").innerHTML = xmlHttpProduct.responseText ;
			document.getElementById("productimage").innerHTML = xmlHttpProduct.responseText ;
			document.getElementById("SelCount").value = parseInt(document.getElementById("SelCount").value) + 1;
			//alert(document.getElementById("SelCount").value);
		} 
		else 
		{
			alert("There was a problem accessing the server: " + xmlHttpProduct.statusText);
		}
	}		
}


/*******************************************************************************************************************************************/
/*******************************************************************************************************************************************/

function ProductDetail()
{
	var no_add = document.getElementById("increase_row").value;
	document.getElementById("paymentDIV").innerHTML = "<img src='images/aloading.gif'>";
	xmlHttpProduct = createXmlHttpRequestObject();
	if (xmlHttpProduct.readyState == 4 || xmlHttpProduct.readyState == 0)
	{
		xmlHttpProduct.open("GET", 'calculation.php?no_add='+no_add+'&mode=add', true);
		xmlHttpProduct.onreadystatechange = ProductDetailResult;
		xmlHttpProduct.send(null);
	}		
}
function ProductDetailResult()
{
	if (xmlHttpProduct.readyState == 4) 
	{
		if (xmlHttpProduct.status == 200) 
		{
			document.getElementById("paymentDIV").innerHTML = xmlHttpProduct.responseText ;
			} 
		else 
		{
			alert("There was a problem accessing the server: " + xmlHttpProduct.statusText);
		}
	}		
}



function ProductDetailDelete()
{
	var no_add = document.getElementById("increase_row").value;
	document.getElementById("paymentDIV").innerHTML = "<img src='images/aloading.gif'>";
	xmlHttpProduct = createXmlHttpRequestObject();
	if (xmlHttpProduct.readyState == 4 || xmlHttpProduct.readyState == 0)
	{
		xmlHttpProduct.open("GET", 'calculation.php?no_add='+no_add+'&mode=del', true);
		xmlHttpProduct.onreadystatechange = DeleteResult;
		xmlHttpProduct.send(null);
	}		
}
function DeleteResult()
{
	if (xmlHttpProduct.readyState == 4) 
	{
		if (xmlHttpProduct.status == 200) 
		{
			document.getElementById("paymentDIV").innerHTML = xmlHttpProduct.responseText ;
			} 
		else 
		{
			alert("There was a problem accessing the server: " + xmlHttpProduct.statusText);
		}
	}		
}

