﻿var  flag=false;  
function  DrawImage(ImgD,width,height){  
     var  image=new  Image();  
     image.src=ImgD.src;  
     if(image.width>0  &&  image.height>0){  
       flag=true;  
       if(image.width/image.height>=  width/height){  
         if(image.width>width){      
         ImgD.width=width;  
         ImgD.height=(image.height*width)/image.width;  
         }else{  
         ImgD.width=image.width;      
         ImgD.height=image.height;  
         }  
    //     ImgD.alt=image.width+"×"+image.height;  
         }  
       else{  
         if(image.height>height){      
         ImgD.height=height;  
         ImgD.width=(image.width*height)/image.height;            
         }else{  
         ImgD.width=image.width;
         ImgD.height=image.height;  
         }  
  //       ImgD.alt=image.width+"×"+image.height;  
         }  
       }
}
//onload="javascript:DrawImage(this,width,height);"

function showModal(url,width,height)
{
	try
	{
		window.showModalDialog(url,window,'dialogHeight:'+height+' px; dialogWidth:'+width+' px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll:No');
	}
	catch(e){}	
}

function showimg(path)
{

	var img=new Image();
	img.src=path;
	//								img.style.position="absolute";
	//								img.style.visibility="hidden";
	//img.attachEvent("onreadystatechange","orsc(this)");
	setTimeout(_orsc(img), 100);
	//img.attachEvent("onerror",oe);
	if((img.width==0 && img.height==0)||(img.width==28 && img.height==30 ))
	{
		oe();
	}
//								document.body.insertAdjacentElement("beforeend",img);
}

function oe()
{
	//alert("error! cant load img");
}

function _orsc(img)
{
	return function()
	{
		orsc(img);
	}
}

function orsc(img)
{
	if(img.readyState!="complete")
	{
		setTimeout(_orsc(img), 100);
	}else
	{
		var w=img.width;
		var h=img.height;
		//alert("高:"+img.width+"\n宽:"+img.height);
		var ua = navigator.userAgent.toLowerCase();//客户端浏览器信息
		var size="";
		if (window.ActiveXObject)//判断IE浏览器
		size=ua.match(/msie ([\d.]+)/)[1];//得出IE的版本大小
		if(size=="6.0")
		{
			w=w+6;
			h=h+60;
		}
		else
		{	/*...*/	}
		showModal(img.src,w,h)
	}
}
