﻿// JScript File

//创建ＸＭＬhttp
function CreateXMLhttp()
{
   if(window.XMLHttpRequest)
   {
      var xmlObj = new XMLHttpRequest();
   } 
   else 
   {
      var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
	  //var MSXML = ["MSXML2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP.2.6","Msxml2.XMLHTTP.1.0","Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];	  
      for(var n = 0; n < MSXML.length; n++)
      {
         try
         {
            var xmlObj = new ActiveXObject(MSXML[n]);        
            break;
         }
         catch(e)
         {
         }
      }
   } 
 
   return xmlObj;
}


//把指定ＵＲＬ的信息显示到指定ＤＩＶ中
//stype 加载方式 false:同步加载 true:异步加载
function ShowMsg2Div(sUrl,ObjectID,stype)
{
   var DivID = document.getElementById(ObjectID);
   var xmlhttp =CreateXMLhttp();
   xmlhttp.open("GET", sUrl, stype);
   xmlhttp.send(null);
   if (xmlhttp.statusText=="OK")
   {
       //alert(xmlhttp.responseText);
       DivID.innerHTML=xmlhttp.responseText;
   }
}

//取指定ＵＲＬ的信息
//stype 加载方式 false:同步加载 true:异步加载
function GetMsg(sUrl,stype)
{   
   var xmlhttp =CreateXMLhttp();
   //var xmlhttp =GetMsXmlHttp();
   
   xmlhttp.open("GET", sUrl, stype);   
   xmlhttp.send(null);
   if (xmlhttp.statusText=="OK")
   {
       return xmlhttp.responseText;
   }
}

//往指定页面发请求，不要返回结果
function GetMsg_N(sUrl)
{   
   var xmlhttp =CreateXMLhttp();
   xmlhttp.open("GET", sUrl, true);  
   xmlhttp.send(null);
}

function isNly()
{
   if(LyForm.isN.checked)
   {
	  UserLogin.style.display = "none";
   }else{
	  UserLogin.style.display = "";
   }
}
function LySubmitform()
{
    if(!LyForm.isN.checked)
	{
	   if (LyForm.isLogin.value=="1")
	   {
	   
	   }else{	   
	     if (LyForm.UserName.value=="" || LyForm.PassWord.value=="")
	     {
	       alert("请输入用户名密码或者选择匿名发言");
		   LyForm.UserName.focus();
		   return false;
	     }
	   }
	}
	if(LyForm.Title.value=="")
	{
	       alert("请输入标题");
		   LyForm.Title.focus();
		   return false;
	}

	if (LyForm.Title.value.length>100)
	{
	       alert("标题字数请在100字以内");
		   LyForm.Title.focus();
		   return false;	
	}
	if(LyForm.Ly.value=="")
	{
	       alert("请输入内容");
		   LyForm.Ly.focus();
		   return false;
	}
	return true;
} 

function PageIndex_List(Total, PageSize, CurrentPage,sType)
    {
        var ReTXT = "";
        var IndexLen = 0, i = 0;
        var lefti = 0, righti = 0;
        IndexLen = Math.ceil(Total / PageSize);		
		
        lefti = CurrentPage - 6;
        righti = CurrentPage + 6;


        if (IndexLen <= 1) return "";

        ReTXT += "<table width=\"100%\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">";
        ReTXT += "<tr> ";
        ReTXT += "<td class=\"page-number\">";
        if (lefti <= 1)
        {
            lefti = 1;
        }
        if (righti >= IndexLen)
        {
            righti = IndexLen;
        }
        ReTXT += "<a href=\"?sType="+sType+"&CurrentPage=1&PageSize=" + PageSize+ "\">[第1页]</a> <a href=\"?sType="+sType+"&CurrentPage=" + (CurrentPage - 1) + "&PageSize=" + PageSize+ "\">[上一页]</a>";
        if (lefti > 1)
        {
            ReTXT += " …… ";
        }
        for (i = lefti; i <= righti; i++)
        {
            if (i == CurrentPage)
                ReTXT += "<span class=\"page-number1\">" + i + "</span> ";
            else
                ReTXT += "<a href=\"?sType="+sType+"&CurrentPage=" + i + "&PageSize=" + PageSize + "\" class='page-number2'>" + i + "</a> ";
        }
        if (righti < IndexLen)
        {
            ReTXT += " …… ";
        }
        ReTXT += " <a href=\"?sType="+sType+"&CurrentPage=" + (CurrentPage + 1) + "&PageSize=" + PageSize + "\">[下一页]</a> <a href=\"?sType="+sType+"&CurrentPage=" + IndexLen + "&PageSize=" + PageSize + "\">[第" + IndexLen + "页]</a> ";

        ReTXT += "</td></tr>";
        ReTXT += "</table>";

        return ReTXT;
    }
	
function PageIndex_List2(Total, PageSize, CurrentPage,sWhere)
    {
        var ReTXT = "";
        var IndexLen = 0, i = 0;
        var lefti = 0, righti = 0;
        IndexLen = Math.ceil(Total / PageSize);		
		
        lefti = CurrentPage - 6;
        righti = CurrentPage + 6;


        if (IndexLen <= 1) return "";

        ReTXT += "<table width=\"100%\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">";
        ReTXT += "<tr> ";
        ReTXT += "<td class=\"page-number\">";
        if (lefti <= 1)
        {
            lefti = 1;
        }
        if (righti >= IndexLen)
        {
            righti = IndexLen;
        }
		if (CurrentPage==1)
		{
            ReTXT += "<a href=\"?"+sWhere+"&CurrentPage=1&PageSize=" + PageSize+ "\">[第1页]</a> [上一页]";
		}else{
			ReTXT += "<a href=\"?"+sWhere+"&CurrentPage=1&PageSize=" + PageSize+ "\">[第1页]</a> <a href=\"?"+sWhere+"&CurrentPage=" + (CurrentPage - 1) + "&PageSize=" + PageSize+ "\">[上一页]</a>";
		}
        if (lefti > 1)
        {
            ReTXT += " …… ";
        }
        for (i = lefti; i <= righti; i++)
        {
            if (i == CurrentPage)
                ReTXT += "<span class=\"page-number1\">" + i + "</span> ";
            else
                ReTXT += "<a href=\"?"+sWhere+"&CurrentPage=" + i + "&PageSize=" + PageSize + "\" class='page-number2'>" + i + "</a> ";
        }
        if (righti < IndexLen)
        {
            ReTXT += " …… ";
        }
        //ReTXT += " <a href=\"?"+sWhere+"&CurrentPage=" + (CurrentPage + 1) + "&PageSize=" + PageSize + "\">[下一页]</a> <a href=\"?"+sWhere+"&CurrentPage=" + IndexLen + "&PageSize=" + PageSize + "\">[第" + IndexLen + "页]</a> ";
		if (CurrentPage==IndexLen)
		{
			ReTXT += " [下一页] <a href=\"?"+sWhere+"&CurrentPage=" + IndexLen + "&PageSize=" + PageSize + "\">[最末页]</a> ";
		}
		else{
		       ReTXT += " <a href=\"?"+sWhere+"&CurrentPage=" + (CurrentPage + 1) + "&PageSize=" + PageSize + "\">[下一页]</a> <a href=\"?"+sWhere+"&CurrentPage=" + IndexLen + "&PageSize=" + PageSize + "\">[最末页]</a> ";
		}

        ReTXT += "</td></tr>";
        ReTXT += "</table>";

        return ReTXT;
    }
	
function ChangeyzmImg()
{
	yzmImg.src="/YZM.asp";
}
function ShowYZMDiv()
{
	if (ShowYZMtag==0)
	{
	    isYZM.location="/ShowYZM.asp";
		ShowYZMtag=1;
	}
}
function   changeImg(mypic){   
  var   xw=500;   
  var   xl=400;   
    
  var   width   =   mypic.width;   
  var   height   =   mypic.height;   
  //var   bili   =   xw/width; 
  var   bili   =   width/height;   

   
   /**
   if(width   >   xw )
   {
      mypic.width=xw;   
      //mypic.height=mypic.height*bili; 	
	  mypic.height=Math.round(mypic.height*bili);
   }
   **/
  if(width   >   xw   ||   height   >   xl)   
  {   
  if(width/height>xw/xl)   
  {   
  mypic.width=xw;   
  mypic.height=xw/bili;   
  }   
  if(width/height<xw/xl)   
  {   
  mypic.width=xl*bili;   
  mypic.height=xl;   
  }   
  }   
 
}
	function IndexSearch()
	{
	    var frm=document.LySearchForm;
		var sUrl="";
		var sType="1";
for(i=0;i<frm.sType.length;i++)
{
   if(frm.sType[i].checked==true)
   {
    sType=frm.sType[i].value;
   }
}

		if (sType=="1")
		{
			sUrl="/SearchGroup.asp?key="+frm.skey.value;
		}else
		{
			sUrl="/SearchNews.asp?key="+frm.skey.value;
			}
		window.open(sUrl);
	}