jQuery.fn.iframe = function(options) {
    return this.each(function() {
        var $this = jQuery(this);
        var cls = this.className;
        
        var opts = jQuery.extend({
            frameborder:  ((cls.match(/fb:(\d+)/)||[])[1]) || ((cls.match(/fb-(\d+)/)||[])[1]) || 0,
            marginwidth:  ((cls.match(/wm:(\d+)/)||[])[1]) || ((cls.match(/wm-(\d+)/)||[])[1]) || 0,
            marginheight: ((cls.match(/hm:(\d+)/)||[])[1]) || ((cls.match(/hm-(\d+)/)||[])[1]) || 0,
            width:        ((cls.match(/w:(\d+)/)||[])[1]) || ((cls.match(/w-(\d+)/)||[])[1]) || 640,
            height:       ((cls.match(/h:(\d+)/)||[])[1]) || ((cls.match(/h-(\d+)/)||[])[1]) || 480,
            scrolling:    ((cls.match(/sc:(\w+)/)||[])[1]) || ((cls.match(/sc-(\w+)/)||[])[1]) || "auto",
            version:     '1,0,0,0',
            cls:          cls,
            src:          $this.attr('href') || $this.attr('src'),
			id:			  $this.attr("id"),
            caption:      $this.text(),
            attrs:        {},
            elementType:  'div',
            xhtml:        true
        }, options || {});
        
        //var endTag = opts.xhtml ? ' />' : '>';

        var a = ['<iframe src="' + opts.src + '"'];
		if(opts.id){
			a.push(' id="' + opts.id + '"');
		}else{
			a.push(' id="content_iframe"');
		}
		a.push(' frameborder="' + opts.frameborder + '"');
		a.push(' marginwidth="' + opts.marginwidth + '"');
		a.push(' marginheight="' + opts.marginheight + '"');
		if(opts.width>0){
			a.push(' width="' + opts.width + '"');
		}else{
			a.push(' width="100%"');
		}
		if(opts.height>0){
			a.push(' height="' + opts.height + '"');
		}else{
			a.push(' height="100%"');
		}
		a.push(' scrolling="' + opts.scrolling + '"');
		a.push('></iframe>');

        // convert anchor to span/div/whatever...
        var $el = jQuery('<' + opts.elementType + ' class="' + opts.cls + '"></' + opts.elementType + '>');
        $this.after($el).remove();
        $el.html(a.join(''));

        // Eolas workaround for IE (Thanks Kurt!)
        if(jQuery.browser.msie){ $el[0].outerHTML = $el[0].outerHTML; }
    });
};
