﻿
   var playerHandler=null;
   var checkxmlHttp = false;
   var newwintitle = "课程学习";
   var newwinurl ="";
   var newwinargs ="";
    var lWidth=screen.availWidth;  
    var lHeight=screen.availHeight;   
    newwinargs ="fullscreen=1,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,"+
         " resizable=1,width="   +   lWidth   +   ",height="   +   lHeight   +   ",top=0,left=0";
    
    // 
  try 
    {
        checkxmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) 
    {
        try 
        {
            checkxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e2) 
        {
            checkxmlHttp = false;
        }
    }
    
    if (!checkxmlHttp && typeof XMLHttpRequest != 'undefined') {
        checkxmlHttp = new XMLHttpRequest();
    }
    
    
     //个人课程学习页面跳转
    function turnToPayStudyPage(id,firstclass) {
        var url = "../Study/" + id + "/01/11/" + firstclass + ".html";
        newwinurl = url;
        CheckLoginBeforeLearn(id);
         //playerHandler=window.open(url,"课程学习","fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,"+
         //" resizable=1,width="   +   lWidth   +   ",height="   +   lHeight   +   ",top=0,left=0",true);
         //playerHandler.focus();
    }
    
    //体验课程学习页面跳转
    function turnToExpStudyPage(id,firstclass)
    {

        var url = "../Study/" + id + "/01/12/" + firstclass + ".html";
        newwinurl = url;
        CheckLoginBeforeLearn(id);
        //         playerHandler=window.open(url,"课程学习","fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,"+
        //         " resizable=1,width="   +   lWidth   +   ",height="   +   lHeight   +   ",top=0,left=0",true);
         //playerHandler.focus();
    }
    
     //个人课程学习页面跳转(用于错题记录)
    function turnToPayStudyPageErr(id,firstclass)
    {

        var url = "../Study/" + id + "/01/11/" + firstclass + ".html";
        newwinurl = url;
        CheckLoginBeforeLearn(id);
        //         playerHandler=window.open(url,"课程学习","fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,"+
        //         " resizable=1,width="   +   lWidth   +   ",height="   +   lHeight   +   ",top=0,left=0",true);
         //playerHandler.focus();
    }
    
    //体验课程学习页面跳转（用于错题记录）
    function turnToExpStudyPageErr(id,firstclass)
    {

        var url = "../Study/" + id + "/01/12/" + firstclass + ".html";
        newwinurl = url;
        CheckLoginBeforeLearn(id);
        //         playerHandler=window.open(url,"课程学习","fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,"+
        //         " resizable=1,width="   +   lWidth   +   ",height="   +   lHeight   +   ",top=0,left=0",true);
         //playerHandler.focus();
    }
    
    //试用课程学习页面跳转
    function turnToTryStudyPage(id,firstclass)
    {
        var url = "../Study/" + id + "/02/11/" + firstclass + ".html";
        newwinurl = url;
        CheckLoginBeforeLearn(id);
        //         playerHandler=window.open(url,"课程学习","fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,"+
        //         " resizable=1,width="   +   lWidth   +   ",height="   +   lHeight   +   ",top=0,left=0",true);
         //playerHandler.focus();
    }

    //打开个人课程-用于用户控件
    function turnToPayStudyControl(id, firstclass) {
        var url = "http://www.kingsunedu.com/fzsyncclass/Study/" + id + "/01/11/" + firstclass + ".html";
        newwinurl = url;
        var now = new Date();
        var url = "http://www.kingsunedu.com/fzsyncclass/SynCourse/AjaxCheckLogin.aspx?classid=" + decodeURIComponent(id) + "&data=" + now.toLocaleString();
        
        checkxmlHttp.open("GET", url, true);
        checkxmlHttp.onreadystatechange = turnToPayStudyControlBack;
        checkxmlHttp.send(null);
    }

    //打开个人课程-用于用户控件-返回时处理函数
    function turnToPayStudyControlBack() {
       
        if (checkxmlHttp.readyState == 4) {
            switch (checkxmlHttp.responseText) {

                case "1":
                    //已经登录
                    playerHandler = window.open(newwinurl, newwintitle, newwinargs, true);
                   // playerHandler.focus();
                    break;
                case "2":
                {
                    if(confirm("\n您需要登录后才能继续此操作！是否现在登录？\n\n"))
                    {
                        window.location.href="http://www.kingsunedu.com/fzuums/UserInterface/Login.aspx?backURL="+window.location.href;
                    }
                    break;
                }
                default:
                    break;
            }
        }
    }
    
    
    
    //检测用户是否登录
    function CheckLoginBeforeLearn(id) {
        
        //加上这个时间是为了重新发送，如果不加，IE则认为在缓存中取，不重新发送。
        var now = new Date();
        var url = "../SynCourse/AjaxCheckLogin.aspx?classid=" + decodeURIComponent(id)+"&data="+now.toLocaleString();
        //alert(url);
        checkxmlHttp.open("GET", url, true);
       
        checkxmlHttp.onreadystatechange = checkCallBack;
        
        checkxmlHttp.send(null);
    }
    //返回时处理函数
    function checkCallBack()
    {
      if (checkxmlHttp.readyState == 4) {
             
          switch(checkxmlHttp.responseText)
          {
            
              case "1":
                  //已经登录
                  playerHandler = window.open(newwinurl, newwintitle, newwinargs, true);
                 // playerHandler.focus();
                  break;  
              case "2":
                {
                    if(confirm("\n您需要登录后才能继续此操作！是否现在登录？\n\n"))
                    {
                        window.location.href="http://www.kingsunedu.com/fzuums/UserInterface/Login.aspx?backURL="+window.location.href;
                    }
                    break;
                }
             default:
                 break;
          }
       }
    }
 //处理模式窗口的几个方法。
 //要取消模式窗口功能，就注释focus的那几行。
// window.onfocus=function ()  
//{
// if(playerHandler){
//  if(!playerHandler.closed)
//  {
//    //playerHandler.focus();
//   }
// } 
//}; 

//window.document.onfocus=function ()
//{  
// if(playerHandler){
//  if(!playerHandler.closed)
//  {
//     //playerHandler.focus();
//  }
// } 
// 
//}; 

//window.document.onclick=function ()
//{  
// if(playerHandler){
//  if(!playerHandler.closed)
//  {
//    //playerHandler.focus();
//  }
// } 
//}; 

//window.document.ondblclick=function ()
//{  
// if(playerHandler){
//  if(!playerHandler.closed)
//  {
//    //playerHandler.focus();
//  }
// } 
//}; 

