function PicFixSize(widths,heights,photosrc){
   var imgsrc = photosrc;
   var photowidth = 0;
   var photoheight = 0;
   var photo = new Image();
   while(photowidth ==0 || photoheight == 0)
   {
      photo.src = photosrc
      photowidth = photo.width;
      photoheight = photo.height;
   }
   if(photowidth > widths || photoheight > heights){
      if(photowidth > widths && photoheight > heights){
         height = heights;
         width = (photowidth * height) / photoheight;
         if(width > widths){
            var tmpwidth = width;
            width = widths;
            height = (height * width) / tmpwidth;
         }
      }
      if(photowidth > widths && photoheight <= heights){
         width = widths;
         height = (photoheight * width) / photowidth; 
      }
      if(photowidth <= widths && photoheight > heights){
         height =heights;
         width = (photowidth * height) / photoheight;
      }
   }
   else{
      width = photowidth;
      height = photoheight;  
   }
   return('<a href="#" onclick="NewImg(\'' + imgsrc +'\')"><img src=' + imgsrc + ' width=' + width + ' height=' + height +' border=1 align=left></a>')
}

function NewImg(imgurl) {
   newwin=window.open('about:blank','','top=10');
   newwin.document.write('<body leftmargin=0 topmargin=0><img src='+imgurl+' onload="self.resizeTo(this.offsetWidth+10, this.offsetHeight+30);">');
}

function OpenWindow(htmurl,widths,heights)
{
   var paramet = 'toolbar=no,resizable=no,scrollbars=no,width='+ widths + ',height=' + heights;
   newWindow = window.open(htmurl,"newWin",paramet);
   newWindow.focus();
}