function changepic(objects,picname){
   return objects.src=picname;
}

function trim(inputString) { 
	if (typeof inputString != "string") { return inputString; } 
	var retValue = inputString; 
	var ch = retValue.substring(0, 1); 
	while (ch == " ") { 
		retValue = retValue.substring(1, retValue.length); 
		ch = retValue.substring(0, 1); 
	} 
	ch = retValue.substring(retValue.length-1, retValue.length); 
	while (ch == " ") { 
		retValue = retValue.substring(0, retValue.length-1); 
		ch = retValue.substring(retValue.length-1, retValue.length); 
	} 
	while (retValue.indexOf(" ") != -1) { 
	retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); 
	} 
	return retValue; 
} 

function CheckSearch(theForm){
   var searchkey = trim(theForm.searchkey.value);
   if(searchkey == ""){
      alert("Please enter search key!");
      theForm.searchkey.focus();
      return  (false);
   }
}

function OpenWindow(htmurl,widths,heights)
{
   var paramet = 'toolbar=no,resizable=no,scrollbars=yes,width='+ widths + ',height=' + heights;
   newWindow = window.open(htmurl,"newWin",paramet);
   newWindow.focus();
}

function PicFixSize(widths,heights,photosrc,position){
   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;
   }
   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('<img src=' + imgsrc + ' width=' + width + ' height=' + height +' border=0 align=' + position + '>')
}