function imgresize(o,w,h)
{
    var temi;
    var maxw,maxh;
    
    //alert(h.toString());
    if (o!=null && o.width>0 && o.height>0)
    {
        maxw = w;
        maxh = h;
        if (o.width>=o.height)
        {
            if (w>0)
            {
                temi = (o.height/o.width)*w;
	 	        if((temi > h) && (h>0))
	 	        {
	 	            maxw = (o.width/o.height)*h;
		        }
		        else
		        {
		            maxh = temi;
		        }
		    }
		    else
		    {
                temi = (o.width/o.height)*h;
		        maxw = temi;
		    }
        }
        else
        {	
            if (h>0)
            {
                temi = (o.width/o.height)*h;
                
	 	        if((temi > w) && (w>0))
	 	        {
	 	            maxh = (o.height/o.width)*w;
		        }
		        else
		        {
		            maxw = temi;
		        }
		    }
		    else
		    {
                temi = (o.height/o.width)*w;
                maxh = temi;
		    }
        }
		o.style.width=maxw.toString()+'px';
		o.style.height=maxh.toString() + 'px';
    }
}