/* Bookmark Dienst */
(function($){  
	$.fn.BookmarkService = function(options) {  
		var ButtonText = "Bookmarken";
		var BackgroundImageButton = false;
		var IconDirectory = "";
		var AsList = true;
		var FetchTitle = false;
		
		if( options )
		{
			/* Setting Option Defaults */
			if( options.ButtonText ) ButtonText = options.ButtonText;
			if( options.BackgroundImageButton ) BackgroundImageButton = options.BackgroundImageButton;
			if( options.IconDirectory ) IconDirectory = options.IconDirectory; 
			if( options.AsList != undefined ) AsList = options.AsList;
			if( options.FetchTitleFrom ) FetchTitle = options.FetchTitleFrom;
		}
		
		$(this).addClass("lp-social-networks");
		return this.each(function() {   
			 
						
			/* Creating the DOM */
			$(this).html( "<p class='bookmark-header'>Social Bookmarks</p><ul class='bookmark-list'></ul>" );			
			$t = $(this).find(".bookmark-list");
			
			/* Adding Clients to  list 
				List of the bookmark services
			*/	
			
			var location = escape(document.location);
			var title = "";
			if( FetchTitle )
				title = FetchTitle.html();
			if( title == null )
				title = document.title;
			
			var Clients = new Array();
			Clients[0] = new Object({ name: "Delicious", href: "http://del.icio.us/post?url=" + location + "&title=" + title, icon: "delicious.gif" });
			Clients[1] = new Object({ name: "Mister Wong", href: "http://www.mister-wong.de/index.php?action=addurl&bm_url="+ location + "&bm_description=" + title, icon: "misterwong.gif" });
			Clients[2] = new Object({ name: "Twitter", href: "http://twitter.com/home?status=" + location , icon: "twitter_smaller.gif" });
			Clients[3] = new Object({ name: "Google", href: "http://www.google.com/bookmarks/mark?op=add&bkmk=" + location + "&title=" + title, icon: "google_book.gif" });
			Clients[4] = new Object({ name: "Yahoo", href: "http://myweb2.search.yahoo.com/myresults/bookmarklet?t="+title+"&d=&tag=&u=" + location, icon: "yahoo.gif" });
			Clients[5] = new Object({ name: "Yigg", href: "http://www.yigg.de/neu?exturl=" + location + "&exttitle=" + title, icon: "yigg.gif" });
			Clients[6] = new Object({ name: "Oneview", href: "http://www.oneview.de/login/loginBookmarklet.jsf?title=" + title + "&URL="+ location, icon: "oneview.gif" });
						
			for( var i = 0; i < Clients.length; i++ )
				$t.append("<li><a href='" + Clients[i].href + "' target='_blank'><img src='" + IconDirectory + "" + Clients[i].icon + "' />" + Clients[i].name +"</a></li>");
		
			
			
		});
	};
})(jQuery);