/**
 * description:生成无序分享内容,可以用三种传参方式
 * 			1、直接传参，依次是"classId" , "divId" , "url" , "title" , "content" , "showCode", "funs", "site", "cssPath", "source"。
 * 				例：var share = new koolearn_share("classId" , "divId" , "url" , "title" , "content");
 *					share.doShare();
 *			2、使用对象的方式传参，只需要传自己需要的参数
 *				例：var share = new koolearn_share({
 *								classId:"classId",
 *								url:"http://www.koolearn.com",
 *								funs:"Qzone,Renren,Sina,Kaixin,Tqq"
 *					});
 *					share.doShare();
 *			3、先定义后修改
 *				例：var share = new koolearn_share();
 *					share.classId = "classId";
 *					share.url = "http://www.koolearn.com";
 *					share.funs = "Qzone,Renren,Sina,Kaixin,Tqq";
 * @param {String} classId：分享组件的classId
 * @param {String} divId：显示位置的divId
 * @param {String} url：分享页面的链接地址
 * @param {String} title：分享页面的标题
 * @param {String} content：开心网使用的简介参数
 * @param {String} showCode：由调用者设置相应的参数来决定显示的具体样式:0不显示文字，1显示文字(目前没有此功能了)
 * @param {String} funs：要显示的分享按钮，及顺序，如："Qzone,Renren,Sina,Kaixin,Tqq,Msn,Douban,T163,Tsohu,Fetion"
 * @param {String} site：网站地址
 * @param {String} pics：分享的图片（多个图片用|分开）
 * @param {String} cssPath：分享条使用的样式表路径
 * @param {String} source：网站的名称
 * 进一步了解请联系：cuidingfeng@koolearn-inc.com
 */
var koolearn_share = function() {
	this.funs="Qzone,Renren,Sina,Kaixin,Tqq,Msn,Douban,T163,Tsohu,Fetion";
	this.site = "www.koolearn.com";
	this.cssPath="http://www.koolearn.com/css/share.css";
	this.source="新东方在线";
	if(typeof arguments[0] == "object"){
		for(arg in arguments[0]){
			this[arg]=arguments[0][arg];
		}
	}else{
		var args=["classId" , "divId" , "url" , "title" , "content" , "showCode", "funs", "site", "pics", "cssPath", "source"];
		for(arg in args){
			if(arguments[arg])this[args[arg]]=arguments[arg];
		}
	}
	var g_share = this;
	var defaultClassId = "defaultClass" ;
	this.getClassId = function() {
		if(this.classId == null||this.classId == "") {
			this.classId = defaultClassId ;
		}
		return this.classId ;
	}
	this.getContainer = function() {
		var obj = null;
        if (!this.divId || !(obj=document.getElementById(this.divId))) {
            return null;
        }
        return obj;
	}
	this.getUrl = function(){
        if (this.url == null || this.url == "") {
            var param = window.location.search;
            this.url = window.location.href;
            if (param != null && param != "") {
                this.url += "?" + param;
            }
        }
        return encodeURIComponent(this.url);
    }
    this.getTitle = function(){
        if (this.title == null || this.title == "") {
            this.title = document.title;
        }
        return encodeURIComponent(this.title);
    }
    this.getPics = function(){
        if (this.pics == null || this.title == "") {
            this.pics = "";
        }
        return encodeURIComponent(this.pics);
    }
	this.getContent = function() {
		if(this.content == null||this.content == "") {
			return null ;
		}
		return encodeURIComponent(this.content) ;
	}
	this.getSource = function() {
		if(this.source == null||this.source == "") {
			return "" ;
		}
		return encodeURIComponent(this.source) ;
	}
	<!--开心-->
	function getKaixin(){
        var url = "http://www.kaixin001.com/~repaste/repaste.php?";
		url += "rurl=" + g_share.getUrl() + "&rtitle=" + g_share.getTitle();
		if (g_share.getContent()){
			url += "&rcontent="+g_share.getContent();
		}
        return {href:url,title:"分享到开心网"};
    }
	<!--豆瓣-->
    function getDouban(){
        var url = "http://www.douban.com/recommend/?"
        url += "url=" + g_share.getUrl() + "&title=" + g_share.getTitle();
        return {href:url,title:"分享到豆瓣网"};
    }
	<!--人人-->
    function getRenren(){
        var url = "http://share.xiaonei.com/share/buttonshare.do?";
        url += "link=" + g_share.getUrl() + "&title=" + g_share.getTitle();
        return {href:url,title:"分享到人人网"};
    }
    <!--新浪微博-->
    function getSina(){
        var appKey = "3297384058";
        var url = "http://v.t.sina.com.cn/share/share.php?";
        url += "appkey=" + appKey + "&url=" + g_share.getUrl() + "&title=" + g_share.getTitle() + '&pic=' + g_share.getPics();
        return {href:url,title:"分享到新浪微博"};
    }
    <!--Qzone-->
    function getQzone(){
        var url = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?";
        url += "url=" + g_share.getUrl() + "&title=" + g_share.getTitle() + "&pics=" + g_share.getPics();
        return {href:url,title:"分享到Qzone"};
    }
    <!--腾讯微博-->
    function getTqq(){
		var appkey = "ba36faf481494730bccc2c58de9f6cf9";
        var url = "http://v.t.qq.com/share/share.php?";
        url += "title=" + g_share.getTitle() + "&url=" + g_share.getUrl() + "&appkey=" + appkey + "&site=" + g_share.site + '&pic=' + g_share.getPics();
        return {href:url,title:"分享到腾讯微博"};
    }
    <!--MSN-->
    function getMsn(){
        var url = "http://profile.live.com/badge?";
        url += "url=" + g_share.getUrl();
        return {href:url,title:"分享到MSN"};
    }
    <!--网易微博-->
    function getT163(){
        var url = "http://t.163.com/article/user/checkLogin.do?";
		url += "source=" + g_share.getSource() + "&info=" + g_share.getTitle() + "+" + g_share.getUrl();
        return {href:url,title:"分享到网易微博"};
    }
    <!--搜狐微博-->
    function getTsohu(){
        var url = "http://t.sohu.com/third/post.jsp?";
        url += "url=" + g_share.getUrl() + "&title=" + g_share.getTitle() + "&content=" + g_share.getContent();
        return {href:url,title:"分享到搜狐微博"};
    }
    <!--飞信-->
    function getFetion(){
        var url = "http://space.feixin.10086.cn/api/share?";
        url += "source=" + g_share.getSource() + "&title=" + g_share.getTitle() + "&url=" + g_share.getUrl();
        return {href:url,title:"分享到飞信"};
    }
	this.doShare = function() {
		koolearn_share.len++;
		setCss();
		getCt();
		<!--返回html代码,插入相应的位置-->
        function getCt(){
            var html = '<span class="koo_share '+g_share.getClassId()+'" id="koo_share'+koolearn_share.len+'"><span>分享到：</span><div class="koo_share_all">';
			var arrFun = g_share.funs.split(",");
			var fnData = null;
			for(i in arrFun){
				try {
					if (arrFun[i]) {
						eval("fnData = get" + arrFun[i] + "();");
						html += '<a href="' + fnData.href + '" target="_blank" title="' + fnData.title + '" class="koo_share_' + arrFun[i] + '"></a>';
					}
				} catch (e) {
				}
			}
			html += '</div></span>' ;
			if (g_share.getContainer() == null){
				document.write(html);
			}else{
	            g_share.getContainer().innerHTML = html;
			}
			(function(box){
				box.onmouseover = function(){
					this.getElementsByTagName("div")[0].style.height="auto";
					this.getElementsByTagName("div")[0].style.borderColor="#ddd";
					this.getElementsByTagName("div")[0].style.position="relative";
					return this;
				};
				box.onmouseout = function(){
					this.getElementsByTagName("div")[0].style.height="";
					this.getElementsByTagName("div")[0].style.borderColor="";
					this.getElementsByTagName("div")[0].style.position="";
					return this;
				};
			})(document.getElementById("koo_share"+koolearn_share.len));
        }
		function setCss(){
			if(document.getElementById("shareCss"))return;
			var fileref=document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("id", "shareCss");
			fileref.setAttribute("href", g_share.cssPath);
			document.getElementsByTagName("head")[0].appendChild(fileref);
		}
	}
}
koolearn_share.len=0;
