var xmlhttp

function getPrice(prov,offer,sub_id) {
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) {
    alert ("Your browser does not support AJAX!");
    return;
  }
  var url="get_price.php";
  //url="http://mysubscription.ca/snowgoer/"+url;
  url+="?prov="+prov;
  url+="&offer="+offer;
  url+="&sub_id="+sub_id
  url+="&rid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

function stateChanged() {
  if (xmlhttp.readyState==4) {
    document.getElementById("price").innerHTML=xmlhttp.responseText;
    
  }
}
function enable() {
	document.order.action = document.order.title;
	document.order.invoice.disabled = false;
	document.getElementById('pp').disabled = false;
}

function GetXmlHttpObject() {
  if (window.XMLHttpRequest) {
    return new XMLHttpRequest();
  }
  if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP");
  }
  return null;
}

function checkRadio(radioName) {
  if (radioName.length) {
    for (i=0; i<radioName.length; i++) if (radioName[i].checked) break;
    if (i==radioName.length) return false;
  } else 
    return false;
  return true;
}

function verifySubmit() {
  var fieldList='';
  if (order.firstname.value  == "") fieldList+='First Name\n';
  if (order.lastname.value   == "") fieldList+='Last Name\n';
  if (order.address.value    == "") fieldList+='Address\n';
  if (order.city.value       == "") fieldList+='City\n';
  if (order.postcode.value   == "") fieldList+='Postal Code\n';
  if (order.prov.value       == "") fieldList+='Province\n';
  if (order.phone.value      == "") fieldList+='Phone\n';
  if (order.email.value      == "") fieldList+='E-mail\n'; 
  
  if (!document.getElementById('valid')) {
  	alert('No valid Subscription chosen.')
  	return false;
  }
  if (fieldList) {
	  alert("Please fill out the following fields:\n\n"+fieldList);
	  return false;
	}
	return true;  
}

function verifyGiftSubmit() {
  var fieldList='';

  if (order.dfirstname.value  == "") fieldList+='Donor First Name\n';
  if (order.dlastname.value   == "") fieldList+='Donor Last Name\n';
  if (order.daddress.value    == "") fieldList+='Donor Address\n';
  if (order.dcity.value       == "") fieldList+='Donor City\n';
  if (order.dpostcode.value   == "") fieldList+='Donor Postal Code\n';
  if (order.dprov.value       == "") fieldList+='Donor Province\n';
  if (order.dphone.value      == "") fieldList+='Donor Phone Number\n';
  if (order.demail.value      == "") fieldList+='Donor Email Address\n';
  if (order.sub_id.value      == "") fieldList+='Subscription\n';
  if (order.firstname.value   == "") fieldList+='First Name\n';
  if (order.lastname.value    == "") fieldList+='Last Name\n';
  if (order.address.value     == "") fieldList+='Address\n';
  if (order.city.value        == "") fieldList+='City\n';
  if (order.postcode.value    == "") fieldList+='Postal Code\n';
  if (order.prov.value        == "") fieldList+='Province\n';
  if (order.phone.value       == "") fieldList+='Phone Number\n';
  if (order.email.value       == "") fieldList+='Email Address\n';
    
  if (!document.getElementById('valid')) {
  	alert('No valid Subscription chosen.')
  	return false;
  }
  if (fieldList) {
	  alert("Please fill out the following fields:\n\n"+fieldList);
	  return false;
	}
	return true;  
}
