/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
 * in the JSON will become a property of the element itself.
 *
 * There are three supported types of metadata storage:
 *
 *   attr:  Inside an attribute. The name parameter indicates *which* attribute.
 *          
 *   class: Inside the class attribute, wrapped in curly braces: { }
 *   
 *   elem:  Inside a child element (e.g. a script tag). The
 *          name parameter indicates *which* element.
 *          
 * The metadata for an element is loaded the first time the element is accessed via jQuery.
 *
 * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
 * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
 * 
 * @name $.metadata.setType
 *
 * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("class")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from the class attribute
 * 
 * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("attr", "data")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a "data" attribute
 * 
 * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
 * @before $.metadata.setType("elem", "script")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a nested script element
 * 
 * @param String type The encoding type
 * @param String name The name of the attribute to be used to get metadata (optional)
 * @cat Plugins/Metadata
 * @descr Sets the type of encoding to be used when loading metadata for the first time
 * @type undefined
 * @see metadata()
 */

(function($) {

$.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);
			// check for empty string in single property
			if ( !settings.single.length ) settings.single = 'metadata';
			
			var data = $.data(elem, settings.single);
			// returned cached data if it already exists
			if ( data ) return data;
			
			data = "{}";
			
			if ( settings.type == "class" ) {
				var m = settings.cre.exec( elem.className );
				if ( m )
					data = m[1];
			} else if ( settings.type == "elem" ) {
				if( !elem.getElementsByTagName ) return;
				var e = elem.getElementsByTagName(settings.name);
				if ( e.length )
					data = $.trim(e[0].innerHTML);
			} else if ( elem.getAttribute != undefined ) {
				var attr = elem.getAttribute( settings.name );
				if ( attr )
					data = attr;
			}
			
			if ( data.indexOf( '{' ) <0 )
			data = "{" + data + "}";
			
			data = eval("(" + data + ")");
			
			$.data( elem, settings.single, data );
			return data;
		}
	}
});

/**
 * Returns the metadata object for the first member of the jQuery object.
 *
 * @name metadata
 * @descr Returns element's metadata object
 * @param Object opts An object contianing settings to override the defaults
 * @type jQuery
 * @cat Plugins/Metadata
 */
$.fn.metadata = function( opts ){
	return $.metadata.get( this[0], opts );
};

})(jQuery);

/*
 ### jQuery Star Rating Plugin v2.61 - 2009-01-23 ###
 * http://www.fyneworks.com/ - diego@fyneworks.com
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
 Project: http://plugins.jquery.com/project/MultipleFriendlyStarRating
 Website: http://www.fyneworks.com/jquery/star-rating/
*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';6(1M.P)(7($){6($.19.1h)1k{1l.1o("1q",1r,1s)}1t(e){}$.3={x:\'1d 1g\',T:\'\',o:0,L:16,5:{},8:{I:7(n,a,b,c){4.m(n);$(a).O(\'.u\'+n).Q().k(\'1p\'+(c||\'J\'));j d=$(a).s(\'a\');9=d.y();6(b.Y)b.Y.D($.3.5[n].f[0],[9,d[0]])},m:7(n,a,b){$.3.5[n].f.1e(\'.u\'+n).A(\'t\').A(\'1i\')},r:7(n,a,b){6(!$($.3.5[n].q).1n(\'.x\'))$($.3.5[n].q).O(\'.u\'+n).Q().k(\'t\');j c=$(a).s(\'a\');9=c.y();6(b.W)b.W.D($.3.5[n].f[0],[9,c[0]])},p:7(n,a,b){$.3.5[n].q=a;j c=$(a).s(\'a\');9=c.y();$.3.5[n].f.9(9);$.3.8.m(n,a,b);$.3.8.r(n,a,b);6(b.11)b.11.D($.3.5[n].f[0],[9,c[0]])}}};$.13.3=7(d){6(4.14==0)F 4;d=$.K({},$.3,d||{});4.1y(7(i){j a=$.K({},d||{},($.M?$(4).M():($.15?$(4).17():18))||{});j n=(4.N||\'1a-3\').1b(/\\[|\\]+/g,"1c");6(!$.3.5[n])$.3.5[n]={z:0};i=$.3.5[n].z;$.3.5[n].z++;$.3.5[n].l=$.3.5[n].l||a.l||$(4).1f(\'B\');6(i==0){$.3.5[n].f=$(\'<R S="1j" N="\'+n+\'" C=""\'+(a.l?\' B="B"\':\'\')+\'/>\');$(4).U($.3.5[n].f);6($.3.5[n].l||a.1m){}V{$(4).U($(\'<w X="x"><a E="\'+a.x+\'">\'+a.T+\'</a></w>\').Z(7(){$.3.8.m(n,4,a);$(4).k(\'t\')}).10(7(){$.3.8.r(n,4,a);$(4).A(\'t\')}).p(7(){$.3.8.p(n,4,a)}))}};h=$(\'<w X="12"><a E="\'+(4.E||4.C)+\'">\'+4.C+\'</a></w>\');$(4).1u(h);6(a.1O)a.o=2;6(1w a.o==\'1x\'&&a.o>0){j b=($.13.G?$(h).G():0)||a.L;j c=(i%a.o),H=1z.1A(b/a.o);$(h).G(H).1B(\'a\').1C({\'1D-1E\':\'-\'+(c*H)+\'1F\'})};$(h).k(\'u\'+n);6($.3.5[n].l)$(h).k(\'1G\');V $(h).k(\'1H\').Z(7(){$.3.8.m(n,4,a);$.3.8.I(n,4,a,\'J\')}).10(7(){$.3.8.m(n,4,a);$.3.8.r(n,4,a)}).p(7(){$.3.8.p(n,4,a)});6(4.1I)$.3.5[n].q=h;$(4).1J();6(i+1==4.14)$.3.8.r(n,4,a)});1K(n 1L $.3.5)(7(c,v,n){6(!c)F;$.3.8.I(n,c,d||{},\'1N\');$(v).9($(c).s(\'a\').y())})($.3.5[n].q,$.3.5[n].f,n);F 4};$(7(){$(\'R[S=1v].12\').3()})})(P);',62,113,'|||rating|this|groups|if|function|event|val||||||valueElem||eStar||var|addClass|readOnly|drain||split|click|current|reset|children|star_on|star_group_||div|cancel|text|count|removeClass|disabled|value|apply|title|return|width|spw|fill|hover|extend|starWidth|metadata|name|prevAll|jQuery|andSelf|input|type|cancelValue|before|else|blur|class|focus|mouseover|mouseout|callback|star|fn|length|meta||data|null|browser|unnamed|replace|_|Cancel|siblings|attr|Rating|msie|star_hover|hidden|try|document|required|is|execCommand|star_|BackgroundImageCache|false|true|catch|after|radio|typeof|number|each|Math|floor|find|css|margin|left|px|star_readonly|star_live|checked|remove|for|in|window|on|half'.split('|'),0,{}))