
function showInterest(ride_id) {

  if(ride_id) {
       collapse = false ;
       document.getElementById("interest." + ride_id).innerHTML = "Showing..." ; 
       Http.get({
		url: "./ajax/interest.php?action=show&ride_id=" + ride_id,
		callback: interestReply,
		cache: Http.Cache.Get
	},[ride_id, collapse]);
  }
}

function removeInterest(ride_id, collapse) {

  if(ride_id) {
       document.getElementById("interest." + ride_id).innerHTML = "Removing..." ;
       Http.get({
		url: "./ajax/interest.php?action=remove&ride_id=" + ride_id,
		callback: interestReply,
		cache: Http.Cache.Get
	},[ride_id, collapse]);
  }

}

function interestReply(xmlReply, ride_id, collapse) {

  if(xmlReply.status == Http.Status.OK) {
     
     var parts = xmlReply.responseText.split("=") ;
     var action = parts[0] ;
     var sucess = parts[1] ;
     var li = document.getElementById("interest." + ride_id) ;
     var showLink = "<a href=\"#\" onClick=\"showInterest(" + ride_id + "); return false;\">Show Interest</a>" ;
     var removeLink = "<a href=\"#\" onClick=\"removeInterest(" + ride_id + "," + collapse + "); return false;\">Remove Interest</a>"
     
     if(action == "add") {
       if(sucess) {
         li.innerHTML = removeLink ;
       } else {
         li.innerHTML = showLink ;
         alert("Show interest failed, which is odd. You should look into your sanity, or perhaps we should look into ours.") ;
       }     
     
     } else if(action=="remove") {
     
       if(sucess) {
         li.innerHTML = showLink ;
         if(collapse) {
           document.getElementById("listing." + ride_id).style.display = "none" ;         
         }
       } else {
         li.innerHTML = removeLink ;
         alert("Remove interest failed, which is odd. You should look into your sanity, or perhaps we should look into ours.") ;
       }
     
     } else {
      //wtf?
     }
     
   } else {
     alert("Ajax call failed.") ;
   }

}

