//acsend$(document).ready(function () {
  //    gettalk();
  
  //  getuser();
   
//});

//在线学员
var student = 0;
function getuser2() {
 
    $.ajax({
        type: 'Post',
        datatype: 'text',
        url: "index.aspx?c=course&a=liveplay&frame=no&action=getuser",
        data: { courseID: CourseID, id: id },
        success: function (msg) {
            //alert(msg);
            if (msg.length > student) {
                student = msg.length;
                if ($("#student").html()) {
                    document.getElementById('student').innerHTML = msg;
                    $(function () {
                        var i = 1
                        var num = $(".studentlist li").length
                        num = Math.ceil(num / 8)
                        $(".next").click(function () {
                            i++
                            if (i >= num) i = num
                            var h = $(".studentlist").height() * i - 400
                            $(".block02 .student").animate({ top: -h }, 400);
                            $(".prve").removeClass("cur")
                            if (i == num) {
                                $(".next").addClass("cur")
                            }
                        })
                        $(".prve").click(function () {
                            i--
                            if (i <= 1) i = 1
                            var h = $(".studentlist").height() * i - 400
                            $(".block02 .student").animate({ top: h }, 400);
                            $(".next").removeClass("cur")
                            if (i == 1) {
                                $(".prve").addClass("cur")
                            }
                        })
                    });
                }
            }
        }
    });
    setTimeout("getuser()", 10000);
}

//笔记
function savebj(id) {

    var Intro = jQuery("#TxtIntro").val();
   
    var share = 0; //0不分享  1分享
    if ($('#shareBjClick').attr('class').indexOf('checked-bt')!=-1){
         share=1;
    }  
    jQuery.ajax({
        url: "/index.aspx?c=course&a=liveplay&action=savebj&courseid="+CourseID+"&share=" + share + "&pid=" + id + "&rnd=" + Math.random() + "&Intro=" + escape(Intro), success: function (d) {
          
            jQuery("#notes_ulist").html(d);
        }
    });
}
//聊天
function subask() {
    jQuery.ajax({
        type: "POST",
        datatype: "xml",
        url: "/plus/ajaxs.ashx",
        data: "a=checkislogin",
        success: function (xml) {
            var islogin = jQuery(xml).find("login islogin").text();
            if (islogin == 'false') {
                showuserlogin();
                return false;
            }
            else {
                var content = $("#saytext").val();
                //var content = editor.getContent();
                if(content=='')
                    {
               // if (editor.hasContents() == false) {
                    alert("请输入问题内容");
                   // editor.focus();
                } else {
                    //content = content.replace("<p>", "");
                   // content = content.replace("</p>", "");

                    //editor.execCommand('cleardoc');
                    //alert(content);
                    $.ajax({
                        type: 'Post',
                        datatype: 'text',
                        url: '/index.aspx?c=course&a=liveplay&frame=no&action=getuserstatus',
                        data: { courseID: CourseID, id: id, content: content },
                        success: function (msg) {
                            //alert("11");
                            var stcrolltop = document.getElementById('showuserask').scrollHeight;
                            $('.discuss_list').animate({ scrollTop: "" + stcrolltop + "px" }, 500);
                            $("#saytext").val('');
                        }
                    });
                }
            }
        }
    });
}
//获取聊天记录
function gettalk() {
    $.ajax({
        type: 'Post',
        datatype: 'text',
        url: "index.aspx?c=course&a=liveplay&action=gettalk",
        data: { courseID: CourseID, id: id },
        success: function (msg) {
            if (msg != "") {
                $("#showuserask").append(msg);
                $("#showuserask li").each(function () {
                    var id = $(this).find(".userid").text()
                    if (id == userid) {
                        $(this).removeClass("discussother");
                        $(this).addClass("discussme");
                    }
                    else {
                        $(this).addClass("discussother")
                    }
                });
                var stcrolltop = document.getElementById('chatlists').scrollHeight;
                $('.discuss_list').animate({ scrollTop: "" + stcrolltop + "px" }, 500);
            }
        }
    });
    setTimeout("gettalk()",10000);
}
//获取在线学员
function getuser() {
    $.ajax({
        type: 'Post',
        datatype: 'text',
        url: "index.aspx?c=course&a=liveplay&frame=no&action=getuser",
        data: { courseID: CourseID, id: id },
        success: function (msg) {
            if (msg.length > student) {
                student = msg.length;
                document.getElementById('student').innerHTML = msg;
            }
        }
    });
    setTimeout("getuser()", 10000);
}
//送道具
function acsend(acid, num, courseid, periodid, coursetype, page,playtype) {
    var acnum = parseInt($("#acnum" + acid + "").html());//道具数量
    if (acnum == 0) {    //判断登录
        jQuery.ajax({
            type: "POST",
            datatype: "xml",
            url: "/plus/ajaxs.ashx",
            data: "a=checkislogin",
            success: function (xml) {
                var islogin = jQuery(xml).find("login islogin").text();
                if (islogin == 'false') {
                    showuserlogin();
                }
                else {
                    if (confirm("您赠送的道具数量不足，是否去购买")) {
                        openwinbuy();
                    }
                }
            }
        });
    }
    else {
        if (acnum < num)//判断道具数量
        {
            if (confirm("您赠送的道具数量不足，是否去购买")) {
                openwinbuy();
            }
        }
        else {
            if (confirm("您确定送出道具吗？")) {
                var actionplaytype = "liveplay";
                if (playtype == 1)//点播状况
                {
                    actionplaytype = "play";
                }
                var contribute = $("#GX" + acid).html();
                var imgsrc = $("#ac" + acid).find("img").attr("src");
                var sendertype = parseInt($("#sendtype").val())
                if (sendertype == "" || isNaN(sendertype) || typeof (sendertype) == "undefined")
                {
                    sendertype = 0;
                }
                $.ajax({
                    type: 'Post',
                    datatype: 'text',
                    url: "index.aspx?c=course&a=" + actionplaytype + "&action=stuacsend",
                    data: { num: num, acid: acid, acepter: "", sendertype: sendertype, sendtime: 1, CourseID: courseid, id: periodid, GX: contribute, imgsrc: imgsrc },
                    success: function (msg) { 
                        if (msg == "0") {
                            showuserlogin();
                        } else if (msg == "alike") {
                            alert("不可以自己送自己礼物哦~~");
                        } else if (msg == "error") {
                            alert("参数出现错误哦~~请重试！");
                        } else {
                            $("#acnum" + acid + "").html(acnum - num);//页面数量减一
                            showplaychat(courseid, periodid, coursetype, page);
                        }
                    }
                });
            }
        }
    }
}
var box1 = '';

function openwinbuy() {
        box1 = $.dialog.open("/plus/course/buyprop.aspx", { fixed: true, title: "<div style='text-align:left'>购买道具</div>", width: 700, height: 600, max: false, min: false });
}
function gosend(acid, course, period, coursetype, page) {
    var sendnum = $("#sendnum" + acid).val();
    if (!isNaN(sendnum)) {
        if (sendnum > 0) {
            acsend(acid, sendnum, course, period, coursetype, page);
        }
    }
    else {
        alert("您输入的数量有误");
    }
}

// 贡献值
function showGX() {

    $(".live_rightbox .tab_name li").addClass('curr').siblings().removeClass('curr');
    var index = 4;
    $('.tab_con .tabbox:eq(' + index + ')').show().siblings().hide();
    $.ajax({
        type: 'Post',
        datatype: 'text',
        url: "index.aspx?c=course&a=liveplay&action=getGX",
        data: { courseID: CourseID, id: id },
        success: function (msg) {
            $("#GXB").html(msg);
        }
    });
}

//显示批量赠送的道具信息
function showmorenum(acid)
{ 
    $('.gife2').hide();
    $("#send" + acid).fadeIn(300);
    
}

function hidemorenum(){
    $('.gife2').fadeOut(300);
}



 


//校验直播的道具信息
function checkliveprop() {
    jQuery.ajax({
        type: "get",
        url: "/plus/course/learnscore.aspx?action=checkprop&CourseID=" + CourseID + "&PeriodId=" + id,
        datatype: "JSON",
        success: function (obj) {
            //console.log(obj);
            var json = jQuery.parseJSON(obj);
            //console.log(json);
            //存在道具信息    以及   可使用的道具信息不为空
            if (json.type == "success" && json.propid != "") {
                var propid = json.propid.split(",");//可执行的道具信息
                var propinfo = json.data;
                for (var i = 0; i < propid.length - 1; i++) {
                    //console.log(i + "++++++");
                    for (var p = 0; p < json.data.length; p++)//所有的道具信息
                    {
                        //console.log(p + "|||----|||" + propid[i] + "****" + propinfo[p].propid + "####" + parseInt(propinfo[p].proptype));
                          //if (propid[i] == propinfo[p].propid)//道具条件满足触发
                        if (1 == 1&&$("#proplive").is(":hidden")==true) {
                            $("#proplive").show();
                            //道具类型信息
                            switch (parseInt(propinfo[p].proptype)) {
                                case 0://赠送积分 
                                    PropScore(propinfo[p]);
                                    break;
                                case 1://问卷
                                    PropQuestion(propinfo[p]);
                                    break;
                                case 2://公告 
                                    PropAnnounce(propinfo[p]);
                                    break;
                                case 3://投票   
                                    PropVote(propinfo[p]);
                                    break;
                                case 4://试卷
                                    PropExam(propinfo[p]);
                                    break;
                                case 5://商品
                                    PropShop(propinfo[p]);
                                    break;
                                case 6://游戏
                                    PropGame(propinfo[p]);
                                    break;
                                case 7://签到 
                                    PropCall(propinfo[p]);
                                    break;
                            }
							
                        } else {
                            break;
                        }
                    }
                }
				$('.innercon').each(function () {
					//超出的滚动条
					$(this).niceScroll({
						cursorcolor: "rgba(0,0,0,0.1)",
						cursoropacitymax: 1,
						touchbehavior: false,
						cursorwidth: "6px",
						cursorborder: "0",
						cursorborderradius: "5px"
					});
				}); 
            }
        }
    });
}
///获取抢答答案信息
function addcheck(propid, proptype, propinfo, courseid, lessonid) {
    var sid = 0;
    for (var i = 0; i < document.getElementsByName("aoption").length; i++) {
        var KS = document.getElementsByName("aoption")[i];
        if (KS.checked == true) {
            sid = KS.value;//获取答案信息
        }
    }
    if (sid != 0) {
        var data = "&courseid=" + courseid + "&periodid=" + lessonid + "&proptype=" + proptype + "&bindid=" + propinfo;
        jQuery.ajax({
            type: "post",
            url: "/plus/course/LearnScore.aspx?action=savegameanswer&propid=" + propid + "&sid=" + sid + data,
            success: function (obj) {

                var json = jQuery.parseJSON(obj);
                console.log(json);
                if (json.type == "success") {
                    //{type: "success", content: "100", jltype: "资金"}
                    var info = '<div class="integralBox " onclick="CloseProp()">';
                    info += '	<div class="integralNum">' + json.content + json.jltype + '</div>';
                    info += '</div>';
                    $("#proplive").html("<div class='prop' >" + info + "</div>");
                }
                else {
                    var info = '<div id="answerBox" class="prop animated zoomIn" style="display: block;"><div class="answerBox resultbox">';
                    info += '<div class="ans-B">';
                    info += ' <div class="anTitle"><input type="button" class="closeBtn" onclick="closetoupiao(6)">抢答失败</div>';
                    info += '   <div class="anCon">';
                    info += '        <div class="wTlist">';
                    info += '            <div id="a-coursetop">';
                    info += '               <ul>';
                    info += '                </ul>';
                    info += '            </div>';
                    info += '        </div>';
                    info += '       <div class="wTipsBox ">';
                    info += '           <div class="wrongTips"><span> </span><span> </span></div>';
                    info += '           <div class="details"><a href="javascript:;" title="再接再厉" onclick="closetoupiao(6)">下次加油</a></div>';
                    info += '       </div>';
                    info += '   </div>';
                    info += '</div>';
                    info += '</div></div>';
                    var info = '<div class="integralBox " onclick="CloseProp()">';
                    info += '	<div class="integralNum">' + json.content + json.jltype + '</div>';
                    info += '</div>';
                    $("#proplive").html("<div class='prop' >" + info + "</div>");
                }
            }
        });
    } else {
        alert("请选择答案信息！");
        return false;
    }
}


function tjwenjuanl(worknum, sjid) {
    var data = "action=savewenjuan";//传递的答案信息
    if (worknum > 0) {
        for (var i = 1; i <= worknum; i++) {//总题目数量
            if (document.getElementsByName("tmtype" + i)[0].value != 5) {/****单选或多选***/
                var optionnum = document.getElementsByName("optionmum" + i)[0].value;//选项个数
                var ans = null;//声明一个接受答案的变量
                for (var j = 0; j < optionnum; j++)//获取选中的答案信息
                {
					var type = document.getElementsByName("Satisfied" + i)[0].type;
                    var KSC = type === 'radio' ? document.getElementsByName("Satisfied" + i)[j] : document.getElementsByName("Satisfied" + i)[0];
					
                    if (KSC.checked == true) {//选中状态   区分多种情况
                        if (ans == null) {
                            ans = KSC.value;
                        } else { ans += "," + KSC.value; }
                    }
                }
                data += "&num" + i + "=" + ans;//传递答案信息

            } else {//问答题
                data += "&num" + i + "=" + document.getElementsByName("content" + i)[0].value;
            }
            data += "&tmtype" + i + "=" + document.getElementsByName("tmtype" + i)[0].value + "&tmid" + i + "=" + document.getElementsByName("tmid" + i)[0].value;
        }
    }
    data += "&sjid=" + sjid + "&worknum=" + worknum;

    jQuery.ajax({
        type: "post",
        url: "/plus/course/LearnScore.aspx",
        data: data,
        success: function (data) {
            console.log(data);
			var json=jQuery.parseJSON(data);
			
			var info =	'<div name="wenjuan1" id="wenjuan1" class="q-con">';
				info +=	'	<div class="q-innercon innercon" style="overflow: hidden; outline: none;">';
				info +=	'		<div class="q-title">'+json.propinfo[0].title+'</div>';
				info +=	'		<ul class="q-option">';
				for (var n = 0; n < json.propinfo.length; n++) {
					var dataInfo = json.propinfo[n].item; 
					for (var i = 0; i < dataInfo.length; i++) { 
						info += '<li class="clearfix"><span class="fr">票数：'+dataInfo[i].num+'</span><label>'+dataInfo[i].content+'</label></li>';
					}
				}
				info +=	'		</ul>';
				info +=	'	</div>';
				info +=	'	<input type="button" value="关闭" class="q-finish-btn" onclick="CloseProp()">';
				info +=	'</div>';
				$("#proplive").html("<div class='questionBox prop'>" + info + "</div>");
				$("#proplive").show();
				$(".questionBox").show();
        }
    });

}


//提交投票信息
function tjtoupiaol() {
    var data = "action=savetoupiao";//传递的答案集合
    var sid = 0;//答案编号
    var num = document.getElementsByName("voption").length;
    var voteid = document.getElementsByName("voteid")[0].value;
    var votetype = document.getElementsByName("votetype")[0].value;
    //获取答案集合
    for (var i = 0; i < num; i++) {
        var KS = document.getElementsByName("voption")[i];
        if (KS.checked == true) {//选中状态
            sid = KS.value;
        }
        data += "&sv" + i + "=" + sid;
        sid = 0;
    }
    data += "&num=" + num + "&voteid=" + voteid + "&votetype=" + votetype;
    jQuery.ajax({
        type: "post",
        url: "/plus/course/LearnScore.aspx",
        data: data,
        success: function (data) {
            //console.log(data);
			var json=jQuery.parseJSON(data);
			var info =  '<div class="sv-con innercon">';
				info +=	'<div class="sv-title">感谢您对这次投票的支持，持续关注，还有惊喜等着你哦。</div>';
				info +=	'<ul class="sv-option">';
				for (var i = 0; i < json.length; i++) { 
					if (json[i].status == 1) {
						info += '<li class="curr clearfix"><em>'+json[i].name+'</em><input disabled="" type="radio" name="voption2" checked><label>'+json[i].num+'</label></li>';
					} else {
						info += '<li class="clearfix"><em>'+json[i].name+'</em><input disabled="" type="radio" name="voption2"><label>'+json[i].num+'</label></li>';
					}
				}

				info +=	'</ul>';
				info +=	'<div class="v-submit-btn"><input type="image" src="/sysimg/prop/tpbtn2.png" onclick="CloseProp()"></div>';
				info +='</div>';
				$("#proplive").html("<div class='svoteBox prop'>" + info + "</div>");
				$("#proplive").show();
				$(".svoteBox").show();
        }
    });
}
//关闭道具信息
function CloseProp() {
    //隐藏最外层幕布信息
    $("#proplive").hide(); $("#proplive").html("");
}

//签到的触发方法
function PropCall(propinfo) {
    var info = '<div class="a-con"><div class="a-Num">签到打卡</div><input type="button" class="a-btn" value="确定" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ')"></div>';
    $("#proplive").html("<div class='SignIn prop'>" + info + "</div>");
}

//积分的触发方式
function PropScore(propinfo) {
    var info = '<div class="a-con"><div class="a-Num">' + propinfo.bindid + '</div><div class="a-tips">恭喜您获得奖励积分</div><input type="button" class="a-btn" value="领取" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ')"></div>';

    $("#proplive").html("<div class='Advertisement prop'>" + info + "</div>");
}

//公告的触发方式
function PropAnnounce(propinfo) {
    var Announce = propinfo.propinfo;
    var info = '<div class="noticeBox">';
    info += '	<div class="n-con">';
    info += '		<div class="n-innercon innercon" style="overflow: hidden; outline: none;">';
    info += '			<p>' + Announce + '</p>';
    info += '		</div>';
    info += '		<div class="n-btn">';
    info += '			<a href="javascript:;" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ')"></a>';
    info += '		</div>';
    info += '	</div>';
    info += '</div>';
    $("#proplive").html("<div class='Advertisement prop'>" + info + "</div>");
}

//问卷的触发方式
function PropQuestion(propinfo) {
    var QuestItem = propinfo.propinfo;

    var info = '<div class="questionnaire stopclick">';
    for (var i = 0; i < QuestItem.length; i++) {

        var n = i + 1;
        var QuestSelectItem = QuestItem[i].item;

        info += '   <input type="hidden" name="tmid' + n + '" value="' + QuestItem[i].tmid + '" />';
        info += '   <input type="hidden" name="tmtype' + n + '" value="' + QuestItem[i].tmtype + '" />';
        if (n == 1) {
            info += '   <div name="wenjuan' + n + '" id="wenjuan' + n + '" class="q-con" style="display:block">';
        } else {
            info += '   <div name="wenjuan' + n + '" id="wenjuan' + n + '" class="q-con" style="display:none">';
        }

        info += '		<div class="q-innercon innercon" style="overflow: hidden; outline: none;">';
        info += '			 <div class="q-title">' + QuestItem[i].title + '</div>';
        info += '			 <ul class="q-option">';
        for (var s = 0; s < QuestSelectItem.length; s++) {
            var m = s + 1;
            info += '				<li class="clearfix"><input type="checkbox" name="Satisfied' + m + '" value="' + QuestSelectItem[s].num + '" /><label>' + QuestSelectItem[s].content + '</label></li>';
        }
        info += '			 </ul>';
        info += '		</div>';
        info += '		<input type="hidden" name="optionmum1" value="5" />';
        if (n == QuestItem.length) {
            info += '		<input type="button" value="完成" class="q-finish-btn" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ');tjwenjuanl(' + n + ',' + propinfo.bindid + ');" />';
        } else {
            info += '		<input type="button" value="下一题" class="q-finish-btn" onclick="return(nextwenjuan(' + n + ',' + QuestItem.length + '))" />';
        }
        info += '   </div>';
    }
    info += '</div>';
    $("#proplive").html("<div class='questionBox prop' >" + info + "</div>");
	
}

//投票的触发方式
function PropVote(propinfo) {
    var selectItem = propinfo.propinfo[1].item;
    var info = '<div class="v-con">';
    info += '<div class="v-title">参与投票</div>';
    info += '	<div class="v-innercon innercon" style="overflow: hidden; outline: none;">';
    info += '		<div class="v-title2">' + propinfo.propinfo[0].subject + '</div>';
    info += '		<div class="v-tips">';
    if (propinfo.propinfo[0].votetype == 1) {
        info += '单选'
    } else {
        info += '多选'
    }
    info += '		</div>';
    info += '		<ul class="v-option">';

    for (var i = 0; i < selectItem.length; i++) {
        info += '<li class="clearfix"><input type="radio" name="voption" value="' + selectItem[i].itemid + '"><label>' + selectItem[i].itemname + '</label></li>';
    }
    info += '		</ul>';
    info += '	</div>';
    info += '	<input type="hidden" name="votetype" value="' + propinfo.propinfo[0].votetype + '">';
    info += '	<input type="hidden" name="voteid" value="' + propinfo.propinfo[0].voteid + '">';
    info += '	<div class="v-submit-btn">';
    info += '		<input type="image" src="/sysimg/prop/tpbtn.png" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ');tjtoupiaol();">';
    info += '	</div>';
    info += '</div>';
    $("#proplive").html("<div class='voteBox prop'>" + info + "</div>");

}
function nextwenjuan(i, worknum) {
    //切换样式时  判断是否选择答案了
    //全部隐藏   最后显示需要的信息
    for (var j = 1; j < worknum; j++) {
        document.getElementById('wenjuan' + j).style.display = 'none';//隐藏道具信息
    }
    i++;
    document.getElementById('wenjuan' + i).style.display = 'block';//显示道具信息
}
//商品的触发方式
function PropShop(propinfo) {
    var proShop = propinfo.propinfo;
    var info = '<span class="closeBtn2" title="关闭" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ')"></span>';
    info += '<div class="clearfix">';
    info += '	<div class="l-course"> ';
    info += '		<img src="' + proShop[0].photo + '" />';
    info += '	</div>';
    info += '	<div class="r-courinfo">';
    info += '		<div class="c-title">' + proShop[0].title + '</div>';
    info += '		<div class="c-price clearfix">';
    info += '			 <span class="fr read-num">' + proShop[0].hits + '</span>';
    info += '			 <span class="c-money">￥' + proShop[0].price + '</span>';
    info += '			 <a target="_blank" href="' + proShop[0].href + '" class="buy-btn">立即购买</a>';
    info += '		</div>';
    info += '	</div>';
    info += '</div>';
    $("#proplive").html("<div class='CurrpromotBox prop'>" + info + "</div>");
}

//试卷的触发方式
function PropExam(propinfo) {
    var PropExam = propinfo.propinfo;
    var info = '<div class="e-con clearfix">';
    info += '	<a href="' + PropExam + '" class="answerBtn " onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ')"><em class="earrow"></em></a>';
    info += '	<a href="javascript:;" onclick="Close(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + ')" class="noanswerBtn"><em class="earrow"></em></a>';
    info += '</div>';
    $("#proplive").html("<div class='examhomeBox  prop' >" + info + "</div>");
}
//游戏的触发方式大转盘
function PropGame(propinfo) {
    var PropGame = propinfo.propinfo;
    if (PropGame[0].gametype == 0) {
        //大转盘
        var info = '<div class="turntable-bg">';
        info += '<div class="pointer">';
        info += '	<img src="Sysimg/prop/pointer.png" alt="pointer" />';
        info += '</div>';
        info += '<div class="rotate" id="rotate">';
        info += '	<span class="r-2">一等奖';
        info += '		<div class="rimg">';
        info += '			<img src="' + PropGame[1].item[0].img + '" />';
        info += '		</div>';
        info += '	</span>';
        info += '	<span class="r-4">二等奖';
        info += '		<div class="rimg">';
        info += '			<img src="' + PropGame[1].item[1].img + '" />';
        info += '		</div>';
        info += '	</span>';
        info += '	<span class="r-6">三等奖';
        info += '		<div class="rimg">';
        info += '			<img src="' + PropGame[1].item[2].img + '" />';
        info += '		</div>';
        info += '	</span>';
        info += '	<span class="r-3">幸运奖';
        info += '		<div class="rimg">';
        info += '			<img src="' + PropGame[1].item[3].img + '" />';
        info += '		</div>';
        info += '	</span>';
        info += '	<span class="r-5">鼓励奖';
        info += '		<div class="rimg">';
        info += '			<img src="' + PropGame[1].item[4].img + '" />';
        info += '		</div>';
        info += '	</span>';
        info += '	<span class="r-1">谢谢参与';
        info += '		<div class="rimg">';
        info += '			<img src="' + PropGame[1].item[5].img + '" />';
        info += '		</div>';
        info += '	</span>';
        info += '</div>';
        info += '</div>';
        //if(PropGame[1].item.score == 6){
        //					
        //				}else{
        //					info +=	'<div class="SuccessBox prop animated zoomIn" id="successBox" style="display: block;">';
        //					info +=	'	<div class="s-con innercon">获取奖品：一等奖额外奖励：1积分2现金</div>';
        //					info +=	'	<div class="s-btnBox">';
        //					info +=	'	  <a href="javascript:;" title="点击领取" onclick="return(closetoupiao(6))"></a>';
        //					info +=	'	</div>';
        //					info +=	'</div>';
        //				}

        $("#proplive").html("<div class='turnBox prop' >" + info + "</div>");
        BigTurntable(propinfo.bindid, propinfo.propid);
    } else if (PropGame[0].gametype == 1) {
        //红包雨
        var info = ' <div class="canvas-box">';
        info += '	<canvas id="canvas"></canvas>';
        info += '</div>';
        info += '<div class="redrainBox animated zoomIn">';
        info += '  	<div class="redrain-B">';
        info += '    	<a class="redBtn" title="抢红包"></a>';
        info += '  	</div>';
        info += '</div>';
        info += '<div class="openRedBox">';
        info += '	<div class="openred-B" id="hongbao">';
        info += '		<div class="op-tips">' + PropGame[1].item[0].msg + '</div>';
        info += '		<a href="javascript:;" title="关闭" class="shareBtn" onclick="CloseProp()"></a>';
        info += '	</div>';
        info += '</div>';
        $("#proplive").html("<div>" + info + "</div>");
        cavasLoad();
        redrainClick();
    } else {
        //抢答题
        var AnswerQ = PropGame[1].item;
        var info = '<div class="answerBox">';
        info += '<input type="hidden" name="right" value="A">';
        info += '<input type="hidden" name="jiangli" value="100">';
        info += '<div class="ans-B">';
        info += '	<div class="anTitle"><span class="integral">' + PropGame[0].score + '积分</span>题目</div>';
        info += '	<div class="anCon">';
        info += '		<div class="a-innercon innercon" style="overflow: hidden; outline: none;">';
        info += '			<div class="subject"><p>' + PropGame[0].content + '<br></p></div>';
        info += '			<ul class="anOption clearfix">';
        for (var i = 0; i < AnswerQ.length; i++) {
            info += '				<li><input type="radio" name="aoption" value="' + AnswerQ[i].answernum + '"><label>' + AnswerQ[i].answer + '</label></li>';
        }
        info += '			</ul>';
        info += '		</div>';
        info += '		<div class="anBtn"><input type="button" value="确定" onclick="return(addcheck(' + propinfo.propid + ',' + propinfo.proptype + ',' + propinfo.bindid + ',' + CourseID + ',' + id + '));"></div>';
        info += '	</div>';
        info += '</div>';
        info += '</div>';

        //info +=	'<div class="integralBox " onclick="Close()">';
        //					info +=	'	<div class="integralNum">'+PropGame[0].score+'人民币</div>';
        //					info +=	'</div>';
        $("#proplive").html("<div class='prop' >" + info + "</div>");
    }


}


//红包雨
function redrainClick() {
    $(".redrainBox").on('click', '.redBtn', function () {
        $(".redrainBox").addClass("shake2");

        setTimeout(function () {

            $(".redrainBox").removeClass("animated zoomIn shake2");
            $(".redrainBox").css("opacity", "0.3");
            $(".redrainBox").addClass("disabled");
            $(".openRedBox").fadeIn();
        }, 1000);

    });

    $(".shareBtn").click(function () {
        $(".maskbg").fadeOut()
    })
}


var WINDOW_WIDTH = $(window).width();
var WINDOW_HEIGHT = $(window).height();
var canvas, context;
var num = 500;
var stars = [];
var mouseX = WINDOW_WIDTH / 2;
var mouseY = WINDOW_HEIGHT / 2;
var rnd;

function cavasLoad() {

    WINDOW_WIDTH = $(window).width();
    WINDOW_HEIGHT = $(window).height();
    mouseX = WINDOW_WIDTH / 2;
    mouseY = WINDOW_HEIGHT / 2;
    stars = [];
    rnd = 0;
    canvas = document.getElementById('canvas');
    canvas.width = WINDOW_WIDTH;
    canvas.height = WINDOW_HEIGHT;
    context = canvas.getContext('2d');

    addStar();
    setInterval(render, 33);
    liuxing();

}


function liuxing() {
    var time = Math.round(Math.random() * 3000 + 33);
    setTimeout(function () {
        rnd = Math.ceil(Math.random() * stars.length)
        liuxing();
    }, time)
}


function render() {
    context.fillStyle = 'rgba(0,0,0,0.1)';
    context.fillRect(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);

    for (var i = 0; i < num; i++) {
        var star = stars[i];
        if (i == rnd) {
            star.vx = -20;
            star.vy = 20;
            context.beginPath();
            context.strokeStyle = 'rgba(255,255,255,' + star.alpha + ')';
            context.lineWidth = star.r;
            context.moveTo(star.x, star.y);
            context.lineTo(star.x + star.vx, star.y + star.vy);
            context.stroke();
            context.closePath();
        }
        star.alpha += star.ra;
        if (star.alpha <= 0) {
            star.alpha = 0;
            star.ra = -star.ra;
            star.vx = Math.random() * 0.2 - 0.1;
            star.vy = Math.random() * 0.2 - 0.1;
        } else if (star.alpha > 1) {
            star.alpha = 1;
            star.ra = -star.ra
        }
        star.x += star.vx;
        if (star.x >= WINDOW_WIDTH) {
            star.x = 0;
        } else if (star.x < 0) {
            star.x = WINDOW_WIDTH;
            star.vx = Math.random() * 0.2 - 0.1;
            star.vy = Math.random() * 0.2 - 0.1;
        }
        star.y += star.vy;
        if (star.y >= WINDOW_HEIGHT) {
            star.y = 0;
            star.vy = Math.random() * 0.2 - 0.1;
            star.vx = Math.random() * 0.2 - 0.1;
        } else if (star.y < 0) {
            star.y = WINDOW_HEIGHT;
        }
        context.beginPath();
        var bg = context.createRadialGradient(star.x, star.y, 0, star.x, star.y, star.r);
        bg.addColorStop(0, 'rgba(255,255,255,' + star.alpha + ')')
        bg.addColorStop(1, 'rgba(255,255,255,0)')
        context.fillStyle = bg;
        context.arc(star.x, star.y, star.r, 0, Math.PI * 2, true);
        context.fill();
        context.closePath();
    }
}

function addStar() {
    for (var i = 0; i < num; i++) {
        var aStar = {
            x: Math.round(Math.random() * WINDOW_WIDTH),
            y: Math.round(Math.random() * WINDOW_HEIGHT),
            r: Math.random() * 2,
            ra: Math.random() * 0.05,
            alpha: Math.random(),
            vx: Math.random() * 0.2 - 0.1,
            vy: Math.random() * 0.2 - 0.1
        }
        stars.push(aStar);
    }
}

//大转盘 
function BigTurntable(bindid, propid) {
    var rotateTimeOut = function () {
        $('#rotate').rotate({
            angle: 0,
            animateTo: 2160,
            duration: 8000,
            callback: function () {
                alert('网络超时，请检查您的网络设置！');
            }
        });
    };
    var bRotate = false;

    var rotateFn = function (awards, angles, txt) {
        bRotate = !bRotate;
        $('#rotate').stopRotate();
        $('#rotate').rotate({
            angle: 0,
            animateTo: angles + 1800,
            duration: 8000,
            callback: function () {
                var json = jQuery.parseJSON(txt);
                var info = '';
                if (json.type == "success") {
                    info += '<div class="SuccessBox prop animated zoomIn" id="successBox" style="display: block;">';
                    info += '	<div class="s-con innercon">获取奖品：' + json.prize + '额外奖励：' + json.jiangli + '</div>';
                    info += '	<div class="s-btnBox">';
                    info += '	  <a href="javascript:;" title="点击领取" onclick="CloseProp()"></a>';
                    info += '	</div>';
                    info += '</div>';
                    $("#proplive").html(info)
                } else {
                    info = '<div class="FailBox prop animated zoomIn" id="failBox" style="display: block;"></div>';
                    $("#proplive").html(info)
                }



                bRotate = !bRotate;
            }
        })
    };

    $('.pointer').click(function () {

        if (bRotate) return;
        jQuery.ajax({
            type: "post",
            url: "/plus/course/LearnScore.aspx?action=savegame&gameid=" + bindid + "&propid=" + propid,
            success: function (obj) {
                var json = jQuery.parseJSON(obj);
                console.log(obj);
                if (json.type == "success") {
                    if (json.prize.indexOf("一等奖") != -1) {
                        rotateFn(0, 10, obj);
                    } else if (json.prize.indexOf("二等奖") != -1) {
                        rotateFn(2, 127, obj);
                    } else if (json.prize.indexOf("三等奖") != -1) {
                        rotateFn(4, 235, obj);
                    } else if (json.prize.indexOf("幸运奖") != -1) {
                        rotateFn(3, 185, obj);
                    } else if (json.prize.indexOf("鼓励奖") != -1) {
                        rotateFn(1, 50, obj);
                    }
                } else {
                    rotateFn(5, 287, '谢谢参与');
                }
            }
        });
    });
}
function rnd(n, m) {
    return Math.floor(Math.random() * (m - n + 1) + n)
}



//主动触发关闭信息   并传递相关参数信息

//按照时效进行自动关闭状态   并设置为已触发参与
//type     -关闭的类型信息
//times    -显示时间信息
//idname   -该类型的标志信息
function PropCloseTimeOut(type, times, idname) {
    times = parseInt(times);
    //判断是否有触发道具信息   不隐藏则说明已触发   需要关闭
    if (!$("#proplive").is(":hidden")) {
        //判断是立即关闭还是延迟关闭
        if (times > 0) {
            //延迟关闭

        } else {
            //立即关闭
            $("#proplive").hide();
        }
    }
}


//关闭道具信息
//propid              -道具id
//proptype            -道具类型
//propinfo            -道具绑定的id    或者直接奖励信息
//worknum             -题目数量信息 问卷  
//courseid            -课程信息记录
//lessonid            -课时id信息
function Close(propid, proptype, propinfo, courseid, lessonid) {
    jQuery.ajax({
        type: "post",
        url: "/plus/course/LearnScore.aspx?action=recordprops&propid=" + propid + "&courseid=" + courseid + "&propinfo=" + propinfo + "&lessonid=" + lessonid + "&proptype=" + proptype,
        success: function (data) {
            //隐藏最外层幕布信息
            $("#proplive").hide(); $("#proplive").html("");
        }
    });
}



















































