// JavaScript Document
      function Null(str){
	if(typeof(str)=="undefined"||str=="")
		return true;
	else
		return false;
    }
        function formatnum(nums,err){
	        if(typeof(nums)=="undefined"||nums
	        ==""||isNaN(nums))
		        return parseInt(err);
	        else
		        return parseInt(nums);
    }
        //图片按比例缩放
        //obj 对像,
        //w 长
        //h 高
        //url 地址
        
        function setImg(obj,w,h,url,fun){
	        w=formatnum(w,300),h=formatnum(h,300);
	        if(Null(url))url=obj.src;
	        var image=new Image(),ww,hh;
	        image.onload=function(){
		        setImged=true,obj.onload=null,obj.src=url;
		        var wBh=image.width/image.height;
		        if(wBh>=w/h){ww=image.width>=w?w:image.width;hh=ww/wBh;}else{hh=image.height>=h?h:image.height;ww=hh*wBh;}
		        obj.width=ww,obj.height=hh;
		        if(fun){eval(fun+"();");}
	        }
	        image.src=url;
	     
        }
