var xHRObject = false;
if (window.XMLHttpRequest)
{
	xHRObject = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
	xHRObject = new ActiveXObject("Microsoft.XMLHTTP");
}

function confirmDelete()
{
var agree=confirm("Are you sure you want to delete this item?");
if (agree)
	return true ;
else
	return false ;
}

function callPage(command,commandString,GUID){
var requestBody = "command=";
	requestBody += command;
	requestBody += "&commandString=";
	requestBody += commandString;
	requestBody += "&GUID=";
	requestBody += GUID;
	xHRObject.open("POST","proshop.php", true);
	xHRObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xHRObject.onreadystatechange = getData;
	xHRObject.send(requestBody);
}

function getData()
{
	if(xHRObject.readyState == 4 && xHRObject.status == 200)
	
	{
		var objectID =	xHRObject.responseText;

		var commandArray=objectID.split('|');
		
		for(i=0;i<commandArray.length;i=i+2){
			
		document.getElementById(commandArray[i]).innerHTML=commandArray[i+1];		
		}
	}
}
function callPage2(command,commandString,GUID){
var requestBody = "command=";
	requestBody += command;
	requestBody += "&commandString=";
	requestBody += commandString;
	requestBody += "&GUID=";
	requestBody += GUID;
	xHRObject.open("POST","proshop.php", true);
	xHRObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xHRObject.onreadystatechange = getData2;
	xHRObject.send(requestBody);
}

function getData2()
{
	if(xHRObject.readyState == 4 && xHRObject.status == 200)
	
	{
		var objectID =	xHRObject.responseText;

		var commandArray=objectID.split('|');
		
		for(i=0;i<commandArray.length;i=i+2){
			alert(i);
		self.opener.document.getElementById(commandArray[i]).innerHTML=commandArray[i+1];		
		}
	}
}
function addProduct(intProductID,GUID){
	callPage("addProduct",intProductID,GUID);
	
	}
function changeQty(intProductID,GUID){
	var value=document.getElementById(intProductID+'qty').value;
	callPage("changeQty",intProductID+'|'+value,GUID);
	}
function removeItem(intProductID,GUID){
	
	callPage("removeItem",intProductID,GUID);
	}
function clearBasket(GUID){
	callPage("clearBasket","",GUID);
	
	}	
function checkForm(theForm){
	var valid = true;
	if (theForm.firstname.value == "")
	{
		valid=false;
	}
	if (theForm.lastname.value == "")
	{
		valid=false;
	}
	if (theForm.address1.value == "")
	{
		valid=false;
	}
	if (theForm.zip.value == "")
	{
		valid=false;
	}
	if (theForm.delfirstname.value == "")
	{
		valid=false;
	}
	if (theForm.dellastname.value == "")
	{
		valid=false;
	}
	if (theForm.deladdress1.value == "")
	{
		valid=false;
	}
	if (theForm.delzip.value == "")
	{
		valid=false;
	}
	if (theForm.contact_phone.value == "")
	{
		valid=false;
	}
	if (theForm.email.value == "")
	{
		valid=false;
	}
	
	
	
	if(valid == false){
		alert("Please enter fill out both address sections including a contact number and email address ");
		return false;
	}
	
}