(function($,window){$.extend({metadata:{defaults:{type:"class",name:"metadata",cre:/({.*})/,single:"metadata"},setType:function(type,name){this.defaults.type=type;this.defaults.name=name},get:function(elem,opts){var settings=$.extend({},this.defaults,opts),object={},data,match,attr;if(!settings.single.length){settings.single="metadata"}data=$.data(elem,settings.single);if(data){return data}data="{}";function getObject(data){if("string"===typeof data){data=eval("("+data+")")}return data}if(settings.type=="html5"){$(elem.attributes).each(function(){var name=this.nodeName;if(name.match(/^data-/)){name=name.replace(/^data-/,"");object[name]=this.nodeValue}})}else{if(settings.type=="class"){match=settings.cre.exec(elem.className);if(match){data=match[1]}}else{if(settings.type=="elem"){if(!elem.getElementsByTagName){return}match=elem.getElementsByTagName(settings.name);if(match.length){data=$.trim(match[0].innerHTML)}}else{if(undefined!==elem.getAttribute){attr=elem.getAttribute(settings.name);if(attr){data=attr}}}}object=getObject(data.indexOf("{")<0?"{"+data+"}":data)}if(data!=="{}"){$.data(elem,settings.single,object)}return object}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts)}})(jQuery,this);