// JavaScript Document
function handleHttpResponse() {
  if (http.readyState == 4) {
    results = http.responseText;
    document.getElementById(placeholder).innerHTML = results;
  }
}


function getBranch(containerID, url, fr) {
  var params = "b="+fr;
  placeholder = containerID;
  http.open("POST", url, true);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");
  http.send(params);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function subDetails(containerID, url) {
  var params = "name="+document.getElementById('name').value;
  params = params+"&mc="+document.getElementById('mc').value;
  params = params+"&mobile="+document.getElementById('mobile').value;
  params = params+"&email="+document.getElementById('email').value;
  params = params+"&enquiry="+document.getElementById('enquiry').value;
  placeholder = containerID;
  document.getElementById(containerID).innerHTML = '<img src="images/loading.gif" alt="" /> Submitting Form';
  http.open("POST", url, true);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");
  http.send(params);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function subLoyalty(containerID, url) {
  var params = "name="+document.getElementById('name').value;
  params = params+"&add1="+document.getElementById('add1').value;
  params = params+"&add2="+document.getElementById('add2').value;
  params = params+"&town="+document.getElementById('town').value;
  params = params+"&county="+document.getElementById('county').value;
  params = params+"&postcode="+document.getElementById('postcode').value;
  params = params+"&telephone="+document.getElementById('telephone').value;
  params = params+"&email1="+document.getElementById('email1').value;
  params = params+"&email2="+document.getElementById('email2').value;
  placeholder = containerID;
  document.getElementById(containerID).innerHTML = '<img src="images/loading.gif" alt="" /> Submitting Form';
  http.open("POST", url, true);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");
  http.send(params);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function subScroll(containerID, url, fr) {
  var params = "b="+fr;
  placeholder = containerID;
  http.open("POST", url, true);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");
  http.send(params);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}


function newinvite(containerID, url, action, name, email) {
  var params = "a="+action+"&name="+name+"&email="+email;
  placeholder = containerID;
  document.getElementById(containerID).innerHTML = '<img src="images/loading.gif" alt="" /> Sending Invitation';
  http.open("POST", url, true);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");
  http.send(params);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

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 placeholder;
var http = getHTTPObject(); // We create the HTTP Object

