/*
	jQuery delicious tag search interface
	Version 1.0 (09/30/2009)

	Author: Heidi Hysell (hello@heidihysell.com)

	About:
		This plugin takes a listing of tags, places them into a tag cloud and uses that tag cloud as a navigation mechanism.
		It allows the user to search on multiple tags through and or searchs and filters further results on other tags selected.

	API:
		// tells the application to start following the piece of content for the logged in user
		$.deliciousTagSearch.getTagsForUser
		     format: "json", // format of results to return
		     username: "heidihysell", // person whom we're returning results for
		     envUrl: "http://feeds.delicious.com/v2",
		     successCallback: getTagsSuccess,	// returns item if it saved successfully (make sure item id is not null)
		     failureCallback: getTagsFailure // if ajax failed then we get sent to this function
		     
	Example Usage:

		$.followManager.getContentUserIsFollowing({
			successCallback: contentListSuccess,
			failureCallback: contentListFailure,
			page: 1,
			pageSize: 20,
			sort: "RecentlyAdded"
		});

		function contentListSuccess(list) {
			// perform updates on success
		}
		
		function contentListFailure(list) {
			// perform updates on failure
		}

	Dual licensed under the MIT and GPL licenses:
	http://www.opensource.org/licenses/mit-license.php
	http://www.gnu.org/licenses/gpl.html

*/
(function($){ 
	jQuery.deliciousTagSearch = function(options) {

	 };  
	 
	 jQuery.deliciousTagSearch.getEnvUrl = function() {
		 return "http://feeds.delicious.com/v2";
	 };
	 
	 jQuery.deliciousTagSearch.getTagsForUser = function(options) {
		 //alert("jQuery.followManager.startFollowing just triggered!");
		 
		 var container = this;
		 var settings = jQuery.extend({
		     format: "json", 
		     username: "heidihysell",
		     envUrl: "http://feeds.delicious.com/v2",
		     successCallback: getTagsSuccess,	// called with the list of tags for the user
		     failureCallback: getTagsFailure // if ajax failed then we get sent to this function
		   }, options);

		 // use ajax to call delicious to get info
		 $.ajax({
			  type: "GET",
			  url: settings.envUrl + "/" + settings.format + "/tags/" + settings.username + "?callback=?",
			  success: settings.successCallback,
			  failure: settings.failureCallback,
			  cache: false,
			  dataType: "jsonp"
			});
		 
		 function getTagsSuccess() {
			 alert("SUCCESS");
		 }
		 
		 function getTagsFailure() {
			 alert("We are unable to process your request at this time. Please try again later.");
		 }
		 
		 return true;
	 };
	 
})(jQuery);
