﻿ var xmlHttp = false;
  try 
    {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) 
    {
        try 
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e2) 
        {
            xmlHttp = false;
        }
    }
    
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
        xmlHttp = new XMLHttpRequest();
    }
    
      var thisclassid;
      var thistype;
  function CheckThisOrder(classid,type) {
      
     if(classid=="")
       return;
       thisclassid=classid;
       thistype = type;
       var now = new Date();
        var url = "../SynCourse/AjaxCheckOrder.aspx?classid=" + decodeURIComponent(classid)+"&type="+decodeURIComponent(type)+"&data="+now.toLocaleString();
       
        xmlHttp.open("GET", url, true);
       
        xmlHttp.onreadystatechange = CallBack;
        
        xmlHttp.send(null);
  }
    function CallBack() 
    {
       if (xmlHttp.readyState == 4) 
       {
          switch(xmlHttp.responseText)
          {
            
              case "0":
                 Redirct(thisclassid, thistype);
                 break;  
              case "1":
                  alert('您已经购买过该课程，课程过期前不能重复购买！');
                 break;  
              case "2":
                {
                    if(confirm("\n您需要登录后才能继续此操作！是否现在登录？\n\n"))
                    {
                         Redirct(thisclassid, thistype);
                    }
                    break;
                };
              case "3":
                  alert('购物车已存在该课程，不能重复购买！');
                  break;
              default :
                
                    if(confirm("\n您需要登录后才能继续此操作！是否现在登录？\n\n"))
                    {
                        window.location.href=xmlHttp.responseText+"/fzuums/UserInterface/Login.aspx?backURL="+window.location.href;
                    }
                    break;
                
             
          }
       }
   }


   //重定向页面
   function Redirct(classid, type) {
       if (type == "online") {
           window.location.href = "../SynCourse/Shopping" + classid + ".html";
       }
       else {
           window.location.href = "../StudyCard/PayCard" + classid + ".html";
       }
   }