/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 */

/**
 * The bgiframe applies the iframe hack to get around zIndex
 * issues in IE6. It will only apply itself in IE and adds
 * a class to the iframe called 'bgiframe'.
 *
 * @name bgiframe
 * @type jQuery
 * @cat DOM
 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 */
$.fn.bgIframe = $.fn.bgiframe = function() {
	// this is only for IE6
	if (!$.browser.msie) return this;
	
	return this.each(function() {
		var html = '<iframe class="bgiframe" '
		 						+'style="display:block; position:absolute; '
								+'top: expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)  || 0) * -1) + \'px\'); '
								+'left:expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth) || 0) * -1) + \'px\'); '
								+'z-index:-1; filter:Alpha(Opacity=\'0\'); '
								+'width:expression(this.parentNode.offsetWidth); '
								+'height:expression(this.parentNode.offsetHeight)"/>'
		var iframe = document.createElement(html);
		iframe.tabIndex = -1;
		this.insertBefore(iframe, this.firstChild);
	});
};