﻿    var root_url = "http://www.7up.com.cn/";
    
    var data = {
        "title": "7喜邀你圣诞玩许愿",
        "url": "", //
        "message": "7喜邀你圣诞玩许愿，许愿即有机会赢取7777元基金，实现愿望就这么简单！还有话费抽奖每日送不停！", 
        "image": ""
    };
    
    var data_video = {
        "title": "7喜的视频看N遍都给力",
        "url": window.location.href, //
        "message": "7喜的视频看N遍都给力，还能赢积分抽话费！", 
        "image": ""
    };
    
    var data_wish = {
        "title": "圣诞就要玩许愿，赢7777元基金！",
        "url": window.location.href, //
        "message": "", 
        "image": ""
    };
        
 
    function share_kaixin() {
        share_score("website", "kaixin");
        data.url = window.location.href;
       
        data.url =formatUrl(data.url,"kaixin");
        window.open("http://www.kaixin001.com/repaste/share.php?rurl=" + encodeURIComponent(data.url) + "&rcontent=" + encodeURI(data.message) + "&rtitle=" + encodeURIComponent(data.title));
    }
    

    function share_renren() {
        share_score("website", "renren");
        data.url = window.location.href;
        data.url =formatUrl(data.url,"renren");
        window.open("http://share.renren.com/share/buttonshare.do?link=" + encodeURIComponent(data.url) + "&title=" + encodeURIComponent(data.message));
    }
	

    function share_sina() {
        share_score("website", "sina");
        data.url = window.location.href;
        data.url =formatUrl(data.url,"sina");
        window.open("http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_tudou_weibo&url=" + encodeURIComponent(data.url) + "&title=" + encodeURIComponent(data.message) + "&pic=" + encodeURIComponent(data.image));
    }
	
	function share_qq() {
	    share_score("website", "qq");
	    data.url = window.location.href;
	    data.url =formatUrl(data.url,"qq");
	    window.open("http://v.t.qq.com/share/share.php?url="+encodeURIComponent(data.url) +"&title=" + encodeURIComponent(data.message) + "&pic=" + encodeURIComponent(data.image));
	}
	
	
	function share_douban()	{
	    share_score("website", "douban");
	    data.url = window.location.href;
	    data.url =formatUrl(data.url,"douban");
		window.open("http://shuo.douban.com/!service/share?href="+encodeURIComponent(data.url) +"&name="+encodeURI(data.message)+ "&image=" + encodeURIComponent(data.image));
	}
	
    function share_qzone(){
        share_score("website", "qzone");
        data.url = window.location.href;
         data.url =formatUrl(data.url,"qzone");
    	window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+encodeURIComponent(data.url) +"&title="+encodeURI(data.title)+ "&desc=" + encodeURI(data.message));
	}
	
	//分享视频
	
	function share_video_kaixin() {
	    share_score("video", "kaixin");
	    data_video.url = window.location.href;
	    data_video.url = formatUrl(data_video.url,"kaixin");
        window.open("http://www.kaixin001.com/repaste/share.php?rurl=" + encodeURIComponent(data_video.url) + "&rcontent=" + encodeURI(data_video.message) + "&rtitle=" + encodeURIComponent(data_video.title));
    }

    function share_video_renren() {
        share_score("video", "renren");
        data_video.url = window.location.href;
        data_video.url = formatUrl(data_video.url,"renren");
        window.open("http://share.renren.com/share/buttonshare.do?link=" + encodeURIComponent(data_video.url) + "&title=" + encodeURIComponent(data_video.message));
    }
	

    function share_video_sina() {
        share_score("video", "sina");
        data_video.url = window.location.href;
        data_video.url = formatUrl(data_video.url,"sina");
        window.open("http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_tudou_weibo&url=" + encodeURIComponent(data_video.url) + "&title=" + encodeURIComponent(data_video.message) + "&pic=" + encodeURIComponent(data_video.image));
    }
	
	function share_video_qq() {
	    share_score("video", "qq");
	    data_video.url = window.location.href;
	    data_video.url = formatUrl(data_video.url,"qq");
	    window.open("http://v.t.qq.com/share/share.php?url="+encodeURIComponent(data_video.url) +"&title=" + encodeURIComponent(data_video.message) + "&pic=" + encodeURIComponent(data_video.image));
	}
	
	
	function share_video_douban() {
	    share_score("video", "douban");
	    data_video.url = window.location.href;
	    data_video.url = formatUrl(data_video.url,"douban");
		window.open("http://shuo.douban.com/!service/share?href="+encodeURIComponent(data_video.url) +"&name="+encodeURI(data_video.message)+ "&image=" + encodeURIComponent(data_video.image));
	}
	
    function share_video_qzone(){
        share_score("video", "qzone");
        data_video.url = window.location.href;
        data_video.url = formatUrl(data_video.url,"qzone");
    	window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+encodeURIComponent(data_video.url) +"&title="+encodeURI(data_video.title)+ "&desc=" + encodeURI(data_video.message));
	}
	
	
	
	//分享心愿
	
	function share_wish_kaixin(wish,wishid) {
	    share_score("website", "kaixin");
	    data_wish.message = "圣诞就要玩许愿，赢7777元基金！我的愿望是：" + wish;
	    data_wish.url = root_url + "#/viewwish/" + wishid + "/";
	    data_wish.url = formatUrl(data_wish.url,"kaixin");
	    data_wish.image = root_url + "images/resized/" + wishid + ".gif";
        window.open("http://www.kaixin001.com/repaste/share.php?rurl=" + encodeURIComponent(data_wish.url) + "&rcontent=" + encodeURI(data_wish.message) + "&rtitle=" + encodeURIComponent(data_wish.title));
    }

    function share_wish_renren(wish,wishid) {
        share_score("website", "renren");
        data_wish.message = "圣诞就要玩许愿，赢7777元基金！我的愿望是：" + wish;
	    data_wish.url = root_url + "#/viewwish/" + wishid + "/";
	    data_wish.url = formatUrl(data_wish.url,"renren");
	    data_wish.image = root_url + "images/resized/" + wishid + ".gif";
        window.open("http://share.renren.com/share/buttonshare.do?link=" + encodeURIComponent(data_wish.url) + "&title=" + encodeURIComponent(data_wish.message));
    }
	

    function share_wish_sina(wish,wishid) {
        share_score("website", "sina");
        data_wish.message = "圣诞就要玩许愿，赢7777元基金！我的愿望是：" + wish;
	    data_wish.url = root_url + "#/viewwish/" + wishid + "/";
	    data_wish.url = formatUrl(data_wish.url,"sina");
	    data_wish.image = root_url + "images/resized/" + wishid + ".gif";
        window.open("http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_tudou_weibo&url=" + encodeURIComponent(data_wish.url) + "&title=" + encodeURIComponent(data_wish.message) + "&pic=" + encodeURIComponent(data_wish.image));
    }
	
	function share_wish_qq(wish,wishid) {
	    share_score("website", "qq");
	    data_wish.message = "圣诞就要玩许愿，赢7777元基金！我的愿望是：" + wish;
	    data_wish.url = root_url + "#/viewwish/" + wishid + "/";
	    data_wish.url = formatUrl(data_wish.url,"qq");
	    data_wish.image = root_url + "images/resized/" + wishid + ".gif";
	    window.open("http://v.t.qq.com/share/share.php?url="+encodeURIComponent(data_wish.url) +"&title=" + encodeURIComponent(data_wish.message) + "&pic=" + encodeURIComponent(data_wish.image));
	}
	
	
	function share_wish_douban(wish,wishid) {
	    share_score("website", "douban");
	    data_wish.message = "圣诞就要玩许愿，赢7777元基金！我的愿望是：" + wish;
	    data_wish.url = root_url + "#/viewwish/" + wishid + "/";
	    data_wish.url = formatUrl(data_wish.url,"douban");
	    data_wish.image = root_url + "images/resized/" + wishid + ".gif";
		window.open("http://shuo.douban.com/!service/share?href="+encodeURIComponent(data_wish.url) +"&name="+encodeURI(data_wish.message)+ "&image=" + encodeURIComponent(data_wish.image));
	}
	
    function share_wish_qzone(wish) {
        share_score("website", "qzone");
        data_wish.message = "圣诞就要玩许愿，赢7777元基金！我的愿望是：" + wish;
	    data_wish.url = root_url + "#/viewwish/" + wishid + "/";
	    data_wish.url = formatUrl(data_wish.url,"qzone");
	    data_wish.image = root_url + "images/resized/" + wishid + ".gif";
    	window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+encodeURIComponent(data_wish.url) +"&title="+encodeURI(data_wish.title)+ "&desc=" + encodeURI(data_wish.message));
	}
	
	function share_socre2(act, sns){
	
	    if(act == "website") act = "shareactaddscore";
	    if(act == "video") act = "sharevideoaddscore";
	    
	    $.ajax({
          type: "POST",
          url: "api/UserAction.aspx?" + Math.random(),
          data: "act=" + act + "&shareType=" + sns
        })
        return true;
	}
	
	function share_score(act, sns){
	    if(act == "website") action = "shareactaddscore";
	    if(act == "video") action = "sharevideoaddscore";
	    
        $.post("api/UserAction.aspx?" + Math.random(),{act:action,shareType:sns},function(result){
            //$("span").html(result);
        });
	}
	
	function formatUrl(url, sns)
	{
	    if(url.indexOf("share_") > 0)
	    {
            if(url.indexOf("kaixin") > 0)
                url = url.replace("kaixin", sns);
            else if(url.indexOf("renren") > 0)
                url = url.replace("renren", sns);
            else if(url.indexOf("douban") > 0)
                url = url.replace("douban", sns);
            else if(url.indexOf("qq") > 0)
                url = url.replace("qq", sns);
            else if(url.indexOf("sina") > 0)
                url = url.replace("sina", sns);

	    }
	    else
        {
            if(url.substring(url.length - 1) == "/")
            {
                url = url + "share_" + sns;
            }
            else
            {
                url = url + "/share_" + sns;
            } 
        }
        
        return url;
	}
	
	
	
	
    
