document.writeln("<div id=\"share\">");
document.writeln("<span>分享到：</span><ul>");
document.writeln("<li id=\"kaixin001-share\" title=\"开心网\">开心网<\/li>");
document.writeln("<li id=\"renren-share\" title=\"人人网\">人人网<\/li>");
document.writeln("<li id=\"douban-share\" title=\"豆瓣\">豆瓣<\/li>");
document.writeln("<li id=\"sina-share\" title=\"新浪微博\">新浪微博<\/li>");
document.writeln("<li id=\"netease-share\" title=\"网易微博\">网易微博<\/li>");
document.writeln("<li id=\"tencent-share\" title=\"腾讯微博\">腾讯微博<\/li>");
document.writeln("<li id=\"sohu-share\" title=\"搜狐微博\">搜狐微博<\/li>");
document.writeln("<\/ul><\/div>");

function addListener(node, type, listener, obj) {
	var param = obj || {};

	if(node.addEventListener) {
		node.addEventListener(type, function(ev){listener(ev, param);}, false);
		return true;
	} else if(node.attachEvent) {
		node['e' + type + listener] = listener;
		node[type + listener] = function() {
			node['e' + type + listener](window.event, param);
		};
		node.attachEvent('on' + type, node[type + listener]);
		return true;
	}
	return false;
}

function getParamsOfShareWindow(width, height) {
	return ['toolbar=0,status=0,resizable=1,width=' + width + ',height=' + height + ',left=',(screen.width-width)/2,',top=',(screen.height-height)/2].join('');
}

function bindShareList() {
	var link = encodeURIComponent(document.location); // 文章链接
	var title = encodeURIComponent(document.title.replace(" - IE浏览器中文网站","").substring(0,76)); // 文章标题
	var source = encodeURIComponent('IE浏览器中文网站'); // 网站名称
	var windowName = 'share'; // 子窗口别称
	var site = 'http://www.iefans.net/'; // 网站链接

	addListener(document.getElementById('kaixin001-share'), 'click', function() {
		var url = 'http://www.kaixin001.com/repaste/share.php?rurl=' + link + '&rcontent=' + link + '&rtitle=' + title;
		var params = getParamsOfShareWindow(540, 342);
		window.open(url, windowName, params);
	});

	addListener(document.getElementById('renren-share'), 'click', function() {
		var url = 'http://share.renren.com/share/buttonshare?link=' + link + '&title=' + title;
		var params = getParamsOfShareWindow(626, 436);
		window.open(url, windowName, params);
	});

	addListener(document.getElementById('douban-share'), 'click', function() {
		var url = 'http://www.douban.com/recommend/?url=' + link + '&title=' + title;
		var params = getParamsOfShareWindow(450, 350);
		window.open(url, windowName, params);
	});

	addListener(document.getElementById('sina-share'), 'click', function() {
		var url = 'http://v.t.sina.com.cn/share/share.php?url=' + link + '&title=' + title;
		var params = getParamsOfShareWindow(607, 523);
		window.open(url, windowName, params);
	});

	addListener(document.getElementById('netease-share'), 'click', function() {
		var url = 'http://t.163.com/article/user/checkLogin.do?link=' + link + 'source=' + source + '&info='+ title + ' ' + link;
		var params = getParamsOfShareWindow(642, 468);
		window.open(url, windowName, params);
	});

	addListener(document.getElementById('tencent-share'), 'click', function() {
		var url = 'http://v.t.qq.com/share/share.php?title=' + title + '&url=' + link + '&site=' + site;
		var params = getParamsOfShareWindow(634, 668);
		window.open(url, windowName, params);
	});

	addListener(document.getElementById('sohu-share'), 'click', function() {
		var url = 'http://t.sohu.com/third/post.jsp?title=' + link + '&title=' + title + '&content=utf-8';
		var params = getParamsOfShareWindow(650, 510);
		window.open(url, windowName, params);
	});
}

bindShareList();
