﻿ 
  
   //检查域名
 function checkurl()
 {
  
            
            /*
            //检查域名是否包含ignworld.com/aion
    var url=window.location.href;
    
    if(url.substring(0,24)=="http://ignworld.com/aion")//如果是这个域名
    {
        
           document.getElementById("controldiv1").style.display="none";  //把以前的用户控件隐藏
           document.getElementById("indexul1").style.display="none";
           document.getElementById("controldiv2").style.display="block"; //显示改了链接的用户控件
           document.getElementById("indexul2").style.display="block";
       if($("searcontrol1")!=null)
       {
             $("searcontrol1").style.display="none";
             $("searcontrol2").style.display="block";
       }
    }*/
       
 
 }
function  blockul(d)
{ 
     /*
         var url=window.location.href;
    
    if(url.substring(0,24)=="http://ignworld.com/aion")//如果是这个域名
    {
        document.getElementById("myull"+d).style.display="block";
    }
    else
    {
         document.getElementById("myul"+d).style.display="block";
    }*/
    
     document.getElementById("myul"+d).style.display="block";
}
function  displayul(d)
{ 
   
    /*
         var url=window.location.href;
    
    if(url.substring(0,24)=="http://ignworld.com/aion")//如果是这个域名
    {
        document.getElementById("myull"+d).style.display="none";
    }
    else
    {
         document.getElementById("myul"+d).style.display="none";
    }*/
      document.getElementById("myul"+d).style.display="none";
}
 
 function getCookie(cookiename)
{
    var result = '';
    var mycookie = document.cookie;
    var start2 = mycookie.indexOf(cookiename + "=");
    if(start2>-1)
    {
        start=mycookie.indexOf("=",start2)+1;
        var end = mycookie.indexOf(";",start);
        
        if (end == -1)
        {
            end = mycookie.length;
        }
        
        result = unescape(mycookie.substring(start,end));
        
    }
    return result;
}


function setCookie(cookiename, cookievalue, hours)
{
    var date=new Date();
    date.setTime(date.getTime() + Number(hours)*3600*1000);
    temp = escape(cookievalue);
    document.cookie = cookiename + "=" + temp  +"; path=/;expires = " + date.toGMTString();
    ////var o = 0;
}
function CookiesQueryUser()  //查看客户是否已经登陆 
{
   
      //  
       
          var url=window.location.href;
    
  
     var mycook=getCookie("Ignworlduser");
     if(mycook!="")
     {    
     
  
            //if(url.substring(0,24)=="http://ignworld.com/aion"||url.substring(0,24)=="http://aion.ignworld.com"|| window.location.hostname=="localhost")
           // {
                 var loginname=mycook.split('&')[1].substring(mycook.split('&')[1].lastIndexOf('=')+1)
             
                  var time= GetUserDate();
            
                 $("LoginOk").innerHTML="";
           
           
            
                 $("LoginOk").innerHTML="<ul><li class='pl10'><span class='fwb fs14 c_y'>"+loginname+",</span><span class='fwb c_w'> &nbsp;&nbsp;Welcome to Ignworld  "+time+"</span> <span class='pl10'><a href='UserIndex.aspx' class='c_w'>&gt;&nbsp;Go to my User Center &gt; </a></span><span class='pl10'  ><a href='###' class='c_w' onclick='LogOut()'   >logout</a></span></li><ul> ";
           
      
                  if( $("commentchange")!=null)
                  $("commentchange").innerHTML="<ul><li><span class='orange'  >"+loginname+"</span><span> post a comment below: </span></li></ul>";
            // }
           
     } 
}
function ChangeClass(e,type,pagetype)  //键盘控制 0,搜索 1 文本框登陆 2.register登陆,4添加评论
{
    
       var msie = (document.all) ? true : false; 
       var keycode; 
       if(!msie)keycode=e.which; 
       else keycode=event.keyCode;
       if(keycode == 13)
       { 
            if(type==0)
           {
                 var text=document.getElementById("Sear1_txtKey").value;
        
                  window.open("Search.aspx?k="+escape(text));
           //   document.getElementById("Sear1_txtKey").click();
               return false;
           }
           if(type==1)
           {
                UserLogin();
              // alert("test");
            // document.getElementById("test").click();
             return false;
           }
           if(type==2)
           {   
                UserLogin('ok');
               return false;
           }
            if(type==4) //添加评论
          {
                AddCommentsIng(pagetype);
                return false;
              
          }
    
       } 
        


} 

//获得当前时间转换美国格式
function GetUserDate()
{
  
    var date=new Date();
    var year=date.getFullYear();
    var month=date.getMonth()+1;
    var day=date.getDate();
       
    var hours=date.getHours();
    var minutes=date.getMinutes();
    var seconds=date.getSeconds();
    var value="AM";
    
   if(hours>12&&hours<=24) //pm下午以后
   {
         value="PM";
   }
 
  
   if(minutes<10)
   {
        minutes="0"+minutes;
   }
   if(seconds<10)
   {
        seconds="0"+seconds;
   }
   
   
  
   
  return month+"/"+day+"/"+year+" "+hours+":"+minutes+":"+seconds+" "+value;
    
    
    

}
//根据数据库时间转换美国时间
function GetUserDateTwo(Time)
{

   var hours=Time.substring(11,13);
    var value="AM";
     
    if(hours>12&&hours<=24) //pm下午以后
   {
         value="PM";
   }
     
  return   "Posted"+" "+Time.substring(5,7)+"/"+Time.substring(8,10)+"/"+Time.substring(0,4)+" "+Time.substring(11,19)+" "+value;
        

}


 function ConvertTime(time)
 {
    
        var year=time.substring(0,4);
        var month=time.substring(5,7);
        var day=time.substring(8,10);
 
       
      if(month==01)
      {
           month="January";
      }
      if(month==02)
      {
            month="February";
      }
      if(month==03)
      { 
            month="March";
      }
      if(month==04)
      {
            month="April";
      }
      if(month==05)
      {
            month="May";
      }
      if(month==06)
      {
            month="June";
      }
      if(month==07)
      {
           month="July";
      }
      if(month==08)
      {
           month="August";
      }
      if(month==09)
      { 
            month="September";
      }
      if(month==10)
      {
           month="October";
      }
      if(month==11)
      {
            month="November";
      }
      if(month==12)
      {
           month="December";
      }
      
       var time=month+"&nbsp;"+day+","+year;
       return  time;
      
   
        
 }
 
 
    var cpagesize=10; //论坛条数
  //查询公共评论 
 function IsIdQueryCommentIng(type)
{  
   
 
       
       var pageid=$("pageid").value;  //得到页面的id
        
      if(type=="news")
      var url="ashx/news_Query.ashx?id="+pageid+"&newscomments=yes"; 
      if(type=="fic")
      var url="ashx/faction_Query.ashx?id="+pageid+"&newscomments=yes";
      if(type=="video")
      var url="ashx/video_Query.ashx?id="+pageid+"&newscomments=yes";
      if(type=="img")
      var url="ashx/Img_Query.ashx?id="+pageid+"&newscomments=yes";
 
    
       var myajax=new Ajax.Request
                                  (
                                    url,
                                    {
                                    
                                       method:"get",
                                       onComplete:IsIdQueryCommentEd
                                   
                                   
                                    }    
                                  )  

 }
 function IsIdQueryCommentEd(xmlhttp)
 {  
  
     if(xmlhttp.responseText!="<NewDataSet />")
       {
                var  xmlds=xmlhttp.responseXML;
                var items=xmlds.getElementsByTagName("ds");
                datasource=items;
                Page(1,cpagesize,"comment");
              
              
       }
       else
       {
           $("allnews_divnews").innerHTML="";
           $("allnews_divpage").innerHTML="No comments";
           $("allnews_divpage").style.display="block";
       }
        
       
 
 }
 
 //公共的添加评论
function AddCommentsIng(type)
 {  
 
     var content=$("newsdetail_inputcontent").value;//得到内容
     
     if(content=="")
     {
            alert("please input content");
            return false;
     }
 
   
      var mycode=getCookie("CheckCode");
      var code=$("txtcode").value;        //得到验证码

       if(mycode!=code) //判断验证码是否输入正确
        { 
            alert("Authentication code is not correct");
            return false; 
        }
        
        
         var mycook=getCookie("Ignworlduser");
          if(mycook=="")
         {      alert("please login first");
                return false;
         }
      
        var pageid=$("pageid").value;  //得到页面的id
    
        var xml="<News>";
           xml+="<content>"+escape(content)+"</content>";
           xml+="<userid>1</userid>";
           xml+="<intartid>"+pageid+"</intartid>";   
           xml+="<comid>0</comid>";
           xml+="</News>";
        
       if(type=="news")
      var url="ashx/news_Add.ashx"; 
      if(type=="fic")
      var url="ashx/faction_Add.ashx";
      if(type=="video")
      var url="ashx/video_Add.ashx";
      if(type=="img")
      var url="ashx/Img_Add.ashx";
 
       var myajax=new Ajax.Request
                                   (
                                    url,
                                     {
 
                                            method:"post",
                                            postBody:xml,
                                            onComplete:AddCommentsEd
                                    
                                    
                                     }
                                    )
           
              
          
 
 }
 function AddCommentsEd(xmlhttp)
 {
        
        
              
     if(xmlhttp.responseText!="<NewDataSet />")
       {
                var  xmlds=xmlhttp.responseXML;
                var items=xmlds.getElementsByTagName("ds");
                datasource=items;
                
                /*
                var pageIndex=parseInt( parseInt(datasource.length)/ficpagesize ); 
                
                if(parseInt(datasource.length)%ficpagesize!=0)
                pageIndex=parseInt(parseInt(datasource.length)/ficpagesize)+1;
                  */
                Page(1,cpagesize,"comment");
              
              
       }
        
 
 
 
 }
 
 
 
 
 
 //转换url
  function convertnbsp(text)
  {
  
       
     var arr=new Array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "-", "/", ".", "'", ":", ";", ">", "<", "?", "\\", "\"", "{", "}", "[", "]", "|");
     
        for(var i=0;i<arr.length;i++)
        {
            
              text=text.replace(arr[i],""); 
              text=text.replace(" ","_");
        }     
             
            
         
         return text;
  } 
  
 
 
 //根据选中的电影来放映该电影
function  SetTopVideo(i)
{
    var newvideo=document.getElementById("index_inputvideo"+i).value;
           
    $("index_divtopvideo").innerHTML="<embed height='400' width='520' menu='true' loop='true' play='true'  autostart='true'  src="+newvideo+" />		";    

} 

 //注销 
 function LogOut()
{
   
   setCookie("Ignworlduser", "", 1)
   window.location.href="index.html";
 
}




function Qurl(num)
{
    var no=num;
    setCookie("Questsid",no,1);
    if(no==28)
    {
        window.location="Quests28.aspx";
    }
    else if(no==3)
    {
        window.location="Quests3.aspx";
    }
    else
    {
        window.location="Quests.aspx";
    }
}

function divEditButtonContainer()
{
    $("divEditButtonContainer").style.display="none";
}
 
