function alertSize() {
  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;
  }
  var x = document.getElementById("simply").clientHeight;
  var y = document.getElementById("footer").clientHeight;        
  if(myHeight - x - y - 30 > 0)
    document.getElementById("footer").style.height = (myHeight - x - 40) + "px"; 
}

$ (document).ready (function ()
{
        var sBodyClass = $ ('body').attr ('class');
        $ ('img').map (function ()
        {
                var pElement = $ (this);
                var sFilename = pElement.attr ('src');
                if ((sFilename.substring (0, 8) != '/images/' && sFilename.substring (0, 7) != '/files/') ||
                    sFilename.substring (sFilename.length - 3) == 'gif')
                {
                        return;
                }
                var pImage = new Image ();
                pImage.src = sFilename;
                pImage.onload = function ()
                {
                        var nWidth  = pImage.width;
                        var nHeight = pImage.height;
                        if ((sBodyClass == 'simply-portfolio' || sBodyClass == 'simply-cases') &&
                            nWidth > 100 && nHeight > 100)
                        {
                                return;
                        }
                        
                        var sNewDiv = '<div ';
                        if (pElement.attr ('id') != '')
                        {
                                sNewDiv += 'id="' + pElement.attr ('id') + '" ';
                        }
                        sNewDiv += 'class="sprite" style="' + 
                                'background-image: url(\'/sprite' + sFilename + '\');' +
                                'width: ' + nWidth + 'px;height: ' + nHeight + 'px;' +
                                'background-position: 0px 0px;" ' +
                                'onmouseover="$(this).css(\'background-position\', \'0px -' + nHeight + 'px\');" ' +
                                'onmouseout="$(this).css(\'background-position\', \'0px 0px\');">' +
                                '</div>';
                        
                        pElement.replaceWith (sNewDiv);
                };
        });
});
