function isScrolledIntoView(elem)
{
	var docViewTop = $(window).scrollTop();
	var docViewBottom = docViewTop + $(window).height();

	var elemTop = $(elem).offset().top;
	var elemBottom = elemTop + $(elem).height();

	return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
		&& (elemBottom <= docViewBottom) &&  (elemTop >= docViewTop) );
}

$(document).ready(function() {
	$('.auto-focus:first').focus();
});

//jQuery.isNumber=function(a){
//    return(typeof a==="number")
//};jQuery.isBoolean=function(a){
//    return(typeof a==="boolean")
//};jQuery.isNull=function(a){
//    return(a===null)
//};jQuery.isUndefined=function(a){
//    return(typeof a==="undefined")
//};jQuery.isNullOrUndefined=function(a){
//    return jQuery.isNull(a)||jQuery.isUndefined(a)
//};jQuery.isString=function(a){
//    return(typeof a==="string")
//};jQuery.isArray=function(a){
//    return(a!=null&&typeof a=="object"&&"splice" in a&&"join" in a)
//};jQuery.emptyString=function(a){
//    if(jQuery.isNullOrUndefined(a)){
//        return true
//    }else{
//        if(!jQuery.isString(a)){
//            throw"isEmpty: the object is not a string"
//        }else{
//            if(a.length===0){
//                return true
//            }
//        }
//    }return false
//};jQuery.startsWith=function(b,a){
//    if(jQuery.isString(b)){
//        return(b.indexOf(a)===0)
//    }return false
//};jQuery.endsWith=function(b,a){
//    if(!jQuery.isString(b)||!jQuery.isString(a)||jQuery.emptyString(b)||jQuery.emptyString(a)){
//        return false
//    }else{
//        if(a.length>b.length){
//            return false
//        }else{
//            if(b.length-a.length===b.lastIndexOf(a)){
//                return true
//            }
//        }
//    }return false
//};jQuery.formatString=function(){
//    if(arguments.length<2){
//        return""
//    }var d=arguments[0];for(var a=1;a<arguments.length;a++){
//        var c="";if(!jQuery.isNullOrUndefined(c)){
//            c=arguments[a]+""
//        }var b=new RegExp("\\{"+(a-1)+"\\}","g");d=d.replace(b,c)
//    }return d
//};jQuery.log=function(){
//    if(typeof console!=="undefined"){
//        console.log(jQuery.formatString.apply(this,arguments))
//    }
//};
//
//// // Delegate functions for prototype.js version 1.6
//// Â©2008 Ken Snyder (ken d snyder ~at~ gmail ~dot~ com)
//// under the creative commons attribution license v3.0 (http://creativecommons.org/licenses/by/3.0/)
//jQuery.extend(Event, (function() {
//    // Cache our delegates to allow removal.
//    // handlers are stored in nested objects indexed thus:
//    //   element.id => eventName => array of rules objects with selector : handler pairs
//    var cache = { };
//    return {
//        // Add a delegate or set of delegate rules.
//        // 3rd and 4th arguments can be rule, handler
//        //   or 3rd argument can be rule-handler object property-value pairs.
//        // (At least 3 arguments are required.)
//        delegate: function(element, eventName) {
//            // get the passed rules object
//            if (arguments[3]) {
//                // we have rule, handler in two arguments
//                var rules = { };
//                rules[arguments[2]] = arguments[3];
//            } else {
//                // we have a rule object
//                var rules = jQuery.extend({ }, arguments[2]);
//            }
//            var el = $(element), ev = eventName, id = el.identify ? el.identify() : 'document';
//            // set up our caching space if not defined
//            if (!cache[id]) {
//                // define observer function for each element
//                cache[id] = {
//                    '$observer': function(event) {
//                        // function uses 'id' from scope above
//                        var el = event.target;
//                        if (cache[id][event.type])
//                            for (var i = 0, len = cache[id][event.type].length; i < len; i++)
//                                for (var selector in cache[id][event.type][i]){
//                                    //alert(cache[id][event.type][i][selector][1].type);
//                                    // alert(el);
//                                    //                                    console.log(cache[id][event.type][i][selector][1]);
//                                    //                                    console.log($(el));
//
//                                    if (cache[id][event.type][i][selector][1].toString()==$(el).toString()){
//                                        //alert("if");
//                                        cache[id][event.type][i][selector][0](event);
//                                    }
//                                    else{ }
//                                }
//                    }
//                };
//            // observe element
//            }
//            if (!cache[id][ev]) {
//                cache[id][ev] = [];
//                //                el.observe(ev, cache[id]['$observer']);
//                el.bind(ev, cache[id]['$observer']);
//            }
//            // cache the compiled Selector for each selector string
//            for (var selectorStr in rules)
//                rules[selectorStr] = [rules[selectorStr], $(selectorStr)];
//            // cache the rules
//            cache[id][ev].push(rules);
//            return el;
//        },
//        // Cancel a delegate or set of delegate rules.
//        // 3rd argument can be a string rule
//        //   or 3rd argument can be rule-handler object property-value pairs.
//        // Without 3rd argument, all event rules for the event will be stopped.
//        // Without eventName, all event rules for element will be stopped
//        // Without element, all event rules ever defined will be stopped
//        stopDelegating: function(element, eventName) {
//            if (element === undefined) {
//                // no element given, stop delegating everything
//                for (var id in cache)
//                    Event.stopDelegating(id == '$document' ? document : id);
//                cache = { };
//                return true;
//            }
//            // get the passed rules object
//            if (jQuery.isString(arguments[2])) {
//                var rules = { };
//                rules[arguments[2]] = true;
//            } else if (arguments[2]) {
//                var rules = arguments[2];
//            } else {
//                var rules = false;
//            }
//            var el = $(element), ev = eventName, id = el.identify ? el.identify() : '$document';
//            // do we have such an id cached?
//            if (cache[id]) {
//                // do we have such an event cached
//                if (ev && cache[id][ev]) {
//                    // check each rules set registered to this element for this event
//                    for (var i = 0, len = cache[id][ev].length; i < len; i++) {
//                        if (rules) {
//                            // we have one or more rules to stop
//                            for (var selector in rules)
//                                delete cache[id][ev][i][selector];
//                        // check if all rules are now stopped
//                        }
//                        if (!rules || $H(cache[id][ev][i]).any() == false) {
//                            // stop observing if we have no rules for this event
//                            el.stopObserving(ev, cache[id]['$observer']);
//                            cache[id][ev][i] = 'r';
//                        }
//                    }
//                    // remove all the entries that have just had their rules deleted
//                    cache[id][ev] = cache[id][ev].without('r');
//                } else {
//                    // remove all entries for this whole element
//                    for (var evName in cache[id])
//                        if (evName != '$observer')
//                            el.stopObserving(evName, cache[id]['$observer']);
//                    delete cache[id];
//                }
//            }
//            return el;
//        }
//    };
//})());
//
//
//jQuery.curry = function(fn) {
//    if (arguments.length < 2) return fn;
//    args = $.makeArray(arguments).slice(1, arguments.length);
//    return function() {
//        return fn.apply(this, args.concat($.makeArray(arguments)));
//    }
//}
//
//
//
//
//// add our methods to elements and to the document
//jQuery.fn.extend({
//    delegate: Event.delegate,
//    stopDelegating: Event.stopDelegating
//});
////document.delegate = Event.delegate.curry(document);
//document.delegate = $.curry(Event.delegate, document);
////document.stopDelegating = Event.stopDelegating.curry(document);
//document.stopDelegating = $.curry(Event.stopDelegating, document);
////Event.bind(window, 'unload', Event.stopDelegating);
//jQuery(window).bind('unload', Event.stopDelegating);
//
//
//
//// Place your application-specific JavaScript functions and classes here
//// This file is automatically included by javascript_include_tag :defaults
//replace_ids = function(s){
//  var new_id = new Date().getTime();
//  return s.replace(/NEW_RECORD/g, new_id);
//}
//
//var myrules = {
////  '.remove': function(e){
////    el = e.target;
////    console.log(el);
////    target = el.href.replace(/.*#/, '.')
////
////    $(el).closest('.' + target).hide();
////    if(hidden_input = $(el).prev("input[type=hidden]")) hidden_input.value = '1'
////  },
//  '.add_nested_item': function(e){
//    el = e.target;
//    template = eval(el.href.replace(/.*#/, ''))
//    //$('.' + el.rel).append(replace_ids(template));
//    $(el).parent().prevAll('.' + el.rel).append(replace_ids(template));
//  }
//};
//
//
////Event.observe(window, 'load', function(){
////  $('container').delegate('click', myrules);
////});
//jQuery(window).bind('load', function(){
//  $('.add_nested_item').delegate($('.add_nested_item'),'click', myrules);
//});


/* FCBKcomplete 2.7.4 - Jquery version required: 1.2.x, 1.3.x, 1.4.x  Changelog: - 2.00	new version of fcbkcomplete  - 2.01 fixed bugs & added features 		fixed filter bug for preadded items		focus on the input after selecting tag		the element removed pressing backspace when the element is selected		input tag in the control has a border in IE7		added iterate over each match and apply the plugin separately		set focus on the input after selecting tag  - 2.02 fixed fist element selected bug		fixed defaultfilter error bug  - 2.5 	removed selected="selected" attribute due ie bug		element search algorithm changed		better performance fix added		fixed many small bugs		onselect event added		onremove event added  - 2.6 	ie6/7 support fix added		added new public method addItem due request		added new options "firstselected" that you can set true/false to select first element on dropdown list		autoexpand input element added		removeItem bug fixed		and many more bug fixed 		fixed public method to use it $("elem").trigger("addItem",[{"title": "test", "value": "test"}]);		- 2.7 	jquery 1.4 compability 		item lock possability added by adding locked class to preadded option <option value="value" class="selected locked">text</option> 		maximum item that can be added- 2.7.1 bug fixed		ajax delay added thanks to http://github.com/dolorian- 2.7.2 some minor bug fixed		minified version recompacted due some problems		- 2.7.3 event call fixed thanks to William Parry <williamparry!at!gmail.com>- 2.7.4 standart event change call added on addItem, removeItem		preSet also check if item have "selected" attribute		addItem minor fix *//* Coded by: emposha <admin@emposha.com> *//* Copyright: Emposha.com <http://www.emposha.com/> - Distributed under MIT - Keep this message! *//* * json_url         - url to fetch json object * cache       		- use cache * height           - maximum number of element shown before scroll will apear * newel            - show typed text like a element * firstselected	- automaticly select first element from dropdown * filter_case      - case sensitive filter * filter_selected  - filter selected items from list * complete_text    - text for complete page * maxshownitems	- maximum numbers that will be shown at dropdown list (less better performance) * onselect			- fire event on item select * onremove			- fire event on item remove * maxitimes		- maximum items that can be added * delay			- delay between ajax request (bigger delay, lower server time request) */jQuery(function($){$.fn.fcbkcomplete=function(opt){return this.each(function(){function init(){createFCBK();preSet();addInput(0);}function createFCBK(){element.hide();element.attr("multiple","multiple");if(element.attr("name").indexOf("[]")==-1){element.attr("name",element.attr("name")+"[]");}holder=$(document.createElement("ul"));holder.attr("class","holder");element.after(holder);complete=$(document.createElement("div"));complete.addClass("facebook-auto");complete.append('<div class="default">'+options.complete_text+"</div>");if(browser_msie){complete.append('<iframe class="ie6fix" scrolling="no" frameborder="0"></iframe>');browser_msie_frame=complete.children('.ie6fix');}feed=$(document.createElement("ul"));feed.attr("id",elemid+"_feed");complete.prepend(feed);holder.after(complete);feed.css("width",complete.width());}function preSet(){element.children("option").each(function(i,option){option=$(option);if(option.hasClass("selected")||option.is(':selected')){addItem(option.text(),option.val(),true,option.hasClass("locked"));option.attr("selected","selected");}else{option.removeAttr("selected");}cache.push({caption:option.text(),value:option.val()});search_string+=""+(cache.length-1)+":"+option.text()+";";});}$(this).bind("addItem",function(event,data){addItem(data.title,data.value,0,0,0);});function addItem(title,value,preadded,locked,focusme){if(!maxItems()){return false;}var li=document.createElement("li");var txt=document.createTextNode(title);var aclose=document.createElement("a");var liclass="bit-box"+(locked?" locked":"");$(li).attr({"class":liclass,"rel":value});$(li).prepend(txt);$(aclose).attr({"class":"closebutton","href":"#"});li.appendChild(aclose);holder.append(li);$(aclose).click(function(){removeItem($(this).parent("li"));return false;});if(!preadded){$("#"+elemid+"_annoninput").remove();var _item;addInput(focusme);if(element.children("option[value="+value+"]").length){_item=element.children("option[value="+value+"]");_item.get(0).setAttribute("selected","selected");if(!_item.hasClass("selected")){_item.addClass("selected");}}else{var _item=$(document.createElement("option"));_item.attr("value",value).get(0).setAttribute("selected","selected");_item.attr("value",value).addClass("selected");_item.text(title);element.append(_item);}if(options.onselect.length){funCall(options.onselect,_item)}element.change();}holder.children("li.bit-box.deleted").removeClass("deleted");feed.hide();browser_msie?browser_msie_frame.hide():'';}function removeItem(item){if(!item.hasClass('locked')){item.fadeOut("fast");if(options.onremove.length){var _item=element.children("option[value="+item.attr("rel")+"]");funCall(options.onremove,_item)}element.children('option[value="'+item.attr("rel")+'"]').removeAttr("selected").removeClass("selected");item.remove();element.change();deleting=0;}}function addInput(focusme){var li=$(document.createElement("li"));var input=$(document.createElement("input"));var getBoxTimeout=0;li.attr({"class":"bit-input","id":elemid+"_annoninput"});input.attr({"type":"text","class":"maininput","size":"1"});holder.append(li.append(input));input.focus(function(){complete.fadeIn("fast");});input.blur(function(){complete.fadeOut("fast");});holder.click(function(){input.focus();if(feed.length&&input.val().length){feed.show();}else{feed.hide();browser_msie?browser_msie_frame.hide():'';complete.children(".default").show();}});input.keypress(function(event){if(event.keyCode==13||event.keyCode==9){return false;}input.attr("size",input.val().length+1);});input.keydown(function(event){if(event.keyCode==191){event.preventDefault();return false;}});input.keyup(function(event){var etext=xssPrevent(input.val());if(event.keyCode==8&&etext.length==0){feed.hide();browser_msie?browser_msie_frame.hide():'';if(!holder.children("li.bit-box:last").hasClass('locked')){if(holder.children("li.bit-box.deleted").length==0){holder.children("li.bit-box:last").addClass("deleted");return false;}else{if(deleting){return;}deleting=1;holder.children("li.bit-box.deleted").fadeOut("fast",function(){removeItem($(this));return false;});}}}if(event.keyCode!=40&&event.keyCode!=38&&etext.length!=0){counter=0;if(options.json_url){if(options.cache&&json_cache){addMembers(etext);bindEvents();}else{getBoxTimeout++;var getBoxTimeoutValue=getBoxTimeout;setTimeout(function(){if(getBoxTimeoutValue!=getBoxTimeout)return;$.getJSON(options.json_url+(options.json_url.indexOf("?")>-1?"&":"?")+"tag="+etext,null,function(data){addMembers(etext,data);json_cache=true;bindEvents();});},options.delay);}}else{addMembers(etext);bindEvents();}complete.children(".default").hide();feed.show();}});if(focusme){setTimeout(function(){input.focus();complete.children(".default").show();},1);}}function addMembers(etext,data){feed.html('');if(!options.cache&&data!=null){cache=new Array();search_string="";}addTextItem(etext);if(data!=null&&data.length){$.each(data,function(i,val){cache.push({caption:val.caption,value:val.value});search_string+=""+(cache.length-1)+":"+val.caption+";";});}var maximum=options.maxshownitems<cache.length?options.maxshownitems:cache.length;var filter="i";if(options.filter_case){filter="";}var myregexp,match;try{myregexp=eval('/(?:^|;)\\s*(\\d+)\\s*:[^;]*?'+etext+'[^;]*/g'+filter);match=myregexp.exec(search_string);}catch(ex){};var content='';while(match!=null&&maximum>0){var id=match[1];var object=cache[id];if(options.filter_selected&&element.children("option[value="+object.value+"]").hasClass("selected")){}else{content+='<li rel="'+object.value+'">'+itemIllumination(object.caption,etext)+'</li>';counter++;maximum--;}match=myregexp.exec(search_string);}feed.append(content);if(options.firstselected){focuson=feed.children("li:visible:first");focuson.addClass("auto-focus");}if(counter>options.height){feed.css({"height":(options.height*24)+"px","overflow":"auto"});if(browser_msie){browser_msie_frame.css({"height":(options.height*24)+"px","width":feed.width()+"px"}).show();}}else{feed.css("height","auto");if(browser_msie){browser_msie_frame.css({"height":feed.height()+"px","width":feed.width()+"px"}).show();}}}function itemIllumination(text,etext){if(options.filter_case){try{eval("var text = text.replace(/(.*)("+etext+")(.*)/gi,'$1<em>$2</em>$3');");}catch(ex){};}else{try{eval("var text = text.replace(/(.*)("+etext.toLowerCase()+")(.*)/gi,'$1<em>$2</em>$3');");}catch(ex){};}return text;}function bindFeedEvent(){feed.children("li").mouseover(function(){feed.children("li").removeClass("auto-focus");$(this).addClass("auto-focus");focuson=$(this);});feed.children("li").mouseout(function(){$(this).removeClass("auto-focus");focuson=null;});}function removeFeedEvent(){feed.children("li").unbind("mouseover");feed.children("li").unbind("mouseout");feed.mousemove(function(){bindFeedEvent();feed.unbind("mousemove");});}function bindEvents(){var maininput=$("#"+elemid+"_annoninput").children(".maininput");bindFeedEvent();feed.children("li").unbind("mousedown");feed.children("li").mousedown(function(){var option=$(this);addItem(option.text(),option.attr("rel"));feed.hide();browser_msie?browser_msie_frame.hide():'';complete.hide();});maininput.unbind("keydown");maininput.keydown(function(event){if(event.keyCode==191){event.preventDefault();return false;}if(event.keyCode!=8){holder.children("li.bit-box.deleted").removeClass("deleted");}if((event.keyCode==13||event.keyCode==9)&&checkFocusOn()){var option=focuson;addItem(option.text(),option.attr("rel"));complete.hide();event.preventDefault();focuson=null;return false;}if((event.keyCode==13||event.keyCode==9)&&!checkFocusOn()){if(options.newel){var value=xssPrevent($(this).val());addItem(value,value);complete.hide();event.preventDefault();focuson=null;}return false;}if(event.keyCode==40){removeFeedEvent();if(focuson==null||focuson.length==0){focuson=feed.children("li:visible:first");feed.get(0).scrollTop=0;}else{focuson.removeClass("auto-focus");focuson=focuson.nextAll("li:visible:first");var prev=parseInt(focuson.prevAll("li:visible").length,10);var next=parseInt(focuson.nextAll("li:visible").length,10);if((prev>Math.round(options.height/2)||next<=Math.round(options.height/2))&&typeof(focuson.get(0))!="undefined"){feed.get(0).scrollTop=parseInt(focuson.get(0).scrollHeight,10)*(prev-Math.round(options.height/2));}}feed.children("li").removeClass("auto-focus");focuson.addClass("auto-focus");}if(event.keyCode==38){removeFeedEvent();if(focuson==null||focuson.length==0){focuson=feed.children("li:visible:last");feed.get(0).scrollTop=parseInt(focuson.get(0).scrollHeight,10)*(parseInt(feed.children("li:visible").length,10)-Math.round(options.height/2));}else{focuson.removeClass("auto-focus");focuson=focuson.prevAll("li:visible:first");var prev=parseInt(focuson.prevAll("li:visible").length,10);var next=parseInt(focuson.nextAll("li:visible").length,10);if((next>Math.round(options.height/2)||prev<=Math.round(options.height/2))&&typeof(focuson.get(0))!="undefined"){feed.get(0).scrollTop=parseInt(focuson.get(0).scrollHeight,10)*(prev-Math.round(options.height/2));}}feed.children("li").removeClass("auto-focus");focuson.addClass("auto-focus");}});}function maxItems(){if(options.maxitems!=0){if(holder.children("li.bit-box").length<options.maxitems){return true;}else{return false;}}}function addTextItem(value){if(options.newel&&maxItems()){feed.children("li[fckb=1]").remove();if(value.length==0){return;}var li=$(document.createElement("li"));li.attr({"rel":value,"fckb":"1"}).html(value);feed.prepend(li);counter++;}else{return;}}function funCall(func,item){var _object="";for(i=0;i<item.get(0).attributes.length;i++){if(item.get(0).attributes[i].nodeValue!=null){_object+="\"_"+item.get(0).attributes[i].nodeName+"\": \""+item.get(0).attributes[i].nodeValue+"\",";}}_object="{"+_object+" notinuse: 0}";func.call(func,_object);}function checkFocusOn(){if(focuson==null){return false;}if(focuson.length==0){return false;}return true;}function xssPrevent(string){string=string.replace(/[\"\'][\s]*javascript:(.*)[\"\']/g,"\"\"");string=string.replace(/script(.*)/g,"");string=string.replace(/eval\((.*)\)/g,"");string=string.replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/','');return string;}var options=$.extend({json_url:null,cache:false,height:"10",newel:false,firstselected:false,filter_case:false,filter_hide:false,complete_text:"Start to type...",maxshownitems:30,maxitems:10,onselect:"",onremove:"",delay:350},opt);var holder=null;var feed=null;var complete=null;var counter=0;var cache=new Array();var json_cache=false;var search_string="";var focuson=null;var deleting=0;var browser_msie="\v"=="v";var browser_msie_frame;var element=$(this);var elemid=element.attr("id");init();return this;});};});

/*
 * 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 v3.12 - 2009-04-16 ###
 * Home: http://www.fyneworks.com/jquery/star-rating/
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
 *
	* Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
*/

/*# AVOID COLLISIONS #*/
;if(window.jQuery) (function($){
/*# AVOID COLLISIONS #*/
	
	// IE6 Background Image Fix
	if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { };
	// Thanks to http://www.visualjquery.com/rating/rating_redux.html
	
	// plugin initialization
	$.fn.rating = function(options){
		if(this.length==0) return this; // quick fail
		
		// Handle API methods
		if(typeof arguments[0]=='string'){
			// Perform API methods on individual elements
			if(this.length>1){
				var args = arguments;
				return this.each(function(){
					$.fn.rating.apply($(this), args);
    });
			};
			// Invoke API method handler
			$.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
			// Quick exit...
			return this;
		};
		
		// Initialize options for this call
		var options = $.extend(
			{}/* new object */,
			$.fn.rating.options/* default options */,
			options || {} /* just-in-time options */
		);
		
		// Allow multiple controls with the same name by making each call unique
		$.fn.rating.calls++;
		
		// loop through each matched element
		this
		 .not('.star-rating-applied')
			.addClass('star-rating-applied')
		.each(function(){
			
			// Load control parameters / find context / etc
			var control, input = $(this);
			var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,'');
			var context = $(this.form || document.body);
			
			// FIX: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=23
			var raters = context.data('rating');
			if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls };
			var rater = raters[eid];
			
			// if rater is available, verify that the control still exists
			if(rater) control = rater.data('rating');
			
			if(rater && control)//{// save a byte!
				// add star to control if rater is available and the same control still exists
				control.count++;
				
			//}// save a byte!
			else{
				// create new control if first star or control element was removed/replaced
				
				// Initialize options for this raters
				control = $.extend(
					{}/* new object */,
					options || {} /* current call options */,
					($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */
					{ count:0, stars: [], inputs: [] }
				);
				
				// increment number of rating controls
				control.serial = raters.count++;
				
				// create rating element
				rater = $('<span class="star-rating-control"/>');
				input.before(rater);
				
				// Mark element for initialization (once all stars are ready)
				rater.addClass('rating-to-be-drawn');
				
				// Accept readOnly setting from 'disabled' property
				if(input.attr('disabled')) control.readOnly = true;
				
				// Create 'cancel' button
				rater.append(
					control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
					.mouseover(function(){
						$(this).rating('drain');
						$(this).addClass('star-rating-hover');
						//$(this).rating('focus');
					})
					.mouseout(function(){
						$(this).rating('draw');
						$(this).removeClass('star-rating-hover');
						//$(this).rating('blur');
					})
					.click(function(){
					 $(this).rating('select');
					})
					.data('rating', control)
				);
				
			}; // first element of group
			
			// insert rating star
			var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>');
			rater.append(star);
			
			// inherit attributes from input element
			if(this.id) star.attr('id', this.id);
			if(this.className) star.addClass(this.className);
			
			// Half-stars?
			if(control.half) control.split = 2;
			
			// Prepare division control
			if(typeof control.split=='number' && control.split>0){
				var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
				var spi = (control.count % control.split), spw = Math.floor(stw/control.split);
				star
				// restrict star's width and hide overflow (already in CSS)
				.width(spw)
				// move the star left by using a negative margin
				// this is work-around to IE's stupid box model (position:relative doesn't work)
				.find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
			};
			
			// readOnly?
			if(control.readOnly)//{ //save a byte!
				// Mark star as readOnly so user can customize display
				star.addClass('star-rating-readonly');
			//}  //save a byte!
			else//{ //save a byte!
			 // Enable hover css effects
				star.addClass('star-rating-live')
				 // Attach mouse events
					.mouseover(function(){
						$(this).rating('fill');
						$(this).rating('focus');
					})
					.mouseout(function(){
						$(this).rating('draw');
						$(this).rating('blur');
					})
					.click(function(){
						$(this).rating('select');
					})
				;
			//}; //save a byte!
			
			// set current selection
			if(this.checked)	control.current = star;
			
			// hide input element
			input.hide();
			
			// backward compatibility, form element to plugin
			input.change(function(){
    $(this).rating('select');
   });
			
			// attach reference to star to input element and vice-versa
			star.data('rating.input', input.data('rating.star', star));
			
			// store control information in form (or body when form not available)
			control.stars[control.stars.length] = star[0];
			control.inputs[control.inputs.length] = input[0];
			control.rater = raters[eid] = rater;
			control.context = context;
			
			input.data('rating', control);
			rater.data('rating', control);
			star.data('rating', control);
			context.data('rating', raters);
  }); // each element
		
		// Initialize ratings (first draw)
		$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');
		
		return this; // don't break the chain...
	};
	
	/*--------------------------------------------------------*/
	
	/*
		### Core functionality and API ###
	*/
	$.extend($.fn.rating, {
		// Used to append a unique serial number to internal control ID
		// each time the plugin is invoked so same name controls can co-exist
		calls: 0,
		
		focus: function(){
			var control = this.data('rating'); if(!control) return this;
			if(!control.focus) return this; // quick fail if not required
			// find data for event
			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
   // focus handler, as requested by focusdigital.co.uk
			if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
		}, // $.fn.rating.focus
		
		blur: function(){
			var control = this.data('rating'); if(!control) return this;
			if(!control.blur) return this; // quick fail if not required
			// find data for event
			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
   // blur handler, as requested by focusdigital.co.uk
			if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
		}, // $.fn.rating.blur
		
		fill: function(){ // fill to the current mouse position.
			var control = this.data('rating'); if(!control) return this;
			// do not execute when control is in read-only mode
			if(control.readOnly) return;
			// Reset all stars and highlight them up to this element
			this.rating('drain');
			this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
		},// $.fn.rating.fill
		
		drain: function() { // drain all the stars.
			var control = this.data('rating'); if(!control) return this;
			// do not execute when control is in read-only mode
			if(control.readOnly) return;
			// Reset all stars
			control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
		},// $.fn.rating.drain
		
		draw: function(){ // set value and stars to reflect current selection
			var control = this.data('rating'); if(!control) return this;
			// Clear all stars
			this.rating('drain');
			// Set control value
			if(control.current){
				control.current.data('rating.input').attr('checked','checked');
				control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');
			}
			else
			 $(control.inputs).removeAttr('checked');
			// Show/hide 'cancel' button
			control.cancel[control.readOnly || control.required?'hide':'show']();
			// Add/remove read-only classes to remove hand pointer
			this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
		},// $.fn.rating.draw
		
		select: function(value){ // select a value
			var control = this.data('rating'); if(!control) return this;
			// do not execute when control is in read-only mode
			if(control.readOnly) return;
			// clear selection
			control.current = null;
			// programmatically (based on user input)
			if(typeof value!='undefined'){
			 // select by index (0 based)
				if(typeof value=='number')
 			 return $(control.stars[value]).rating('select');
				// select by literal value (must be passed as a string
				if(typeof value=='string')
					//return 
					$.each(control.stars, function(){
						if($(this).data('rating.input').val()==value) $(this).rating('select');
					});
			}
			else
				control.current = this[0].tagName=='INPUT' ? 
				 this.data('rating.star') : 
					(this.is('.rater-'+ control.serial) ? this : null);
			
			// Update rating control state
			this.data('rating', control);
			// Update display
			this.rating('draw');
			// find data for event
			var input = $( control.current ? control.current.data('rating.input') : null );
			// click callback, as requested here: http://plugins.jquery.com/node/1655
			if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
		},// $.fn.rating.select
		
		readOnly: function(toggle, disable){ // make the control read-only (still submits value)
			var control = this.data('rating'); if(!control) return this;
			// setread-only status
			control.readOnly = toggle || toggle==undefined ? true : false;
			// enable/disable control value submission
			if(disable) $(control.inputs).attr("disabled", "disabled");
			else     			$(control.inputs).removeAttr("disabled");
			// Update rating control state
			this.data('rating', control);
			// Update display
			this.rating('draw');
		},// $.fn.rating.readOnly
		
		disable: function(){ // make read-only and never submit value
			this.rating('readOnly', true, true);
		},// $.fn.rating.disable
		
		enable: function(){ // make read/write and submit value
			this.rating('readOnly', false, false);
		}// $.fn.rating.select
		
 });
	
	/*--------------------------------------------------------*/
	
	/*
		### Default Settings ###
		eg.: You can override default control like this:
		$.fn.rating.options.cancel = 'Clear';
	*/
	$.fn.rating.options = { //$.extend($.fn.rating, { options: {
			cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
			cancelValue: '',           // value to submit when user click the 'cancel' link
			split: 0,                  // split the star into how many parts?
			
			// Width of star image in case the plugin can't work it out. This can happen if
			// the jQuery.dimensions plugin is not available OR the image is hidden at installation
			starWidth: 16//,
			
			//NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
			//half:     false,         // just a shortcut to control.split = 2
			//required: false,         // disables the 'cancel' button so user can only select one of the specified values
			//readOnly: false,         // disable rating plugin interaction/ values cannot be changed
			//focus:    function(){},  // executed when stars are focused
			//blur:     function(){},  // executed when stars are focused
			//callback: function(){},  // executed when a star is clicked
 }; //} });
	
	/*--------------------------------------------------------*/
	
	/*
		### Default implementation ###
		The plugin will attach itself to file inputs
		with the class 'multi' when the page loads
	*/
	$(function(){
	 $('input[type=radio].star').rating();
	});
	
	
	
/*# AVOID COLLISIONS #*/
})(jQuery);
/*# AVOID COLLISIONS #*/


(function($) {
    function fixTitle($ele) {
        if ($ele.attr('title') || typeof($ele.attr('original-title')) != 'string') {
            $ele.attr('original-title', $ele.attr('title') || '').removeAttr('title');
        }
    }

    $.fn.tipsy = function(options) {

        options = $.extend({}, $.fn.tipsy.defaults, options);

        return this.each(function() {

            fixTitle($(this));
            var opts = $.fn.tipsy.elementOptions(this, options);

            $(this).hover(function() {

                $.data(this, 'cancel.tipsy', true);

                var tip = $.data(this, 'active.tipsy');
                if (!tip) {
                    tip = $('<div class="tipsy"><div class="tipsy-inner"/></div>');
                    tip.css({position: 'absolute', zIndex: 100000});
                    $.data(this, 'active.tipsy', tip);
                }

                fixTitle($(this));

                var title;
                if (typeof opts.title == 'string') {
                    title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title);
                } else if (typeof opts.title == 'function') {
                    title = opts.title.call(this);
                }

                tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback);

                var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
                tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity
                tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
                var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
                var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity;

                switch (gravity.charAt(0)) {
                    case 'n':
                        tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
                        break;
                    case 's':
                        tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
                        break;
                    case 'e':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
                        break;
                    case 'w':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
                        break;
                }

                if (opts.fade) {
                    tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: opts.opacity});
                } else {
                    tip.css({visibility: 'visible', opacity: opts.opacity});
                }

            }, function() {
                $.data(this, 'cancel.tipsy', false);
                var self = this;
                setTimeout(function() {
                    if ($.data(this, 'cancel.tipsy')) return;
                    var tip = $.data(self, 'active.tipsy');
                    if (opts.fade) {
                        tip.stop().fadeOut(function() { $(this).remove(); });
                    } else {
                        tip.remove();
                    }
                }, 100);

            });

        });

    };

    // Overwrite this method to provide options on a per-element basis.
    // For example, you could store the gravity in a 'tipsy-gravity' attribute:
    // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
    // (remember - do not modify 'options' in place!)
    $.fn.tipsy.elementOptions = function(ele, options) {
        return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
    };

    $.fn.tipsy.defaults = {
        fade: false,
        fallback: '',
        gravity: 'n',
        html: false,
        opacity: 0.8,
        title: 'title'
    };

    $.fn.tipsy.autoNS = function() {
        return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
    };

    $.fn.tipsy.autoWE = function() {
        return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
    };

})(jQuery);

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{	jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open);
   $('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;