function saveJob(jobID) {
  // Create Ajax Request
  createGetRequest();

  //Make sure the Error Message is reset 
  document.getElementById('loginError').style.display="none";
  // Get Form Values
  var url = "job_view_submit.asp?jobID=" + escape(jobID) + "&nocache=" + new Date().getTime();

  request.open("GET", url, true);
  request.onreadystatechange = processSaveJob;
  request.send(null);
}

function processSaveJob() {
  if (request.readyState == 4) {
      if (request.status == 200) {

  		var httpResponse = request.responseText;

  				if (httpResponse=="0"){     // Not Logged in ERROR

                    $('div.loginError').show('slow');

  				}else{ //SAVED

                    //Make sure the Error Message is reset to no display Except the one being called
                     document.getElementById('loginError').style.display="none";
  					//Change the HTML for the div with the response text
  					document.getElementById('jobSaveText').innerHTML = httpResponse;

  				}

      } else {
          alert('There was a problem with the request.');
      }
  }

}

function sendtofriendJV(send,jobID,friendname,friendemail,yourname,youremail) {

  //Hide Previous message if it exists
    var clearEmailStatusOK = document.getElementById('sendFriendSent');
    clearEmailStatusOK.style.display="none";
    var clearEmailStatusErr = document.getElementById('sendFriendError');
    clearEmailStatusErr.style.display="none";

  // Create Ajax Request
  createGetRequest();
  var url = "job_view_submit.asp?jobID=" + jobID + "&send=" + escape(send)+"&friendname=" + escape(friendname) + "&friendemail=" + escape(friendemail)+ "&yourname=" + escape(yourname)+ "&youremail=" + escape(youremail)+ "&nocache=" + new Date().getTime();
  request.open("GET", url, true);
  request.onreadystatechange = sendtofriendJVemail;
  request.send(null);
}

function sendtofriendJVemail() {

  if (request.readyState == 4) {
      if (request.status == 200) {

  		var httpResponse = request.responseText;
        var sendFriendSent = document.getElementById('sendFriendSent');
        var sendFriendError = document.getElementById('sendFriendError');

		if (httpResponse=="0"){     // ERROR

                //Hide previous messages
                $(sendFriendSent).hide('slow');
                //Show Error
			    $(sendFriendError).show('slow');

		}else{     //EMAIL SENT

              //Hide previous messages
              $(sendFriendError).hide('slow');
              //Show Email Sent
              $(sendFriendSent).show('slow');

		}


      } else {
          alert('There was a problem with the request.');
      }
  }

}

// REMOVE Saved Job
function remove_saved_job(jobID){
document.getElementById('removeJob').style.display="none";
   if (confirm("Are you sure you want to remove this Job from your Saved Jobs?\nClick OK to remove or Cancel to return.") == true)
       {
       //alert("Clicked OK");
       window.location=('my_saved_jobs_submit.asp?remove=' + jobID);
       }
}
