function popupprofill(url) {
  popwin = window.open('profilmyndpopup.php?nID=' + url, 'opener_window', 'width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no'); 
  popwin.moveTo((screen.width/2)-400/2,(screen.height/2)-400/2);
}

function popupfrettmynd(url) {
  popwin = window.open('frettmyndpopup.php?imgname=' + url, 'opener_window', 'width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no'); 
  popwin.moveTo((screen.width/2)-400/2,(screen.height/2)-400/2);
}

function fitPic() {
  if (window.innerWidth)
  {
	  iWidth = window.innerWidth;
      iHeight = window.innerHeight;
   }
   else
   {
      iWidth = document.body.clientWidth;
      iHeight =document.body.clientHeight;
   }
      iWidth = document.images[0].width - iWidth;
      iHeight = document.images[0].height - iHeight;
      window.resizeBy(iWidth, iHeight);
};

function fitPic2() {
  if (window.innerWidth)
  {
	  iWidth = window.innerWidth;
      iHeight = window.innerHeight;
   }
   else
   {
      iWidth = document.body.clientWidth;
      iHeight =document.body.clientHeight;
   }
      iWidth = document.images[0].width - iWidth;
      iHeight = document.images[0].height - iHeight + 12;
      window.resizeBy(iWidth, iHeight);
};

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}