/**
 * jQuery Cache
 * The following creates a cache of common jQuery selectors for enormously faster execution.
 * Cache can be accessed from the $c or cQuery objects which are basically synonymous of each other.
 * The name of the object starts with "$" to signify that it refers to a jQuery selector.
 * This optimizes the speed of the script enormously since we are working with these selectors very often.
 * --
 * To cache a selector, simply choose an unused property of $c.
 * Ex: $c.specialTools = jQuery("ul.specialtools");
 * To use it, simply substitute its jQuery() counterpart.
 * Ex: $c.specialTools.toogleClass('hide');
 */
$c = {};
var cQuery = $c,
	_ = jQuery; //alias for jQuery;

$c.window = _(window);
$c.document = _(document);
$c.nothing = _();

_( function() {
	//The following creates two new objects for each header module.  $c.n for each nav item and $c.b for each dropdown. Each property stores the jQuery selector for its corresponding id.
	// Usage:
	// $c.b.spots and $c.b['spots'] are the same as $("#b_spots")
	// Example; to hide or show the spots dropdown:
	// $c.b.spots.toggleClass('hide');
	// OR
	// var daModule = "spots";
	// $c.b[daModule].toggleClass('hide');
	// NOTE: jQuery($c.b.spots) also works; however, it is redundant, unneccisary, and less fast than $c.b.spots
	var TNHmodules = getTNHmodules();
	var count = 0; $c.n = {}; $c.b = {};
	$c.init = function() {
		while (count < TNHmodules.length) {
			$c.n[TNHmodules[count]] = _("#n_"+TNHmodules[count]);
			$c.b[TNHmodules[count]] = _("#b_"+TNHmodules[count]);
			count++;
		}
		$c.n.switcher2 = _("#n2_switcher");

		//Working with all dropdowns
		$c.headd = _('#headd');
		$c.allDropBoxes = _("div.downer");
		$c.staticDropBoxes = _("div.downer[id^=b_i]").add("#b_switcher");
		$c.allDropBoxForms = _("form","div.downer");
		$c.downerOverlay = _('#downerOverlay');
		//Working with all dropdown toggles
		$c.allNavToggles = _("li[id^=n_], div[id^=n_]","#headd");
		$c.rightToggles = _("li[id^=n_]",".icons");
		$c.logoo = _("#logoo");
		//Mainly for instances where a click-to-login or click-to-signup is initiated.
		$c.goLogin = _(".goLogin");
		$c.goSignUp = _(".goSignUp");
		$c.onSuccess = _("input.onSuccess");
		$c.onSuccess.val("");
		//AJAX autocomplete...
		$c.searchSpotsInput = _("#searchSpotsInput");
		$c.searchGroupsInput = _("input","#GROUPsearchform");
		//input fields that have pretty labels
		$c.prettyInputs = _("input","label.fieldname");

		//Set dropdown DIV positions
		$c.allNavToggles.each(function(index) {
			var curModule = this.id.substring(2);
			if (curModule != "isettings" && curModule != "ilogin" && curModule != "switcher") {
				Pos = $c.n[curModule].position().left - 9;
				$c.b[curModule].css("left",Pos+"px");
			} else if (curModule == "ilogin") {
				Pos = $c.n["isettings"].width() + ($c.n["isettings"].css("padding-right").replace("px","") * 2) + 3;
				if (_.browser.opera) Pos = 43;
				$c.b[curModule].css("right",Pos+"px");
			}
		});

	}
	$c.init();
	//------------------Finished caching.
});
;
(function($){$.toJSON=function(o)
{if(typeof(JSON)=='object'&&JSON.stringify)
return JSON.stringify(o);var type=typeof(o);if(o===null)
return"null";if(type=="undefined")
return undefined;if(type=="number"||type=="boolean")
return o+"";if(type=="string")
return $.quoteString(o);if(type=='object')
{if(typeof o.toJSON=="function")
return $.toJSON(o.toJSON());if(o.constructor===Date)
{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array)
{var ret=[];for(var i=0;i<o.length;i++)
ret.push($.toJSON(o[i])||"null");return"["+ret.join(",")+"]";}
var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number")
name='"'+k+'"';else if(type=="string")
name=$.quoteString(k);else
continue;if(typeof o[k]=="function")
continue;var val=$.toJSON(o[k]);pairs.push(name+":"+val);}
return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);return eval("("+src+")");};$.secureEvalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
return eval("("+src+")");else
throw new SyntaxError("Error parsing JSON, source is not valid.");};$.quoteString=function(string)
{if(string.match(_escapeable))
{return'"'+string.replace(_escapeable,function(a)
{var c=_meta[a];if(typeof c==='string')return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};})(jQuery);
;(function(jQuery){jQuery.fn.__bind__=jQuery.fn.bind;jQuery.fn.__unbind__=jQuery.fn.unbind;jQuery.fn.__find__=jQuery.fn.find;var hotkeys={version:'0.7.9',override:/keypress|keydown|keyup/g,triggersMap:{},specialKeys:{27:'esc',9:'tab',32:'space',13:'return',8:'backspace',145:'scroll',20:'capslock',144:'numlock',19:'pause',45:'insert',36:'home',46:'del',35:'end',33:'pageup',34:'pagedown',37:'left',38:'up',39:'right',40:'down',109:'-',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12',191:'/'},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"},newTrigger:function(type,combi,callback){var result={};result[type]={};result[type][combi]={cb:callback,disableInInput:false};return result;}};hotkeys.specialKeys=jQuery.extend(hotkeys.specialKeys,{96:'0',97:'1',98:'2',99:'3',100:'4',101:'5',102:'6',103:'7',104:'8',105:'9',106:'*',107:'+',109:'-',110:'.',111:'/'});jQuery.fn.find=function(selector){this.query=selector;return jQuery.fn.__find__.apply(this,arguments);};jQuery.fn.unbind=function(type,combi,fn){if(jQuery.isFunction(combi)){fn=combi;combi=null;}
if(combi&&typeof combi==='string'){var selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();var hkTypes=type.split(' ');for(var x=0;x<hkTypes.length;x++){delete hotkeys.triggersMap[selectorId][hkTypes[x]][combi];}}
return this.__unbind__(type,fn);};jQuery.fn.bind=function(type,data,fn){var handle=type.match(hotkeys.override);if(jQuery.isFunction(data)||!handle){return this.__bind__(type,data,fn);}
else{var result=null,pass2jq=jQuery.trim(type.replace(hotkeys.override,''));if(pass2jq){result=this.__bind__(pass2jq,data,fn);}
if(typeof data==="string"){data={'combi':data};}
if(data.combi){for(var x=0;x<handle.length;x++){var eventType=handle[x];var combi=data.combi.toLowerCase(),trigger=hotkeys.newTrigger(eventType,combi,fn),selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();trigger[eventType][combi].disableInInput=data.disableInInput;if(!hotkeys.triggersMap[selectorId]){hotkeys.triggersMap[selectorId]=trigger;}
else if(!hotkeys.triggersMap[selectorId][eventType]){hotkeys.triggersMap[selectorId][eventType]=trigger[eventType];}
var mapPoint=hotkeys.triggersMap[selectorId][eventType][combi];if(!mapPoint){hotkeys.triggersMap[selectorId][eventType][combi]=[trigger[eventType][combi]];}
else if(mapPoint.constructor!==Array){hotkeys.triggersMap[selectorId][eventType][combi]=[mapPoint];}
else{hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length]=trigger[eventType][combi];}
this.each(function(){var jqElem=jQuery(this);if(jqElem.attr('hkId')&&jqElem.attr('hkId')!==selectorId){selectorId=jqElem.attr('hkId')+";"+selectorId;}
jqElem.attr('hkId',selectorId);});result=this.__bind__(handle.join(' '),data,hotkeys.handler)}}
return result;}};hotkeys.findElement=function(elem){if(!jQuery(elem).attr('hkId')){if(jQuery.browser.opera||jQuery.browser.safari){while(!jQuery(elem).attr('hkId')&&elem.parentNode){elem=elem.parentNode;}}}
return elem;};hotkeys.handler=function(event){var target=hotkeys.findElement(event.currentTarget),jTarget=jQuery(target),ids=jTarget.attr('hkId');if(ids){ids=ids.split(';');var code=event.which,type=event.type,special=hotkeys.specialKeys[code],character=!special&&String.fromCharCode(code).toLowerCase(),shift=event.shiftKey,ctrl=event.ctrlKey,alt=event.altKey||event.originalEvent.altKey,mapPoint=null;for(var x=0;x<ids.length;x++){if(hotkeys.triggersMap[ids[x]][type]){mapPoint=hotkeys.triggersMap[ids[x]][type];break;}}
if(mapPoint){var trigger;if(!shift&&!ctrl&&!alt){trigger=mapPoint[special]||(character&&mapPoint[character]);}
else{var modif='';if(alt)modif+='alt+';if(ctrl)modif+='ctrl+';if(shift)modif+='shift+';trigger=mapPoint[modif+special];if(!trigger){if(character){trigger=mapPoint[modif+character]||mapPoint[modif+hotkeys.shiftNums[character]]||(modif==='shift+'&&mapPoint[hotkeys.shiftNums[character]]);}}}
if(trigger){var result=false;for(var x=0;x<trigger.length;x++){if(trigger[x].disableInInput){var elem=jQuery(event.target);if(jTarget.is("input")||jTarget.is("textarea")||jTarget.is("select")||elem.is("input")||elem.is("textarea")||elem.is("select")){return true;}}
result=result||trigger[x].cb.apply(this,[event]);}
return result;}}}};window.hotkeys=hotkeys;return jQuery;})(jQuery);
;//For debug mode:
_(document).bind('keydown', 'Alt+Ctrl+Shift+Z', function(evt) {
   evt.stopPropagation( );
   evt.preventDefault( );
   if (getItById('idebug')) {
       window.location.href = window.location.pathname + "?killdebug";
   } else {
       window.location.href = window.location.pathname + "?debug";
   }
   return false;
});

//For logging in & out:
var combPressed = (_.browser.msie) ? "Alt+Ctrl+L" : "Alt+L";
function loginInit(evt) {
   evt.stopPropagation();
   evt.preventDefault();
   if (!$c.workingCtrlL) {
   	$c.workingCtrlL = true;
   } else {
   	$c.workingCtrlL = false;
   	return false;
   }
   if (getItById('b_ilogin')) {
       $c.goLogin.click();
   } else {
   	 var confirmed = confirm("You pressed "+combPressed+" which is a shortcut for \nlogging in and out of The New Hanoian. \n\nAre you sure you want to log out?");
       if (confirmed) {
           _(getItById('bd_logout')).click();
       }
   }
   return false;
}
_(document).bind('keydown', combPressed, loginInit);

_(function() {
	//Press escape or click the downerOverlay to close a dropBox:
	$c.downerOverlay.click(function(e) {
		e.stopPropagation();
		if (!workingClick) {
			$c.downerOverlay.hide();
			e.preventDefault();
			$a.hideBox();
			$a.resetListeners();
		}
	});
	_(document).bind('keyup', 'esc', function(e) {
		$c.downerOverlay.click();
	});
});
;// ColorBox v1.3.9 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(b,gb){var v="none",t="click",N="LoadedContent",d=false,x="resize.",o="y",u="auto",f=true,M="nofollow",q="on",n="x";function e(a,c){a=a?' id="'+k+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===n?m.width():m.height();return typeof a==="string"?Math.round(a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10)):a}function Q(c){c=b.isFunction(c)?c.call(h):c;return a.photo||c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function cb(){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!==q)a[c]=a[c].call(h);a.rel=a.rel||h.rel||M;a.href=a.href||b(h).attr("href");a.title=a.title||h.title}function db(d){h=d;a=b.extend({},b(h).data(r));cb();if(a.rel!==M){i=b("."+H).filter(function(){return (b(this).data(r).rel||this.rel)===a.rel});g=i.index(h);if(g===-1){i=i.add(h);g=i.length-1}}else{i=b(h);g=0}if(!w){w=F=f;R=h;try{R.blur()}catch(e){}b.event.trigger(hb);a.onOpen&&a.onOpen.call(h);y.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":u}).show();a.w=p(a.initialWidth,n);a.h=p(a.initialHeight,o);c.position(0);S&&m.bind(x+O+" scroll."+O,function(){y.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll."+O)}T.add(I).add(J).add(z).add(U).hide();V.html(a.close).show();c.slideshow();c.load()}var eb={transition:"elastic",speed:300,width:d,initialWidth:"600",innerWidth:d,maxWidth:d,height:d,initialHeight:"450",innerHeight:d,maxHeight:d,scalePhotos:f,scrolling:f,inline:d,html:d,iframe:d,photo:d,href:d,title:d,rel:d,opacity:.9,preloading:f,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:d,loop:f,slideshow:d,slideshowAuto:f,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:d,onLoad:d,onComplete:d,onCleanup:d,onClosed:d,overlayClose:f,escKey:f,arrowKey:f},r="colorbox",k="cbox",hb=k+"_open",P=k+"_load",W=k+"_complete",X=k+"_cleanup",fb=k+"_closed",G=b.browser.msie&&!b.support.opacity,S=G&&b.browser.version<7,O=k+"_IE6",y,j,E,s,Y,Z,ab,bb,i,m,l,K,L,U,T,z,J,I,V,C,D,A,B,h,R,g,a,w,F,c,H=k+"Element";c=b.fn[r]=b[r]=function(c,d){var a=this;if(!a[0]&&a.selector)return a;c=c||{};if(d)c.onComplete=d;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=f}a.each(function(){b(this).data(r,b.extend({},b(this).data(r)||eb,c)).addClass(H)});c.open&&db(a[0]);return a};c.init=function(){var h="hover";m=b(gb);j=e().attr({id:r,"class":G?k+"IE":""});y=e("Overlay",S?"position:absolute":"").hide();E=e("Wrapper");s=e("Content").append(l=e(N,"width:0; height:0"),L=e("LoadingOverlay").add(e("LoadingGraphic")),U=e("Title"),T=e("Current"),J=e("Next"),I=e("Previous"),z=e("Slideshow"),V=e("Close"));E.append(e().append(e("TopLeft"),Y=e("TopCenter"),e("TopRight")),e().append(Z=e("MiddleLeft"),s,ab=e("MiddleRight")),e().append(e("BottomLeft"),bb=e("BottomCenter"),e("BottomRight"))).children().children().css({"float":"left"});K=e(d,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(y,j.append(E,K));s.children().hover(function(){b(this).addClass(h)},function(){b(this).removeClass(h)}).addClass(h);C=Y.height()+bb.height()+s.outerHeight(f)-s.height();D=Z.width()+ab.width()+s.outerWidth(f)-s.width();A=l.outerHeight(f);B=l.outerWidth(f);j.css({"padding-bottom":C,"padding-right":D}).hide();J.click(c.next);I.click(c.prev);V.click(c.close);s.children().removeClass(h);b("."+H).live(t,function(a){if(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)return f;else{db(this);return d}});y.click(function(){a.overlayClose&&c.close()});b(document).bind("keydown",function(b){if(w&&a.escKey&&b.keyCode===27){b.preventDefault();c.close()}if(w&&a.arrowKey&&!F&&i[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();I.click()}else if(b.keyCode===39&&(g<i.length-1||a.loop)){b.preventDefault();J.click()}})};c.remove=function(){j.add(y).remove();b("."+H).die(t).removeData(r).removeClass(H)};c.position=function(f,b){function c(a){Y[0].style.width=bb[0].style.width=s[0].style.width=a.style.width;L[0].style.height=L[1].style.height=s[0].style.height=Z[0].style.height=ab[0].style.height=a.style.height}var e,h=Math.max(m.height()-a.h-A-C,0)/2+m.scrollTop(),g=Math.max(m.width()-a.w-B-D,0)/2+m.scrollLeft();e=j.width()===a.w+B&&j.height()===a.h+A?0:f;E[0].style.width=E[0].style.height="9999px";j.dequeue().animate({width:a.w+B,height:a.h+A,top:h,left:g},{duration:e,complete:function(){c(this);F=d;E[0].style.width=a.w+B+D+"px";E[0].style.height=a.h+A+C+"px";b&&b()},step:function(){c(this)}})};c.resize=function(b){if(w){b=b||{};if(b.width)a.w=p(b.width,n)-B-D;if(b.innerWidth)a.w=p(b.innerWidth,n);l.css({width:a.w});if(b.height)a.h=p(b.height,o)-A-C;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}l.css({height:a.h});c.position(a.transition===v?0:a.speed)}};c.prep=function(o){var d="hidden";function n(t){var o,q,s,n,d=i.length,e=a.loop;c.position(t,function(){function t(){G&&j[0].style.removeAttribute("filter")}if(w){G&&p&&l.fadeIn(100);a.iframe&&b("<iframe frameborder=0"+(a.scrolling?"":" scrolling='no'")+(G?" allowtransparency='true'":"")+"/>").attr({src:a.href,name:(new Date).getTime()}).appendTo(l);l.show();U.show().html(a.title);if(d>1){T.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,d)).show();J[e||g<d-1?"show":"hide"]().html(a.next);I[e||g?"show":"hide"]().html(a.previous);o=g?i[g-1]:i[d-1];s=g<d-1?i[g+1]:i[0];if(a.slideshow){z.show();g===d-1&&!e&&j.is("."+k+"Slideshow_on")&&z.click()}if(a.preloading){n=b(s).data(r).href||s.href;q=b(o).data(r).href||o.href;if(Q(n))b("<img/>")[0].src=n;if(Q(q))b("<img/>")[0].src=q}}L.hide();a.transition==="fade"?j.fadeTo(f,1,function(){t()}):t();m.bind(x+k,function(){c.position(0)});b.event.trigger(W);a.onComplete&&a.onComplete.call(h)}})}if(w){var p,f=a.transition===v?0:a.speed;m.unbind(x+k);l.remove();l=e(N).html(o);l.hide().appendTo(K.show()).css({width:function(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?u:d}).css({height:function(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);K.hide();b("#"+k+"Photo").css({cssFloat:v});S&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==d}).css({visibility:d}).one(X,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(f,0,function(){n(0)}):n(f)}};c.load=function(){var j,d,q,m=c.prep;F=f;h=i[g];a=b.extend({},b(h).data(r));cb();b.event.trigger(P);a.onLoad&&a.onLoad.call(h);a.h=a.height?p(a.height,o)-A-C:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,n)-B-D:a.innerWidth&&p(a.innerWidth,n);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,n)-B-D;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-A-C;a.mh=a.h&&a.h<a.mh?a.h:a.mh}j=a.href;L.show();if(a.inline){e("InlineTemp").hide().insertBefore(b(j)[0]).bind(P+" "+X,function(){b(this).replaceWith(l.children())});m(b(j))}else if(a.iframe)m(" ");else if(a.html)m(a.html);else if(Q(j)){d=new Image;d.onload=function(){var e;d.onload=null;d.id=k+"Photo";b(d).css({margin:u,border:v,display:"block",cssFloat:"left"});if(a.scalePhotos){q=function(){d.height-=d.height*e;d.width-=d.width*e};if(a.mw&&d.width>a.mw){e=(d.width-a.mw)/d.width;q()}if(a.mh&&d.height>a.mh){e=(d.height-a.mh)/d.height;q()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";setTimeout(function(){m(d)},1);i[1]&&(g<i.length-1||a.loop)&&b(d).css({cursor:"pointer"}).click(c.next);if(G)d.style.msInterpolationMode="bicubic"};d.src=j}else e().appendTo(K).load(j,function(c,a,b){m(a==="error"?"Request unsuccessful: "+b.statusText:this)})};c.next=function(){if(!F){g=g<i.length-1?g+1:0;c.load()}};c.prev=function(){if(!F){g=g?g-1:i.length-1;c.load()}};c.slideshow=function(){function f(){z.text(a.slideshowStop).bind(W,function(){d=setTimeout(c.next,a.slideshowSpeed)}).bind(P,function(){clearTimeout(d)}).one(t,function(){e()});j.removeClass(b+"off").addClass(b+q)}var e,d,b=k+"Slideshow_";z.bind(fb,function(){z.unbind();clearTimeout(d);j.removeClass(b+"off "+b+q)});e=function(){clearTimeout(d);z.text(a.slideshowStart).unbind(W+" "+P).one(t,function(){f();d=setTimeout(c.next,a.slideshowSpeed)});j.removeClass(b+q).addClass(b+"off")};if(a.slideshow&&i[1])a.slideshowAuto?f():e()};c.close=function(){if(w){w=d;b.event.trigger(X);a.onCleanup&&a.onCleanup.call(h);m.unbind("."+k+" ."+O);y.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){j.find("iframe").attr("src","about:blank");l.remove();j.add(y).css({opacity:1,cursor:u}).hide();try{R.focus()}catch(c){}setTimeout(function(){b.event.trigger(fb);a.onClosed&&a.onClosed.call(h)},1)})}};c.element=function(){return b(h)};c.settings=eb;b(c.init)})(jQuery,this)
;/*Let's define some variables I'll need later
 */
var	workingClick = 0;

//Get variables
var $_GET = {};
window.location.search.replace(/[?&]+([^=&]+)(=[^&]*)?/gi, function(m,key,value) {
	$_GET[key] = (value === undefined) ? true : value.substring(1);
});
//autoComplete can be used to store information for any autoComplete setup.
var autoComplete = {};
//let's make it easier to create a new autoComplete method
autoComplete.New = function (acMethod) {
	if (typeof acMethod == "object") {
		_.each(acMethod,function(k,v){ autoComplete.New(v); });
		return true;
	}
	autoComplete[acMethod] = {};
	//All AJAX data should be cached. In order for caching to work, we need an object to cache the data to.
	autoComplete[acMethod].cached = {};
	autoComplete[acMethod].cached.content = [];
	autoComplete[acMethod].cached.terms = [];

	autoComplete[acMethod].firstRun = true;
	autoComplete[acMethod].postVars = function(request) { return { 'lookup': request.term, 'type': 'json', 'count': 10, 'skip': 0 }; };
	autoComplete[acMethod].options = {
		focus: function() {
			// prevent value inserted on focus
			return false;
		},
		source: function (request, response) {
			request.term = _.escape(request.term);
			if (!autoComplete[acMethod].firstRun) {
				var matcher = new RegExp(_.ui.autocomplete.escapeRegex(request.term), "i");
				response(_.grep(
					autoComplete[acMethod].cached.content,
					function(value) {
						return matcher.test(value.value);
					}
				));
				if (_.inArray(request.term,autoComplete[acMethod].cached.terms) !== -1) return true;
			}
			autoComplete[acMethod].firstRun = false;

			_.post(
				//URL to post to
				autoComplete[acMethod].postToURL,
				//variables to post
				autoComplete[acMethod].postVars(request),
				//What to do with the data
				function(data){
					autoComplete[acMethod].cached.lastData = data;
					//log(autoComplete.spots.cached.content);
					_.each(data,function(dKey,dVal){
						var addedAlready = false;
						_.each(autoComplete[acMethod].cached.content,function(cKey,cVal){
							if (cVal.href == dVal.href) addedAlready = true;
						});
						if (!addedAlready) autoComplete[acMethod].cached.content.unshift(dVal);
						if (acMethod == "spots" || acMethod == "groups") {
							var addedAlready = false;
							_.each(autoComplete.eventOrganizer.cached.content,function(cKey,cVal){
								if (cVal.href == dVal.href) addedAlready = true;
							});
							if (!addedAlready) autoComplete.eventOrganizer.cached.content.unshift(dVal);
						}
					});
					autoComplete[acMethod].cached.terms.unshift(request.term);
					if (acMethod == "spots" || acMethod == "groups") autoComplete.eventOrganizer.cached.terms.unshift(request.term);
					response(data);
				},
				'json' //type of data
			);
		},
		delay: 10,
		minLength: 2
	};
}
autoComplete.New(['general','spots','groups','eventOrganizer']);

//And now for the options:
autoComplete.spots.postToURL = '/venue/autocomplete_venuename';
autoComplete.groups.postToURL = '/group/autocomplete_groupname';
autoComplete.eventOrganizer.postToURL = '/event/organizer_search';



/* Original 'source' option in case something goes wrong:

		source: function(request, response) {
			request.term = _.escape(request.term);
			if (autoComplete.spots.cache.term == request.term && autoComplete.spots.cache.content) {
				response(autoComplete.spots.cache.content);
			}
			if (new RegExp(autoComplete.spots.cache.term).test(request.term) && autoComplete.spots.cache.content && autoComplete.spots.cache.content.length < 13) {
				var matcher = new RegExp(_.ui.autocomplete.escapeRegex(request.term), "i");
				response(_.grep(autoComplete.spots.cache.content, function(value) {
				return matcher.test(value.value);
				}));
			}
			_.post(
				//URL to post to
				'/venue/autocomplete_venuename',
				//variables to post
				{ 'venuename': request, 'type': 'json', 'count': autoComplete.spots.max, 'skip': autoComplete.spots.start },
				//What to do with the data
				function(data){
					autoComplete.spots.cache.term = request.term;
					autoComplete.spots.cache.content = data;
					response(data);
				},
				'json' //type of data
			);
		},

*/

//Actions will be under this object
$a = {};

var ignoreList = $c.nothing;
function addIgnore(a) {
	ignoreList = ignoreList.add(a);
}
addIgnore(_("[class*=ui-]"));

$c.resetListeners = $c.nothing;
resetListenersInclude = function(a) {
	$c.resetListeners = $c.resetListeners.add(a);
}
resetListenersClear = function(a) {
	$c.resetListeners = $c.nothing;
}

var debugNow = 0;

var FancyForm = {};
FancyForm.start = function () {};

function log(t,p) {
	if (window.console && window.console.log){
		if (p !== undefined) {
			window.console.log(t);
			window.console.log(p);
		} else {
			window.console.log(t);
		}
	}
	return t;
}

//Escape characters plugin
(function() {
escape_re = /[#;&,\.\+\*~':"!\^\$\[\]\(\)=>|\/\\]/;
_.escape = function jQuery$escape(s) {
  var left = s.split(escape_re, 1)[0];
  if (left == s) return s;
  return left + '\\' +
    s.substr(left.length, 1) +
    _.escape(s.substr(left.length+1));
}
})();

//Adds the .unique method to arrays so we can remove all duplicates from an array.
//Ex: var arr = [1,2,3,4,4,3]; Arr = arr.unique(); Arr is now [1,2,3,4]
//Does not work for objects apparently.
Array.prototype.unique = function(){
	var vals = this;
	var uniques = [];
	for(var i=vals.length;i--;){
		var val = vals[i];
		if(typeof val != "object" && _.inArray( val, uniques )===-1){
			uniques.unshift(val);
		}
	}
	return uniques;
}

function startDebug() {
	debugNow = 1;
	return "Debugging mode enabled.";
}
//This will create a cross-browser version of "getElementById"
function getItById(id) {
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}
//Allows top nav items to be directed to their cooresponding pages via double-click
function dblClickNav(list_id_of_href) {
	window.location = _('a',getItById(list_id_of_href)).attr('href');
	return false;
}

function getTNHmodules(official) {
	if (official) {
		var theTNHmodules = ["venue","aska","listing","group","event","propertylisting","job"];
	} else {
		var theTNHmodules = ["spots","aska","listing","group","event","propertylisting","job","isettings","ilogin","switcher"];
	}
	//isettings, ilogin, and switcher are not a modules but they each have drop downs.
	return theTNHmodules;

}
var TNHmodules = [];
TNHmodules = getTNHmodules();

function wClick(dowhat) {
	workingClick = dowhat;
}

//if a node is hidden via display: none, you cannot query it's size.
//This function displays it, gets its size and hides it quickly.
function getHiddenValue(value,of,donthide) {
	_(of).parent().css("display","");
	var returnThis = 0;
	if (value == "outerWidth") {
		returnThis = _(of).outerWidth(true);
	} else if (value == "outerHeight") {
		returnThis = _(of).outerHeight(true);
	}
	if (!donthide) {
		_(of).parent().css("display","none");
	}
	return returnThis;
}

//Checks to see if the anchor is present. If it matches, the callback is activated
if (document.location.hash.split('#')[1] != undefined) {
	$c.anchor = document.location.hash.split('#')[1];
}
$a.checkAnchor = function (anchor,callback) {
	if (typeof anchor == "boolean") {
		if (anchor) return callback(anchor);
	}
	if ($c.anchor) {
		if ($c.anchor == anchor) return callback(anchor);
		return false;
	}
}

$a.bindAnchor = function (anchor,callback) {
	_(document).bind('checkAnchor',function() {
		$a.checkAnchor(anchor,callback);
	});
}
//List of anchors that apply on almost any page.
$a.bindAnchor("goLogin",function(){ $a.goLogin("hsi_username"); });
$a.bindAnchor("goSignUp",function(){ $a.goLogin("hsu_username"); });

_(function() {
	$c.modalBoxes = _("a[rel^=modalBox]");

	$a.colorBoxLoginParams = function (onSuccess) {
		return colorBoxLoginParams = {
			width: getHiddenValue("outerWidth",$c.b.ilogin)+"px",
			height: (getHiddenValue("outerHeight",$c.b.ilogin)+33)+"px",
			inline: true,
			href: "#b_ilogin",
			onOpen: function(){
				if (onSuccess) $c.onSuccess.val(onSuccess);
				$c.b.ilogin.css("right","");
				$c.b.ilogin.css("top","");
				$c.b.ilogin.css("margin","0");
			},
			onClosed: function(){
				$c.init();
			}
		};
	}
	//Initiate colorbox upon click of any rel="modalbox;{...options...}"
	$a.initModalBox = function () {
		$c.modalBoxes.click(function(e) { e.preventDefault(); });
		$c.modalBoxes.each(function(index) {
			var relSplit = _(this).attr('rel').split(';');
			if (relSplit.length > 1) {
				try {
					var theOptions = _.parseJSON(relSplit[1]);
				} catch(e) {
					log("Invalid JSON in "+_(this).attr('rel'));
					return true;
				}
				if (!theOptions.rel) theOptions.rel = 'nofollow';
				if (getItById('b_ilogin') && theOptions.loginRequired && theOptions.iframe) {
					if (!theOptions.hash && !theOptions.location) {
						if (!theOptions.href) theOptions.href = this.href;
						theOptions.hash = "colorbox:"+_.toJSON(theOptions);
					}
					if (!theOptions.hash) theOptions.hash = "";
					if (!theOptions.location) theOptions.location = window.location.pathname+"#"+theOptions.hash;
					theOptions = $a.colorBoxLoginParams(theOptions.location);
				}
				_(this).colorbox(theOptions);
			}
		});
	}
	$a.initModalBox();
	$a.bindAnchor(window.$c.anchor && $c.anchor.startsWith("colorbox:"),function(){
			elem = $c.anchor.split(':'); elem.shift();
			try {
				var theOptions = _.parseJSON(elem.join(':'));
			} catch(e) {
				log("Invalid JSON in anchor: "+$c.anchor);
				return true;
			}
			if (typeof theOptions == "object") {
				if (getItById('b_ilogin') && theOptions.loginRequired && theOptions.iframe) {
					if (!theOptions.hash && !theOptions.location) {
						if (!theOptions.href) theOptions.href = this.href;
						theOptions.hash = "colorbox:"+_.toJSON(theOptions);
					}
					if (!theOptions.hash) theOptions.hash = "";
					if (!theOptions.location) theOptions.location = window.location.pathname+"#"+theOptions.hash;
					theOptions = $a.colorBoxLoginParams(theOptions.location);
				}
				_.fn.colorbox(theOptions);
			}
	});
});
$a.scrollTo = function (jQuerySelector,speed,offset,callback) {
	var $selected = _(jQuerySelector).eq(0);
	if (!callback) callback = function() {};
	if (offset	== undefined)	offset = 0;
	if (speed	== undefined)	speed = 0;
	return _('html, body').last().animate({
		scrollTop: $selected.offset().top+offset
	}, speed,callback);
}

$c.formLockedCache = {};
$a.FormLocked = function (id) {
	if ($c.formLockedCache[id] == true) return true;
	return false;
}
$a.lockForm = function (id) {
	$c.formLockedCache[id] = true;
}
$a.unlockForm = function (id) {
	$c.formLockedCache[id] = false;
}
$a.$methodExists = function (method) {
	return (typeof _()[method] == 'function');
}

//Quickly and easily create a vertically centered div
//ex: _(this).html($a.vCenterDiv.start()+"Processing. Please wait..."+$a.vCenterDiv.end);
$a.vCenterDiv = {};
$a.vCenterDiv.start = function(styles,classes) {
	if (styles === undefined) styles = '';
	if (classes === undefined) classes = '';
	return '<div class="'+classes+'" style="'+styles+' display: table; #position: relative; overflow: hidden;"><div style=" #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;"><div style=" #position: relative; #top: -50%">'
};
$a.vCenterDiv.end = '</div></div></div>';

function propIt(propTypeId, propName, thingClass, thingId, callback) {
	var originalTextID,originalID,params,url;

	url = '/prop/add';
	params = '?proptype_id='+propTypeId+'&thing_class='+thingClass+'&thing_id='+thingId;

	slctr = '#proptype_'+propTypeId+'_'+thingClass+'_id_'+thingId;
	$c.prop = _(slctr);

	originalHTML = $c.prop.html();
	originalTextID = $c.prop.find('span').text();
	originalID = originalTextID.substring(1,originalTextID.length-1);
	$c.prop.html('<img src="/images/icons/indicator.gif" width="16" height="16" />');

	try {
		_.getJSON(
			url+params,
			function (data) { //On success...
				var	numProps = data.numprops,
					admessage = data.additional_message;
				if (numProps == -1) {
					// not logged in - throw up shadow box login
					log("not logged in",admessage);
					_.fn.colorbox($a.colorBoxLoginParams());
					$c.prop.html(originalHTML);
					return false;
				} else if (numProps == -2) {
					// no more fails
					log("no more fails",admessage);
					_.fn.colorbox({href:"/help/no_fails_left.php",iframe:true,height:280,width:500});
					$c.allFailProps = _("div.prop_button[id^=proptype_7]");
					$c.allFailProps.each(function(){
						thisNumProps = _("span",this).text();
						_(this).html(propName + ' <span class="numprops">' + thisNumProps + '</span>');
					});
					$c.prop.html(propName + ' <span class="numprops">(' + originalID + ')</span>');
					$c.allFailProps.css({'text-decoration': 'line-through'});
					return false;
				} else if (numProps == -3) {
					log('invalid thingClass',admessage);
					alert("There was an error on our part. \nWe were unable to process your request.");
					$c.prop.html(originalHTML);
					return false;
				} else if (numProps < 0) {
					log('Unmanaged Error',admessage);
					alert("There was an error on our part. \nWe were unable to process your request.");
					$c.prop.html(originalHTML);
					return false;
				}
				$c.prop.html(propName + ' <span class="numprops">(' + numProps + ')</span>');
				if (typeof callback === 'function') callback(data);
			}
		);
	} catch(e) {
		log("exception: " + e);
	}
}
;_(document).ready(function() {
	function lockDropBox() {
		if ($c.resetListeners) $c.resetListeners.unbind();
		resetListenersClear();
		//Show the invisible overlay (so if the user clicks outside the dropBox, it will close)
		$c.downerOverlay.show();
		//IE6 fix?
		if (_.browser.msie && !_.support.opacity && _.browser.version < 7) {
			$c.downerOverlay.css({
				width: $c.window.width(),
				height: $c.window.height(),
				top: $c.window.scrollTop(),
				left: $c.window.scrollLeft()
			});
		}

		$c.allNavToggles.not($c.n.switcher).not($c.rightToggles).click(function(e) {
			e.preventDefault();
			e.stopPropagation();
			resetListeners();
			dropBox(this.id.substring(2),'1');
		});
		resetListenersInclude($c.allNavToggles.not($c.n.switcher).not($c.rightToggles));

		$c.n.switcher.add($c.rightToggles).click(function(e) {
			e.preventDefault();
			e.stopPropagation();
			if ($c.n[this.id.substring(2)].hasClass("obj_dark") && !$c.b[this.id.substring(2)].hasClass("hide")) {
				hideBox(); resetListeners();
				return;
			} else {
				dropBox(this.id.substring(2),true);
			}
		});
		resetListenersInclude($c.n.switcher.add($c.rightToggles));

		$c.n.switcher2.click(function(e) {
			hideBox(); resetListeners();
		});
		resetListenersInclude($c.n.switcher2);
		setTimeout('wClick(false)',100);
	}

	//the following will activate the toolbar dropBox for the cooresponding module
	function dropBox(BoxModuleToActivate,ForceShow,doFocus) {
		wClick(true);
		if (ForceShow != true && $c.n[BoxModuleToActivate].hasClass("obj_dark") && !$c.b[BoxModuleToActivate].hasClass("hide")) {
			hideBox(); resetListeners();
			return;
		}

		$c.allDropBoxes.not($c.b.ilogin).addClass('hide');
		$c.b.ilogin.parent().css('display','none');
		$c.allNavToggles.removeClass('obj_dark n_selected').addClass('obj_dark_hover');
		$c.b[BoxModuleToActivate].removeClass('hide');
		$c.n[BoxModuleToActivate].addClass('obj_dark').removeClass('obj_dark_hover');

		if (BoxModuleToActivate == "ilogin") {
			$c.b.ilogin.parent().css('display','');
		}

		//Listen for clicks outside of dropped window
		if (ForceShow === true) {
			lockDropBox();
		}
		if (BoxModuleToActivate == "ilogin" && !doFocus) {
			getItById("hsi_username").focus();
		}
	}
	$a.dropBox = function(BoxModuleToActivate,ForceShow,doFocus) { dropBox(BoxModuleToActivate,ForceShow,doFocus); };

	function hideBox() {
		$c.downerOverlay.hide();
		$c.allNavToggles.removeClass('obj_dark n_selected').addClass('obj_dark_hover');
		$c.allDropBoxes.not($c.b.ilogin).addClass('hide');
		$c.b.ilogin.parent().css('display','none');
		if (thisModule == "venue") {
			$c.n.spots.addClass('obj_dark n_selected').removeClass('obj_dark_hover');
		} else if (thisModule != "" && _.inArray(thisModule,getTNHmodules(1)) != -1) {
			$c.n[thisModule].addClass('obj_dark n_selected').removeClass('obj_dark_hover');
		}
	}
	_.hideBox = function() { hideBox(); };
	$a.hideBox = function() { hideBox(); };

	$a.goLogin = function(focusOn) {
		$a.dropBox('ilogin',true,true);
		var callback = function () { };
		if (focusOn) var callback = function () { getItById(focusOn).focus(); };
		_('html, body').last().animate({scrollTop:"0px"}, 'fast', callback);
	};

	function resetListeners() {
		//reset to a fresh start
		if ($c.resetListeners) $c.resetListeners.unbind();
		resetListenersClear();
		//allows the dropbox to be shown if someone hovers over a nav item
		$c.allNavToggles.not($c.n.switcher).not($c.rightToggles).mouseenter(function(e) {
			dropBox(this.id.substring(2),'1');
		});
		resetListenersInclude($c.allNavToggles.not($c.n.switcher).not($c.rightToggles));
		//hide dropBox if mouse leaves the headd
		_($c.headd).mouseleave(function () { _.hideBox(); });
		resetListenersInclude(_($c.headd));
		//allows the site switcher to be shown upon hovering over the logo
		//$c.logoo.mouseenter(function() {
		$c.n.switcher.add($c.rightToggles).click(function(e) {
			e.preventDefault();
			dropBox(this.id.substring(2),true);
		});
		resetListenersInclude($c.n.switcher.add($c.rightToggles));
		$c.n.switcher2.click(function(e) {
			hideBox(); resetListeners();
		});
		resetListenersInclude($c.n.switcher2);

		//If a user clicks an element with goLogin class, open the Login box, move the user to the top of the page, and focus on the Login username field
		$c.goLogin.click(function(e){
			if (!getItById('b_ilogin')) return false;
			e.preventDefault(); $a.goLogin("hsi_username");
		});
		resetListenersInclude($c.goLogin);

		//If a user clicks an element with goSignUp class, open the Login box, move the user to the top of the page, and focus on the Sign up username field
		$c.goSignUp.click(function(e){
			if (!getItById('b_ilogin')) return false;
			e.preventDefault(); $a.goLogin("hsu_username");
		});
		resetListenersInclude($c.goSignUp);

		//if anyone clicks a form element inside a dropBox, lock it so the mouse can move outside the dropBox
		$c.allDropBoxForms.click(function(e){
			e.stopPropagation();
			wClick(true);
			lockDropBox();
		});
		resetListenersInclude($c.allDropBoxForms);
	}
	resetListeners();
	$a.resetListeners = function() { resetListeners(); };

	//Spots AJAX autocomplete
	addIgnore($c.searchSpotsInput);
	autoComplete.spots.options.select = function(event, ui) {
		//This will be initated when the user selects an item.
		var reviewHash = '';
		if (_(getItById('d_spot_review')).hasClass('d_selected')) reviewHash = '#writeReview';
		if (ui.item) window.location = ui.item.href+reviewHash;
	};
	$c.searchSpotsInput.autocomplete(autoComplete.spots.options);

	//Groups AJAX autocomplete
	autoComplete.groups.options.select = function(event, ui) {
		//This will be initated when the user selects an item.
		if (ui.item) window.location = ui.item.href;
	};
	$c.searchGroupsInput.autocomplete(autoComplete.groups.options);

	//watch those input boxes and shift the elements around when one is focused.
	$c.prettyInputs.keydown(function(e) {
	    var keyCode = e.keyCode || e.which;
	    if (keyCode == 9) {
		    _(this).parent().find("span").removeClass("hide");
		    _(this).css("text-align","right");
	    }
	});
	$c.prettyInputs.keypress(function(e) {
	    _(this).parent().find("span").addClass("hide");
	    _(this).css("text-align","left");
	});
	$c.prettyInputs.blur(function() {
	    _(this).parent().find("span").removeClass("hide");
	    _(this).css("text-align","right");
	});
	addIgnore($c.prettyInputs);

});
;/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
;/*!
 * jQuery UI Widget 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b){var j=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add(this).each(function(){b(this).triggerHandler("remove")});return j.call(b(this),a,c)})};b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend({},c.options);b[e][a].prototype=
b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.substring(0,1)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==undefined){h=i;return false}}):this.each(function(){var g=
b.data(this,a);if(g){d&&g.option(d);g._init()}else b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){this.element=b(c).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(c)[this.widgetName],a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();
this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a,e=this;if(arguments.length===0)return b.extend({},e.options);if(typeof a==="string"){if(c===undefined)return this.options[a];d={};d[a]=c}b.each(d,function(f,
h){e._setOption(f,h)});return e},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=
b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);

;/*
 * jQuery UI Position 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Position
 */
(function(c){c.ui=c.ui||{};var m=/left|center|right/,n=/top|center|bottom/,p=c.fn.position,q=c.fn.offset;c.fn.position=function(a){if(!a||!a.of)return p.apply(this,arguments);a=c.extend({},a);var b=c(a.of),d=(a.collision||"flip").split(" "),e=a.offset?a.offset.split(" "):[0,0],g,h,i;if(a.of.nodeType===9){g=b.width();h=b.height();i={top:0,left:0}}else if(a.of.scrollTo&&a.of.document){g=b.width();h=b.height();i={top:b.scrollTop(),left:b.scrollLeft()}}else if(a.of.preventDefault){a.at="left top";g=h=
0;i={top:a.of.pageY,left:a.of.pageX}}else{g=b.outerWidth();h=b.outerHeight();i=b.offset()}c.each(["my","at"],function(){var f=(a[this]||"").split(" ");if(f.length===1)f=m.test(f[0])?f.concat(["center"]):n.test(f[0])?["center"].concat(f):["center","center"];f[0]=m.test(f[0])?f[0]:"center";f[1]=n.test(f[1])?f[1]:"center";a[this]=f});if(d.length===1)d[1]=d[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(a.at[0]==="right")i.left+=g;else if(a.at[0]==="center")i.left+=
g/2;if(a.at[1]==="bottom")i.top+=h;else if(a.at[1]==="center")i.top+=h/2;i.left+=e[0];i.top+=e[1];return this.each(function(){var f=c(this),k=f.outerWidth(),l=f.outerHeight(),j=c.extend({},i);if(a.my[0]==="right")j.left-=k;else if(a.my[0]==="center")j.left-=k/2;if(a.my[1]==="bottom")j.top-=l;else if(a.my[1]==="center")j.top-=l/2;j.left=parseInt(j.left);j.top=parseInt(j.top);c.each(["left","top"],function(o,r){c.ui.position[d[o]]&&c.ui.position[d[o]][r](j,{targetWidth:g,targetHeight:h,elemWidth:k,
elemHeight:l,offset:e,my:a.my,at:a.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(j,{using:a.using}))})};c.ui.position={fit:{left:function(a,b){var d=c(window);b=a.left+b.elemWidth-d.width()-d.scrollLeft();a.left=b>0?a.left-b:Math.max(0,a.left)},top:function(a,b){var d=c(window);b=a.top+b.elemHeight-d.height()-d.scrollTop();a.top=b>0?a.top-b:Math.max(0,a.top)}},flip:{left:function(a,b){if(b.at[0]!=="center"){var d=c(window);d=a.left+b.elemWidth-d.width()-d.scrollLeft();var e=b.my[0]==="left"?
-b.elemWidth:b.my[0]==="right"?b.elemWidth:0,g=-2*b.offset[0];a.left+=a.left<0?e+b.targetWidth+g:d>0?e-b.targetWidth+g:0}},top:function(a,b){if(b.at[1]!=="center"){var d=c(window);d=a.top+b.elemHeight-d.height()-d.scrollTop();var e=b.my[1]==="top"?-b.elemHeight:b.my[1]==="bottom"?b.elemHeight:0,g=b.at[1]==="top"?b.targetHeight:-b.targetHeight,h=-2*b.offset[1];a.top+=a.top<0?e+b.targetHeight+h:d>0?e+g+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(a,b){if(/static/.test(c.curCSS(a,"position")))a.style.position=
"relative";var d=c(a),e=d.offset(),g=parseInt(c.curCSS(a,"top",true),10)||0,h=parseInt(c.curCSS(a,"left",true),10)||0;e={top:b.top-e.top+g,left:b.left-e.left+h};"using"in b?b.using.call(a,e):d.css(e)};c.fn.offset=function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(){c.offset.setOffset(this,a)});return q.call(this)}}})(jQuery);

;/*
 * jQuery UI Autocomplete 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Autocomplete
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	jquery.ui.position.js
 */
(function(e){e.widget("ui.autocomplete",{options:{minLength:1,delay:300},_create:function(){var a=this,b=this.element[0].ownerDocument;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){var d=e.ui.keyCode;switch(c.keyCode){case d.PAGE_UP:a._move("previousPage",c);break;case d.PAGE_DOWN:a._move("nextPage",c);break;case d.UP:a._move("previous",c);c.preventDefault();
break;case d.DOWN:a._move("next",c);c.preventDefault();break;case d.ENTER:a.menu.active&&c.preventDefault();case d.TAB:if(!a.menu.active)return;a.menu.select(c);break;case d.ESCAPE:a.element.val(a.term);a.close(c);break;case d.LEFT:case d.RIGHT:case d.SHIFT:case d.CONTROL:case d.ALT:break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){a.search(null,c)},a.options.delay);break}}).bind("focus.autocomplete",function(){a.selectedItem=null;a.previous=a.element.val()}).bind("blur.autocomplete",
function(c){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)});this._initSource();this.response=function(){return a._response.apply(a,arguments)};this.menu=e("<ul></ul>").addClass("ui-autocomplete").appendTo("body",b).menu({focus:function(c,d){d=d.item.data("item.autocomplete");false!==a._trigger("focus",null,{item:d})&&/^key/.test(c.originalEvent.type)&&a.element.val(d.value)},selected:function(c,d){d=d.item.data("item.autocomplete");false!==a._trigger("select",
c,{item:d})&&a.element.val(d.value);a.close(c);c=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=c}a.selectedItem=d},blur:function(){a.menu.element.is(":visible")&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");e.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");
this.menu.element.remove();e.Widget.prototype.destroy.call(this)},_setOption:function(a){e.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource()},_initSource:function(){var a,b;if(e.isArray(this.options.source)){a=this.options.source;this.source=function(c,d){d(e.ui.autocomplete.filter(a,c.term))}}else if(typeof this.options.source==="string"){b=this.options.source;this.source=function(c,d){e.getJSON(b,c,d)}}else this.source=this.options.source},search:function(a,b){a=
a!=null?a:this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search")!==false)return this._search(a)},_search:function(a){this.term=this.element.addClass("ui-autocomplete-loading").val();this.source({term:a},this.response)},_response:function(a){if(a.length){a=this._normalize(a);this._suggest(a);this._trigger("open")}else this.close();this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);
if(this.menu.element.is(":visible")){this._trigger("close",a);this.menu.element.hide();this.menu.deactivate()}},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){if(a.length&&a[0].label&&a[0].value)return a;return e.map(a,function(b){if(typeof b==="string")return{label:b,value:b};return e.extend({label:b.label||b.value,value:b.value||b.label},b)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+
1),c;this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();this.menu.element.show().position({my:"left top",at:"left bottom",of:this.element,collision:"none"});a=b.width("").width();c=this.element.width();b.width(Math.max(a,c))},_renderMenu:function(a,b){var c=this;e.each(b,function(d,f){c._renderItem(a,f)})},_renderItem:function(a,b){return e("<li></li>").data("item.autocomplete",b).append("<a>"+b.label+"</a>").appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&
/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});e.extend(e.ui.autocomplete,{escapeRegex:function(a){return a.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")},filter:function(a,b){var c=new RegExp(e.ui.autocomplete.escapeRegex(b),"i");return e.grep(a,function(d){return c.test(d.label||d.value||d)})}})})(jQuery);
(function(e){e.widget("ui.menu",{_create:function(){var a=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(b){if(e(b.target).closest(".ui-menu-item a").length){b.preventDefault();a.select(b)}});this.refresh()},refresh:function(){var a=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
-1).mouseenter(function(b){a.activate(b,e(this).parent())}).mouseleave(function(){a.deactivate()})},activate:function(a,b){this.deactivate();if(this.hasScroll()){var c=b.offset().top-this.element.offset().top,d=this.element.attr("scrollTop"),f=this.element.height();if(c<0)this.element.attr("scrollTop",d+c);else c>f&&this.element.attr("scrollTop",d+c-f+b.height())}this.active=b.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",a,{item:b})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");
this._trigger("blur");this.active=null}},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prev().length},last:function(){return this.active&&!this.active.next().length},move:function(a,b,c){if(this.active){a=this.active[a+"All"](".ui-menu-item").eq(0);a.length?this.activate(c,a):this.activate(c,this.element.children(b))}else this.activate(c,this.element.children(b))},nextPage:function(a){if(this.hasScroll())if(!this.active||
this.last())this.activate(a,this.element.children(":first"));else{var b=this.active.offset().top,c=this.element.height(),d=this.element.children("li").filter(function(){var f=e(this).offset().top-b-c+e(this).height();return f<10&&f>-10});d.length||(d=this.element.children(":last"));this.activate(a,d)}else this.activate(a,this.element.children(!this.active||this.last()?":first":":last"))},previousPage:function(a){if(this.hasScroll())if(!this.active||this.first())this.activate(a,this.element.children(":last"));
else{var b=this.active.offset().top,c=this.element.height();result=this.element.children("li").filter(function(){var d=e(this).offset().top-b+c-e(this).height();return d<10&&d>-10});result.length||(result=this.element.children(":first"));this.activate(a,result)}else this.activate(a,this.element.children(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element.attr("scrollHeight")},select:function(a){this._trigger("selected",a,{item:this.active})}})})(jQuery);

;/*
 * jQuery UI Tabs 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 */
(function(d){var s=0,u=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>'},_create:function(){this._tabify(true)},_setOption:function(c,e){if(c=="selected")this.options.collapsible&&e==this.options.selected||
this.select(e);else{this.options[c]=e;this._tabify()}},_tabId:function(c){return c.title&&c.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+ ++s},_sanitizeSelector:function(c){return c.replace(/:/g,"\\:")},_cookie:function(){var c=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++u);return d.cookie.apply(null,[c].concat(d.makeArray(arguments)))},_ui:function(c,e){return{tab:c,panel:e,index:this.anchors.index(c)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var c=
d(this);c.html(c.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function e(g,f){g.css({display:""});!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}this.list=this.element.find("ol,ul").eq(0);this.lis=d("li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);var a=this,b=this.options,h=/^#.+/;this.anchors.each(function(g,f){var j=d(f).attr("href"),l=j.split("#")[0],p;if(l&&(l===location.toString().split("#")[0]||
(p=d("base")[0])&&l===p.href)){j=f.hash;f.href=j}if(h.test(j))a.panels=a.panels.add(a._sanitizeSelector(j));else if(j!="#"){d.data(f,"href.tabs",j);d.data(f,"load.tabs",j.replace(/#.*$/,""));j=a._tabId(f);f.href="#"+j;f=d("#"+j);if(!f.length){f=d(b.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else b.disabled.push(g)});if(c){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(b.selected===undefined){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){b.selected=g;return false}});if(typeof b.selected!="number"&&b.cookie)b.selected=parseInt(a._cookie(),10);if(typeof b.selected!="number"&&this.lis.filter(".ui-tabs-selected").length)b.selected=
this.lis.index(this.lis.filter(".ui-tabs-selected"));b.selected=b.selected||(this.lis.length?0:-1)}else if(b.selected===null)b.selected=-1;b.selected=b.selected>=0&&this.anchors[b.selected]||b.selected<0?b.selected:0;b.disabled=d.unique(b.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(b.selected,b.disabled)!=-1&&b.disabled.splice(d.inArray(b.selected,b.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
if(b.selected>=0&&this.anchors.length){this.panels.eq(b.selected).removeClass("ui-tabs-hide");this.lis.eq(b.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[b.selected],a.panels[b.selected]))});this.load(b.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else b.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));this.element[b.collapsible?"addClass":
"removeClass"]("ui-tabs-collapsible");b.cookie&&this._cookie(b.selected,b.cookie);c=0;for(var i;i=this.lis[c];c++)d(i)[d.inArray(c,b.disabled)!=-1&&!d(i).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");b.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(b.event!="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+g)};this.lis.bind("mouseover.tabs",
function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(b.fx)if(d.isArray(b.fx)){m=b.fx[0];o=b.fx[1]}else m=o=b.fx;var q=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",function(){e(f,o);a._trigger("show",
null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},r=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};this.anchors.bind(b.event+".tabs",
function(){var g=this,f=d(this).closest("li"),j=a.panels.filter(":not(.ui-tabs-hide)"),l=d(a._sanitizeSelector(this.hash));if(f.hasClass("ui-tabs-selected")&&!b.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}b.selected=a.anchors.index(this);a.abort();if(b.collapsible)if(f.hasClass("ui-tabs-selected")){b.selected=-1;b.cookie&&a._cookie(b.selected,b.cookie);a.element.queue("tabs",function(){r(g,
j)}).dequeue("tabs");this.blur();return false}else if(!j.length){b.cookie&&a._cookie(b.selected,b.cookie);a.element.queue("tabs",function(){q(g,l)});a.load(a.anchors.index(this));this.blur();return false}b.cookie&&a._cookie(b.selected,b.cookie);if(l.length){j.length&&a.element.queue("tabs",function(){r(g,j)});a.element.queue("tabs",function(){q(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",
function(){return false})},destroy:function(){var c=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(b,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,
"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});c.cookie&&this._cookie(null,c.cookie);return this},add:function(c,e,a){if(a===undefined)a=this.anchors.length;var b=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,e));c=!c.indexOf("#")?c.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",
true);var i=d("#"+c);i.length||(i=d(h.panelTemplate).attr("id",c).data("destroy.tabs",true));i.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);i.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);i.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");i.removeClass("ui-tabs-hide");
this.element.queue("tabs",function(){b._trigger("show",null,b._ui(b.anchors[0],b.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(c){var e=this.options,a=this.lis.eq(c).remove(),b=this.panels.eq(c).remove();if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(c+(c+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(h){return h!=c}),function(h){return h>=c?--h:h});this._tabify();this._trigger("remove",
null,this._ui(a.find("a")[0],b[0]));return this},enable:function(c){var e=this.options;if(d.inArray(c,e.disabled)!=-1){this.lis.eq(c).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=c});this._trigger("enable",null,this._ui(this.anchors[c],this.panels[c]));return this}},disable:function(c){var e=this.options;if(c!=e.selected){this.lis.eq(c).addClass("ui-state-disabled");e.disabled.push(c);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[c],this.panels[c]))}return this},
select:function(c){if(typeof c=="string")c=this.anchors.index(this.anchors.filter("[href$="+c+"]"));else if(c===null)c=-1;if(c==-1&&this.options.collapsible)c=this.options.selected;this.anchors.eq(c).trigger(this.options.event+".tabs");return this},load:function(c){var e=this,a=this.options,b=this.anchors.eq(c)[0],h=d.data(b,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(b,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(c).addClass("ui-state-processing");
if(a.spinner){var i=d("span",b);i.data("label.tabs",i.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){d(e._sanitizeSelector(b.hash)).html(k);e._cleanup();a.cache&&d.data(b,"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[c],e.panels[c]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[c],e.panels[c]));try{a.ajaxOptions.error(k,n,c,b)}catch(m){}}}));e.element.dequeue("tabs");return this}},
abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},url:function(c,e){this.anchors.eq(c).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.1"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(c,e){var a=this,b=this.options,h=a._rotate||(a._rotate=
function(i){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=b.selected;a.select(++k<a.anchors.length?k:0)},c);i&&i.stopPropagation()});e=a._unrotate||(a._unrotate=!e?function(i){i.clientX&&a.rotate(null)}:function(){t=b.selected;h()});if(c){this.element.bind("tabsshow",h);this.anchors.bind(b.event+".tabs",e);h()}else{clearTimeout(a.rotation);this.element.unbind("tabsshow",h);this.anchors.unbind(b.event+".tabs",e);delete this._rotate;delete this._unrotate}return this}})})(jQuery);
