/*
 * jQuery UI @VERSION
 *
 * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
;(function($) {

/** jQuery core modifications and additions **/
$.keyCode = {
	BACKSPACE: 8,
	CAPS_LOCK: 20,
	COMMA: 188,
	CONTROL: 17,
	DELETE: 46,
	DOWN: 40,
	END: 35,
	ENTER: 13,
	ESCAPE: 27,
	HOME: 36,
	INSERT: 45,
	LEFT: 37,
	NUMPAD_ADD: 107,
	NUMPAD_DECIMAL: 110,
	NUMPAD_DIVIDE: 111,
	NUMPAD_ENTER: 108,
	NUMPAD_MULTIPLY: 106,
	NUMPAD_SUBTRACT: 109,
	PAGE_DOWN: 34,
	PAGE_UP: 33,
	PERIOD: 190,
	RIGHT: 39,
	SHIFT: 16,
	SPACE: 32,
	TAB: 9,
	UP: 38
};

//Temporary mappings
var _remove = $.fn.remove;
var isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);


//Helper functions and ui object
$.ui = {
	
	version: "@VERSION",
	
	// $.ui.plugin is deprecated.  Use the proxy pattern instead.
	plugin: {
		add: function(module, option, set) {
			var proto = $.ui[module].prototype;
			for(var i in set) {
				proto.plugins[i] = proto.plugins[i] || [];
				proto.plugins[i].push([option, set[i]]);
			}
		},
		call: function(instance, name, args) {
			var set = instance.plugins[name];
			if(!set) { return; }
			
			for (var i = 0; i < set.length; i++) {
				if (instance.options[set[i][0]]) {
					set[i][1].apply(instance.element, args);
				}
			}
		}	
	},
	
	cssCache: {},
	css: function(name) {
		if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
		var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
		
		//if (!$.browser.safari)
			//tmp.appendTo('body');
		
		//Opera and Safari set width and height to 0px instead of auto
		//Safari returns rgba(0,0,0,0) when bgcolor is not set
		$.ui.cssCache[name] = !!(
			(!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || 
			!(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
		);
		try { $('body').get(0).removeChild(tmp.get(0));	} catch(e){}
		return $.ui.cssCache[name];
	},

	hasScroll: function(e, a) {
		
		//If overflow is hidden, the element might have extra content, but the user wants to hide it
		if ($(e).css('overflow') == 'hidden') { return false; }
		
		var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
			has = false;
		
		if (e[scroll] > 0) { return true; }
		
		// TODO: determine which cases actually cause this to happen
		// if the element doesn't have the scroll set, see if it's possible to
		// set the scroll
		e[scroll] = 1;
		has = (e[scroll] > 0);
		e[scroll] = 0;
		return has;
	}
};


//jQuery plugins
$.fn.extend({
	
	remove: function() {
		// Safari has a native remove event which actually removes DOM elements,
		// so we have to use triggerHandler instead of trigger (#3037).
		$("*", this).add(this).each(function() {
			$(this).triggerHandler("remove");
		});
		return _remove.apply(this, arguments );
	},
	
	enableSelection: function() {
		return this
			.attr('unselectable', 'off')
			.css('MozUserSelect', '')
			.unbind('selectstart.ui');
	},
	
	disableSelection: function() {
		return this
			.attr('unselectable', 'on')
			.css('MozUserSelect', 'none')
			.bind('selectstart.ui', function() { return false; });
	},
	
	// WAI-ARIA Semantics
	ariaRole: function(role) {
		return (role !== undefined
			
			// setter
			? this.attr("role", isFF2 ? "wairole:" + role : role)
			
			// getter
			: (this.attr("role") || "").replace(/^wairole:/, ""));
	},
	
	ariaState: function(state, value) {
		return (value !== undefined
			
			// setter
			? this.each(function(i, el) {
				(isFF2
					? el.setAttributeNS("http://www.w3.org/2005/07/aaa",
						"aaa:" + state, value)
					: $(el).attr("aria-" + state, value));
			})
			
			// getter
			: this.attr(isFF2 ? "aaa:" + state : "aria-" + state));
	}
	
});


//Additional selectors
$.extend($.expr[':'], {
	
	data: function(a, i, m) {
		return $.data(a, m[3]);
	},
	
	// TODO: add support for object, area
	tabbable: function(a, i, m) {

		var nodeName = a.nodeName.toLowerCase();
		var isVisible = function(element) {
			function checkStyles(element) {
				var style = element.style;
				return (style.display != 'none' && style.visibility != 'hidden');
			}
			
			var visible = checkStyles(element);
			
			(visible && $.each($.dir(element, 'parentNode'), function() {
				return (visible = checkStyles(this));
			}));
			
			return visible;
		};
		
		return (
			// in tab order
			a.tabIndex >= 0 &&
			
			( // filter node types that participate in the tab order
				
				// anchor tag
				('a' == nodeName && a.href) ||
				
				// enabled form element
				(/input|select|textarea|button/.test(nodeName) &&
					'hidden' != a.type && !a.disabled)
			) &&
			
			// visible on page
			isVisible(a)
		);
		
	}
	
});


// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
// created by Scott GonzÃ¡lez and JÃ¶rn Zaefferer
function getter(namespace, plugin, method, args) {
	function getMethods(type) {
		var methods = $[namespace][plugin][type] || [];
		return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
	}
	
	var methods = getMethods('getter');
	if (args.length == 1 && typeof args[0] == 'string') {
		methods = methods.concat(getMethods('getterSetter'));
	}
	return ($.inArray(method, methods) != -1);
}

$.widget = function(name, prototype) {
	var namespace = name.split(".")[0];
	name = name.split(".")[1];
	
	// create plugin method
	$.fn[name] = function(options) {
		var isMethodCall = (typeof options == 'string'),
			args = Array.prototype.slice.call(arguments, 1);
		
		// prevent calls to internal methods
		if (isMethodCall && options.substring(0, 1) == '_') {
			return this;
		}
		
		// handle getter methods
		if (isMethodCall && getter(namespace, name, options, args)) {
			var instance = $.data(this[0], name);
			return (instance ? instance[options].apply(instance, args)
				: undefined);
		}
		
		// handle initialization and non-getter methods
		return this.each(function() {
			var instance = $.data(this, name);
			
			// constructor
			(!instance && !isMethodCall &&
				$.data(this, name, new $[namespace][name](this, options)));
			
			// method call
			(instance && isMethodCall && $.isFunction(instance[options]) &&
				instance[options].apply(instance, args));
		});
	};
	
	// create widget constructor
	$[namespace] = $[namespace] || {};
	$[namespace][name] = function(element, options) {
		var self = this;
		
		this.widgetName = name;
		this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
		this.widgetBaseClass = namespace + '-' + name;
		
		this.options = $.extend({},
			$.widget.defaults,
			$[namespace][name].defaults,
			$.metadata && $.metadata.get(element)[name],
			options);
		
		this.element = $(element)
			.bind('setData.' + name, function(e, key, value) {
				return self._setData(key, value);
			})
			.bind('getData.' + name, function(e, key) {
				return self._getData(key);
			})
			.bind('remove', function() {
				return self.destroy();
			});
		
		this._init();
	};
	
	// add widget prototype
	$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
	
	// TODO: merge getter and getterSetter properties from widget prototype
	// and plugin prototype
	$[namespace][name].getterSetter = 'option';
};

$.widget.prototype = {
	_init: function() {},
	destroy: function() {
		this.element.removeData(this.widgetName);
	},
	
	option: function(key, value) {
		var options = key,
			self = this;
		
		if (typeof key == "string") {
			if (value === undefined) {
				return this._getData(key);
			}
			options = {};
			options[key] = value;
		}
		
		$.each(options, function(key, value) {
			self._setData(key, value);
		});
	},
	_getData: function(key) {
		return this.options[key];
	},
	_setData: function(key, value) {
		this.options[key] = value;
		
		if (key == 'disabled') {
			this.element[value ? 'addClass' : 'removeClass'](
				this.widgetBaseClass + '-disabled');
		}
	},
	
	enable: function() {
		this._setData('disabled', false);
	},
	disable: function() {
		this._setData('disabled', true);
	},
	
	_trigger: function(type, e, data) {
		var eventName = (type == this.widgetEventPrefix
			? type : this.widgetEventPrefix + type);
		e = e  || $.event.fix({ type: eventName, target: this.element[0] });
		return this.element.triggerHandler(eventName, [e, data], this.options[type]);
	}
};

$.widget.defaults = {
	disabled: false
};


/** Mouse Interaction Plugin **/

$.ui.mouse = {
	_mouseInit: function() {
		var self = this;
	
		this.element
			.bind('mousedown.'+this.widgetName, function(e) {
				return self._mouseDown(e);
			})
			.bind('click.'+this.widgetName, function(e) {
				if(self._preventClickEvent) {
					self._preventClickEvent = false;
					return false;
				}
			});
		
		// Prevent text selection in IE
		if ($.browser.msie) {
			this._mouseUnselectable = this.element.attr('unselectable');
			this.element.attr('unselectable', 'on');
		}
		
		this.started = false;
	},
	
	// TODO: make sure destroying one instance of mouse doesn't mess with
	// other instances of mouse
	_mouseDestroy: function() {
		this.element.unbind('.'+this.widgetName);
		
		// Restore text selection in IE
		($.browser.msie
			&& this.element.attr('unselectable', this._mouseUnselectable));
	},
	
	_mouseDown: function(e) {
		// we may have missed mouseup (out of window)
		(this._mouseStarted && this._mouseUp(e));
		
		this._mouseDownEvent = e;
		
		var self = this,
			btnIsLeft = (e.which == 1),
			elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
		if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) {
			return true;
		}
		
		this.mouseDelayMet = !this.options.delay;
		if (!this.mouseDelayMet) {
			this._mouseDelayTimer = setTimeout(function() {
				self.mouseDelayMet = true;
			}, this.options.delay);
		}
		
		if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
			this._mouseStarted = (this._mouseStart(e) !== false);
			if (!this._mouseStarted) {
				e.preventDefault();
				return true;
			}
		}
		
		// these delegates are required to keep context
		this._mouseMoveDelegate = function(e) {
			return self._mouseMove(e);
		};
		this._mouseUpDelegate = function(e) {
			return self._mouseUp(e);
		};
		$(document)
			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
		
		return false;
	},
	
	_mouseMove: function(e) {
		// IE mouseup check - mouseup happened when mouse was out of window
		if ($.browser.msie && !e.button) {
			return this._mouseUp(e);
		}
		
		if (this._mouseStarted) {
			this._mouseDrag(e);
			return false;
		}
		
		if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
			this._mouseStarted =
				(this._mouseStart(this._mouseDownEvent, e) !== false);
			(this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e));
		}
		
		return !this._mouseStarted;
	},
	
	_mouseUp: function(e) {
		$(document)
			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
		
		if (this._mouseStarted) {
			this._mouseStarted = false;
			this._preventClickEvent = true;
			this._mouseStop(e);
		}
		
		return false;
	},
	
	_mouseDistanceMet: function(e) {
		return (Math.max(
				Math.abs(this._mouseDownEvent.pageX - e.pageX),
				Math.abs(this._mouseDownEvent.pageY - e.pageY)
			) >= this.options.distance
		);
	},
	
	_mouseDelayMet: function(e) {
		return this.mouseDelayMet;
	},
	
	// These are placeholder methods, to be overriden by extending plugin
	_mouseStart: function(e) {},
	_mouseDrag: function(e) {},
	_mouseStop: function(e) {},
	_mouseCapture: function(e) { return true; }
};

$.ui.mouse.defaults = {
	cancel: null,
	distance: 1,
	delay: 0
};

})(jQuery);


(function($){$().ajaxSend(function(a,xhr,s){xhr.setRequestHeader("Accept","text/javascript, text/html, application/xml, text/xml, */*");});})(jQuery);(function($){$.extend({fieldEvent:function(el,obs){var field=el[0]||el,e='change';if(field.type=='radio'||field.type=='checkbox')e='click';else if(obs&&field.type=='text'||field.type=='textarea')e='keyup';return e;}});$.fn.extend({delayedObserver:function(delay,callback){var el=$(this);if(typeof window.delayedObserverStack=='undefined')window.delayedObserverStack=[];if(typeof window.delayedObserverCallback=='undefined'){window.delayedObserverCallback=function(stackPos){observed=window.delayedObserverStack[stackPos];if(observed.timer)clearTimeout(observed.timer);observed.timer=setTimeout(function(){observed.timer=null;observed.callback(observed.obj,observed.obj.formVal());},observed.delay*1000);observed.oldVal=observed.obj.formVal();}}
window.delayedObserverStack.push({obj:el,timer:null,delay:delay,oldVal:el.formVal(),callback:callback});var stackPos=window.delayedObserverStack.length-1;if(el[0].tagName=='FORM'){$(':input',el).each(function(){var field=$(this);field.bind($.fieldEvent(field,delay),function(){observed=window.delayedObserverStack[stackPos];if(observed.obj.formVal()==observed.obj.oldVal)return;else window.delayedObserverCallback(stackPos);});});}else{el.bind($.fieldEvent(el,delay),function(){observed=window.delayedObserverStack[stackPos];if(observed.obj.formVal()==observed.obj.oldVal)return;else window.delayedObserverCallback(stackPos);});};},formVal:function(){var el=this[0];if(el.tagName=='FORM')return this.serialize();if(el.type=='checkbox'||self.type=='radio')return this.filter('input:checked').val()||'';else return this.val();}});})(jQuery);(function($){$.fn.fadeToggle=function(speed,easing,callback){return this.animate({opacity:'toggle'},speed,easing,callback);};$.fn.extend({visualEffect:function(o){return this.effect(o);},Appear:function(speed,callback){return this.fadeIn(speed,callback);},BlindDown:function(speed,callback){this.show('blind',{direction:'vertical'},speed,callback);return this;},BlindUp:function(speed,callback){this.hide('blind',{direction:'vertical'},speed,callback);return this;},BlindRight:function(speed,callback){this.show('blind',{direction:'horizontal'},speed,callback);return this;},BlindLeft:function(speed,callback){this.hide('blind',{direction:'horizontal'},speed,callback);return this;},DropOut:function(speed,callback){this.hide('drop',{direction:'down'},speed,callback);return this;},DropIn:function(speed,callback){this.show('drop',{direction:'up'},speed,callback);return this;},Fade:function(speed,callback){return this.fadeOut(speed,callback);},Fold:function(speed,callback){this.hide('fold',{},speed,callback);return this;},FoldOut:function(speed,callback){this.show('fold',{},speed,callback);return this;},Grow:function(speed,callback){this.show('scale',{},speed,callback);return this;},Highlight:function(speed,callback){this.show('highlight',{},speed,callback);return this;},Puff:function(speed,callback){this.hide('puff',{},speed,callback);return this;},Pulsate:function(speed,callback){this.show('pulsate',{},speed,callback);return this;},Shake:function(speed,callback){this.show('shake',{},speed,callback);return this;},Shrink:function(speed,callback){this.hide('scale',{},speed,callback);return this;},Squish:function(speed,callback){this.hide('scale',{origin:['top','left']},speed,callback);return this;},SlideUp:function(speed,callback){this.hide('slide',{direction:'up'},speed,callback);return this;},SlideDown:function(speed,callback){this.show('slide',{direction:'up'},speed,callback);return this;},SwitchOff:function(speed,callback){this.hide('clip',{},speed,callback);return this;},SwitchOn:function(speed,callback){this.show('clip',{},speed,callback);return this;}});})(jQuery);

/*
 * jQuery UI Tabs @VERSION
 *
 * Copyright (c) 2007, 2008 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	ui.core.js
 */
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}('(4($){$.3b("8.3",{2J:4(){2.19(1g)},2W:4(b,a){5((/^7/).2f(b))2.17(a);E{2.x[b]=a;2.19()}},D:4(){v 2.$3.D},1F:4(a){v a.1W&&a.1W.X(/\\s/g,\'1S\').X(/[^A-2g-2e-9\\-1S:\\.]/g,\'\')||2.x.1N+$.z(a)},8:4(a,b){v{x:2.x,39:a,1u:b,P:2.$3.P(a)}},1j:4(a){v a.X(/:/g,\'\\\\:\')},1a:4(){6 a=2.J||(2.J=\'8-3-\'+$.z(2.Y[0]));v $.J.2H(u,[a].1V($.2A(2w)))},19:4(g){2.$w=$(\'K:2o(a[F])\',2.Y);2.$3=2.$w.1l(4(){v $(\'a\',2)[0]});2.$q=$([]);6 f=2,o=2.x;2.$3.11(4(i,a){5(a.Q&&a.Q.X(\'#\',\'\'))f.$q=f.$q.18(f.1j(a.Q));E 5($(a).1y(\'F\')!=\'#\'){$.z(a,\'F.3\',a.F);$.z(a,\'G.3\',a.F);6 b=f.1F(a);a.F=\'#\'+b;6 c=$(\'#\'+b);5(!c.D){c=$(o.1x).1y(\'1L\',b).C(o.1i).37(f.$q[i-1]||f.Y);c.z(\'1f.3\',1g)}f.$q=f.$q.18(c)}E o.y.1t(i+1)});5(g){2.Y.C(o.1I);2.$q.C(o.1i);5(o.7===1r){5(25.Q){2.$3.11(4(i,a){5(a.Q==25.Q){o.7=i;v H}})}E 5(o.J){6 l=2R(f.1a(),10);5(l&&f.$3[l])o.7=l}E 5(f.$w.R(\'.\'+o.B).D)o.7=f.$w.P(f.$w.R(\'.\'+o.B)[0])}o.7=o.7===u||o.7!==1r?o.7:0;o.y=$.2M(o.y.1V($.1l(2.$w.R(\'.\'+o.W),4(n,i){v f.$w.P(n)}))).1X();5($.1n(o.7,o.y)!=-1)o.y.2D($.1n(o.7,o.y),1);2.$q.C(o.M);2.$w.I(o.B);5(o.7!==u){2.$q.L(o.7).I(o.M);6 m=[o.B];5(o.13)m.1t(o.14);2.$w.L(o.7).C(m.15(\' \'));6 k=4(){f.O(\'N\',u,f.8(f.$3[o.7],f.$q[o.7]))};5($.z(2.$3[o.7],\'G.3\'))2.G(o.7,k);E k()}$(2p).1c(\'2m\',4(){f.$3.1d(\'.3\');f.$w=f.$3=f.$q=u})}E o.7=2.$w.P(2.$w.R(\'.\'+o.B)[0]);5(o.J)2.1a(o.7,o.J);2j(6 i=0,K;K=2.$w[i];i++)$(K)[$.1n(i,o.y)!=-1&&!$(K).12(o.B)?\'C\':\'I\'](o.W);5(o.S===H)2.$3.1k(\'S.3\');6 p,V;5(o.Z){5(o.Z.2i==2h){p=o.Z[0];V=o.Z[1]}E p=V=o.Z}4 1B(a,b){a.1A({1z:\'\'});5($.1w.1R&&b.2d)a[0].2c.2b(\'R\')}6 j=V?4(b,a){a.1Q(V,V.1P||\'1O\',4(){a.I(o.M);1B(a,V);f.O(\'N\',u,f.8(b,a[0]))})}:4(b,a){a.I(o.M);f.O(\'N\',u,f.8(b,a[0]))};6 h=p?4(b,c,a){c.1Q(p,p.1P||\'1O\',4(){c.C(o.M);1B(c,p);5(a)j(b,a,c)})}:4(b,c,a){c.C(o.M);5(a)j(b,a)};4 1M(c,a,e,b){6 d=[o.B];5(o.13)d.1t(o.14);a.C(d.15(\' \')).2a().I(d.15(\' \'));h(c,e,b)}2.$3.1d(\'.3\').1c(o.U+\'.3\',4(){6 b=$(2).29(\'K:L(0)\'),$16=f.$q.R(\':38\'),$N=$(f.1j(2.Q));5((b.12(o.B)&&!o.13)||b.12(o.W)||$(2).12(o.1h)||f.O(\'17\',u,f.8(2,$N[0]))===H){2.1v();v H}o.7=f.$3.P(2);5(o.13){5(b.12(o.B)){f.x.7=u;b.I([o.B,o.14].15(\' \'));f.$q.T();h(2,$16);2.1v();v H}E 5(!$16.D){f.$q.T();6 a=2;f.G(f.$3.P(2),4(){b.C([o.B,o.14].15(\' \'));j(a,$N)});2.1v();v H}}5(o.J)f.1a(o.7,o.J);f.$q.T();5($N.D){6 a=2;f.G(f.$3.P(2),$16.D?4(){1M(a,b,$16,$N)}:4(){b.C(o.B);j(a,$N)})}E 36\'27 35 34: 31 30 2Z.\';5($.1w.1R)2.1v();v H});5(o.U!=\'1J\')2.$3.1c(\'1J.3\',4(){v H})},18:4(d,e,f){5(f==1r)f=2.$3.D;6 o=2.x;6 a=$(o.26.X(/#\\{F\\}/g,d).X(/#\\{1s\\}/g,e));a.z(\'1f.3\',1g);6 b=d.2Y(\'#\')==0?d.X(\'#\',\'\'):2.1F($(\'a:2X-2U\',a)[0]);6 c=$(\'#\'+b);5(!c.D){c=$(o.1x).1y(\'1L\',b).C(o.M).z(\'1f.3\',1g)}c.C(o.1i);5(f>=2.$w.D){a.24(2.Y);c.24(2.Y[0].2S)}E{a.23(2.$w[f]);c.23(2.$q[f])}o.y=$.1l(o.y,4(n,i){v n>=f?++n:n});2.19();5(2.$3.D==1){a.C(o.B);c.I(o.M);6 g=$.z(2.$3[0],\'G.3\');5(g)2.G(f,g)}2.O(\'18\',u,2.8(2.$3[f],2.$q[f]))},1b:4(a){6 o=2.x,$K=2.$w.L(a).1b(),$1u=2.$q.L(a).1b();5($K.12(o.B)&&2.$3.D>1)2.17(a+(a+1<2.$3.D?1:-1));o.y=$.1l($.22(o.y,4(n,i){v n!=a}),4(n,i){v n>=a?--n:n});2.19();2.O(\'1b\',u,2.8($K.1K(\'a\')[0],$1u[0]))},21:4(a){6 o=2.x;5($.1n(a,o.y)==-1)v;6 b=2.$w.L(a).I(o.W);5($.1w.2Q){b.1A(\'1z\',\'2P-20\');2O(4(){b.1A(\'1z\',\'20\')},0)}o.y=$.22(o.y,4(n,i){v n!=a});2.O(\'21\',u,2.8(2.$3[a],2.$q[a]))},1Z:4(a){6 b=2,o=2.x;5(a!=o.7){2.$w.L(a).C(o.W);o.y.1t(a);o.y.1X();2.O(\'1Z\',u,2.8(2.$3[a],2.$q[a]))}},17:4(a){5(2N a==\'2L\')a=2.$3.P(2.$3.R(\'[F$=\'+a+\']\')[0]);2.$3.L(a).2K(2.x.U+\'.3\')},G:4(f,c){6 h=2,o=2.x,$a=2.$3.L(f),a=$a[0],1Y=c==1r||c===H,1e=$a.z(\'G.3\');c=c||4(){};5(!1e||!1Y&&$.z(a,\'S.3\')){c();v}6 i=4(a){6 b=$(a),$1q=b.1K(\'*:2I\');v $1q.D&&$1q.2G(\':2F(2E)\')&&$1q||b};6 d=4(){h.$3.R(\'.\'+o.1h).I(o.1h).11(4(){5(o.1m)i(2).2C().1p(i(2).z(\'1s.3\'))});h.1o=u};5(o.1m){6 g=i(a).1p();i(a).2B(\'<1E></1E>\').1K(\'1E\').z(\'1s.3\',g).1p(o.1m)}6 j=$.1H({},o.1G,{1e:1e,1U:4(r,s){$(h.1j(a.Q)).1p(r);d();5(o.S)$.z(a,\'S.3\',1g);h.O(\'G\',u,h.8(h.$3[f],h.$q[f]));2z{o.1G.1U(r,s)}2y(e){}c()}});5(2.1o){2.1o.2x();d()}$a.C(o.1h);h.1o=$.2v(j)},1e:4(a,b){2.$3.L(a).1k(\'S.3\').z(\'G.3\',b)},1f:4(){6 o=2.x;2.Y.1d(\'.3\').I(o.1I).1k(\'3\');2.$3.11(4(){6 b=$.z(2,\'F.3\');5(b)2.F=b;6 c=$(2).1d(\'.3\');$.11([\'F\',\'G\',\'S\'],4(i,a){c.1k(a+\'.3\')})});2.$w.18(2.$q).11(4(){5($.z(2,\'1f.3\'))$(2).1b();E $(2).I([o.B,o.14,o.W,o.1i,o.M].15(\' \'))});5(o.J)2.1a(u,o.J)}});$.1H($.8.3,{2T:\'@2u\',2V:\'D\',2t:{13:H,U:\'1J\',y:[],J:u,1m:\'2s&#2r;\',S:H,1N:\'8-3-\',1G:u,Z:u,26:\'<K><a F="#{F}"><28>#{1s}</28></a></K>\',1x:\'<1T></1T>\',1I:\'8-3-2q\',B:\'8-3-7\',14:\'8-3-13\',W:\'8-3-y\',1i:\'8-3-1u\',M:\'8-3-16\',1h:\'8-3-32\'}});$.1H($.8.3.33,{1D:u,2n:4(c,a){a=a||H;6 b=2,t=2.x.7;4 1C(){b.1D=2l(4(){t=++t<b.$3.D?t:0;b.17(t)},c)}4 T(e){5(!e||e.2k){3a(b.1D)}}5(c){1C();5(!a)2.$3.1c(2.x.U+\'.3\',T);E 2.$3.1c(2.x.U+\'.3\',4(){T();t=b.x.7;1C()})}E{T();2.$3.1d(2.x.U+\'.3\',T)}}})})(27);',62,198,'||this|tabs|function|if|var|selected|ui||||||||||||||||||panels||||null|return|lis|options|disabled|data||selectedClass|addClass|length|else|href|load|false|removeClass|cookie|li|eq|hideClass|show|_trigger|index|hash|filter|cache|stop|event|showFx|disabledClass|replace|element|fx||each|hasClass|deselectable|deselectableClass|join|hide|select|add|_tabify|_cookie|remove|bind|unbind|url|destroy|true|loadingClass|panelClass|_sanitizeSelector|removeData|map|spinner|inArray|xhr|html|inner|undefined|label|push|panel|blur|browser|panelTemplate|attr|display|css|resetStyle|start|rotation|em|_tabId|ajaxOptions|extend|navClass|click|find|id|switchTab|idPrefix|normal|duration|animate|msie|_|div|success|concat|title|sort|bypassCache|disable|block|enable|grep|insertBefore|appendTo|location|tabTemplate|jQuery|span|parents|siblings|removeAttribute|style|opacity|z0|test|Za|Array|constructor|for|clientX|setInterval|unload|rotate|has|window|nav|8230|Loading|defaults|VERSION|ajax|arguments|abort|catch|try|makeArray|wrapInner|parent|splice|img|not|is|apply|last|_init|trigger|string|unique|typeof|setTimeout|inline|safari|parseInt|parentNode|version|child|getter|_setData|first|indexOf|identifier|fragment|Mismatching|loading|prototype|Tabs|UI|throw|insertAfter|visible|tab|clearInterval|widget'.split('|'),0,{}))

/**
 * Interface Elements for jQuery
 * FX - scroll to
 * 
 * http://interface.eyecon.ro
 * 
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 *   
 *
 */
/**
 * Applies a scrolling effect to document until the element gets into viewport
 */
jQuery.fn.extend (
	{
		/**
		 * @name ScrollTo
		 * @description scrolls the document until the lement gets into viewport
		 * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']
		 * @param String axis (optional) whatever to scroll on vertical, horizontal or both axis ['vertical'|'horizontal'|null]
		 * @param String easing (optional) The name of the easing effect that you want to use.
		 * @type jQuery
		 * @cat Plugins/Interface
		 * @author Stefan Petre
		 */
		ScrollTo : function(speed, axis, easing) {
			o = jQuery.speed(speed);
			return this.queue('interfaceFX',function(){
				new jQuery.fx.ScrollTo(this, o, axis, easing);
			});
		},
		/**
		 * @name ScrollToAnchors
		 * @description all links to '#elementId' will animate scroll
		 * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']
		 * @param String axis (optional) whatever to scroll on vertical, horizontal or both axis ['vertical'|'horizontal'|null]
		 * @param String easing (optional) The name of the easing effect that you want to use.
		 * @type jQuery
		 * @cat Plugins/Interface
		 * @author Stefan Petre
		 */
		/*inspired by David Maciejewski www.macx.de*/
		ScrollToAnchors : function(speed, axis, easing) {
			return this.each(
				function()
				{
					jQuery('a[@href*="#"]', this).click(
						function(e)
						{
							parts = this.href.split('#');
							jQuery('#' + parts[1]).ScrollTo(speed, axis, easing);
							return false;
						}
					);
				}
			)
		}
	}
);

jQuery.fx.ScrollTo = function (e, o, axis, easing)
{
	var z = this;
	z.o = o;
	z.e = e;
	z.axis = /vertical|horizontal/.test(axis) ? axis : false;
	z.easing = easing;
	p = jQuery.iUtil.getPosition(e);
	s = jQuery.iUtil.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null;jQuery.dequeue(z.e, 'interfaceFX');};
	z.t=(new Date).getTime();
	s.h = s.h > s.ih ? (s.h - s.ih) : s.h;
	s.w = s.w > s.iw ? (s.w - s.iw) : s.w;
	z.endTop = p.y > s.h ? s.h : p.y;
	z.endLeft = p.x > s.w ? s.w : p.x;
	z.startTop = s.t;
	z.startLeft = s.l;
	z.step = function(){
		var t = (new Date).getTime();
		var n = t - z.t;
		var p = n / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.endTop, z.endLeft)},13);
		} else {
			if (!z.axis || z.axis == 'vertical') {
				if (!jQuery.easing || !jQuery.easing[z.easing]) {
					st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.endTop-z.startTop) + z.startTop;
				} else {
					st = jQuery.easing[z.easing](p, n, z.startTop, (z.endTop - z.startTop), z.o.duration);
				}
			} else {
				st = z.startTop;
			}
			if (!z.axis || z.axis == 'horizontal') {
				if (!jQuery.easing || !jQuery.easing[z.easing]) {
					sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.endLeft-z.startLeft) + z.startLeft;
				} else {
					sl = jQuery.easing[z.easing](p, n, z.startLeft, (z.endLeft - z.startLeft), z.o.duration);
				}
			} else {
				sl = z.startLeft;
			}
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t);};
	z.timer=setInterval(function(){z.step();},13);
};
/**
 * Interface Elements for jQuery
 * utility function
 *
 * http://interface.eyecon.ro
 *
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 *
 */
eval(function(p,a,c,k,e,d){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--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[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}('9.J={1C:6(e){4 x=0;4 y=0;4 7=e.Y;4 12=1H;c(9(e).8(\'A\')==\'T\'){4 N=7.B;4 Q=7.z;12=1f;7.B=\'1r\';7.A=\'1q\';7.z=\'1d\'}4 3=e;R(3){x+=3.1h+(3.O&&!9.1m.1i?d(3.O.17)||0:0);y+=3.1n+(3.O&&!9.1m.1i?d(3.O.18)||0:0);3=3.1t}3=e;R(3&&3.1e&&3.1e.16()!=\'f\'){x-=3.u||0;y-=3.F||0;3=3.1D}c(12==1f){7.A=\'T\';7.z=Q;7.B=N}a{x:x,y:y}},1B:6(3){4 x=0,y=0;R(3){x+=3.1h||0;y+=3.1n||0;3=3.1t}a{x:x,y:y}},1s:6(e){4 w=9.8(e,\'1E\');4 h=9.8(e,\'1G\');4 o=0;4 q=0;4 7=e.Y;c(9(e).8(\'A\')!=\'T\'){o=e.V;q=e.U}p{4 N=7.B;4 Q=7.z;7.B=\'1r\';7.A=\'1q\';7.z=\'1d\';o=e.V;q=e.U;7.A=\'T\';7.z=Q;7.B=N}a{w:w,h:h,o:o,q:q}},1F:6(3){a{o:3.V||0,q:3.U||0}},1I:6(e){4 h,w,C;c(e){w=e.I;h=e.G}p{C=5.j;w=1c.14||P.14||(C&&C.I)||5.f.I;h=1c.10||P.10||(C&&C.G)||5.f.G}a{w:w,h:h}},1p:6(e){4 t=0,l=0,w=0,h=0,s=0,E=0;c(e&&e.1u.16()!=\'f\'){t=e.F;l=e.u;w=e.15;h=e.W;s=0;E=0}p{c(5.j){t=5.j.F;l=5.j.u;w=5.j.15;h=5.j.W}p c(5.f){t=5.f.F;l=5.f.u;w=5.f.15;h=5.f.W}s=P.14||5.j.I||5.f.I||0;E=P.10||5.j.G||5.f.G||0}a{t:t,l:l,w:w,h:h,s:s,E:E}},1v:6(e,D){4 3=9(e);4 t=3.8(\'1w\')||\'\';4 r=3.8(\'1x\')||\'\';4 b=3.8(\'1A\')||\'\';4 l=3.8(\'1z\')||\'\';c(D)a{t:d(t)||0,r:d(r)||0,b:d(b)||0,l:d(l)};p a{t:t,r:r,b:b,l:l}},1y:6(e,D){4 3=9(e);4 t=3.8(\'1J\')||\'\';4 r=3.8(\'1M\')||\'\';4 b=3.8(\'27\')||\'\';4 l=3.8(\'28\')||\'\';c(D)a{t:d(t)||0,r:d(r)||0,b:d(b)||0,l:d(l)};p a{t:t,r:r,b:b,l:l}},26:6(e,D){4 3=9(e);4 t=3.8(\'18\')||\'\';4 r=3.8(\'22\')||\'\';4 b=3.8(\'23\')||\'\';4 l=3.8(\'17\')||\'\';c(D)a{t:d(t)||0,r:d(r)||0,b:d(b)||0,l:d(l)||0};p a{t:t,r:r,b:b,l:l}},2e:6(L){4 x=L.2d||(L.2b+(5.j.u||5.f.u))||0;4 y=L.2c||(L.29+(5.j.F||5.f.F))||0;a{x:x,y:y}},X:6(g,13){13(g);g=g.1O;R(g){9.J.X(g,13);g=g.1L}},1N:6(g){9.J.X(g,6(3){19(4 Z 1T 3){c(1Z 3[Z]===\'6\'){3[Z]=1a}}})},1X:6(3,H){4 k=9.J.1p();4 11=9.J.1s(3);c(!H||H==\'1W\')9(3).8({1U:k.t+((1g.1o(k.h,k.E)-k.t-11.q)/2)+\'1j\'});c(!H||H==\'20\')9(3).8({1Y:k.l+((1g.1o(k.w,k.s)-k.l-11.o)/2)+\'1j\'})},2f:6(3,1l){4 1k=9(\'25[@M*="S"]\',3||5),S;1k.24(6(){S=K.M;K.M=1l;K.Y.2a="21:1R.1P.1V(M=\'"+S+"\')"})}};[].1b||(1S.1Q.1b=6(v,n){n=(n==1a)?0:n;4 m=K.1K;19(4 i=n;i<m;i++)c(K[i]==v)a i;a-1});',62,140,'|||el|var|document|function|es|css|jQuery|return||if|parseInt||body|nodeEl|||documentElement|clientScroll||||wb|else|hb||iw||scrollLeft|||||position|display|visibility|de|toInteger|ih|scrollTop|clientHeight|axis|clientWidth|iUtil|this|event|src|oldVisibility|currentStyle|self|oldPosition|while|png|none|offsetHeight|offsetWidth|scrollHeight|traverseDOM|style|attr|innerHeight|windowSize|restoreStyles|func|innerWidth|scrollWidth|toLowerCase|borderLeftWidth|borderTopWidth|for|null|indexOf|window|absolute|tagName|true|Math|offsetLeft|opera|px|images|emptyGIF|browser|offsetTop|max|getScroll|block|hidden|getSize|offsetParent|nodeName|getMargins|marginTop|marginRight|getPadding|marginLeft|marginBottom|getPositionLite|getPosition|parentNode|width|getSizeLite|height|false|getClient|paddingTop|length|nextSibling|paddingRight|purgeEvents|firstChild|Microsoft|prototype|DXImageTransform|Array|in|top|AlphaImageLoader|vertically|centerEl|left|typeof|horizontally|progid|borderRightWidth|borderBottomWidth|each|img|getBorder|paddingBottom|paddingLeft|clientY|filter|clientX|pageY|pageX|getPointer|fixPNG'.split('|'),0,{}))
$(function() {

// for ƒGƒ‰[: jQuery.dequeue is not a function
( function( $ ) {
$.dequeue = function( a , b ){
return $(a).dequeue(b);
};
})( jQuery );
});

/*
--------------------------------------------------------
suggest.js - Input Suggest
Version 2.1 (Update 2008/04/02)

Copyright (c) 2006-2008 onozaty (http://www.enjoyxstudy.com)

Released under an MIT-style license.

For details, see the web site:
 http://www.enjoyxstudy.com/javascript/suggest/

--------------------------------------------------------
*/

if (!Suggest) {
  var Suggest = {};
}
/*-- KeyCodes -----------------------------------------*/
Suggest.Key = {
  TAB:     9,
  RETURN: 13,
  ESC:    27,
  UP:     38,
  DOWN:   40
};

/*-- Utils --------------------------------------------*/
Suggest.copyProperties = function(dest, src) {
  for (var property in src) {
    dest[property] = src[property];
  }
  return dest;
};

/*-- Suggest.Local ------------------------------------*/
Suggest.Local = function() {
  this.initialize.apply(this, arguments);
};
Suggest.Local.prototype = {
  initialize: function(input, suggestArea, candidateList) {

    this.input = this._getElement(input);
    this.suggestArea = this._getElement(suggestArea);
    this.candidateList = candidateList;
    this.oldText = this.getInputText();

    if (arguments[3]) this.setOptions(arguments[3]);

    // reg event
    this._addEvent(this.input, 'focus', this._bind(this.checkLoop));
    this._addEvent(this.input, 'blur', this._bind(this.inputBlur));

    var keyevent = 'keydown';
    if (window.opera || (navigator.userAgent.indexOf('Gecko') >= 0 && navigator.userAgent.indexOf('KHTML') == -1)) {
      keyevent = 'keypress';
    }
    this._addEvent(this.input, keyevent, this._bindEvent(this.keyEvent));

    // init
    this.clearSuggestArea();
  },

  // options
  interval: 500,
  dispMax: 20,
  listTagName: 'div',
  prefix: false,
  ignoreCase: true,
  highlight: false,
  dispAllKey: false,
  classMouseOver: 'over',
  classSelect: 'select',
  hookBeforeSearch: function(){},

  setOptions: function(options) {
    Suggest.copyProperties(this, options);
  },

  inputBlur: function() {

    this.changeUnactive();
    this.oldText = this.getInputText();

    if (this.timerId) clearTimeout(this.timerId);
    this.timerId = null;

    setTimeout(this._bind(this.clearSuggestArea), 500);
  },

  checkLoop: function() {
    var text = this.getInputText();
    if (text != this.oldText) {
      this.oldText = text;
      this.search();
    }
    if (this.timerId) clearTimeout(this.timerId);
    this.timerId = setTimeout(this._bind(this.checkLoop), this.interval);
  },

  search: function() {

    // init
    this.clearSuggestArea();

    var text = this.getInputText();

    if (text == '' || text == null) return;

    this.hookBeforeSearch(text);
    var resultList = this._search(text);
    if (resultList != 0) this.createSuggestArea(resultList);
  },

  _search: function(text) {

    var resultList = [];
    var temp; 
    this.suggestIndexList = [];

    for (var i = 0, length = this.candidateList.length; i < length; i++) {
      if ((temp = this.isMatch(this.candidateList[i], text)) != null) {
        resultList.push(temp);
        this.suggestIndexList.push(i);

        if (this.dispMax != 0 && resultList.length >= this.dispMax) break;
      }
    }
    return resultList;
  },

  isMatch: function(value, pattern) {

    if (value == null) return null;

    var pos = (this.ignoreCase) ?
      value.toLowerCase().indexOf(pattern.toLowerCase())
      : value.indexOf(pattern);

    if ((pos == -1) || (this.prefix && pos != 0)) return null;

    if (this.highlight) {
      return (this._escapeHTML(value.substr(0, pos)) + '<strong>' 
             + this._escapeHTML(value.substr(pos, pattern.length)) 
               + '</strong>' + this._escapeHTML(value.substr(pos + pattern.length)));
    } else {
      return this._escapeHTML(value);
    }
  },

  clearSuggestArea: function() {
    this.suggestArea.innerHTML = '';
    this.suggestArea.style.display = 'none';
    this.suggestList = null;
    this.suggestIndexList = null;
    this.activePosition = null;
  },

  createSuggestArea: function(resultList) {

    this.suggestList = [];
    this.inputValueBackup = this.input.value;

    for (var i = 0, length = resultList.length; i < length; i++) {
      var element = document.createElement(this.listTagName);
      element.innerHTML = resultList[i];
      this.suggestArea.appendChild(element);

      this._addEvent(element, 'click', this._bindEvent(this.listClick, i));
      this._addEvent(element, 'mouseover', this._bindEvent(this.listMouseOver, i));
      this._addEvent(element, 'mouseout', this._bindEvent(this.listMouseOut, i));

      this.suggestList.push(element);
    }

    this.suggestArea.style.display = '';
  },

  getInputText: function() {
    return this.input.value;
  },

  setInputText: function(text) {
    this.input.value = text;
  },

  // key event
  keyEvent: function(event) {

    if (!this.timerId) {
      this.timerId = setTimeout(this._bind(this.checkLoop), this.interval);
    }

    if (this.dispAllKey && event.ctrlKey 
        && this.getInputText() == ''
        && !this.suggestList
        && event.keyCode == Suggest.Key.DOWN) {
      // dispAll
      this._stopEvent(event);
      this.keyEventDispAll();
    } else if (event.keyCode == Suggest.Key.UP ||
               event.keyCode == Suggest.Key.DOWN) {
      // key move
      if (this.suggestList && this.suggestList.length != 0) {
        this._stopEvent(event);
        this.keyEventMove(event.keyCode);
      }
    } else if (event.keyCode == Suggest.Key.RETURN) {
      // fix
      if (this.suggestList && this.suggestList.length != 0) {
        this._stopEvent(event);
        this.keyEventReturn();
      }
    } else if (event.keyCode == Suggest.Key.ESC) {
      // cancel
      if (this.suggestList && this.suggestList.length != 0) {
        this._stopEvent(event);
        this.keyEventEsc();
      }
    } else {
      this.keyEventOther(event);
    }
  },

  keyEventDispAll: function() {

    // init
    this.clearSuggestArea();

    this.oldText = this.getInputText();

    this.suggestIndexList = [];
    for (var i = 0, length = this.candidateList.length; i < length; i++) {
      this.suggestIndexList.push(i);
    }

    this.createSuggestArea(this.candidateList);
  },

  keyEventMove: function(keyCode) {

    this.changeUnactive();

    if (keyCode == Suggest.Key.UP) {
      // up
      if (this.activePosition == null) {
        this.activePosition = this.suggestList.length -1;
      }else{
        this.activePosition--;
        if (this.activePosition < 0) {
          this.activePosition = null;
          this.input.value = this.inputValueBackup;
          return;
        }
      }
    }else{
      // down
      if (this.activePosition == null) {
        this.activePosition = 0;
      }else{
        this.activePosition++;
      }

      if (this.activePosition >= this.suggestList.length) {
        this.activePosition = null;
        this.input.value = this.inputValueBackup;
        return;
      }
    }

    this.changeActive(this.activePosition);
  },

  keyEventReturn: function() {

    this.clearSuggestArea();
    this.moveEnd();
  },

  keyEventEsc: function() {

    this.clearSuggestArea();
    this.input.value = this.inputValueBackup;
    this.oldText = this.getInputText();

    if (window.opera) setTimeout(this._bind(this.moveEnd), 5);
  },

  keyEventOther: function(event) {},

  changeActive: function(index) {

    this.setStyleActive(this.suggestList[index]);

    this.setInputText(this.candidateList[this.suggestIndexList[index]]);

    this.oldText = this.getInputText();
    this.input.focus();
  },

  changeUnactive: function() {

    if (this.suggestList != null 
        && this.suggestList.length > 0
        && this.activePosition != null) {
      this.setStyleUnactive(this.suggestList[this.activePosition]);
    }
  },

  listClick: function(event, index) {

    this.changeUnactive();
    this.activePosition = index;
    this.changeActive(index);

    this.moveEnd();
  },

  listMouseOver: function(event, index) {
    this.setStyleMouseOver(this._getEventElement(event));
  },

  listMouseOut: function(event, index) {

    if (!this.suggestList) return;

    var element = this._getEventElement(event);

    if (index == this.activePosition) {
      this.setStyleActive(element);
    }else{
      this.setStyleUnactive(element);
    }
  },

  setStyleActive: function(element) {
    element.className = this.classSelect;
  },

  setStyleUnactive: function(element) {
    element.className = '';
  },

  setStyleMouseOver: function(element) {
    element.className = this.classMouseOver;
  },

  moveEnd: function() {

    if (this.input.createTextRange) {
      this.input.focus(); // Opera
      var range = this.input.createTextRange();
      range.move('character', this.input.value.length);
      range.select();
    } else if (this.input.setSelectionRange) {
      this.input.setSelectionRange(this.input.value.length, this.input.value.length);
    }
  },

  // Utils
  _getElement: function(element) {
    return (typeof element == 'string') ? document.getElementById(element) : element;
  },
  _addEvent: (window.addEventListener ?
    function(element, type, func) {
      element.addEventListener(type, func, false);
    } :
    function(element, type, func) {
      element.attachEvent('on' + type, func);
    }),
  _stopEvent: function(event) {
    if (event.preventDefault) {
      event.preventDefault();
      event.stopPropagation();
    } else {
      event.returnValue = false;
      event.cancelBubble = true;
    }
  },
  _getEventElement: function(event) {
    return event.target || event.srcElement;
  },
  _bind: function(func) {
    var self = this;
    var args = Array.prototype.slice.call(arguments, 1);
    return function(){ func.apply(self, args); };
  },
  _bindEvent: function(func) {
    var self = this;
    var args = Array.prototype.slice.call(arguments, 1);
    return function(event){ event = event || window.event; func.apply(self, [event].concat(args)); };
  },
  _escapeHTML: function(value) {
    return value.replace(/\&/g, '&amp;').replace( /</g, '&lt;').replace(/>/g, '&gt;')
             .replace(/\"/g, '&quot;').replace(/\'/g, '&#39;');
  }
};

/*-- Suggest.LocalMulti ---------------------------------*/
Suggest.LocalMulti = function() {
  this.initialize.apply(this, arguments);
};
Suggest.copyProperties(Suggest.LocalMulti.prototype, Suggest.Local.prototype);

Suggest.LocalMulti.prototype.delim = ' '; // delimiter

Suggest.LocalMulti.prototype.keyEventReturn = function() {

  this.clearSuggestArea();
  this.input.value += this.delim;
  this.moveEnd();
};

Suggest.LocalMulti.prototype.keyEventOther = function(event) {

  if (event.keyCode == Suggest.Key.TAB) {
    // fix
    if (this.suggestList && this.suggestList.length != 0) {
      this._stopEvent(event);

      if (!this.activePosition) {
        this.activePosition = 0;
        this.changeActive(this.activePosition);
      }

      this.clearSuggestArea();
      this.input.value += this.delim;
      if (window.opera) {
        setTimeout(this._bind(this.moveEnd), 5);
      } else {
        this.moveEnd();
      }
    }
  }
};

Suggest.LocalMulti.prototype.listClick = function(event, index) {

  this.changeUnactive();
  this.activePosition = index;
  this.changeActive(index);

  this.input.value += this.delim;
  this.moveEnd();
};

Suggest.LocalMulti.prototype.getInputText = function() {

  var pos = this.getLastTokenPos();

  if (pos == -1) {
    return this.input.value;
  } else {
    return this.input.value.substr(pos + 1);
  }
};

Suggest.LocalMulti.prototype.setInputText = function(text) {

  var pos = this.getLastTokenPos();

  if (pos == -1) {
    this.input.value = text;
  } else {
    this.input.value = this.input.value.substr(0 , pos + 1) + text;
  }
};

Suggest.LocalMulti.prototype.getLastTokenPos = function() {
  return this.input.value.lastIndexOf(this.delim);
};



// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// Yahoo JavaScript åœ°å›³ V3 ç¸®å°ºè¨ˆç®—
// getLayer({width: 800, height: 400}, {lat: 35.0000, lng: 134.000}, {lat: 35.0001, lng: 134.0001});
var YMAP_SCALES = [750, 1500, 3000, 6000, 8000, 16000, 21000, 40000, 75000, 150000, 300000, 480000, 750000, 1500000, 3000000, 6000000, 12000000, 24000000, 48000000];
function getLayer(size, minLatLng, maxLatLng) {
    var ret = getDistance(minLatLng, maxLatLng);
    // Yahoo JavaScript åœ°å›³ V3 ã«ãŠã„ã¦ã€1/1ã®ç¸®å°ºã¨ã™ã‚‹ã¨ 1m = 3000px
    var fraction_x = ret.x * 3000 / size.width;
    var fraction_y = ret.y * 3000 / size.height;
    var fraction = Math.max(fraction_x, fraction_y);
    for(var i=0; i < YMAP_SCALES.length; i++) {
	var scale = YMAP_SCALES[i];
	var layer = i + 1;
	if(scale > fraction)
	    return layer;
    }
    return YMAP_SCALES.length;
}

// 2ç‚¹é–“ã®è·é›¢ã‚’è¨ˆç®—
// var ret = getDistance(latlng1, latlng2);
function getDistance(latlng1, latlng2) {
    var A = 6378137;
    var dx = A * toRadian(latlng2.lng - latlng1.lng) * Math.cos(toRadian(latlng1.lat));
    var dy = A * toRadian(latlng2.lat - latlng1.lat);
    var l = Math.sqrt(dx * dx + dy * dy);
    var theta = Math.atan(dy / dx);
    return {x:Math.abs(dx), y:Math.abs(dy), l:l, theta:theta};
}

function toRadian(angle) {
    return (Math.PI / 180.0 * angle);
}

// æ¤œç´¢åœ°å›³
function appendMap(mapId, lat, lng, layer, callback) {
    loadScript('yahoomap', 'http://map.yahooapis.jp/MapsService/js/V3/?appid=kawaraban');
    wait('YahooMapsCtrl', function() {
	var ymap = new YahooMapsCtrl(mapId, lat + ", " + lng, layer, YMapMode.MAP, YDatumType.WGS84);
	callback(ymap);
    });
}

// ã‚¹ã‚¯ãƒªãƒ—ãƒˆã®èª­ã¿è¾¼ã¿
function loadScript(id, url) {
    var script = $('#'+id);
    if(script.length > 0) return false;
    script = $('<script type="text/javascript"></script>');
    script.attr('id', id);
    script.attr('src', url);
    script.appendTo('body');
    return true;
}

// è§’åº¦ã‚’æ–¹è§’ã«å¤‰æ›
// åŒ—ã‚’0åº¦ã¨ã—ã€æ™‚è¨ˆå›žã‚Šã«
function degrees2direction(degree) {
    if(degree > 337.5 || degree <= 22.5) 
	return "åŒ—";
    else if (22.5 < degree && degree <= 67.5)
	return "åŒ—æ±";
    else if (67.5 < degree && degree <= 112.5)
	return "æ±";
    else if (112.5 < degree && degree <= 157.5)
	return "å—æ±";
    else if (157.5 < degree && degree <= 202.5)
	return "å—";
    else if (202.5 < degree && degree <= 247.5)
	return "å—è¥¿";
    else if (247.5 < degree && degree <= 292.5)
	return "è¥¿";
    else
	return "åŒ—è¥¿";
}

// Cookieèª­ã¿æ›¸ã
// setCookie('query', 'ã‚­ãƒ¼ï¼‘=å€¤ï¼‘&ã‚­ãƒ¼ï¼’=å€¤ï¼’')
// getCookie('query');  => "ã‚­ãƒ¼ï¼‘=å€¤ï¼‘&ã‚­ãƒ¼ï¼’=å€¤ï¼’"
function getCookie(key){
    var str = " " + document.cookie + ';';
    var last = 0;
    var next = 0;
    var len = str.length;
    while(last < len){
	next = str.indexOf(';', last);
	var record = str.substring(last + 1, next);  // ; ã®1æ–‡å­—å‰ã¾ã§å–ã‚Šå‡ºã™
	var index = record.indexOf('=');
	if(record.substring(0, index) == key){
	    return(unescape(record.substring(index + 1, record.length)));
	}
	last = next + 1;
    }
    return('');
}

// setCookie(ã‚­ãƒ¼, å€¤, æ°¸ç¶šãƒ•ãƒ©ã‚°);
// ç¬¬3å¼•æ•°ã«æ•°å€¤ã‚’è¨­å®šã™ã‚‹ã¨ã€æ•°å€¤åˆ†å¾Œã¾ã§ã®Cookieã¨ãªã‚‹
function setCookie(key, val, permanent){
    if(typeof(val) == 'undefined' || val == null)
	val = '';
    var str = key + '=' + escape(val) + '; ';
    if(typeof(permanent) == 'boolean' && permanent == true){
	str += 'expires=Tue, 31-Dec-2030 23:59:59; ';
    }else if(typeof(permanent) == 'number'){
	var date = new Date();
	date.setTime(date.getTime() + permanent * 60 * 1000);
	var year = date.getYear();
	if(year < 1900)
	    year += 1900;
	
	var Mname = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
	var Dname = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	if(day < 10)
	    day = '0'+day;
	if(hour < 10)
	    hour = '0'+hour;
	if(minute < 10)
	    minute = '0'+minute;
	if(second < 10)
	    second = '0'+second;
	
	str += 'expires='+Dname[date.getDay()]+', '+day+'-'+Mname[date.getMonth()]+'-'+year+' '+hour+':'+minute+':'+second+'; ';
    }
    document.cookie = str;
}

function saveCurrentUrl(name){
    name = name || 'backurl';
    setCookie(name, window.location.href);
}

function wait(a,func){
  var check = 0;
  try{
    eval("check = " + a);
  }catch(e){
  }
  if(check){
    func()
  }else{
    var f = function(){wait(a,func)};
    setTimeout(f,100);
  }
}

function request(id, url, callback) {
    var query = $('#'+id).serialize();
    startLoading();
    $.ajax({
        type: "GET",
        url: url,
        data: query,
        dataType: "script",
        success: function(msg) {
            endLoading();
            if(typeof(callback) == 'function')
		callback();
        },
        error: function(msg) {
            endLoading();
        }
    });
}

function through_enter(event) {
    if(event.keyCode == 13) {
        return false;
    } else {
        return true;
    }
}

function catchEnter(event) {
    return !through_enter(event);
}

var startLoading = function(){
    $('#loading').css('display', 'block');
};

var endLoading = function(){
    $('#loading').css('display', 'none');
}

/* ã‚¿ã‚°ã‚ªãƒ¼ãƒˆã‚³ãƒ³ãƒ—ãƒªãƒ¼ãƒˆåˆæœŸåŒ– */
function setupTagSuggest(id, auto_complete_id, items) {
    if($('#' + auto_complete_id).length > 0) {
        new Suggest.LocalMulti(id,
                               auto_complete_id,
                               items,
                               {
                                   interval: 100,
                                   delim: ' '
                               })
    }
}

/* ã‚¿ã‚°ç·¨é›† */
function updateTag(container, url) {
    var divs = document.getElementsByClassName('tag', document.getElementById(container), 'div') || [];
    var tags = [];
    for(var i = 0; i < divs.length; i++) {
        tags.push(divs[i].innerHTML);
    }
    var token = $('input[@name="authenticity_token"]').val();
    startLoading();
    $.ajax({
        type: "PUT",
        url: url,
        data: 'tag='+encodeURI(tags.join(' ')) + '&authenticity_token=' + token,
        dataType: "script",
        success: function(msg) {
            endLoading();
        },
        error: function(msg) {
            endLoading();
        }
    });
}

function addTagFromField(source, container) {
    var newTag = $('#' + source).val();
    var tags = newTag.replace('ã€€', ' ').split(' ');
    for(var i = 0; i < tags.length; i++) {
	addTag(tags[i], container);
    }
    $('#' + source).val('');
}

function addTag(tag, container) {
    var escapedTag = tag.replace('<', '&lt;').replace('>', '&gt;').replace('ã€€', ' ').replace(' ', '');
    if(escapedTag.length == 0) return;

    var tagDiv = document.createElement('div');
    tagDiv.id = tag;
    if($('#' + tag).length > 0) return;

    var data = document.createElement('div');
    data.style.width = '150px';
    try{data.style.styleFloat = 'left';}catch(e){};
    try{data.style.cssFloat = 'left';}catch(e){};
    data.className = 'tag';
    data.innerHTML = escapedTag;
    tagDiv.appendChild(data);

    var button = document.createElement('input');
    button.type = 'button';
    button.value = "å‰Šé™¤";
    $(button).click(function(){removeTag(tag);});
    tagDiv.appendChild(button);

    $('#' + container).append(tagDiv);
}

function removeTag(tag) {
    $('#' + tag).remove();
}

document.getElementsByClassName = function(className, pElement, tagName){
    var d = document, nodes = [], item;
    try { // XPathã‚’ã‚µãƒãƒ¼ãƒˆã—ã¦ã„ã‚‹ãªã‚‰ã“ã‚Œã‚’ä½¿ã†
        var xp = d.evaluate(
            './/'+(tagName || '*')+'[contains(concat(" ", @class, " "), " '+className+' ")]',
            (pElement || d), null, XPathResult.ANY_TYPE, null
        );
        for (item = xp.iterateNext(); item; item = xp.iterateNext()){
            nodes.push(item);
        }
    } catch(e){ // ãã†ã§ãªã‘ã‚Œã°åœ°é“ã«DOMè§£æž
        var cls, items = (pElement || d).getElementsByTagName((tagName || '*'));
        for(var i = 0, l = items.length; i < l; i++){
            item = items[i];
            if(item.className){
                cls = item.className.split(/Â¥s+/);
                for(var j = 0, k = cls.length; j < k; j++){
                    if(cls[j]==className){
			nodes[nodes.length] = item; break;
                    }
                }
            }
        }
    }
    return nodes.length > 0 ? nodes : null;
}

function createPopupWindow(url, w, h) {
        switch (arguments.length) {
   case 1: w = 800;
   case 2: h = 600;
 }

        x = (screen.width - w) / 2;
        y = (screen.height - h) / 2;
  obj = window.open(url, "popup", 'width='+w+',height='+h+',scrollbars=yes');
        obj.moveTo(x,y);
  obj.focus();

  return false;
}

// submitã‚’æŠ¼ã—ãŸçµæžœã‚’ãƒãƒƒãƒ—ã‚¢ãƒƒãƒ—ã‚¦ã‚¤ãƒ³ãƒ‰ã‚¦ã«è¡¨ç¤º
function withPopupWindow(obj) {
        switch (arguments.length) {
   case 1: w = 800;
   case 2: h = 600;
 }
 x = (screen.width - w) / 2;
        y = (screen.height - h) / 2;
  wobj = window.open("", "popup", 'width='+w+',height='+h+',scrollbars=yes');
  obj.target = "popup";
  wobj.focus();
  return false;
}

function update_hours(target_field_id, hour_field_id, minute_field_id) {
    if($('#'+hour_field_id).val() == '') {
        $('#'+target_field_id).val('');
    } else {
        $('#'+target_field_id).val($('#'+hour_field_id).val() * 60 + $('#'+minute_field_id).val() * 1);
    }
}


function floatToMapFan(value) {
    var di = Math.floor(value);
    var dd = value - di;
    var dm = dd * 60;
    var ds = (dd * 60 - Math.floor(dm)) * 60
    dms = (dd * 60 * 60 - Math.floor(dm) * 60 - Math.floor(ds)) * 60

    var mapfan = "" + di + "." + Math.floor(dm) + "." + Math.floor(ds) + "." + Math.floor(dms)
    return mapfan;
}

function sendKoKoMail(data) {
    var title = data['title'] || "";
    var mapFanLat = floatToMapFan(data['lat']);
    var mapFanLng = floatToMapFan(data['lng']);
    var kokoUrl = "http://kokomail.mapfan.com/receivew.cgi?MAP=E"+mapFanLng+"N"+mapFanLat+"&ZM=9&CI=R";
    top.window.location.href = "mailto:?subject=" + title + "&body=" + kokoUrl;
}

function tabPagination(scrollTo, url){
    startLoading();
    $.ajax({
        type: "GET",
        url: url,
        dataType: "script",
        success: function(msg) {
            endLoading();
	    $('#'+scrollTo).ScrollTo(1000, 'easeout');
        },
        error: function(msg) {
            endLoading();
	    $('#'+scrollTo).ScrollTo(1000, 'easeout');
        }
    });
}

// ãƒ­ã‚°ã‚¤ãƒ³ãƒã‚§ãƒƒã‚¯ãƒ»æ›¸ãæ›ãˆå‡¦ç†
function checkLogin(url, option) {
    $.ajax({
	type: "GET",
	url: url+'?'+(new Date()).getTime(),
	dataType: "json",
	success: function(userdata) {
	    if(userdata.error == 0) {
		if(option.success) option.success(userdata);
	    } else {
		if(option.failure) option.failure(userdata);
	    }
	}
    });
}

// HTML ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—
function escapeHTML(str) {
    var tmp = str;
    tmp = tmp.replace('<', '&lt;');
    tmp = tmp.replace('>', '&gt;');
    return tmp;
}