  var xmlDoc = null ;
  var tp_number2;
  var action2;
  
      function tp_update(tp_number, action) {
		  tp_number2 = tp_number;
		  action2 = action;
        if (typeof window.ActiveXObject != 'undefined' ) {
          xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
          xmlDoc.onreadystatechange = process;
        }
        else {
          xmlDoc = new XMLHttpRequest();
          xmlDoc.onload = process;
        }
 
        xmlDoc.open( "GET", "/itinerary/tp_update.php?tp_id=tp"+tp_number+"&action="+action, true );
        xmlDoc.send( null );
      }
	  
      function process() {
        if ( xmlDoc.readyState != 4 ) return
		if (action2 == "add"){
		document.getElementById(tp_number2).innerHTML='<span class="address_info">Added to Planner</span><br><a class="address_info" href="javascript:tp_update(\''+tp_number2+'\', \'remove\')">Remove</a>';
		} else if (action2 == "remove"){
			document.getElementById(tp_number2).innerHTML='<a class="address_info" href="javascript:tp_update(\''+tp_number2+'\', \'add\')">Add to Planner</a>';
		} else if (action2 == "tp_remove"){
			document.getElementById(tp_number2).innerHTML='';
		} else {
		alert("An error has occured, there is something wrong with the action variable.");	
		}
      }