function innerSize(wh) 
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  
  if (wh == 'height') {
    return myHeight;
  } else if (wh == 'width') {
    return myWidth;
  } else {
    return 0;
  }
}

function fitPic(imgW,imgH) 
{
    w = ( imgW > screen.width - 10 ) ? screen.width - 10 : imgW;
    h = ( imgH > screen.height - 60 ) ? screen.height - 60 : imgH;
    iWidth = w - innerSize('width');
    iHeight = h - innerSize('height');
    window.resizeBy(iWidth, iHeight);
    
    // moveTo
    iX = ( w == screen.width - 10 ) ? 0 : ( screen.width - w ) / 2;
    iY = ( h == screen.height - 60 ) ? 0 : ( screen.height - h ) / 2;
    moveTo(iX, iY);
}
