//when button is clicked
$.fn.clicker=function() {
	$(this).click(function() {
		//response messages
		var error404 = 'We are sorry, there has been an error. Please try submitting again.';
		var success = 'This attraction has been added to your destination library.<br /><br /><a style="color:#fff;" href="/roadtrip-planner/index.aspx">Go to your Destination Library</a>';
		var fail = 'Your submission has failed. Please try again.';
		var exists = 'You have already added this item to your destination library and cannot add it again.';	
		var catchall = 'There was an unknown error. Please try submitting again.';	
		
		//send data and display feedback
		jQuery.ajax({ 
			url: this.href,
			timeout: 2000,
			error: function() { //on 404
				$('p.status').html(error404).fadeIn(500);
				setTimeout('$(\'p.status\').fadeOut(500)', 3000 );
			},
			success: function(r) { 
				if (r == 'success=true') { //save success
					$('p.status').html(success).fadeIn(500);
					setTimeout('$(\'p.status\').fadeOut(500)', 3000 );
					//update current user
					$("#loginBody").load("/TemplateMarkupCallbackHandler.ashx?templateId=72");
				}
				else if (r == 'success=false') { //save failure
					$('p.status').html(fail).fadeIn(500);
					setTimeout('$(\'p.status\').fadeOut(500)', 3000 );
				}
				else if (r == 'success=exists') { //save exists already
					$('p.status').html(exists).fadeIn(500);
					setTimeout('$(\'p.status\').fadeOut(500)', 3000 );
				}
				else { //catch all
					$('p.status').html(catchall).fadeIn(500);
					setTimeout('$(\'p.status\').fadeOut(500)', 3000 );
				}
			}
		})
		return false;
	})
};	
