//http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial
//http://www.gmarwaha.com/blog/2009/06/16/ctrl-key-combination-simple-jquery-plugin/

jQuery.fn.fitToParent = function() 
{
  this.each(function()
  {
    //we do one massive disable of this module.
    return; 
    
    var width  = $(this).width();
    var height = $(this).height();
    var parentWidth  = $(this).parent().width();
    var parentHeight = $(this).parent().height();
    if(width/parentWidth < height/parentHeight)
    {
      newWidth  = parentWidth;
      newHeight = newWidth/width*height;         
    }
    else
    {
      newHeight = parentHeight;                 
      newWidth  = newHeight/height*width;         
    }
    
    //alert("["+width+","+height+"]["+parentWidth+","+parentHeight+"]");
    
    margin_top  = (parentHeight - newHeight) / 2;         
    margin_left = (parentWidth  - newWidth ) / 2;          
    
    $(this).css({'margin-top' :margin_top  + 'px',
                 'margin-left':margin_left + 'px', 
                 'height'     :newHeight   + 'px',                      
                 'width'      :newWidth    + 'px'});
  });
};
