function PicFixSize(widths,heights,photosrc,position){
   var breakpoint = 30;
   var i = 0;
   var imgsrc = photosrc;
   var photowidth = 0;
   var photoheight = 0;
   var photo = new Image();
   if (position=="")
   {
      position = "left"
   }
   while(photowidth ==0 || photoheight == 0)
   {
      photo.src = photosrc
      photowidth = photo.width;
      photoheight = photo.height;
	  i++;
      if (i > breakpoint){
         break;
      } 
   }
   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;
	  if(width == 0 || width == ""){
         width = 105
		 height =140
	  }
   }
   return('<img src=' + imgsrc + ' width=' + width + ' height=' + height +' border=0 align=' + position + ' class=img_broder>')
}

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();
}