﻿

(function ($) {


    $.fn.bgIframe = $.fn.bgiframe = function (s) {
        // This is only for IE6
        //alert(/6.0/.test(navigator.userAgent));
        if ($.browser.msie && (/6.0/.test(navigator.userAgent)||/7.0/.test(navigator.userAgent)||/8.0/.test(navigator.userAgent)) ) {
            s = $.extend({
                top: 'auto', // auto == .currentStyle.borderTopWidth
                left: 'auto', // auto == .currentStyle.borderLeftWidth
                width: 'auto', // auto == offsetWidth
                height: 'auto', // auto == offsetHeight
                opacity: true,
                src: ''
            }, s || {});
            var prop = function (n) { return n && n.constructor == Number ? n + 'px' : n; },
		    html = '<iframe class="bgiframe customTip_" frameborder="0 " tabindex="-1" src="' + s.src + '"' +
		               ' style="display:block;position:absolute;z-index:-1;' +
			               (s.opacity != true ? 'filter:Alpha(Opacity=\'0\');' : '') +
					       'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' +
					       'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' +
					       'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' +
					       'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' +
					'"></iframe>';
            return this.each(function () {
                if ($('> iframe.bgiframe', this).length == 0) {
                    var e = document.createElement(html);
                    this.insertBefore(e, this.firstChild);
                }
            });
        }
        return this;
    };

})(jQuery);

