/*
 * Copyright (c) 2008 Flixn, Inc.
 * Authored by Samuel J. Greear
 *
 * Tri-licensed under the New BSD, MIT and LGPL licenses:
 * http://www.opensource.org/licenses/bsd-license.php
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/lgpl.html
 *
 *
 * NOTES:
 *
 * Script requires a blank/empty image file to be present
 * at /img/blank.gif, the location may be set below.
 *
 * Script limits itself to tiling an image 100 times in either
 * direction. 100x100 will cause the browser a great deal of pain
 * but it should keep it from hanging forever. For best performance
 * background images should be cut substantially wider/taller than
 * 1 pixel.
 *
 * IE would prefer not to load htc files cross-domain.
 *
 * USAGE EXAMPLES:
 *
 * Apply fix to all (non-background) images:
 *
 * img {
 *   behavior: url('/js/fx-IESVGFix.htc');
 * }
 *
 * Repeating background:
 *
 * #header {
 *   background-image: url('IMAGENAME.svg');
 *   background-repeat: repeat-x;
 *   behavior: url('/js/fx-IESVGFix.htc');
 * }
 *
 * Custom bullet for list item:
 *
 * ul li {
 *   padding-left: 11px;
 *   background-image: url('IMAGENAME.svg');
 *   background-repeat: no-repeat;
 *   background-position: 0% 5px;
 *   behavior: url('/js/fx-IESVGFix.htc');
 * }
 */

<PUBLIC:COMPONENT lightWeight="true">
<!-- saved from url=(0014)about:internet -->
<PUBLIC:ATTACH EVENT="oncontentready" FOR="element" ONEVENT="init()" />
<PUBLIC:ATTACH EVENT="ondocumentready" FOR="element" ONEVENT="init()" />
<script type="text/javascript">
var IESVGFix = window['IESVGFix'];

if( !IESVGFix ) {
    IESVGFix = window['IESVGFix'] = {

    blankImage: '/img/blank.gif',
    maxTile: 100,
    svgRegex: /\.svg$/i,

    _transformString: "progid:DXImageTransform.Microsoft.AlphaImageLoader(" +
                      "enabled=true,sizingMethod='{sizingMethod}',src='{src}')",

    _versionIEMin: 8,
    _versionIEMax: 8,
    init: function(el){
      this.init = this._checkBrowser() ? this.fix : function(){};
      this.init(el);
    },
    fix: function(el) {
        switch (el.nodeName) {
        case 'IMG':
            if (this.svgRegex.test(el.src)) {
            	el.src = el.src.replace(this.svgRegex, ".png");
                /*el.style.filter = this._getFilter(el.src);
                el.style.width = el.offsetWidth;
                el.style.height = el.offsetHeight;
                el.src = this.blankImage;*/
            }
            break;

        }
    
    },
    
    _checkBrowser: function() {
        if (/MSIE (\d+\.\d+)/.test(navigator.userAgent)) {
            var IEVersion = new Number(RegExp.$1);
            if (IEVersion >= this._versionIEMin && IEVersion <= this._versionIEMax)
                return true;
        }

        return false;
    }
   
};
}
var el = element;
function init() {
    var IESVGFix = window[ 'IESVGFix' ];
    if( IESVGFix ) {
        IESVGFix.init( el );
    }
}
</script>
</PUBLIC:COMPONENT>
