﻿// 按比例生成缩略图									----------------------------
function DrawImage(MyPic,W,H){
  var flag=false;
  var image=new Image();
  image.src=MyPic.src;
  if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= W/H){
      if(image.width>W){  
        MyPic.width=W;
        MyPic.height=(image.height*W)/image.width;
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
    else{
      if(image.height>H){  
        MyPic.height=H;
        MyPic.width=(image.width*H)/image.height;     
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
  }
}
// 点击验证码图换数字									----------------------------
function UpVerifyCode(){
  document.getElementById("PhotoSN").src = "../Include/VerifyCode.asp?t="+Math.random();
}
// 指向变换背景图片  									----------------------------
function ChangeBackground(MyObj,NewBackground){ 
  MyObj.style.backgroundImage=NewBackground;
}   




//拷贝过来的代码

function CheckSearch()
{
	if(document.searchform.keywords.value == "")
	{
		alert("请输入搜索关键词！");
		document.searchform.keywords.focus();
		return false;
	}
	return true;
}

function CheckSearch2()
{
	if(document.searchform.keywords.value == "")
	{
		alert("Please enter search keywords！");
		document.searchform.keywords.focus();
		return false;
	}
	return true;
}

//等比例缩放图片
var flag=false; 
function MyImage(Img,WIDTH,HEIGHT){ 
var image=new Image(); 
image.src=Img.src; 
width=WIDTH;//预先设置的所期望的宽的值 
height=HEIGHT;//预先设置的所期望的高的值 
if(image.width>width||image.height>height){//现有图片只有宽或高超了预设值就进行js控制 
w=image.width/width; 
h=image.height/height; 
if(w>h){//比值比较大==>宽比高大 
//定下宽度为width的宽度 
Img.width=width; 
//以下为计算高度 
Img.height=image.height/w; 

}else{//高比宽大 
//定下宽度为height高度 
Img.height=height; 
//以下为计算高度 
Img.width=image.width/h; 
} 
} 
} 

//菜单栏JS
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}