var fix_overlay_iterator = 0;
(function($) {
	$.fn.fix_overlay = function(options){
		
		if (!jQuery.browser.msie || parseInt($.browser.version) >= 7) {
			return;
		}

		$(this).each(function() {
				var iterator = fix_overlay_iterator;

				this.show_fix = function() {
					jQuery(this).find('.fix_overlay').remove();
					jQuery(this).prepend('<div id="fix_overlay_'+iterator+'" class="fix_overlay" style="z-index: -1; filter:alpha(opacity=0)"><iframe></iframe></div>');
					
					jQuery('#fix_overlay_'+iterator).css('position', 'absolute');
					jQuery('#fix_overlay_'+iterator).css('top', '0px');
					jQuery('#fix_overlay_'+iterator).css('bottom', '0px');
					jQuery('#fix_overlay_'+iterator).css('left', '0px');
					jQuery('#fix_overlay_'+iterator).css('right', '0px');
					jQuery('#fix_overlay_'+iterator).css('width', '100%');
					jQuery('#fix_overlay_'+iterator).css('height', '100%');
					
					if (options && options.maxWidth) {
						jQuery('#fix_overlay_'+iterator).css('width', options.maxWidth+'px');
					} else {
						jQuery('#fix_overlay_'+iterator).css('width', jQuery('#fix_overlay_'+iterator).width()+'px');
					}
					
					if (!jQuery('#fix_overlay_'+iterator).width()) {
						jQuery('#fix_overlay_'+iterator).width(jQuery('#fix_overlay_'+iterator).parent().width());
					}

					var fix_el = document.getElementById('fix_overlay_'+iterator);
					
					jQuery('#fix_overlay_'+iterator).css('height', jQuery('#fix_overlay_'+iterator).parent().height()+'px');
					
					jQuery('#fix_overlay_'+iterator).css('overflow', 'hidden');
					
					jQuery('#fix_overlay_'+iterator+' iframe').css('width',fix_el.style.width);
					jQuery('#fix_overlay_'+iterator+' iframe').css('height',fix_el.style.height);
				};
				
				this.show_fix();
				
				this.hide_fix = function() {
					jQuery(this).parent().remove('#fix_overlay_'+iterator);
				};
				
				fix_overlay_iterator++;
		});
	}
})(jQuery);
