// System Functions
function getHTTPObject(){
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
      try{
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(E){
      xmlhttp = false;
    }
  }
  @else
    xmlhttp = false;
  @end @*/
  if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    try {
      xmlhttp = new XMLHttpRequest();
    }catch(e){
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var cpml_http = getHTTPObject();
function urlencode(str) {
	return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}
function cpml_OVon(){
	document.getElementById('cpml_BK').style.display = "block";
}
function cpml_OVoff(){
	document.getElementById('cpml_BK').style.display = "none";
	document.getElementById('cpml_OV').innerHTML = "Loading...";
}
function cpml_OVchg(){
  if(cpml_http.readyState == 4){
   goToThankyou();
  }
}
function cpml_AJAX(url,params){
	cpml_http.open("POST", url, true);
	cpml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	cpml_http.setRequestHeader("Content-length", params.length);
	cpml_http.setRequestHeader("Connection", "close");
	cpml_http.onreadystatechange = cpml_OVchg;
	cpml_http.send(params);
}
function goToThankyou(){
	window.parent.location.href = "http://convoyautorepair.com/coupon-thankyou"
	//window.parent.location.href = "http://convoyautorepair.localhost/coupon-thankyou"
}
// Local Functions

//function cpml_join() {	// REMOVED BY REQUEST?
//	cpml_OVon();
//	var url = "cpml/ajax.php";
//	var params = "a=joinDialog";
//	cpml_AJAX(url,params);
//}

function cpml_save(objForm) {
	//cpml_OVon();
	var url = "coupons/cpml/ajax.php";
	var params = "a=joinAction";
	params += "&first_name="+urlencode(objForm.userFName.value);
	params += "&last_name="+urlencode(objForm.userLName.value);
	params += "&email="+urlencode(objForm.userEmail.value);
	//document.getElementById('cpml_OV').innerHTML = "<h2>Processing</h2>";
	cpml_AJAX(url,params);
	//setTimeout("cpml_OVoff();",10000);
}