// JavaScript Document
var BDJob=new Object();
BDJob.images=new Object();
//图片按规定大小缩放
BDJob.images.LaodImage = function(Obj,w,h)
{
	  if (w!=0)
	  {
		Obj.width=w;  
	  }
	  if (h!=0)
	  {
		Obj.height=h;  
	  }
	  //Obj.src=ImgURL;
}
/*
调用：
<script type="text/javascript">
put('<img src="/webbuild-model/hangye-b/images/hangye-b_btn_Pe_Reg.gif" onload="javascript:BDJob.images.LaodImage(this,161,4)">');
</script>
*/

//图片按比例缩放
BDJob.images.DrawImage = function(ImgD,strWidth,strHeight)
{
	var flag=false;
	var image=new Image();
	var iwidth = strWidth; //定义允许图片宽度，当宽度大于这个值时等比例缩小
	var iheight = strHeight; //定义允许图片高度，当宽度大于这个值时等比例缩小
	image.src=ImgD.src;
	//alert(image.height);
	if(image.width>0 && image.height>0){
		//alert(image.width+"X"+image.height);
		//alert(iwidth+"X"+iheight);
		flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){ 
				if (iwidth>0){
				  ImgD.width=iwidth;}else{
				  ImgD.width=image.width;}
				if (iwidth>0){
				  ImgD.height=(image.height*iwidth)/image.width;}else{
				  ImgD.height=image.height;}
				 // alert(image.height);
			}
			else
			{
				ImgD.width=image.width; 
				ImgD.height=image.height;

			}
			
			//ImgD.alt= "点击查看";
		}
		else
		{
			if(image.height>iheight)
			{ 
				if (iheight!=0){
				  ImgD.height=iheight;
				 }else{
				  ImgD.height=image.height;}
				if (iheight!=0){
				  ImgD.width=(image.width*iheight)/image.height;
				 }else{
				  ImgD.width=image.width;}


			}
			else
			{
				ImgD.width=image.width; 
				ImgD.height=image.height;

			}
			////.alt= "点击查看";
			/////////image.width+"×"+image.height
			//ImgD.display='';
		}
	}
} 
/*
调用：
<script type="text/javascript">
put('<img src="/webbuild-model/hangye-b/images/hangye-b_btn_Pe_Reg.gif" onload="javascript:BDJob.images.DrawImage(this,161,4)">');
</script>
*/


function put(s) { document.write(s); }