(function() {
	var SocialBookmark = function() {
		
		this.services = [];
		
		this.addService('Facebook', 'http://www.facebook.com/share.php?src=bm&u=__URL__&t=__TITLE__&v=3');
		this.addService('Digg', 'http://digg.com/submit/?url=__URL__&title=__TITLE__');
		this.addService('Delicious', 'http://del.icio.us/post?&url=__URL__&title=__TITLE__');
		this.addService('Google', 'http://www.google.com/bookmarks/mark?op=add&title=__TITLE__&bkmk=__URL__');
		this.addService('Yahoo!', 'http://e.my.yahoo.com/config/edit_bookmark?.src=bookmarks&.folder=1&.name=__TITLE__&.url=__URL__&.save=+Save+');
		this.addService('StumbleUpon', 'http://www.stumbleupon.com/submit?url=__URL__&title=__TITLE__');
		this.addService('MySpace', 'http://www.myspace.com/Modules/PostTo/Pages/?t=__TITLE__&c=%20&u=__URL__&l=2');
		this.addService('Technorati', 'http://technorati.com/faves?add=__URL__');
		this.addService('Reddit', 'http://reddit.com/submit?url=__URL__&title=__TITLE__');
		this.addService('Ask', 'http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&title=__TITLE__&url=__URL__');
		this.addService('Live', 'http://favorites.live.com/quickadd.aspx?url=__URL__&title=__TITLE__');
		this.addService('Mixx', 'http://www.mixx.com/submit?page_url=__URL__');
		this.addService('Blinklist', 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=__URL__&Title=__TITLE__');
		this.addService('Twitter', 'http://twitter.com/home/?status=__TITLE__%3A%20__URL__');
		
		this.element = jQuery("<table></table>");
		var self = this;
		for( var i=0, length=this.services.length ; i<length ; i++ ) {
			var service = $("<tr service-id='"+i+"' style='cursor: pointer;'></tr>");
			service.append("<td><img src='"+baseUrl+"m/art_networking/social-bar/style/images/bookmark-icons/"+this.services[i].icon+"' width='15px' /></td><td>"+this.services[i].name+"</td>");
			
			
			service.click(function( event ) {
				event.preventDefault();
				
				self.addBoomarkToService($(this).attr("service-id"));
			});
			this.element.append(service);
			
		}
		
		this.icon = jQuery("<div class='share-button'></div>");
	};
	
	SocialBookmark.prototype = {
		
		addBoomarkToService : function(i) {
			var url = this.services[i].url;
			var location = window.encodeURIComponent(window.location);
			var title =jQuery("head title").text();
			
			url = url.replace("__TITLE__",title);
			url = url.replace("__URL__",location);
			
			
			window.open (url, "_sozial_bookmark");
		},
		
		addService : function( name, url ) {
			var iconName = name.toLowerCase();
			iconName = iconName.replace(/[^a-z]/,"");
			iconName = "bm_"+iconName+".gif";
			
			this.services.push({"name":name,"url":url,"icon":iconName})
		},
		
		setContent : function() {

		},
		
		getToolbarIcon : function() {
			return this.icon;
		},
		
		getElement : function() {
			return this.element;
		},
		
		getToolbarTitle : function() {
			
		},
		
		getPosition : function() {
			return "left";
		},
		
		isAvailable : function() {
			return true;
		}
	};
	
	
	window.SocialBookmark = SocialBookmark;
})();
