﻿TY.Syn = {
        loadStudyInfo:function(day) {
            $.getJSON(TY.Url + TY.loadStudyInfoUrl + "?jsoncallback=?",{day: day, r: Math.random()}, function(json) {
                $(".exercise ol").html(json)
            });
        },
        setTextBook:function() {
            if (TY.Syn.scrCheckLogin()) {
                window.open(TY.Url + "/xiaowuManage/index.aspx?my_url=SelectJiaoCai_One");
            }
        },
        exit:function() {
            document.location.href = TY.synIndexUrl;
            TY.reload();
        },
        showLogin:function(info) {
            if (typeof(info) != 'undefined' && info != '' && null != info) {
                var html = "<div class=\"user-state\">";
                html += "<div class=\"top\"></div>";
			    html += "<ul class=\"content\">";
			    var pic = info.UP;
			    html += "<li class=\"welcome\"><img src=\"" + pic + "\" alt=\"" + info.TN + "\" />";
			    html += "   <a href=\"" + TY.Url + "/xiaowuManage/index.aspx\" class=\"user-name\">" + info.TN + "</a> 欢迎你！";
			    html += "   <a href=\"javascript:TY.exit(TY.Syn.exit);\" class=\"gray\">［退出］</a>";
			    html += "</li>";
			    html += "<li class=\"value lh20\">";
			    html += "   <span class=\"ico\">语文：</span>" + info.YWTF + "<br />";
			    html += "   <span>数学：</span>" + info.SXTF + "<br />";
			    html += "   <span>英语：</span>" + info.YYTF;
			    html += "</li>";
			    html += "<li class=\"cb\"><a href=\"" + TY.Url +TY.resultsUrl+ "\" class=\"btn-score dib fr\">成绩查询</a></li>";
			    html += "</ul>";
	            html += "<div class=\"bottom\"></div>";
                html += "</div>";
                $("#loginInfo").html(html);
            } else {
                var html = "<div class=\"entrance\">";
	            html += "<div class=\"top\">";
		        html += "<h2>用户登陆</h2>";
		        html += "<div class=\"e-tab\">";
			    html += "   <a href=\"javascript:void(0)\" class=\"click\"><span>学生（家长）</span></a><a href=\"javascript:void(0)\"><span>　老师　</span></a>";
		        html += "</div>";
	            html += "</div>";
	            html += "<ul class=\"content cb\">";
		        html += "<li>帐号：<input type=\"text\" id=\"input_userName\" size=\"12\" /></li>";
		        html += "<li>密码：<input type=\"password\" id=\"input_userPwd\" size=\"12\"/><input type=\"hidden\" id=\"input_userType\"/>";
		        html += "<input type=\"submit\" onclick=\"TY.userLogin(TY.reload);\" value=\"登陆\" class=\"btn-signin\" /></li>";
		        html += "<li><input type=\"radio\" name=\"isCnc\" checked/> 电信 <input id=\"isCnc\" type=\"radio\" name=\"isCnc\"/> 网通（联通）";
		        html += "</li>";
		        html += "<li><a href=\"" + TY.Url + TY.findPasswordUrl+ "\" class=\"forgot-password\">·忘记密码</a>";
		        html += "    <a href=\"" + TY.Url + TY.regUrl+ "\" class=\"regsiter\">免费注册</a>";
		        html += "</li>";
		        html += "</ul>";
	            html += "<div class=\"bottom\"></div>";
                html += "</div>";
                $("#loginInfo").html(html);
            }
        },
        playGame:function(obj, type, isTeacher, isCertif) {
            if (TY.isLogin()) {
                if (isNaN(isTeacher) || parseInt(isTeacher) == 1) {
                    isTeacher = "0";
                } else {
                    isTeacher = "1";
                }
                if (isNaN(isCertif) || parseInt(isCertif) == 1) {
                    isCertif = "1";
                } else {
                    isCertif = "0";
                }
                var info = TY.getUserInfo("UD", true);
                if (type != 3) {
                    if ((info.IV == "0" || info.IV == "2") && info.UT == "0") {
                        if (isCertif == "1"){
				            $("#certification").css({"top":(($(window).height()-$("#certification").innerHeight())/2+$(window).scrollTop())+"px","left":(($(window).width()-$("#certification").innerWidth())/2)+"px"}).show();
                            return;
                        }
                    }
                }
                var isIE=!!window.ActiveXObject;
	            var isIE6=isIE&&!window.XMLHttpRequest;

	            var dialogWidth;
	            var dialogHeight = isIE6?670:630;
	            var isLoad = "";
	            if (type != 1 && (TY.site == "139" || TY.site == "" || TY.site == "cy52")) {
	            
                    TY.synPlayUrl = "http://www.91118.com/klxt/synclassroom/play/play.aspx";
                } else if (type == 1 && TY.site == "139") {
		            TY.synPlayUrl = "http://klxt.jiaxiaoquan.com/139/klxt/synclassroom/play/play_v2.aspx";
	            } else {
                    isLoad = "loadtype=load";
                }
                var score = window.showModalDialog(TY.synPlayUrl + "?obj=" + escape(obj) + "&type=" + type + "&isTeacher=" + isTeacher + "&site=" + TY.site + "&" + isLoad, "play"
                ,"dialogWidth:900px;dialogHeight:" +dialogHeight+ "px;help:no;status:no;scroll:no", true);
                TY.cookie("GameScore", score, {path:TY.path, domain:TY.domain});
                if (typeof(score) != 'undefined' && !isNaN(score) && parseInt(score) >= 60 && type == 1) {
		            dialogWidth = isIE6?440:430;
		            dialogHeight = isIE6?605:550;
		            var n = window.showModalDialog("/synclassroom/report_" + obj + "," + Math.round(Math.random()*1000000),window,"dialogWidth:"+dialogWidth+"px;dialogHeight:"+dialogHeight+"px;center:yes;scroll:off");
		            TY.cookie("GameScore", null);
                }
            } else {
                alert("你还没有登录！");
            }
        },
        closeIframe:function() {
            $("#msg-eye").remove();
        },
        playIframe:function(url) {
            $("#msg-eye").remove();
	        if ($("#msg-eye").size() < 1) {
		        $("body").append("<div id=\"msg-eye\" style=\"position:absolute;width:0;height:0\"><iframe id=\"eye\" name=\"eye\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" src=\"about:blank\"><\/iframe></div>");
		        $("#eye").attr("src", url);
	        }
        },
        playGameByVerify:function(obj, type, verify, isTeacher) {
            if (isNaN(isTeacher) || parseInt(isTeacher) == 1) {
                isTeacher = "0";
            } else {
                isTeacher = "1";
            }
            if (type != 1 && (TY.site == "139" || TY.site == "" || TY.site == "cy52")) {
                TY.synPlayUrl = "http://www.91118.com/klxt/synclassroom/play/play.aspx";
            } else if (type == 1 && TY.site == "139") {
		        TY.synPlayUrl = "http://klxt.jiaxiaoquan.com/139/klxt/synclassroom/play/play_v2.aspx";
	        } else {
                isLoad = "loadtype=load";
            }
            var isIE=!!window.ActiveXObject;
	        var isIE6=isIE&&!window.XMLHttpRequest;
            var dialogHeight = isIE6?670:630;
            window.showModalDialog(TY.synPlayUrl + "?obj=" + escape(obj) + "&loadtype=load&isTeacher=" + isTeacher + "&verify=" + verify + "&site=" + TY.site + "&type=" + type, "play"
                ,"dialogWidth:900px;dialogHeight:" +dialogHeight+ "px;help:no;status:no;scroll:no", true);
        },
        teacherChangeVersion:function() {
	        $("select[id^='sel_grade']").each(function(){
	            $(this).hide();
            });
            $("#sel_grade_" + $("#sel_versionInfo").val()).show();
            //TY.Syn.teacherChangeGrade($("#sel_grade_" + $("#sel_versionInfo").val()));
        },
        teacherChangeGrade:function(obj) {
            if ($(obj).val() != -1)
                window.location.href = "http://www.91118.com/synclassroom/" + $("#pageType").val() + "/" + $(obj).val() + ",grade";
        },
        scrCheckLogin:function() {
            if (TY.isLogin()) {
                return true;
            } else {
                alert("你还没有登录！");
                return false;
            }
        }
    };
