﻿// JScript 文件
var newsId=0;
function fontZoom(size)
{
document.getElementById('fontZoom').style.fontSize=size+'px'
}


function GetNewsRight(id)
{  

newsId=id;
    var strUrl = "http://" + window.location.host + "/Html/newsRight.aspx?ID="+id+"&r=" + Math.random();
    ajax.Get(strUrl,GetNewsRightCallBack);
}
function GetNewsRightCallBack()
{

    if(ajax.IsReady() == true)
    {
        document.getElementById("divNewsRight").innerHTML = ajax.ResponseText();
        AddNewsCount(newsId);
    }
}
function AddNewsCount(id)
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?ID="+id+"&strType=0&r=" + Math.random();
    ajax.Get(strUrl,AddNewsCountCallBack);
}
function AddNewsCountCallBack()
{
    if(ajax.IsReady() == true)
    {
       AddPlNum(newsId);
    }
}
function AddPlNum(id)
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?ID="+id+"&strType=2&r=" + Math.random();
    ajax.Get(strUrl,AddPlNumCallBack);
}
function AddPlNumCallBack()
{

    if(ajax.IsReady() == true)
    {
       document.getElementById("divplnum").innerHTML = ajax.ResponseText();
       getHotWords();
    }
}
//热词
function getHotWords()
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?strType=3&r=" + Math.random();
    ajax.Get(strUrl,getHotWordsCallBack);
}
function getHotWordsCallBack()
{

    if(ajax.IsReady() == true)
    {
    var strhtml=document.getElementById('fontZoom').innerHTML;
       var arr=ajax.ResponseText().split(',');
       for(var i=0;i<arr.length;i++)
       {
       var arrsub=arr[i].split('|');
       if(arrsub[0]!="")
       {
       var reg=new RegExp(arrsub[0],"g"); 
       strhtml=strhtml.replace(reg,"<a href=\""+arrsub[1]+"\" onmousemove=\"showalt('<img src="+arrsub[2]+" >')\" onmouseout=\"hidealt()\" ><span  class='font14blue'>" + arrsub[0] + "</span></a>");
       }
       }
       document.getElementById('fontZoom').innerHTML=strhtml;
       getNewsAD();
    }
}
//广告
function getNewsAD()
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?strType=4&r=" + Math.random();
    ajax.Get(strUrl,getNewsADCallBack);
}
function getNewsADCallBack()
{

    if(ajax.IsReady() == true)
    {
     document.getElementById("divadbanner").innerHTML = ajax.ResponseText();
     getNewsCur();
    }
}
//相关新闻
function getNewsCur()
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?ID="+newsId+"&strType=5&r=" + Math.random();
    ajax.Get(strUrl,getNewsCurCallBack);
}
function getNewsCurCallBack()
{

    if(ajax.IsReady() == true)
    {
     document.getElementById("divNewsCor").innerHTML = ajax.ResponseText();
     getNewsTopAd1();
    }
}
//头部广告位1
function getNewsTopAd1()
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?strType=6&r=" + Math.random();
    ajax.Get(strUrl,getNewsTopAd1CallBack);
}
function getNewsTopAd1CallBack()
{

    if(ajax.IsReady() == true)
    {
     document.getElementById("divtopad1").innerHTML = ajax.ResponseText();
      getNewsTopAd2();
    }
}
//头部广告位2
function getNewsTopAd2()
{  
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?strType=7&r=" + Math.random();
    ajax.Get(strUrl,getNewsTopAd2CallBack);
}
function getNewsTopAd2CallBack()
{

    if(ajax.IsReady() == true)
    {
     document.getElementById("divtopad2").innerHTML = ajax.ResponseText();
    }
}

function userLoginInfo()
{  
    var nickname=document.getElementById('txtNickName').value;
     if(nickname=="")
    {
      alert("请输入名称！");
        return false;
    }
    var pwd=document.getElementById('txtPassword').value;
     if(pwd=="")
    {
      alert("请输入密码！");
        return false;
    }
    var strValidateCode=document.getElementById('txtTopValidateCode').value;
    if(strValidateCode=="")
    {
      alert("请输入验证码！");
        return false;
    }
      var data="strValidateCode=" + strValidateCode + "&nickname=" + nickname + "&pwd=" + pwd;
    
    var strUrl = "http://" + window.location.host + "/Html/userLogin.aspx?r=" + Math.random();
    ajax.Post(strUrl, data, userLoginInfoCallBack);
}
function userLoginInfoCallBack()
{

    if(ajax.IsReady() == true)
    {
    if(ajax.ResponseText()=="0")
    alert('验证码错误 ！');
    else if(ajax.ResponseText()=="1")
    alert('[用户不存在] 或 [用户名和密码不对应] ！');
    else
        document.getElementById("divlogininfo").innerHTML = ajax.ResponseText();
    }
}

function commentAction(id)
{  
    var txtTitle=document.getElementById('txtTitle').value;
     if(txtTitle=="")
    {
      alert("请输入标题！");
        return false;
    }
    var txtContent=document.getElementById('txtContent').value;
     if(txtContent=="")
    {
      alert("请输入内容！");
        return false;
    }
      var strurl=document.getElementById('hidUrl').value;
      var data="id="+id+"&txtTitle=" + txtTitle + "&txtContent=" + txtContent+"&strurl="+strurl;
    
    var strUrl = "http://" + window.location.host + "/Html/commentAction.aspx?r=" + Math.random();
    ajax.Post(strUrl, data, commentActionCallBack);
}
function commentActionCallBack()
{

    if(ajax.IsReady() == true)
    {
 
      window.location.href=ajax.ResponseText();

    }
}

function SearchAction()
{  

    var ddlSearchType=document.getElementById('ddlSearchType');
   
    var searchName=document.getElementById('txtsearchName').value;
     if(searchName=="")
    {
      alert("请输入搜索内容！");
        return false;
    }

      var data="SearchType=" + ddlSearchType.options[ddlSearchType.selectedIndex].value + "&searchName=" + searchName;
        
    var strUrl = "http://" + window.location.host + "/Html/newsCount.aspx?strType=8&r=" + Math.random();
    
    ajax.Post(strUrl, data, SearchActionCallBack);
}
function SearchActionCallBack()
{

    if(ajax.IsReady() == true)
    {
      window.location.href=ajax.ResponseText();

    }
}
//显示热词
function selHotWord(strname,strlink,strimage)
{
showalt("<a href='"+strlink+"'><img src='"+strimage+"'></a>");
}

