﻿function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 
{ 
var arVersion = navigator.appVersion.split("MSIE") 
var version = parseFloat(arVersion[1]) 
if ((version >= 5.5) && (document.body.filters)) 
{ 
for(var j=0; j<document.images.length; j++) 
{ 
var img = document.images[j] 
var imgName = img.src.toUpperCase() 
if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
{ 
var imgID = (img.id) ? "id='" + img.id + "' " : "" 
var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
var imgStyle = "display:inline-block;" + img.style.cssText 
if (img.align == "left") imgStyle = "float:left;" + imgStyle 
if (img.align == "right") imgStyle = "float:right;" + imgStyle 
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
var strNewHTML = "<span " + imgID + imgClass + imgTitle 
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
img.outerHTML = strNewHTML 
j = j-1 
} 
} 
} 
} 
window.attachEvent("onload", correctPNG);

<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){ 
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width; 
        ImgD.height=image.height;
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){ 
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }else{
        ImgD.width=image.width; 
        ImgD.height=image.height;
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    }
} 

function getEvent() //获取event对象,同时兼容ie和ff的写法 
{  
	if(document.all)  return window.event;    
	func=getEvent.caller;        
	while(func!=null){  
		var arg0=func.arguments[0]; 
		if(arg0) 
		{ 
		  if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) 
		  {  
		  return arg0; 
		  } 
		} 
		func=func.caller; 
	} 
	return null; 
}

function showMaxImage(MaxImage)
{//根据鼠标位置显示对象,参数ev为event
	var ObjX,ObjX1,ObjY,ObjY1;//对象的位置(x,y)
	var mouseWidth=20;//对象的(x)水平位置距离鼠标的宽度
	var mouseHeight=20;//对象的(y)垂直位置距离鼠标的高度
	var mouseX;//鼠标的x坐标
	var mouseY;//鼠标的y坐标
	var scrollTop = 0;//网页被卷去的高
	var dialog_height=400;//对话框的高度
	var dialog_width=600;//对话框的宽度	
    var scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
	var scrollLeft = document.documentElement.scrollLeft||document.body.scrollLeft;
	var clientHeight = document.documentElement.clientHeight||document.body.clientHeight;
	var clientWidth = document.documentElement.clientWidth||document.body.clientWidth;	
	
	var obj = document.getElementById("maxImage_dialog");//对话框对象	

	var event = getEvent();
	if(event.pageX || event.pageY)
	{//firefox鼠标的位置
		mouseX = event.pageX;
		mouseY = event.pageY;
	}
	else
	{//IE鼠标的位置				
		mouseX = event.clientX + scrollLeft- document.body.clientLeft;
		mouseY = event.clientY + scrollTop - document.body.clientTop;		
	}
	
	ObjX = mouseX;
	ObjY = mouseY;	
	
	var height2 = scrollTop+clientHeight-ObjY;
	width1 = ObjX+dialog_width;
	if(height2<dialog_height && width1>clientWidth)
	{
		ObjY = ObjY-dialog_height;
		if(ObjY<scrollTop) ObjY = scrollTop;
		ObjX = ObjX-dialog_width-mouseWidth;
	}
	else if(height2<dialog_height)
	{
		ObjY = ObjY-dialog_height;
		if(ObjY<scrollTop) ObjY = scrollTop;
		ObjX = ObjX+mouseWidth;
	}
	else if(width1>clientWidth)
	{		
		ObjX = ObjX-dialog_width;
		height2 = height2+mouseHeight;
		if(height2<dialog_height)
			ObjY = ObjY+(dialog_height-height2);
		else
			ObjY = ObjY+mouseHeight;
	}
	else
		ObjY = ObjY+mouseHeight;

	obj.style.left = ObjX + 'px';
	obj.style.top = ObjY + 'px';	
	
	if(MaxImage!="") obj.innerHTML="<img src=\""+MaxImage+"\">";
	obj.style.display='';//显示或隐藏对象
}

function hideMaxImage()
{
	document.getElementById("maxImage_dialog").style.display='none';
}
//-->

