function xmlhttpPost(strURL,formID,dispID) {
	document.getElementById("products_loading").innerHTML = "<table border=0><tr><td height=200 valign=middle><img border=0 src='rewards/loading.gif' /></td></tr></table>";
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
		//self.xmlHttpReq.overrideMimeType("text/xml");
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open("POST", strURL, true);
	self.xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			updatepage(self.xmlHttpReq.responseText,dispID);
		}
	}
	self.xmlHttpReq.send(getquerystring(formID));
}

function getquerystring(formID) {
	var qstr= "";
	obj = document.getElementById(formID);
	for(i=0;i<obj.length;i++) {
		qstr+=obj[i].name+"="+escape(obj[i].value)+"&";
	}
	return qstr;
}
function updatepage(str,dispID){
	document.getElementById("products_loading").innerHTML='';
	document.getElementById(dispID).innerHTML = str;
}

function checkForm(obj) {

	if(obj.firstname.value=='') { 
		obj.firstname.focus();
		alert('Please enter your first name.');
		return false;
	}
	if(obj.lastname.value=='') { 
		obj.lastname.focus();
		alert('Please enter your last name.');
		return false;
	}	
	if(obj.streetaddress.value=='') { 
		obj.streetaddress.focus();
		alert('Please enter your street address.');
		return false;
	}	
	if(obj.city.value=='') { 
		obj.city.focus();
		alert('Please enter city name.');
		return false;
	}
	if(obj.province.value=='') { 
		obj.province.focus();
		alert('Province is an required field.');
		return false;
	}	
	if(obj.postalcode.value=='') { 
		obj.postalcode.focus();
		alert('Please enter your postal code.');
		return false;
	}
	if(obj.phone.value=='') { 
		obj.phone.focus();
		alert('Please enter your phone number.');
		return false;
	}	
	
	setStyle(obj.firstname);
	setStyle(obj.lastname);
	setStyle(obj.streetaddress);
	setStyle(obj.streetaddress);
	setStyle(obj.suite);
	setStyle(obj.city);	
	setStyle(obj.postalcode);
	setStyle(obj.phone);
	obj.order_check.style.display="none";
	obj.order_edit.style.display="inline";
	obj.order_submit.style.display="inline";	
	alert("Please verify your information.  Click submit to proceed.");
	return false;
}
function editForm() {
	var obj = document.claim;
	unSetStyle(obj.firstname);
	unSetStyle(obj.lastname);
	unSetStyle(obj.streetaddress);
	unSetStyle(obj.streetaddress);
	unSetStyle(obj.suite);
	unSetStyle(obj.city);	
	unSetStyle(obj.postalcode);
	unSetStyle(obj.phone);
	obj.order_check.style.display="inline";
	obj.order_edit.style.display="none";
	obj.order_submit.style.display="none";		
	return false;
}
function submitForm() {
	xmlhttpPost('rewards.ajax.php?todo=orders','claim','products_all');
	return false;
}
function setStyle(obj) {
	obj.readOnly=true;
	obj.style.border="0px solid white";
	obj.style.fontWeight="600";
}
function unSetStyle(obj) {
	obj.readOnly=false;
	obj.style.border="1px solid #666";
	obj.style.fontWeight="normal";
}