(function($){
$.fn.shareHatenaBookmark = function(){
	$(this).each(function(){
		var anchor = $(this);
		var curLocation = encodeURIComponent(location.href);
		var url = 'http://b.hatena.ne.jp/append?' + curLocation;
		anchor.attr('href',url);
		anchor.attr('target','_blank');
	});
	return this;
};
$.fn.shareDelicious = function(){
	$(this).each(function(){
		var anchor = $(this);
		var title = encodeURIComponent(document.title);
		var curLocation = encodeURIComponent(location.href);
		var url = 'http://del.icio.us/post?url=' + 
			curLocation + '&title=' + title + '&v=5&jump=yes';
		anchor.attr('href',url);
		anchor.attr('target','_blank');
	});
	return this;
};
$.fn.shareTwitter = function(){
	var setting = $.extend({
		hrefText : false,
		query : ''
	}, $.makeArray(arguments).shift());
	$(this).each(function(){
		var anchor = $(this);
		var url = ''
		if(setting.hrefText){
			var text = encodeURIComponent($(anchor.attr('href')).text());
			url = 'http://twitter.com/?status='+text;
		} else if(setting.query != ''){
			var defQuery = encodeURIComponent(setting.query);
			url = 'http://twitter.com/?status='+defQuery;
		}  else {
			var curLocation = encodeURIComponent(location.href);
			url = 'http://twitter.com/?status='+curLocation;
		}
		anchor.attr('href',url);
		anchor.attr('target','_blank');
	});
	return this;
};
$.fn.shareMailTo = function(){
	$(this).each(function(){
		var anchor = $(this);
		var curLocation = encodeURIComponent(location.href);
		var url = 'mailto:?Body=' + curLocation;
		anchor.attr('href',url);
	});
	return this;
};
$.fn.shareFacebook = function(){
	var setting = $.extend({
		locate : ''
	}, $.makeArray(arguments).shift());
	$(this).each(function(){
		var anchor = $(this);
		var title = encodeURIComponent(document.title);
		var curLocation = encodeURIComponent(location.href);
		if(setting.locate){
			curLocation = encodeURIComponent(setting.locate);
		}
		var url = 'http://www.facebook.com/share.php?u='+curLocation+'&t='+title;
		anchor.attr('href',url);
		anchor.attr('target','_blank');
	});
	return this;
};
$.fn.shareTumblr = function(){
	var setting = $.extend({
		hrefText : false,
		locate : ''
	}, $.makeArray(arguments).shift());
	$(this).each(function(){
		var anchor = $(this);
		var title = encodeURIComponent(document.title);
		var curLocation = encodeURIComponent(location.href);
		if(setting.locate){
			curLocation = encodeURIComponent(setting.locate);
		}
		var text = '';
		if(setting.hrefText){
			text = encodeURIComponent($(anchor.attr('href')).text());
		}
		var url = 'http://www.tumblr.com/share?v=3&u='+curLocation+'&t='+title+'&s='+text;
		anchor.attr('href',url);
		anchor.attr('target','_blank');
	});
	return this;
};
$.fn.shareGoogleBookmarks = function(){
	$(this).each(function(){
		var anchor = $(this);
		var title = encodeURIComponent(document.title);
		var curLocation = encodeURIComponent(location.href);
		var url = 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + 
			curLocation + '&title=' + title;
		anchor.attr('href',url);
		anchor.attr('target','_blank');
	});
	return this;
};
$.fn.shareYahooBookmark = function(){
	$(this).each(function(){
		var anchor = $(this);
		var title = encodeURIComponent(document.title);
		var curLocation = encodeURIComponent(location.href);
		var url = 'http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t=' + 
			title + '&u=' + curLocation + '&opener=bm&ei=UTF-8';
		anchor.attr('href',url);
		anchor.attr('target','_blank');
		/*
			release these if you wannna open window using window.open.
			this can avoid window resizing.
		*/
		anchor.click(function(e){
			e.preventDefault();
			window.open(url,'popup','width=550px,height=480px,status=1,location=0,resizable=1,scrollbars=0,left=100,top=50',0);
		});
	});
	return this;
};
})(jQuery);
