var cartType = 0; // small cart to start

function showCart(type) {
    cartType = 1 - cartType;
    addToCart(0);
}

function addToCart(pid) {
	processAction("add",pid);
}

function removeItem(pid) {
	processAction("remove",pid);
}

function emptyCart() {
	processAction("empty",0);
}

function saveNameAddr(strClientName,strEmailAddress) {
    var strFormValues = "action=purchase&pid=0&clientName="+escape(strClientName)+"&emailAddress="+escape(strEmailAddress);
    var cartDiv = document.getElementById("publicationCart");
    xmlHttp = GetXmlHttpObject();
    xmlHttp.open("POST","publicationCart.asp",true)
    xmlHttp.onreadystatechange = function() {
       	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        	cartDiv.innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(strFormValues);
}

function makePurchase() {
	processAction("purchase",0);
}

function processAction(strAction,pid) {
    var strFormValues = "action="+strAction+"&pid="+pid+"&type="+cartType;
    var cartDiv = document.getElementById("publicationCart");
    xmlHttp = GetXmlHttpObject();
    xmlHttp.open("POST","publicationCart.asp",true)
    xmlHttp.onreadystatechange = function() {
       	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        	cartDiv.innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(strFormValues);
}

function displayJob(lngJobId,lngPN) {
    var strFormValues = ""
    if (lngJobId != '0') strFormValues += "action=display&";
    strFormValues += "jobid="+lngJobId + "&start=" + lngPN;
    var jpDiv = document.getElementById("jobPostings");
    xmlHttp = GetXmlHttpObject();
    xmlHttp.open("POST","JobPostings.asp",true)
    xmlHttp.onreadystatechange = function() {
       	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        	jpDiv.innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlHttp.send(strFormValues);
}

//*************************** Ajax "plumbing"  ***************************
//*************************** Ajax "plumbing"  ***************************
//*************************** Ajax "plumbing"  ***************************


function GetXmlHttpObject() { 
var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
   {
    alert("This example doesn't work in Opera") 
    return;  
   }
if (navigator.userAgent.indexOf("MSIE")>=0)
   { 
   var strName="Msxml2.XMLHTTP"
   if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
      {
      strName="Microsoft.XMLHTTP"
      } 
   try
      { 
      objXmlHttp=new ActiveXObject(strName)
      //objXmlHttp.onreadystatechange=handler 
      return objXmlHttp
      } 
   catch(e)
      { 
      alert("Error. Scripting for ActiveX might be disabled") 
      return 
      } 
    } 
if (navigator.userAgent.indexOf("Mozilla")>=0)
   {
   objXmlHttp=new XMLHttpRequest()
   //objXmlHttp.onload=handler
   //objXmlHttp.onerror=handler 
   return objXmlHttp
   }
}

