﻿// JScript File
var __popup=0;
function articleReplys(parentID,popup)
{
   __popup=popup;
   var content=$("replyContent").value;
   var user=getCurrentUser();
    if(user!=null)
    {
       if(content=="")
       {
           
           alert("回复内容不能为空！");
           return;
       }
   }
   else
   {
        alert("请先登录");
        location.href="http://www.veduchina.com/login.aspx?returnurl="+location.href;
        return;
   }
   $("submitReply").disabled="disabled";
   Veduchina.Components.ArticleManager.CreateArticleReplys(parentID,content,articleReplys_callback);
    
}
function articleReplys_callback(res)
{
    $("submitReply").disabled="";
    if(res!=null&&res.value!=null)
    {
       var success=res.value;
       if(success==0)
       {
          alert("评论失败!");
          return;
       }
       else
       {
          $("ReplyCount").innerHTML="<b>"+success+"</b>";
          $("replyContent").value="";
          return;
       }
    }
    alertError("对不起，添加评论失败，请重新尝试！");
}

function ScrollText(content,btnPrevious,btnNext,autoStart,timeout,isSmoothScroll)
{
    this.Speed = 10;
    this.Timeout = timeout;
    this.stopscroll =false
    this.isSmoothScroll= isSmoothScroll;
    this.LineHeight = 29;
    this.NextButton = this.$(btnNext);
    this.PreviousButton = this.$(btnPrevious);
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
if(this.PreviousButton)

{
    this.PreviousButton.onclick = this.GetFunction(this,"Previous"); 
    this.PreviousButton.onmouseover = this.GetFunction(this,"MouseOver");
    this.PreviousButton.onmouseout = this.GetFunction(this,"MouseOut");
}
if(this.NextButton)
{
    this.NextButton.onclick = this.GetFunction(this,"Next");
    this.NextButton.onmouseover = this.GetFunction(this,"MouseOver");
    this.NextButton.onmouseout = this.GetFunction(this,"MouseOut");
}
    this.ScrollContent.onmouseover = this.GetFunction(this,"MouseOver");
    this.ScrollContent.onmouseout = this.GetFunction(this,"MouseOut");

    if(autoStart)
    {
        this.Start();
    }
}

ScrollText.prototype = {

$:function(element)
{
    return document.getElementById(element);
},
Previous:function()
{
    this.stopscroll = true;
    this.Scroll("up");
},
Next:function()
{
    this.stopscroll = true;
    this.Scroll("down");
},
Start:function()
{
    if(this.isSmoothScroll)
    {
        this.AutoScrollTimer = setInterval(this.GetFunction(this,"SmoothScroll"), this.Timeout);

    }
    else
    {		
        this.AutoScrollTimer = setInterval(this.GetFunction(this,"AutoScroll"), this.Timeout);
    }
},
Stop:function()
{
    clearTimeout(this.AutoScrollTimer);
    this.DelayTimerStop = 0;
},
MouseOver:function()
{	
    this.stopscroll = true;
},
MouseOut:function()
{
    this.stopscroll = false;
},
AutoScroll:function()
{
if(this.stopscroll) 
{
    return;
}
this.ScrollContent.scrollTop++;
if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
{
    this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Speed);
}
else
{
    if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
    {
        this.ScrollContent.scrollTop = 0;
    }
    clearTimeout(this.ScrollTimer);
//this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
}
},
SmoothScroll:function()
{
    if(this.stopscroll) 
    {
        return;
    }
    this.ScrollContent.scrollTop++;
    if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
    {
        this.ScrollContent.scrollTop = 0;
    }
},
Scroll:function(direction)
{
    if(direction=="up")
    {
        this.ScrollContent.scrollTop--;
    }
    else
    {
        this.ScrollContent.scrollTop++;
    }
    if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
    {
        this.ScrollContent.scrollTop = 0;
    }
    else if(parseInt(this.ScrollContent.scrollTop)<=0)
    {
        this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
    }

    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Speed);
    }
},
GetFunction:function(variable,method,param)
{
    return function()
    {
        variable[method](param);
    }
}
}

function ignoreError() {
 return true;
}
window.onerror = ignoreError;

function WriteUser()
{
    var user=getCurrentUser();
    if(user==null)
    {
        document.write('<form id="fmLogin" name="fmLogin" action="http://www.veduchina.com/login.aspx?FormLogin=1&returnurl='+window.location.href+'" method="post"><b>用户登陆：</b><input class="wbk2" name="VeduUserName" type="text" id="VeduUserName"><input class="wbk2" name="VeduPwd" type="password" id="VeduPwd"><input class="an2" type="submit" id="btnSubmit" value=""> <span><a href="http://www.veduchina.com/reg.aspx" target="_blank">注册</a></span></form>');
    }
    else
    {    
      document.write("<a href='http://www.veduchina.com/user/default.aspx'>"+user.Name+"的设置</a>&nbsp; | &nbsp;<a href='http://www.veduchina.com/user/default.aspx?url=http://www.veduchina.com/user/subject/list.aspx'>课程</a>&nbsp; | &nbsp;<a id='ausermsg' href='http://www.veduchina.com/user/default.aspx?url=%2fuser%2fmessage%2flist.aspx%3fInboxOrOut%3d1%26type%3d2'>邮件<span id='msgcount' style='color:red;'></span></a>&nbsp; | &nbsp;<a href='http://www.veduchina.com/logout.aspx'>退出</a>");
    }
}

function Result(search)
{
    var q=document.getElementById(search).value;
    var cx=["011739841680837636807%3abyjoqztqieu","011739841680837636807%3aoirixqlf4bq","011739841680837636807%3ay60gvdxiore","011739841680837636807%3azqkh90pepo8","011739841680837636807%3ad0zy3b4ckzw"];
    location.href="http://s.veduchina.com/default.aspx?cx="+cx[0]+"&ie=UTF-8&sa=%E6%90%9C%E7%B4%A2&cof=FORID%3A9&q="+EncodeUtf8(q);
}




