
function createXMLHttpRequest() {

var ua;

if(window.XMLHttpRequest) {
    try {
      ua = new XMLHttpRequest();
    } catch(e) {
      ua = false;
    }
  } else if(window.ActiveXObject) {
    try {
      ua = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
      ua = false;
    }
  }
  return ua;
}

var req = createXMLHttpRequest();


/* ----------- Display jobPosting ------------- */


function displayJobs(theRequest,theType) {

posType = theType;

req.open('get', 'func.php?requestType=' + theRequest +'&posType='+posType);



	req.onreadystatechange = handleResponse;
	req.send(null);
	document.getElementById('dynContent').innerHTML = "<div id='promptLeft'><img src='images/processing.gif'/></div><div id='promptRightSuccess'>Processing Request.</div>";

}


/* ----------- Add Applicant ------------- */


function addApplicant(theRequest) {



	/* list the variables we need to send to the backend */
	the_job = document.getElementById("job").value;
		
	the_firstName = document.getElementById("firstName").value;
	
	the_middleName = document.getElementById("middleName").value;
	
	the_lastName = document.getElementById("lastName").value;
	
	the_areaCode1 = document.getElementById("areaCode1").value;
	
	the_phoneNum1 = document.getElementById("phoneNum1").value;
	
	the_areaCode2 = document.getElementById("areaCode2").value;
	
	the_phoneNum2 = document.getElementById("phoneNum2").value;
	
	the_email = document.getElementById("email").value;
	
	the_address = document.getElementById("address").value;

	the_city = document.getElementById("city").value;
	
	the_province = document.getElementById("province").value;
	
	the_postalCode = document.getElementById("postalCode").value;

	the_zone = document.getElementById("zone").value;
	the_trade1 = document.getElementById("trade1").value;
	the_trade2 = document.getElementById("trade2").value;
	the_resume = document.getElementById("resume").value;



req.open('get', 'func.php?requestType=' + theRequest 
+'&job='+the_job
+'&firstName='+the_firstName
+'&middleName='+the_middleName
+'&lastName='+the_lastName
+'&areaCode1='+the_areaCode1
+'&phoneNum1='+the_phoneNum1
+'&areaCode2='+the_areaCode2
+'&phoneNum2='+the_phoneNum2
+'&email='+the_email
+'&address='+the_address
+'&city='+the_city
+'&province='+the_province
+'&postalCode='+the_postalCode
+'&zone='+the_zone
+'&trade1='+the_trade1
+'&trade2='+the_trade2
+'&resume='+the_resume
);



	req.onreadystatechange = handleResponse;
	req.send(null);
	document.getElementById('formPrompt').innerHTML = "<div id='promptLeft'><img src='images/prompts/processing.gif'/></div><div id='promptRightSuccess'>Processing Request.</div>";

}


/* -- handle the response and send it back to the front end -- */


function handleResponse() {

  if(req.readyState == 4){
    var response = req.responseText;
    var update = new Array();

    if(response.indexOf('||' != -1)) {
      update = response.split('||');
      document.getElementById(update[0]).innerHTML = update[1];
    }
  }
 // else
  //alert("loading" + req.readyState);
}












