function changepic(objects,picname){
   return objects.src=picname;
   
}

function CheckLogin(theForm){
   var AdminName = theForm.AdminName.value;
   if(AdminName == ""){
      alert("请输入用户名!");
      theForm.AdminName.focus();
      return  (false);
   }
   var PassWord = theForm.PassWord.value;
   if(PassWord ==""){
      alert("请输入密码!");
      theForm.PassWord.focus();
      return  (false);
   }
}

function killErrors() {
	return true;
}

window.onerror = killErrors;

function PicFixSize(widths,heights,photosrc,position){
   var breakpoint = 50;
   var i = 0;
   var photowidth = 0;
   var photoheight = 0;
   var photo = new Image();

   if (position=="")
   {
      position = "left"
   }

   while(photowidth == 0 || photoheight == 0){
      photo.src = photosrc;
      photowidth = photo.width;
      photoheight = photo.height;
	  i++;
      if (i == breakpoint){
         break;
      } 
   }

   if(photowidth > widths || photoheight > heights){
      if(photowidth > widths && photoheight > heights){
         height = heights;
         width = (photowidth * height) / photoheight;
         if(width > widths){
            var tmpwidth = width;
            width = widths;
            height = (height * width) / tmpwidth;
         }
      }
      if(photowidth > widths && photoheight <= heights){
         width = widths;
         height = (photoheight * width) / photowidth; 
      }
      if(photowidth <= widths && photoheight > heights){
         height =heights;
         width = (photowidth * height) / photoheight;
      }
   }
   else{
      width = photowidth;
      height = photoheight;  
   }

   if (width < 10 || height < 10){
      width = widths;
	  height = heights;
   }

   return('<img src=' + photosrc + ' width=' + width + ' height=' + height +' border=0 align=' + position + '>')
}

function NewImg(imgurl) {
   newwin=window.open('about:blank','','top=10');
   newwin.document.write('<body leftmargin=0 topmargin=0><img src='+imgurl+' onload="self.resizeTo(this.offsetWidth+10, this.offsetHeight+30);">');
}

function OpenWindow(htmurl,widths,heights)
{
   var paramet = 'toolbar=no,resizable=no,scrollbars=no,width='+ widths + ',height=' + heights;
   newWindow = window.open(htmurl,"newWin",paramet);
   newWindow.focus();
}

function onlynumber(){
if (!((event.keyCode>47 && event.keyCode<58)))
   event.keyCode=0;
}

//图片等比缩放
function DrawImage(ImgD,w,h){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
  if(image.width/image.height>= w/h){ 
   if(image.width>w){
    ImgD.width=w; 
    ImgD.height=(image.height*h)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
  else{ 
   if(image.height>h){
    ImgD.height=h; 
    ImgD.width=(image.width*h)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
}
}
