function JsVideo(){
    this.add_favour = function(video_id){
        var favs = Cookie.read("fav");
        if (!favs) 
            favs = ",";
        if (favs.indexOf("," + video_id + ",") >= 0) {
            jsUtils.showMsg("该节目已经在你的收藏中!");
            return;
        }
        else 
            favs = favs + video_id + ",";
        Cookie.write("fav", favs, {
            path: "/",
            duration: 365
        });
        jsUtils.showMsg("成功将该节目加入你的收藏中!");
    }
    this.del_favour = function(video_id){
        var favs = Cookie.read("fav");
        if (!favs) 
            favs = ",";
        if (favs.indexOf("," + video_id + ",") >= 0) {
            favs = favs.replace("," + video_id + ",", ",");
        }
        Cookie.write("fav", favs, {
            path: "/",
            duration: 365
        });
        window.location.reload();
    }
    this.clear_favour = function(){
        if (!confirm("你确定要清空收藏吗?")) 
            return;
        Cookie.write("fav", ",", {
            path: "/",
            duration: 365
        });
        window.location.reload();
    }
	this.play_ad = function(play_div){
		swfobject.embedSWF("/static/swf/BJKP_Player.swf", play_div, "480", "385", "9.0.0");
	}
    this.playv = function(play_div, play_url, auto_play, splash, video_id){
        if (auto_play == null || auto_play == undefined) 
            auto_play = true;
        var vod_url = encodeURI(play_url);
        var cas = {};
        if (splash == null || splash == undefined) {
            cas.backgroundColor = "#000";
            cas.backgroundGradient = "none";
        }
        else {
            cas.background = "url(" + splash + ") no-repeat 50pct 0pct";
        }
		$(play_div).innerHTML = "";
        var plays = flowplayer(play_div, {
            src: "/static/swf/player-3.0.6.swf" + "?" + jsUtils.rand(),
            wmode: "opaque",
            version: [9, 115],
            onFail: function(){
                $(play_div).set("html", "<div class='sectText'>你需要最新版本的Flash Player来观看本节目<br />" +
                "你目前的版本是<span class='msgAlert'>" +
                this.getVersion() +
                "</span></div>");
            }
        }, {
            clip: {
                url: vod_url,
                autoPlay: auto_play,
                scaling: 'fit',
                provider: 'pseudostreaming'
            },
            canvas: cas,
            plugins: {
                pseudostreaming: {
                    url: '/static/swf/player.pseudostreaming-3.1.1.swf'
                },
                controls: {
                    url: '/static/swf/player.controls-3.0.4.swf',
                    height: 25,
                    // base color
                    backgroundColor: '#a6a6a6',
                    backgroundGradient: 'high',
                    borderRadius: '0',
                    opacity: 1.0,
                    // control color
                    timeColor: '#ff6216',
                    durationColor: '#ffffff',
                    progressColor: '#ff4900',
                    progressGradient: 'medium',
                    bufferColor: '#ffc9b4',
                    bufferGradient: 'middle',
                    sliderColor: '#333333',
                    sliderGradient: 'low',
                    buttonColor: '#808080',
                    buttonOverColor: '#ff6216'
                }
            }
        });
        // 做pv统计
        if (auto_play == false) {
            if (jsUtils.is_int(video_id)) {
                var ply = $f();
                if (ply) {
                    ply.onBegin(function(){
                        var params = "video_id=" + video_id;
                        jsUtils.s_ajax("/svplay/", params, {
                            re_load: false
                        });
                    });
                }
            }
        }
        else {
            if (jsUtils.is_int(video_id)) {
                var params = "video_id=" + video_id;
                jsUtils.s_ajax("/svplay/", params, {
                    re_load: false
                });
            }
        }
    }
}

var jsVideo = new JsVideo();
