/*  
===============================================================================  
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://www.mondotondo.com/aercolino/noteslog/?page_id=105 
UPDATES: http://www.mondotondo.com/aercolino/noteslog/?cat=20  
===============================================================================  
*/ 
 
( function($) { 
$.metaobjects = function( options ) { 
 
    options = $.extend( { 
          context:  document 
        , clean:    true 
        , selector: 'object.metaobject' 
    }, options ); 
 
    function jsValue( value ) { 
        eval( 'value = ' + value + ";" ); 
        return value; 
    } 
 
    return $( options.selector, options.context ) 
    .each( function() { 
 
        var settings = { target: this.parentNode }; 
        $( '> param[@name=metaparam]', this ) 
        .each( function() {  
            $.extend( settings, jsValue( this.value ) ); 
        } ); 
 
        $( '> param', this ) 
        .not( '[@name=metaparam]' ) 
        .each( function() { 
            var name = this.name, value = jsValue( this.value ); 
            $( settings.target ) 
            .each( function() { 
                this[ name ] = value; 
            } ); 
        } ); 
 
        if( options.clean ) { 
            $( this ).remove(); 
        } 
    } ); 
} 
} ) ( jQuery );
