﻿// JScript 文件

function ImgLoad(img,w,h)
		{
			var image=new Image();
			image.src=img.src;

			var MaxWidth=w;//设置图片宽度界限 
			var MaxHeight=h;//设置图片高度界限 
			var HeightWidth=image.height/image.width;//设置高宽比 
			var WidthHeight=image.width/image.height;//设置宽高比 
		      
			img.width = image.width;
			img.height = image.height; //alert(img.width);alert(img.height);
			if(img.width>MaxWidth){ 
			img.width=MaxWidth; 
			img.height=MaxWidth*HeightWidth; 
			} 
			if(img.height>MaxHeight){ 
			img.height=MaxHeight; 
			img.width=MaxHeight*WidthHeight; 
			} 
		}
		
		//获取元素的纵坐标
        function getTop(e){
            var offset=e.offsetTop;
            if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
            return offset;
        }
        //获取元素的横坐标
        function getLeft(e){
            var offset=e.offsetLeft;
            if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
            return offset;
        }