/*  
===============================================================================  
Metaobjects is a jQuery plugin for setting properties of DOM elements  by means  
of metaobjects (OBJECT elements with a 'metaobject' class) 
...............................................................................                                                 
                                               Copyright 2007 / Andrea Ercolino  
-------------------------------------------------------------------------------  
LICENSE: http://www.opensource.org/licenses/mit-license.php 
MANUAL:  http://noteslog.com/metaobjects/ 
UPDATES: http://noteslog.com/category/metaobjects/  
=============================================================================== 

Modified 12/14/2007 by DHW to be a plugin
usage: $('object.metaobject').metaobjects(opts);
*/ 
 
(function($) { 
$.fn.metaobjects = function(options) { 
    options = $.extend({clean: true}, options); 
 
    function jsValue(value) { return eval ('('+value+')') }; 
 
    return this.each( function() { 
        var settings = {target: this.parentNode}; 
        $('> param[name=metaparam]', this).each (function(){  
          $.extend(settings, jsValue(this.value)); 
        }); 
 
        $('> param[name!=metaparam]', this).each (function(){ 
            var name = this.name, value = jsValue(this.value); 
            $(settings.target).each (function(){this[name] = value}); 
        }); 
 
        if(options.clean) $(this).remove(); 
    }); 
};
})(jQuery);
