function ajaxAddEventItinJQuery(eventid)
{
	var thisUrl  = imgroot+'/itinerary/index.cfm';
	var thisData = 'action=ajax_addEventItin&eventid='+eventid; 
	thisData += '&avoideCatch=' + myTimestamp(); 

	$.ajax({
	   type: "POST",
	   url: thisUrl,
	   data: thisData,
	   success: function (response){
			//$('#itinEvent_' + eventid).parent().css('backgroundPosition','top left');
			var theImg = $('#itinEvent_' + eventid + ' img');
			$('#itinEvent_' + eventid).empty().html(theImg);
			$('#itinEvent_' + eventid).append('<br /><a href="' + thisUrl + '" class="addeditin">VIEW<br />TRIP PLANNER</a>');
			updateItin();
		},
	   failure: handlerFailuer
	 });
}


function ajaxAddItinJQuery(listingid)
{
	var thisUrl  = imgroot+'/itinerary/index.cfm';
	var thisData = 'action=ajax_addItin&listingid='+listingid;
	thisData += '&avoideCatch=' + myTimestamp(); 

	$.ajax({
	   type: "POST",
	   url: thisUrl,
	   data: thisData,
	   success: function (response){
			var theImg = $('#itin_' + listingid + ' img');
			$('#itin_' + listingid).attr("href",imgroot + "/itinerary/");
			$('#itin_' + listingid).empty().html(theImg);
			$('#itin_' + listingid).append('Added to Itinerary');
			updateItin();
		},
	   failure: handlerFailuer
	 });
}

function removeListing(listingid)
{
	var thisUrl  = imgroot+'/itinerary/index.cfm';
	var thisData = 'action=ajax_update&remove='+listingid; 
	thisData += '&avoideCatch=' + myTimestamp(); 

	$.ajax({
	   type: "POST",
	   url: thisUrl,
	   data: thisData,
	   success: function (response){
			$('#itin_' + listingid).html('<a href="javascript:ajaxAddItinJQuery('+listingid+')">ADD TO ITINERARY</a>');
			updateItin();
		},
	   failure: handlerFailuer
	 });
}

function removeEvent(eventid)
{
	var thisUrl  = imgroot+'/itinerary/index.cfm';
	var thisData = 'action=ajax_update&removecal='+eventid; 
	thisData += '&avoideCatch=' + myTimestamp(); 

	$.ajax({
	   type: "POST",
	   url: thisUrl,
	   data: thisData,
	   success: function (response){
			$('#itinEvent_' + eventid).html('<a href="javascript:ajaxAddEventItinJQuery('+eventid+')">Add to Itinerary</a>');
			updateItin();
		},
	   failure: handlerFailuer
	 });
}


function updateItin(){
	/*$.get(imgroot + '/includes/cftags/itinerary/itineraryDisplay.cfc', {method: "updateItin", fuse_root: imgroot,avoideCache: myTimestamp()},
		function(data){
			$('#itinListHolder').fadeOut().empty();
			$('#itinListHolder').html(data).fadeIn();
		}
	);*/
	$.get(imgroot + '/includes/cftags/itinerary/itineraryDisplay.cfc', {method: "countItin",avoideCache: myTimestamp()},
		  function(data){
			  $('#itineraryDisplay').show();
			  $('#itinCount').empty();
			  $('#itinCount').html(data + ' item(s)');
			  
		  }
	);
}

function handleSuccess(response)
{
	document.body.innerHTML = response.responseText;
			return false;
}

function handlerFailuer(response)
{
	alert(response);
}

function myTimestamp(){
    tstmp = new Date();    
    return tstmp.getTime();
} 
