var image;
function DrawImage(t,w,h){

  var width,height;
  image = new Image();
  image.src = t.src;

    while(image.width>w || image.height>h)
		{  
	     if(image.width>w  &&  image.height>h)
			 {
          width=w;
          height=image.height*( width/image.width);   
	     }
	     if(image.width>w)
		   {
          width=w;
          height=image.height*( width/image.width); 			
	      }
       if(image.height>h)
			 {
          height=h;
          width=image.width*(height/image.height); 					 
  	    }
	      image.width=width;
	      image.height=height;  			
    }
		t.width=image.width;
		t.height=image.height;  
}