﻿	function gotopage(pagenum)
	{
		var surl,ssearch,turl,last;
		surl = self.location.href;
		ssearch = self.location.search.substring(1);
		if (ssearch.indexOf("page") != -1)
		{
		  last = surl.lastIndexOf("=");
		  turl = surl.substring(0,last+1) + pagenum;
		  }
		else if (surl.indexOf("?") != -1)
		{
		  turl = surl + "&page=" + pagenum;
		  }
		else 
		{
		  turl = surl + "?page=" + pagenum;
		  }
		self.location = turl;
	}
	function select_all(thecheckbox)
	{
		var nn=document.all.item("option")
		if (thecheckbox.checked==true)
			for (j=0; j<nn.length; j++)
				document.all.item("option",j).checked=true;
		else
			for (j=0; j<nn.length; j++)
				document.all.item("option",j).checked=false;
	}
	
function del_selected(del_page)
{
  var s = false; //用来记录是否存在被选中的复选框
  var Newsid, n=0; 
  var strid, strurl;
  var nn = self.document.all.item("option"); //返回复选框Cate的数量
  for (j=0; j<nn.length; j++) 
  {
    if (self.document.all.item("option",j).checked) 
	{
      n = n + 1;
      s = true;
      logid = self.document.all.item("option",j).value;  //转换为字符串
      //生成要删除新闻编号的列表
      if(n==1) 
	  {
        strid = logid;
      }
      else 
	  {
        strid = strid + "," + logid;
      }
    }
  }
  if(!s) 
  {
    alert("请选择要删除的记录项目!");
    return false;
  }	
  if (confirm("确定要删除删除的项目吗？")) 
  {
	window.open(del_page+"&id="+ strid,"","alwaysRaised=yes,resizable=auto,minimizebutton=yes,width=200,height=120");
  }
}
	
function confirmdel(delfile){
       if (confirm("真的要删除这条记录?")) 
      	   open(delfile,"","alwaysRaised=yes,resizable=auto,minimizebutton=yes,width=200,height=120");
     }

function keywordok(theform)
{
if (trim(theform.key_word.value)=="")
  {
    alert("Keyword is required!");
    theform.key_word.focus();
    return (false);
  }
	var str = theform.key_word.value
	var reg = /\s{2,}/g;
	var arr = str.replace(reg," ");
	theform.key_word.value=arr;
	return(true);
}
//&#21435;&#24038;&#31354;&#26684;; 
function ltrim(s){ 
return s.replace( /^\s*/, ""); 
} 
//&#21435;&#21491;&#31354;&#26684;; 
function rtrim(s){ 
return s.replace( /\s*$/, ""); 
} 
//&#21435;&#24038;&#21491;&#31354;&#26684;; 
function trim(s){ 
return rtrim(ltrim(s)); 
} 
//图片按比例缩放 
var flag=false; 
function DrawImage(ImgD){ 
 var image=new Image(); 
 var iwidth = 100;  //定义允许图片宽度 
 var iheight = 100;  //定义允许图片高度 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
 flag=true; 
 if(image.width/image.height>= iwidth/iheight){ 
  if(image.width>iwidth){   
  ImgD.width=iwidth; 
  ImgD.height=(image.height*iwidth)/image.width; 
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  ImgD.alt=image.width+"×"+image.height; 
  } 
 else{ 
  if(image.height>iheight){   
  ImgD.height=iheight; 
  ImgD.width=(image.width*iheight)/image.height;   
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  ImgD.alt=image.width+"×"+image.height; 
  } 
 } 
}  

