/*
新闻模块常用JS
*/

function InsertComment(){

    var newsId = $F("NewsId").trim();
    var body = $F("CommentBody").trim();
    var isHiddenIP = $("IsHiddenIP").checked?1:0;
    var code= "";
    try{
        code = $F("vcode");
    }catch(e){}

    if(newsId =="") return alertmsg(false,"异常：新闻ID不能为空！");

    if(body =="")  return alertmsg(false,"评论内容不能为空！");

    if(body.length > 200) return alertmsg(false,"评论内容不能超过200字！");

    var url = "&CommentBody="+escape(body)+"&NewsID="+escape(newsId)+"&IsHiddenIP="+escape(isHiddenIP)+"&code=" + code;
 
    var ajax = new Ajax("XY015",url);
    ajax.onSuccess = function(){
        if(ajax.state.result ==1)
        {
            $("CommentBody").value="";
             try
            {
                ShowNewsCommentList();   
                $("vCodeImg").src = GetNewCode();
            }catch(e){}
        }
        if(ajax.state.result ==0 )
        {
            return alertmsg(false,ajax.state.message);
        }
    }
}

function ShowNewsCommentList()
  {
     //$("listst").innerHTML = "<div>评论载入中.....</div>";

     var ajax = new Ajax("XY026","&value="+$("NewsId").value);
     ajax.onSuccess = function(){
        
        if(ajax.state.result ==1)
        {
            var list ="";
            var length = ajax.data.comment.length;
            var url ="";

            for(var i=0;i<length;i++){
                var url = ajax.data.comment[i].user[0].shopurl;
                list +="<dd>";
                if(url != ""){
                    list += "<strong><a href='"+url+"' target='_blank'>"+ajax.data.comment[i].user[0].name+"</a></strong>";    
                }else{
                    if(ajax.data.comment[i].user[0].type == "person")
                        list += "<strong>"+ajax.data.comment[i].user[0].name+"</strong>(个人会员)";    
                    else
                        list += "<strong>"+ajax.data.comment[i].user[0].name+"</strong>(匿名网友)";    
                }
                list += " 于 <span>" + ajax.data.comment[i].sendtime + "</span>";
                
                list +="</dd>";
                
                list += "<dt>" +ajax.data.comment[i].content + "</dt>";
            }

            $("listst").innerHTML = list;            
        }
        if(ajax.state.result ==0 )
        {
            $("listst").innerHTML = ajax.state.message;
        }
    }
  }



  function reSet()
  {
      document.getElementById("NewsDiscussContent").value = "";    
  }
  
function GetDiscuss()
{
    try{
        ShowNewsCommentList();
    }catch(e){}
}



  
 function toBreakWord(intLen)
 {
    var obj=document.getElementById("ff");
    var strContent=obj.innerHTML; 
    var strTemp="";
    while(strContent.length>intLen)
    {
      strTemp+=strContent.substr(0,intLen)+" "; 
      strContent=strContent.substr(intLen,strContent.length); 
    }
    strTemp+=" "+strContent;
    obj.innerHTML=strTemp;
 }
 if(document.getElementById && !document.all) 
    toBreakWord(20)
  /* 发送评论 */

function Showok()
{
    var webmoney = document.getElementById("hwebmoney").value;
    var money = document.getElementById("hmoney").value;  

    var url = "&webmoney="+webmoney+"&money="+money+"&nid="+document.getElementById("NID").value;
    var ajax = new Ajax("XY031",url);
    ajax.onSuccess = function(){
        if(ajax.state.result ==1)
        {
             window.location.href = $("newurl").value;
        }
        if(ajax.state.result ==0 )
        {
            alert(ajax.state.message);
            var returl = config.WebURL +"news/Redirect."+config.Suffix+"?type=1&ret="+tempvalue+"&old="+document.getElementById("geturl").value;

            window.location.href = returl 
        }
    }
}

function Showno()
{
    window.location.href = document.getElementById("geturl").value;
}

//*******投稿***********//

function CheckContributorNews()
{
    if($("title").value.trim()=="")
    {
        return alertmsg(false,'新闻标题为填项！');
    } 
    
    var content = FCKeditorAPI.GetInstance('xyecom').GetXHTML(true); 
    if(content.trim()=="")
    {
        return alertmsg(false,'新闻内容为必填项！');
    }
    
    if(content.length>8000)
    {
        return alertmsg(false,'您输入的内容过长！');
    }
    
    if($("hidTypeId").value==""){
        return alertmsg(false,'请选择对应栏目！');
    }
    
    if($("newskeyword").value.trim()==""){
        return alertmsg(false,'请填写关键字！');
    }
    if($("vcode"))
    {
        var code = $F("vcode").trim();
        if(code=="" || code.length !=6)return alertmsg(false,'请输入正确的验证码！');
    }
}


/*****************************/ 
function _Settab_ByType(prefix,total,curCls,curIndex)
{
    for(var i=1;i<= total;i++)
    {
        var  tab = prefix+"_tab"+i;
        var  model = prefix+"_cnt"+i;

        if(i!=curIndex)
        {
            $(tab).className = "";
            $(model).style.display="none";
        }
        else
        {
            $(tab).className = curCls;
            $(model).style.display="block";
        }
    }
}
        
        
    function _SetQBtab(n)
    {
        switch(n)
                {
                    case 1 :
                        $("QBtab1").className = "current";
                        $("QBtab2").className = "";
                        $("cnt3B").style.display = "block";
                        $("cnt4B").style.display = "none";
                        break;
                    case 2 :
                        $("QBtab1").className = "";
                        $("QBtab2").className = "current";
                        $("cnt3B").style.display = "none";
                        $("cnt4B").style.display = "block";
                        break;          
                }
     }
     

     function _Othertab(n)
    {
        switch(n)
                {
                    case 1 :
                        $("othertab1").className = "current";
                        $("othertab2").className = "";
                        $("othertab3").className = "";
                        $("othertab4").className = "";
                        $("othertab5").className = "";
                        
                        $("ft_rt1").style.display = "block";
                        $("ft_rt2").style.display = "none";
                        $("ft_rt3").style.display = "none";
                        $("ft_rt4").style.display = "none";
                        $("ft_rt5").style.display = "none";

                        break;
                    case 2 :
                        $("othertab1").className = "";
                        $("othertab2").className = "current";
                        $("othertab3").className = "";
                        $("othertab4").className = "";
                        $("othertab5").className = "";
                        
                        $("ft_rt1").style.display = "none";
                        $("ft_rt2").style.display = "block";
                        $("ft_rt3").style.display = "none";
                        $("ft_rt4").style.display = "none";
                        $("ft_rt5").style.display = "none";

                        break;
                    case 3 :
                        $("othertab1").className = "";
                        $("othertab2").className = "";
                        $("othertab3").className = "current";
                        $("othertab4").className = "";
                        $("othertab5").className = "";
                        
                        $("ft_rt1").style.display = "none";
                        $("ft_rt2").style.display = "none";
                        $("ft_rt3").style.display = "block";
                        $("ft_rt4").style.display = "none";
                        $("ft_rt5").style.display = "none";

                        break;          
                    case 4 :
                        $("othertab1").className = "";
                        $("othertab2").className = "";
                        $("othertab3").className = "";
                        $("othertab4").className = "current";
                        $("othertab5").className = "";
                        
                        $("ft_rt1").style.display = "none";
                        $("ft_rt2").style.display = "none";
                        $("ft_rt3").style.display = "none";
                        $("ft_rt4").style.display = "block";
                        $("ft_rt5").style.display = "none";

                        break;          
                    case 5 :
                        $("othertab1").className = "";
                        $("othertab2").className = "";
                        $("othertab3").className = "";
                        $("othertab4").className = "";
                        $("othertab5").className = "current";
                        
                        $("ft_rt1").style.display = "none";
                        $("ft_rt2").style.display = "none";
                        $("ft_rt3").style.display = "none";
                        $("ft_rt4").style.display = "none";
                        $("ft_rt5").style.display = "block";

                        break;   
						   case 6 :
                        $("othertab6").className = "current";
                        $("othertab7").className = "";
                        $("othertab8").className = "";
                        $("othertab9").className = "";
                        $("othertab10").className = "";
                        
                        $("ft_rt6").style.display = "block";
                        $("ft_rt7").style.display = "none";
                        $("ft_rt8").style.display = "none";
                        $("ft_rt9").style.display = "none";
                        $("ft_rt10").style.display = "none";

                        break;
                    case 7 :
                        $("othertab6").className = "";
                        $("othertab7").className = "current";
                        $("othertab8").className = "";
                        $("othertab9").className = "";
                        $("othertab10").className = "";
                        
                        $("ft_rt6").style.display = "none";
                        $("ft_rt7").style.display = "block";
                        $("ft_rt8").style.display = "none";
                        $("ft_rt9").style.display = "none";
                        $("ft_rt10").style.display = "none";

                        break;
                    case 8 :
                        $("othertab6").className = "";
                        $("othertab7").className = "";
                        $("othertab8").className = "current";
                        $("othertab9").className = "";
                        $("othertab10").className = "";
                        
                        $("ft_rt6").style.display = "none";
                        $("ft_rt7").style.display = "none";
                        $("ft_rt8").style.display = "block";
                        $("ft_rt9").style.display = "none";
                        $("ft_rt10").style.display = "none";

                        break;          
                    case 9 :
                        $("othertab6").className = "";
                        $("othertab7").className = "";
                        $("othertab8").className = "";
                        $("othertab9").className = "current";
                        $("othertab10").className = "";
                        
                        $("ft_rt6").style.display = "none";
                        $("ft_rt7").style.display = "none";
                        $("ft_rt8").style.display = "none";
                        $("ft_rt9").style.display = "block";
                        $("ft_rt10").style.display = "none";

                        break;          
                    case 10 :
                        $("othertab6").className = "";
                        $("othertab7").className = "";
                        $("othertab8").className = "";
                        $("othertab9").className = "";
                        $("othertab10").className = "current";
                        
                        $("ft_rt6").style.display = "none";
                        $("ft_rt7").style.display = "none";
                        $("ft_rt8").style.display = "none";
                        $("ft_rt9").style.display = "none";
                        $("ft_rt10").style.display = "block";

                        break;    
                }
     }
     
      //OFFER主页面的股票选项卡
     function _SettabStockoffer(n)
    {
        switch(n)
                {
                    case 1 :
                        $("stock1").className = "current";
                        $("stock2").className = "";
                        $("stock3").className = "";
                        $("stock4").className = "";
                        $("stock5").className = "";
                        
                        $("stockup1").style.display = "block";
                        $("stockup2").style.display = "none";
                        $("stockup3").style.display = "none";
                        $("stockup4").style.display = "none";
                        $("stockup5").style.display = "none";
                        
                        $("stockdown1").style.display = "block";
                        $("stockdown2").style.display = "none";
                        $("stockdown3").style.display = "none";
                        $("stockdown4").style.display = "none";
                        $("stockdown5").style.display = "none";
                        
                        break;
                    case 2 :
                        $("stock1").className = "";
                        $("stock2").className = "current";
                        $("stock3").className = "";
                        $("stock4").className = "";
                        $("stock5").className = "";
                        
                        $("stockup1").style.display = "none";
                        $("stockup2").style.display = "block";
                        $("stockup3").style.display = "none";
                        $("stockup4").style.display = "none";
                        $("stockup5").style.display = "none";
                        
                        $("stockdown1").style.display = "none";
                        $("stockdown2").style.display = "block";
                        $("stockdown3").style.display = "none";
                        $("stockdown4").style.display = "none";
                        $("stockdown5").style.display = "none";
                        
                        break;
                    case 3 :
                        $("stock1").className = "";
                        $("stock2").className = "";
                        $("stock3").className = "current";
                        $("stock4").className = "";
                        $("stock5").className = "";
                        $("stockup1").style.display = "none";
                        $("stockup2").style.display = "none";
                        $("stockup3").style.display = "block";
                        $("stockup4").style.display = "none";
                        $("stockup5").style.display = "none";
                        
                        $("stockdown1").style.display = "none";
                        $("stockdown2").style.display = "none";
                        $("stockdown3").style.display = "block";
                        $("stockdown4").style.display = "none";
                        $("stockdown5").style.display = "none";
                        
                        break;
                    case 4 :
                        $("stock1").className = "";
                        $("stock2").className = "";
                        $("stock3").className = "";
                        $("stock4").className = "current";
                        $("stock5").className = "";
                        
                        $("stockup1").style.display = "none";
                        $("stockup2").style.display = "none";
                        $("stockup3").style.display = "none";
                        $("stockup4").style.display = "block";
                        $("stockup5").style.display = "none";
                        
                        $("stockdown1").style.display = "none";
                        $("stockdown2").style.display = "none";
                        $("stockdown3").style.display = "none";
                        $("stockdown4").style.display = "none";
                        $("stockdown5").style.display = "block";
                        
                        break;
                    case 5 :
                        $("stock1").className = "";
                        $("stock2").className = "";
                        $("stock3").className = "";
                        $("stock4").className = "";
                        $("stock5").className = "current";
                        
                        $("stockup1").style.display = "none";
                        $("stockup2").style.display = "none";
                        $("stockup3").style.display = "none";
                        $("stockup4").style.display = "none";
                        $("stockup5").style.display = "block";
                        
                        $("stockdown1").style.display = "none";
                        $("stockdown2").style.display = "none";
                        $("stockdown3").style.display = "none";
                        $("stockdown4").style.display = "none";
                        $("stockdown5").style.display = "block";
                        
                        break;
                }
     }      
     
     
     
     
     
     function _SettabStock(n)
    {
        switch(n)
                {
                    case 1 :
                        $("stock1").className = "current";
                        $("stock2").className = "";
                        $("stock3").className = "";
                        $("stock4").className = "";
                        $("stockup1").style.display = "block";
                        $("stockup2").style.display = "none";
                       $("stockup3").style.display = "none";
                       $("stockup4").style.display = "none";
                        break;
                    case 2 :
                        $("stock1").className = "";
                        $("stock2").className = "current";
                       $("stock3").className = "";
                      $("stock4").className = "";
                        $("stockup1").style.display = "none";
                        $("stockup2").style.display = "block";
                      $("stockup3").style.display = "none";
                       $("stockup4").style.display = "none";
                        break;
                    case 3 :
                     $("stock1").className = "";
                       $("stock2").className = "";
                        $("stock3").className = "current";
                        $("stock4").className = "";
                       $("stockup1").style.display = "none";
                       $("stockup2").style.display = "none";
                        $("stockup3").style.display = "block";
                        $("stockup4").style.display = "none";
                        break;
                    case 4 :
                       $("stock1").className = "";
                       $("stock2").className = "";
                        $("stock3").className = "";
                        $("stock4").className = "current";
                       $("stockup1").style.display = "none";
                        $("stockup2").style.display = "none";
                        $("stockup3").style.display = "none";
                        $("stockup4").style.display = "block";         
                        break;
                }
     }      
        
        
            
     function _SettabStockdata(n)
    {
        switch(n)
                {
                    case 1 :
                        $("stock1").className = "current";
                        $("stock2").className = "";
                       // $("stock3").className = "";
                       // $("stock4").className = "";
                        $("stockup1").style.display = "block";
                        $("stockup2").style.display = "none";
                      //  $("stockup3").style.display = "none";
                      //  $("stockup4").style.display = "none";
                        break;
                    case 2 :
                        $("stock1").className = "";
                        $("stock2").className = "current";
                      //  $("stock3").className = "";
                     //   $("stock4").className = "";
                        $("stockup1").style.display = "none";
                        $("stockup2").style.display = "block";
                      //  $("stockup3").style.display = "none";
                     //   $("stockup4").style.display = "none";
                        break;
                    case 3 :
                        //$("stock1").className = "";
                     //   $("stock2").className = "";
                        $("stock3").className = "current";
                        $("stock4").className = "";
                      //  $("stockup1").style.display = "none";
                       // $("stockup2").style.display = "none";
                        $("stockup3").style.display = "block";
                        $("stockup4").style.display = "none";
                        break;
                    case 4 :
                       // $("stock1").className = "";
                       // $("stock2").className = "";
                        $("stock3").className = "";
                        $("stock4").className = "current";
                      //  $("stockup1").style.display = "none";
                       // $("stockup2").style.display = "none";
                        $("stockup3").style.display = "none";
                        $("stockup4").style.display = "block";         
                        break;
                }
     }      
        
        
    



	function setTab(name,cursel,n){
		var RefreshID=null;
		if (RefreshID) { clearTimeout(RefreshID); }
		RefreshID = setTimeout("Switch('"+name+"','"+cursel+"','"+n+"')", 10);
	}

	function Switch(name,cursel,n){
		for(i=1;i<=n;i++){
			var menu=document.getElementById(name+i);
			var con=document.getElementById("con_"+name+"_"+i);
			menu.className=i==cursel?"current":"";
			con.style.display=i==cursel?"block":"none";
		}
	}


	function kf_tab(n){
		if(n==1){
			document.getElementById("kfc_tab1").className = "current";
			document.getElementById("kf_tab_cnt1").style.display = "";
			document.getElementById("kfc_tab2").className = "";
			document.getElementById("kf_tab_cnt2").style.display = "none";
			document.getElementById("kfc_tab3").className = "";
			document.getElementById("kf_tab_cnt3").style.display = "none";
			document.getElementById("kfc_tab4").className = "";
			document.getElementById("kf_tab_cnt4").style.display = "none";
		}
		if(n==2){
			document.getElementById("kfc_tab1").className = "";
			document.getElementById("kf_tab_cnt1").style.display = "none";
			document.getElementById("kfc_tab2").className = "current";
			document.getElementById("kf_tab_cnt2").style.display = "";
			document.getElementById("kfc_tab3").className = "";
			document.getElementById("kf_tab_cnt3").style.display = "none";
			document.getElementById("kfc_tab4").className = "";
			document.getElementById("kf_tab_cnt4").style.display = "none";
		}
		if(n==3){
			document.getElementById("kfc_tab1").className = "";
			document.getElementById("kf_tab_cnt1").style.display = "none";
			document.getElementById("kfc_tab2").className = "";
			document.getElementById("kf_tab_cnt2").style.display = "none";
			document.getElementById("kfc_tab3").className = "current";
			document.getElementById("kf_tab_cnt3").style.display = "";
			document.getElementById("kfc_tab4").className = "";
			document.getElementById("kf_tab_cnt4").style.display = "none";
		}
		if(n==4){
			document.getElementById("kfc_tab1").className = "";
			document.getElementById("kf_tab_cnt1").style.display = "none";
			document.getElementById("kfc_tab2").className = "";
			document.getElementById("kf_tab_cnt2").style.display = "none";
			document.getElementById("kfc_tab3").className = "";
			document.getElementById("kf_tab_cnt3").style.display = "none";
			document.getElementById("kfc_tab4").className = "current";
			document.getElementById("kf_tab_cnt4").style.display = "";
		}
		
	}
function daohangTabChange(id)
{
    for(var i= 1;i< 6;i++)
    {
        if(i==id)
        {
            document.getElementById("daohang_tab" + i).className = "current";
        }
        else
        {
            document.getElementById("daohang_tab" + i).className = "";
        }
    }
}

//取得cookie
function getCliiCookie(c_name)
{
    if (document.cookie.length>0)
    {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
      { 
        c_start=c_start + c_name.length+1 ;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
       } 
    }
    return ""
}
//设置cookie
function setCliiCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
   
}

window.onload = function()
{
   var tempDate = new Date();
   var tempStr = "";
   tempStr = tempDate.getFullYear() + "年" + (tempDate.getMonth() + 1) + "月" + tempDate.getDate() + "日 ";
   switch(tempDate.getDay())
   {
        case 0 :
            tempStr += "星期日";
            break;
        case 1 :
            tempStr += "星期一";
            break;
        case 2 :
            tempStr += "星期二";
            break;
        case 3 :
            tempStr += "星期三";
            break;
        case 4 :
            tempStr += "星期四";
            break;
        case 5 :
            tempStr += "星期五";
            break;
        case 6 :
            tempStr += "星期六";
            break;
   }
   tempStr += " " + GetLunarDay(tempDate.getFullYear(),tempDate.getMonth() + 1,tempDate.getDate());
   document.getElementById("date_panel").innerHTML = tempStr;
}
