function fResizeImg(w, h, id){ 
var img=''; 
var obj; 
if(id==undefined)obj=document.images; 
else obj=document.getElementById(id).getElementsByTagName('img'); 
 
for(var i=0; i<obj.length; i++){ 
img=obj[i]; 
if (img.height<img.width){
if(img.width>w&&(img.height<img.width)){ 
img.height=img.height-(img.height/(img.width/(img.width-w))) 
img.width=w; 
}
if(img.height>h&&(img.height<img.width)){ 
img.width=img.width-(img.width/(img.height/(img.height-h))) 
img.height=h; 
}
} 
else if (img.height>img.width)
{
if(img.height>h&&(img.height>img.width)){ 
img.width=img.width-(img.width/(img.height/(img.height-h))) 
img.height=h; 
}
if(img.width>w&&(img.height>img.width)){ 
img.height=img.height-(img.height/(img.width/(img.width-w))) 
img.width=w;  
}
}

img.onclick=function()
{ 
try{ imgPopup.close();} catch(e){} 
imgPopup=window.open('','','')
imgPopup.document.write('<script>document.onclick=function(){ close();}<\/script>'); 
imgPopup.document.write('<img src="'+this.src+'"/>', 
'<style>body{margin:0; padding:0;} .hd{visibility:hidden;}<\/style>'); 
imgPopup.focus(); 
imgPopup.document.close(); 
} 
}  
}
