// JavaScript Document
function LogOut()
{
      path = location;
      location = "http://www.tt-xx.com/userspace/login.aspx?action=logout&From="+path;
}
/* 搜索tab */
function setTab(name,cursel,n)
{
     for(i=1;i<=n;i++)
     {
          var menu=document.getElementById(name+i);
          var con=document.getElementById("con_"+name+"_"+cursel);
          var type = document.getElementById("hid_type");
          menu.className=i==cursel?"hover":"";
          if(i==cursel)
            type.value = menu.innerHTML;
          con.style.display=i==cursel?"block":"none";
     }
}
/* 选择科目 */
function AjaxSelectBox(v){
 var dl = v.parentNode;
 var dd = dl.getElementsByTagName("dd")[0];
 var dt = dl.getElementsByTagName("dt")[0];
 var lis = dl.getElementsByTagName("li");
 var html = '';
 for(var y=0; y<lis.length; y++){   
  html += '<li onclick="SetSelectInput(this,1);" onmouseout="SetSelectInput(this,2);" onmousemove="SetSelectInput(this,3);" value="'+lis[y].value+'">' + lis[y].innerHTML + '</li>';
 }
 dl.getElementsByTagName("ul")[0].innerHTML = html;
 dd.style.display = "block";
 dl.onmouseout = function() {dd.style.display = "none";}
 dd.onmouseover = function() {dd.style.display = "block";} 
}

function SetSelectInput(v,flag){
 var dl = v.parentNode;
 while(dl.nodeName != 'DL'){
  dl = dl.parentNode;
 }
 var dd = dl.getElementsByTagName("dd")[0]; 
 var dt = dl.getElementsByTagName("dt")[0]; 
 dd.onmouseover = function() {dd.style.display = "block";}
 v.onmouseover = function() {dd.style.display = "block";} 
 dd.onmouseout = function() {dd.style.display = "none"} 
 if(flag == 1){
  dt.innerHTML = v.innerHTML;
  var subject = document.getElementById("hid_subject");
  subject.value = dt.innerHTML;
  dd.style.display = "none";
 } else if(flag == 2){
  v.className = 'out'; return; 
 } else{
  v.className = 'move'; return; 
 }  
}

/* 展开
function show(c_Str,imgg)
{if(document.all(c_Str).style.display=='none')
{document.all(c_Str).style.display='block';
document.all(imgg).src='http://www.lanrentuku.com/down/js/images/12493937251.gif'}
else{document.all(c_Str).style.display='none';
document.all(imgg).src='http://www.lanrentuku.com/down/js/images/12493937250.gif'}}

<!--
function preview(){
pr=window.open('','Preview','scrollbars=1,menubar=1,status=1,width=480 height=320,left=10,top=10');
pr.document.write(jstxt.innerText);}
//--> 
*/
function TestBlack(TagName){
	var obj = document.getElementById(TagName);
	if(obj.style.display==""){
		obj.style.display = "none";
	}else{
		obj.style.display = "";
	}
}


function inPutValue(txt_id,  _value, status)
{
    _text = document.getElementById(txt_id);
    if(status)
    {
        if(_text.value.replace(/(^\s*)|(\s*$)/g,"").indexOf(_value) != -1)
        {
            return;
        }
        else
        {
            _text.value += _value;
        }
    }
    else
    {
        _text.value=_value;
    }
}

function valueBind()
{
    var type = document.getElementById("hid_type");
    var subject = document.getElementById("hid_subject");
    if(type.value.replace(/(^\s*)|(\s*$)/g,"") == "")
    {
        for(i=1;i<=3;i++)
        {
             var menu=document.getElementById("one"+i);
             if(menu.className=="hover")
                type.value = menu.innerHTML;
        }
    }
    else
    {
        for(i=1;i<=3;i++)
        {
             var menu=document.getElementById("one"+i);
             if(menu.innerHTML.replace(/(^\s*)|(\s*$)/g,"") == type.value.replace(/(^\s*)|(\s*$)/g,""))
                menu.className="hover"; 
             else
             {
                menu.className=""; 
             }    
        }
    }
    if(subject.value.replace(/(^\s*)|(\s*$)/g,"") == "")
    {
        subject.value = document.getElementById("dt_sub").innerHTML;
    }
    else
    {
        document.getElementById("dt_sub").innerHTML = subject.value;
    }
}

valueBind();








//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var point
var needpoint;
var activation;
var onlinesite;
        
        function Get(id)
        {
            return document.getElementById(id);
        }
        
        function GoReg()
        {
            window.open(onlinesite+"/UserRegister");
        }
        
        function Login()
        {
            name = Get("txt_user").value;
            pd = Get("txt_pwd").value;
            if(name == "")
            {
                alert("请输入用户名");
                return;
            }
            if(pd == "")
            {
                alert("请输入密码");
                return;
            }
            value = PubWeb.Resource.Result.login(name,pd).value;
            if(value == "1")
            {
                alert("登录成功");
                WinHide();
                window.location.reload();
            }
            else
            {
                alert(value);
                WinHide();
            }
        }
        
            function Download(uid){
            if (IsInstallZeno())
            {
                $.get("/GenFile.ashx?attach="+uid,null,function(data)
                {
                        window.open(data,'_self');
                }
                );
            }
            else
            {
                window.alert('请下载最新Zeno软件！');
                window.open(onlinesite+'/Online/SoftWare_Download.aspx');
            }
        }
        
        function DoDownLoad(uid)
        {
            html = "";
            if(point == -1)
            {
                html = "<div style=\"height:100%; width:100%; background-color:#ffffff;\">";
                
                html += "<table cellpadding=\"0\" cellspacing=\"0\" width=\"330px;\">";
                html += "<tr>";
                html += "<td colspan=\"2\" align=\"right\" style='padding-top:5px;'><img onclick=\"WinHide()\" onmouseover='this.src=\"/images/090407_Xhover.gif\"' onmouseout = 'this.src = \"/images/090407_X.gif\"' src='/images/090407_X.gif'/></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td height=\"30\" colspan=\"2\"><span class=\"STYLE1\"><div class=\"msgbox_content\" id=\"msgBoxContent\"><div id=\"msgBoxIcon\" class=\"msgbox_icon\"></div><img src=\"../images/091027_01.gif\" style=\"margin-bottom:-4px;\" />您进行的操作，需要“登录”后才能继续…</span></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td height=\"30\" colspan=\"2\" bgcolor=\"#f3f3f3\"><img src=\"../images/091027_02.gif\" width=\"16\" height=\"16\" style=\"margin-bottom:-2px;\" /> <span class=\"STYLE2\">注册用户请直接登录</span></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td width=\"103\" height=\"40\" align=\"right\"><span class=\"STYLE3\">帐户：</span></td>";
                html += "<td width=\"220\" align=\"left\"><input type=\"text\" id=\"txt_user\" maxlength=\"60\" style=\"height:16px; width:150px;\" /></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td align=\"right\"><span class=\"STYLE3\">密码：</span></td>";
                html += "<td align=\"left\"><input type=\"password\" id=\"txt_pwd\" maxlength=\"60\" style=\"height:16px; width:150px;\" />";
                html += "<a href=\""+onlinesite+"/livim/findpwd.aspx\" target=\"_blank\" class=\"STYLE4\">忘记密码？</a></td>";
                html += "</tr>";
                html += "<tr><td height=\"30\">&nbsp;</td>";
                html += "<td align=\"left\"><input id=\"mem_pass\" type=\"checkbox\" style=\"margin-bottom:-3px;\" />";
                html += "<label for=\"mem_pass\" class=\"STYLE3\">记住我的登录状态</label></td>";
                html += "</tr>";
                html += "<tr>";
                html += "<td height=\"40\">&nbsp;</td>";
                html += "<td align=\"left\"><input id=\"btn_login\" type=\"button\" style=\" padding:1px;\"  value=\" 登录 \" onclick=\"Login()\"/>&nbsp;&nbsp;";
                html += "<input id=\"btn_reg\" type=\"button\" style=\"padding:1px;\"  value=\" 注册 \" onclick=\"GoReg()\"/></td>";
                html += "</tr>";
                html += "</table>";
                html+="</div>";
            }
            else if(!activation)
            {
                html = "<div style='height:100%; width:100%; background-color:#ffffff;'>";
                html+="<table border='0' width=\"95%\">";
                html+="<tr>";
                html+="<td align=\"right\" style='padding-top:5px;'><img onclick=\"WinHide()\" onmouseover='this.src=\"/images/090407_Xhover.gif\"' onmouseout = 'this.src = \"/images/090407_X.gif\"' src='/images/090407_X.gif'/></td>"
                html+="</tr>";
                html+="<tr height='20px;'><td></td></tr><tr height='20px;'><td></td></tr>";
                html+="<tr align='left'>";
                html+="<td align='center' style='font-size:15px; color:#049; font-weight:blod;'><div class='msgbox_content' id='msgBoxContent'><div id='msgBoxIcon' class='msgbox_icon'></div>您注册的帐户尚未激活，只有注册并激活用户可以下载资源，注意查看注册邮箱。若未收到激活邮件，点此&nbsp;<a href='javascript:void(0);' onclick='SendMailAgain()'>重发激活邮件</a>，收到邮件并激活后刷新此页面继续下载。</div></td>";
                html+="</tr><tr align='left'><td>&nbsp;</td></tr>";
                html+="<tr height='10px;'><td></td></tr>";
                html+="<tr><td align='center'><input style='width:80px;' type=\"button\" value=\"返回\" class='bt' onclick=\"WinHide()\" /></td></tr></table></div>";
            }
            else
            {
                html = "<div style='height:100%; width:100%; background-color:#ffffff;'>";
                html+="<table border='0' width=\"95%\">";
                html+="<tr>";
                html+="<td align=\"right\" style='padding-top:5px;'><img onclick=\"WinHide()\" onmouseover='this.src=\"/images/090407_Xhover.gif\"' onmouseout = 'this.src = \"/images/090407_X.gif\"' src='/images/090407_X.gif'/></td>"
                html+="</tr>";
                html+="<tr height='20px;'><td></td></tr><tr height='20px;'><td></td></tr>";
                html+="<tr align='left'>";
                html+="<td align='center' style='font-size:15px; color:#049; font-weight:blod;'><div class='msgbox_content' id='msgBoxContent'><div id='msgBoxIcon' class='msgbox_icon'></div>您当前有"+point+"个积分,下载此试卷(课件)需要"+needpoint+"个积分，您确定要下载吗？&nbsp;<a href='"+onlinesite+"/Online/Payment.aspx' target='_blank'>获取积分</a></div></td>";
                html+="</tr><tr align='left'><td>&nbsp;</td></tr>";
                html+="<tr height='10px;'><td></td></tr>";
                html+="<tr><td align='center'><input type=\"button\" value=\"确定\" style='width:80px;' class='bt' onclick=\"Download('"+uid+"')\" />&nbsp;&nbsp;<input style='width:80px;' type=\"button\" value=\"返回\" class='bt' onclick=\"WinHide()\" /></td></tr></table></div>";
            }
            
            MessageBox(html);
        }
        
    var MB_OK = 0;
    var MB_CANCEL = 1;
    var MB_OKCANCEL = 2;
    var MB_YES = 3;
    var MB_NO = 4;
    var MB_YESNO = 5;
    var MB_YESNOCANCEL = 6;
    // 控制按钮文本
    var MB_OK_TEXT = "继续提问";
    var MB_CANCEL_TEXT = "取消";
    var MB_YES_TEXT = " 是 ";
    var MB_NO_TEXT = " 否 ";
    //提示图标
    var MB_ICON = "/images/q_icon.gif";
    //委托方法
    var MB_OK_METHOD = null;
    var MB_CANCEL_METHOD = null;
    var MB_YES_METHOD = null;
    var MB_NO_METHOD = null;
    var MB_BACKCALL = null;
    var MB_STR = '<style type="text/css"><!--' +
                'body{margin:0px;}' +
                '.msgbox_title{background-color: #B1CDF3;height:25px;position:relative;font-size:14px;line-height:25px;padding-left:10px;border-bottom:1px solid #000;}' +
                '.msgbox_control{text-align:center;clear:both;height:28px;}' +
                '.msgbox_button{background-color: #B1CDF3;border:1px solid #003366;font-size:12px;line-height:20px;height:21px;}' +
                '.msgbox_content{padding:10px;float:left;line-height:20px;width:300px;}' +
                '.msgbox_icon{width: 20px;height: 20px;float: left; line-height:20px;}' +
                '.msgbox_mask{position:absolute;left:0px;top:0px;z-index:99999;background-color:#333333;width:100%;height:100%;}' +
                '.msgbox{background-color: #E4E4E4;position: absolute;height:250px;font-size:12px;top:50%;left:50%;padding:5px;}' +
                '--></style>' +
                '<div id="msgBoxMask" class="msgbox_mask" style="filter: alpha(opacity=0);display:none;"></div>' +
                '<div class="msgbox" style="display:none; z-index:100000;" id="msgBox"></div>';
    var Timer = null;
    document.write(MB_STR);
    var icon = new Image();
    icon.src = MB_ICON;
    /* 提示对话框
    * 参数 1 : 提示内容
    * 参数 2 : 提示标题
    * 参数 3 : 图标路径
    * 参数 4 : 按钮类型
    */
    function MessageBox(){
       html = arguments[0]
       MB_BACKCALL = arguments[1];
      
       //解决　FF 下会复位
       ScrollTop = GetBrowserDocument().scrollTop;
       ScrollLeft = GetBrowserDocument().scrollLeft;
       GetBrowserDocument().style.overflow = "hidden";
       GetBrowserDocument().scrollTop = ScrollTop;  
       GetBrowserDocument().scrollLeft = ScrollLeft;
      
       Get('msgBox').innerHTML = html;
      
       OpacityValue = 0;
       Get("msgBox").style.display = "";      
       try{Get("msgBoxMask").filters("alpha").opacity = 0;}catch(e){};
       Get("msgBoxMask").style.opacity = 0;
       Get("msgBoxMask").style.display = "";
       Get("msgBoxMask").style.height = GetBrowserDocument().scrollHeight + "px";
       Get("msgBoxMask").style.width = GetBrowserDocument().scrollWidth + "px";
      
       Timer = setInterval("DoAlpha()",1);
       //设置位置  
       Get("msgBox").style.width = "100%";  
       Get("msgBox").style.width = (Get("msgBoxIcon").offsetWidth + Get("msgBoxContent").offsetWidth + 2) + "px";
      
       Get("msgBox").style.marginTop = (-Get("msgBox").offsetHeight/2 + GetBrowserDocument().scrollTop) + "px";
       Get("msgBox").style.marginLeft = (-Get("msgBox").offsetWidth/2 + GetBrowserDocument().scrollLeft) + "px";  

    }
    var OpacityValue = 0;
    var ScrollTop = 0;
    var ScrollLeft = 0;
    function GetBrowserDocument()
    {
       var _dcw = document.documentElement.clientHeight;
       var _dow = document.documentElement.offsetHeight;
       var _bcw = document.body.clientHeight;
       var _bow = document.body.offsetHeight;
      
       if(_dcw == 0) return document.body;
       if(_dcw == _dow) return document.documentElement;
      
       if(_bcw == _bow && _dcw != 0)
         return document.documentElement;
       else
         return document.body;
    }
    function SetOpacity(obj,opacity){
            if(opacity >=1 ) opacity = opacity / 100;   
               
            try{obj.style.opacity = opacity; }catch(e){}
           
            try{
                if(obj.filters){
                    obj.filters("alpha").opacity = opacity * 100;
                }
               
            }catch(e){}
    }
       
    function DoAlpha(){
        if (OpacityValue > 20){clearInterval(Timer);return 0;}
        OpacityValue += 5;   
        SetOpacity(Get("msgBoxMask"),OpacityValue);
    }

    function MBMethod(obj)
    {  
       switch(obj.id)
       {
          case "msgBoxBtnOk" : if(MB_BACKCALL) {MB_BACKCALL(MB_OK);} else {if(MB_OK_METHOD) MB_OK_METHOD();} break;
       }  
    }

    function WinHide()
    {
     
       Get("msgBox").style.display = "none";
       Get("msgBoxMask").style.display = "none";    
       GetBrowserDocument().style.overflow = "";
       GetBrowserDocument().scrollTop = ScrollTop;
       GetBrowserDocument().scrollLeft = ScrollLeft;
    }

    String.prototype.toFormatString = function(){
       var _str = this;
       for(var i = 0; i < arguments.length; i++){   
          _str = eval("_str.replace(/\\{"+ i +"\\}/ig,'" + arguments[i] + "')");
       }
       return _str;
    }
     
   function downLoadError(uid, msg)
   {
       result = PubWeb.Resource.Result.DownLoadError(uid, msg).value;
       if(result > 0)
       {
           Dialog.alert("下载错误的信息提交成功");
       }
       else
       {
           Dialog.alert("下载错误的信息提交失败");
       }
   }
   
   function tortReport(uid, msg)
   {
       result = PubWeb.Resource.Result.TortReport(uid, msg).value;
       if(result > 0)
       {
           Dialog.alert("侵权举报的信息提交成功");
       }
       else
       {
           Dialog.alert("侵权举报的信息提交失败");
       }
   }
   
   function SendMailAgain()
   {
       url = PubWeb.Resource.Result.GetSendUrl().value;
       window.open(url);
   }
   

