(function(_w)
{
	var share,_width = 0,_height = 0,_w = 0,_h = 0,_dl = 0,_dt = 0;
	
	NetShare = {};
	
	NetShare.render = function(_url, _title, _content)
	{
		var url = _url || document.location.href, title = _title || document.title, content = _content || title
		document.write(getHTML(url, title, content));
	}
	
	NetShare.close = function()
	{
		if( share )
		{
			share.hide();
		}
		return false;
	}
	NetShare.open = function(event,_url, _title, _content)
	{
		event = $.event.fix( event || window.event );
		event.stopPropagation();
		var obj = event.target;
		if( !share )
		{
			share = $('<div style="border:1px solid #ccc;position:absolute;z-index:10000;background:#fff"></div>').appendTo("body");
			share.mousedown(function(event){event.stopPropagation();});
			$(document).click(function(){NetShare.close()});
		}
		
		var position = $(obj).offset();
		
		var url = _url || document.location.href, title = _title || document.title, content = _content || title
		
		share.html(getHTML(url, title, content));
		$("#_closeNetShare_",share).show();
		_width = share.width();
		_height = share.height();
		
		_w = $(window).width();
		_h = $(window).height();
		
		_dt = $(window).scrollTop();
		_dl = $(window).scrollLeft();
		
		var _l = position.left;
		if( _l+_width > _w+_dl )
		{
			_l = _w+_dl - _width - 2;
		}
		var _t = position.top+$(obj).height();
		if( _t+_height > _h+_dt )
		{
			_t = _h+_dt - _height - $(obj).height()-6;
		}
		share.css("top",_t).css("left",_l).show();
		
		return false;
	}
	
	
	function getHTML(url,title,content)
	{
		var html = [];
		html.push('<table border="0" style="border-collapse:separate;border-spacing:6px;">');
		html.push('<tr style="font-size:12px;color:#000;">');
		html.push('<td>分享到：</td>');
		html.push('<td><a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(url)+'" target="_blank" title="分享到QQ空间"><img border="0" align="absMiddle" alt="分享到QQ空间" src="http://qzonestyle.gtimg.cn/ac/qzone_v5/app/app_share/qz_logo.png" width="16" height="16"></a></td>');
		html.push('<td><a href="http://v.t.qq.com/share/share.php?title='+encodeURIComponent(title)+'&url='+encodeURIComponent(url)+'" target="_blank" title="分享到腾讯微博"><img border="0" align="absMiddle" alt="分享到腾讯微博" src="http://file.mafengwo.net/images/login/ico_qq.png" width="16" height="16"></a></td>');
		html.push('<td><a href="http://share.renren.com/share/buttonshare.do?title='+encodeURIComponent(title)+'&link='+encodeURIComponent(url)+'&content='+encodeURIComponent(content)+'" target="_blank" title="分享到人人网"><img border="0" align="absMiddle" src="http://s.xnimg.cn/favicon-rr.ico" alt="分享到人人网" width="16" height="16"></a></td>');
		html.push("<td><a href=\"javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=639365318',u=z||d.location,p=['&amp;url=',e(u),'&amp;title=',e(t||d.title),'&amp;source=',e(r),'&amp;sourceUrl=',e(l),'&amp;content=',c||'gb2312','&amp;pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','"+title+"','"+url+"','utf-8'));\" title=\"分享到新浪微博\"><img border=\"0\" align=\"absMiddle\" src=\"http://file.mafengwo.net/images/login/ico_sina.gif\" alt=\"分享到新浪微博\"  width=\"16\" height=\"16\"></a></td>");
		html.push('<td><a href="http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(title)+'&rurl='+encodeURIComponent(url)+'&rcontent='+encodeURIComponent(content)+'" target="_blank" title="转帖到开心网"><img border="0" align="absMiddle" src="http://img1.kaixin001.com.cn/i/favicon.ico" alt="转帖到开心网"  width="16" height="16"></a></td>');
		html.push('<td><a href="http://www.douban.com/recommend/?title='+encodeURIComponent(title)+'&url='+encodeURIComponent(url)+'&rcontent='+encodeURIComponent(content)+'" target="_blank" title="分享到豆瓣"><img border="0" align="absMiddle" src="http://www.douban.com/favicon.ico" alt="分享到豆瓣" width="16" height="16"></a></td>');
		html.push('</tr>');
		html.push('</table>');
		return html.join("");
	}
})(window)

