﻿function setPicRange(oImage,Max_Width,Max_Height) 
{ 
  if(oImage.readyState!="complete") 
    { 
     return false; 
    }
  var MaxWidth=parseInt(Max_Width);
  var MaxHeight=parseInt(Max_Height);
  var imgobj=new Image();
  if(imgobj.src!=oImage.src)imgobj.src=oImage.src;
  
  var ImgHeight = imgobj.height; 
  var ImgWidth = imgobj.width; 

  if ((ImgWidth > MaxWidth) || (ImgHeight > MaxHeight))
     {
      if((ImgWidth/MaxWidth) == (ImgHeight/MaxHeight))
	    { 
         oImage.style.width=MaxWidth;       
         oImage.style.height=MaxHeight;       
        }
      else
	    {     
         if((ImgWidth/MaxWidth) > (ImgHeight/MaxHeight))
		   { 
            oImage.style.width=MaxWidth;    
            //alert(ImgHeight/(MaxWidth/ImgWidth));     
            oImage.style.height=ImgHeight/(ImgWidth/MaxWidth);       
           }
         else
		   {
            //alert(ImgWidth); 
            oImage.style.height=MaxHeight;
            oImage.style.width=ImgWidth/(ImgHeight/MaxHeight); 
		   }     
	    }  
     }
  else
     {
      oImage.style.width=ImgWidth;       
      oImage.style.height=ImgHeight; 
     }
      //oImage.style.visibility="visible";
      //oImage.style.display='';
} 
