/*====================================================
	Order Functions
====================================================*/

	function TogglePassword(act)
		{
		if(act == 'e')
			{
//			alert('Enable');
			var obj = document.getElementById('UserPassword');
			obj.style.backgroundColor='#FFF';
			obj.disabled=false;
			}
		else if(act == 'd')
			{
//			alert('Disable');
			var obj = document.getElementById('UserPassword');
			obj.value='';
			obj.style.backgroundColor='#DDD';
			obj.disabled=true;
			}
		}


/*====================================================
	Order Functions
====================================================*/

	function AddItem(item, qty)
		{
//		alert(item);
//		alert(qty);
//		alert(item + ', ' + qty);
		if(qty != '')
			{
			var ProductQuantity = qty;
//			var ProductQuantity = document.getElementById(item + '_ProductQuantity').value;
			if(ProductQuantity > 0)
				{
				var MyMsg = 'Product Code: ' + item + '\nQuantity: ' + ProductQuantity;
				UpdateOrder(item, ProductQuantity, 'I');
				}
			else
				{
				var MyMsg = 'You must select a quantity of at least 1 to add this item to an inquiry';
				alert(MyMsg);
				}
//			alert(MyMsg);
			}
		else
			{
			var MyMsg = 'You must select a quantity of at least 1 to add this item to an inquiry';
			alert(MyMsg);
			}
		}


	function DeleteItem(item)
		{
//		alert('Delete Item: ' + item);
		UpdateOrder(item, 0, 'D');
		}
		

	function InitOrder()
		{
//		alert('Init Order');
		LoadOrder()
		}

/*====================================================
	Ajax Functions
====================================================*/

//	[ Create Objects ]
	if (window.XMLHttpRequest)
		{
		xOrderDetail = new XMLHttpRequest();
		xOrderUpdate = new XMLHttpRequest();
		}
	else if (window.ActiveXObject)
		{
		xOrderDetail = new ActiveXObject('Microsoft.XMLHTTP');
		xOrderUpdate = new ActiveXObject('Microsoft.XMLHTTP');
		}


	function LoadOrder()
		{
//		alert('LoadResults');

		if(xOrderDetail)
			{
			xOrderDetail.open('GET', '/Orders/OrderSummary.asp');
			xOrderDetail.onreadystatechange = function()
				{
//				alert('test');
				try
					{
					if (xOrderDetail.readyState == 4 && xOrderDetail.status == 200)
						{
						document.getElementById('OrderSummary').innerHTML = xOrderDetail.responseText;
//						document.getElementById('divPageNav2').style.display='block';
						}
					}
				catch(err){}
				}
			try
				{
				xOrderDetail.send(null);
				}
			catch(err){}
			}
		}


	function UpdateOrder(ProductId, ProductQuantity, Action)
		{
//		alert('OrderUpdate');
//		alert('OrderUpdate: ' + ProductId + ', ' + ProductQuantity + ', ' + Action);


		if(xOrderUpdate)
			{
//			var MyArgs = 'pid=' + ProductId + '&pq=' + ProductQuantity + '&act=' + Action
//			alert('MyArgs: ' + MyArgs);
			xOrderUpdate.open('GET', '/Orders/OrderUpdate.asp?pid=' + ProductId + '&pq=' + ProductQuantity + '&act=' + Action);
			xOrderUpdate.onreadystatechange = function()
				{
//				alert('test');
				try
					{
					if (xOrderUpdate.readyState == 4 && xOrderUpdate.status == 200)
						{
						document.getElementById('OrderSummary').innerHTML = xOrderUpdate.responseText;
						document.getElementById(ProductId + '_ProductQuantity').value = '';
						location.reload();
//						location.href='http://dev.fitanatomy.com/?p=ProductList&z=123';
						}
					}
				catch(err){}
				}
			try
				{
				xOrderUpdate.send(null);
				}
			catch(err){}
			}

		}



