/* /js/unit/ek/hosted/v1/venues/detail.js */
;(function($,jQuery){/* Copyright Eventful, Inc. All rights reserved except where otherwise noted. */
if(typeof window.Eventful==="undefined"){window.Eventful={};}
if(jQuery&&jQuery.fn.jquery>="1.4"){jQuery.ajaxSettings.traditional=true;}
if(window.console==="undefined"){window.console=(function(){var console={},noOp=function(){},aProps=['assert','count','debug','dir','dirxml','error','group','groupCollapsed','groupEnd','info','log','markTimeline','profile','profileEnd','time','timeEnd','trace','warn'],i,l;for(i=0,l=aProps.length;i<l;i++){console[aProps[i]]=noOp;}
return console;})();}
Eventful.isIE=false/*@cc_on @*//*@if (@_win32) || true/*@end @*/;Eventful.isSafari=navigator&&navigator.userAgent.indexOf('Safari')>0;Eventful.JSCheck=function(){document.body.className+=" has-js";};Eventful.fixKeyCode=function(keyCode){var keyEnter=13;if(Eventful.isSafari&&keyCode===3){return keyEnter;}
if(Eventful.isIE&&keyCode===0){return keyEnter;}
return keyCode;};Eventful.UIEvent=function()
{this.subscribers=[];}
Eventful.UIEvent.prototype.subscribe=function(fnCallback)
{this.subscribers.push(fnCallback);}
Eventful.UIEvent.prototype.fire=function()
{var aArgs=arguments;for(var i=0;i<this.subscribers.length;i++)
{this.subscribers[i].apply(undefined,aArgs);}}
Eventful.TrackPageview=function(oArgs)
{oArgs=oArgs||{};if(typeof oArgs=='string')
{return Eventful.TrackPageview({page:oArgs});}
oArgs.page=oArgs.page||window.location.pathname;oArgs.query=oArgs.query||'';var sQuery=Eventful.TrackPageview.query();if(oArgs.query&&oArgs.page.indexOf('?')>=0)
{oArgs.query='&'+oArgs.query.substring(1);}
if(sQuery&&(oArgs.page.indexOf('?')>=0||oArgs.query))
{sQuery='&'+sQuery.substring(1);}
Eventful.TrackPageview.track(oArgs.page+oArgs.query+sQuery);}
Eventful.TrackPageview.track=function(sPage)
{if(window.pageTracker)
{pageTracker._trackPageview(sPage);}}
Eventful.TrackPageview.trackVirturalEvent=function()
{Eventful.TrackPageview.track('/virtual/event/'+Array.prototype.slice.call(arguments).join('/'));}
Eventful.TrackPageview.trackEvent=function(category,action,optional_label,optional_value)
{if(window.pageTracker)
{pageTracker._trackEvent(category,action,optional_label,optional_value);}}
Eventful.TrackPageview.query=function(sQuery)
{return Eventful.TrackPageview._sQuery=sQuery||Eventful.TrackPageview._sQuery||window.location.search.toLowerCase();}
Eventful.TrackPageview.setParams=function(oParams)
{var aParams=[];for(var sKey in oParams)
{aParams.push(sKey+'='+oParams[sKey]);}
var sQuery=Eventful.TrackPageview.query();Eventful.TrackPageview.query((sQuery?sQuery+'&':'?')+aParams.join('&'));}
Eventful.Forms={};Eventful.Forms.focusFirstField=function(elForm){$(":input",elForm)
.not(':hidden')
.eq(0)
.not('[value],.inactive,:file')
.focus();}
if(!Function.prototype.bind)
{Function.prototype.bind=function(){var __method=this,args=Array.prototype.slice.call(arguments),object=args.shift();return function(){var local_args=args.concat(Array.prototype.slice.call(arguments));if(this!==window)local_args.push(this);return __method.apply(object,local_args);}}}
Function.prototype.mixin=function(fn)
{this.prototype=$.extend(this.prototype,fn.prototype);return this;}
Function.prototype.later=function(msec)
{var fn=this,args=Array.prototype.slice.call(arguments,1);return window.setTimeout(function(){fn.apply(this,args)},msec);}
Function.prototype.slow=function(msec,next){var fn=this,tm;if(next){return function(){if(tm)return;tm=1;fn.apply(this,Array.prototype.slice.call(arguments));(function(){tm=0;}).later(msec);}}else{return function(){if(tm)clearTimeout(tm);tm=(function(args){tm=0;fn.apply(this,args);})
.bind(this,Array.prototype.slice.call(arguments))
.later(msec);}}}
Function.prototype.invert=function()
{return function()
{return!this.call();}.bind(this);};/*
 * SimpleModal 1.1.1 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://plugins.jquery.com/project/SimpleModal
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2007 Eric Martin - http://ericmmartin.com
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Revision: $Id: jquery.simplemodal.js 93 2008-01-15 16:14:20Z emartin24 $
 *
 */
(function($){$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close(true);};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={overlay:50,overlayId:'modalOverlay',overlayCss:{},containerId:'modalContainer',containerCss:{},close:true,closeTitle:'Close',closeClass:'modalClose',persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}
this.opts=$.extend({},$.modal.defaults,options);if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.original=data.clone(true);}}}
else if(typeof data=='string'||typeof data=='number'){data=$('<div>').html(data);}
else{if(console){console.log('SimpleModal Error: Unsupported data type: '+typeof data);}
return false;}
this.dialog.data=data.addClass('modalData');data=null;this.create();this.open();if($.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}
return this;},create:function(){this.dialog.overlay=$('<div>')
.attr('id',this.opts.overlayId)
.addClass('modalOverlay')
.css($.extend(this.opts.overlayCss,{opacity:this.opts.overlay/100,height:'100%',width:'100%',position:'fixed',left:0,top:0,zIndex:10000}))
.hide()
.appendTo('body');this.dialog.container=$('<div>')
.attr('id',this.opts.containerId)
.addClass('modalContainer')
.css($.extend(this.opts.containerCss,{zIndex:10100}))
.append(this.opts.close?'<a class="modalCloseImg '
+this.opts.closeClass
+'" title="'
+this.opts.closeTitle+'"></a>':'')
.hide()
.appendTo('body');if($.browser.msie&&($.browser.version<7)){this.fixIE();}
this.dialog.container.append(this.dialog.data.hide());},bindEvents:function(){var modal=this;$('.'+this.opts.closeClass).click(function(e){e.preventDefault();modal.close();});},unbindEvents:function(){$('.'+this.opts.closeClass).unbind('click');},fixIE:function(){if($(document.body).height()<$(document).height())
{$(document.body).css({height:'100%'});}
var wHeight=$(document.body).height()+'px';var wWidth=$(document.body).width()+'px';this.dialog.overlay.css({position:'absolute',height:wHeight,width:wWidth});this.dialog.container.css({position:'absolute'});this.dialog.iframe=$('<iframe src="javascript:false;">')
.css($.extend(this.opts.iframeCss,{opacity:0,position:'absolute',height:wHeight,width:wWidth,zIndex:1000,width:'100%',top:0,left:0}))
.hide()
.appendTo('body');},open:function(){if(this.dialog.iframe){this.dialog.iframe.show();}
if($.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}
else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}},close:function(external){if(!this.dialog.data){return false;}
if($.isFunction(this.opts.onClose)&&!external){this.opts.onClose.apply(this,[this.dialog]);}
if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}
else{this.dialog.data.remove();this.dialog.original.appendTo(this.dialog.parentNode);}}
else{this.dialog.data.remove();}
this.dialog.container.remove();this.dialog.overlay.remove();if(this.dialog.iframe){this.dialog.iframe.remove();}
this.dialog={};this.unbindEvents();}};})(jQuery);Eventful.Panel=function(id){this.id=id;this.trackingString=null;this.eventShow=new Eventful.UIEvent();this.eventClose=new Eventful.UIEvent();this.eventReady=new Eventful.UIEvent();var fnToggleAds=function(){var ads=$('.rev-gen').filter(function(){return $(this).parents('.panel').length==0?this:null;});ads.toggle();};this.eventShow.subscribe(fnToggleAds);this.eventClose.subscribe(fnToggleAds);}
Eventful.Panel.prototype.panel=function(){if(!this.jqPanel)this.jqPanel=$('#'+this.id);return this.jqPanel;}
Eventful.Panel.prototype.find=function(sExpr){return this.panel().find(sExpr)}
Eventful.Panel.prototype.options=function(oOptions){if(oOptions.tracking_string)
{this.trackingString=oOptions.tracking_string;}
if(oOptions.width)
{oOptions.width=+oOptions.width.toString().replace('px','');oOptions.containerCss=$.extend(oOptions.containerCss,{width:oOptions.width,marginLeft:-oOptions.width/2});}
oOptions=$.extend({persist:true,overlay:75,onShow:this.listenShow.bind(this),closeClass:'modalClose',closeOnKeyEsc:false},oOptions);oOptions.containerCss=$.extend({position:'absolute'},oOptions.containerCss);this.oOptions=oOptions;return this;}
Eventful.Panel.prototype.autoShow=function(sHash){if(window.location.hash=="#"+sHash)
{$(this.show.bind(this));}}
Eventful.Panel.prototype.clickShow=function(sQuery){return this.clickClose(sQuery,true);}
Eventful.Panel.prototype.clickClose=function(sQuery,bShow){$(function()
{if(sQuery instanceof Array)sQuery=$.map(sQuery,function(id){return'#'+id}).join();$(sQuery).click(function(evt)
{evt.preventDefault();if(bShow)this.show(evt);else this.close(evt);}.bind(this));}.bind(this));return this;}
Eventful.Panel.prototype.show=function(evt){if(!this.panel().length)return this;if(this.oOptions.containerCss.position=='absolute')
{this.oOptions.containerCss.top=(Eventful.scrollTop()+30)+'px';}
if(this.parent(Eventful.Panel.current()))
{this.parent().close();}
var jqModal=this.panel().modal(this.oOptions);if(jqModal){this.jqModal=jqModal;}
Eventful.Panel.current(this);if(this.oOptions.containerCss.position=='fixed'&&!($.browser.msie&&($.browser.version<7)))
{var jqMC=$('#modalContainer');jqMC
.css('top','50%')
.css('marginTop','-'+Math.round(jqMC.height()*0.67)+'px');}
if(this.oOptions.closeOnKeyEsc)
{$('#modalContainer').one('keyup',function(evt){if(evt.keyCode==27)this.close();}.bind(this));}
$('#modalContainer .'+this.oOptions.closeClass).one('click',this.close.bind(this));if(this.trackingString){Eventful.TrackPageview.track(this.trackingString);}
this.eventShow.fire(evt);return this;}
Eventful.Panel.prototype.close=function(evt){if(this.jqModal)this.jqModal.close();this.eventClose.fire(evt);if(Eventful.Panel.current()==this)
{Eventful.Panel.current(null);}
if(this.parent())
{this.parent().show();this.parent(null);}
return this;}
Eventful.Panel.prototype.parent=function(obj){return obj!==undefined?this.oParent=obj:this.oParent||null;}
Eventful.Panel.prototype.listenShow=function(){Eventful.Forms.focusFirstField(this.panel());}
Eventful.Panel.current=function(obj){return obj!==undefined?Eventful.Panel.oCurrent=obj:Eventful.Panel.oCurrent||null;}
Eventful.scrollTop=function(){return document.body.scrollTop||document.documentElement.scrollTop||0;}
Eventful.InactiveText=function(el)
{el=$(el);el.blur();el.blur(Eventful.InactiveText.listenBlur);el.focus(Eventful.InactiveText.listenFocus);if(!el.prop('defaultValue'))
{el.val(el.attr('alt'));el.addClass('inactive');}else
{el.val(el.prop('defaultValue'));}
el.removeClass('inactive-text');}
Eventful.InactiveText.attachHandlers=function(root)
{$('.inactive-text',root).each(function(_,el){Eventful.InactiveText(el);});}
Eventful.InactiveText.listenBlur=function(evt)
{var el=$(evt.target);if(!el.val()&&!el.parents('.field-container.has-error').size())
{el.addClass('inactive');el.val(el.attr('alt'));}}
Eventful.InactiveText.listenFocus=function(evt)
{var el=$(evt.target);if(el.hasClass('inactive'))
{el.removeClass('inactive');el.val('');}}
Eventful.InactiveText.doForcedUpdate=function(el)
{el=$(el);el.addClass('inactive');el.val(el.attr('alt'));}
Eventful.GrowTextarea=function(el)
{$(el).
css({overflowY:'hidden'}).
each(function()
{Eventful.GrowTextarea.adjustHeight(this);}).
keyup(function()
{Eventful.GrowTextarea.adjustHeight(this);});}
Eventful.GrowTextarea.adjustHeight=function(el)
{var jq=$(el);var nMinHeight=el.scrollHeight;if($.browser.safari)
{nMinHeight-=jq.css('paddingTop').replace('px','');nMinHeight-=jq.css('paddingBottom').replace('px','');}
if(jq.height()<nMinHeight)
{jq.height(nMinHeight);}}
Eventful.FormVal=function(formJExpr,summaryJExpr,oArgs){this.jForm=$(formJExpr);if(summaryJExpr)this.jqFormSummary=$(summaryJExpr);if(!oArgs)oArgs={};this.args={summaryError:oArgs.summaryError||"Oh no! Errors! Please check the fields above.",summaryEmpty:oArgs.summaryEmpty||"You forgot to fill out the fields! Good thing I reminded you.",keepValidate:oArgs.keepValidate===undefined?false:oArgs.keepValidate,isMobile:oArgs.isMobile||false};this.rules=[];this.eventPassValid=new Eventful.UIEvent();this.eventJSONValidate=new Eventful.UIEvent();this.eventFailValid=new Eventful.UIEvent();this.eventErrorShown=new Eventful.UIEvent();this.eventFailFormEmpty=new Eventful.UIEvent();this.initialize();}
Eventful.FormVal.prototype.bindEvent=function(nm,fn){var nmEvts={'passValid':this.eventPassValid,'failValid':this.eventFailValid,'errorShown':this.eventErrorShown,'JSONValidate':this.eventJSONValidate};if(nmEvts[nm])nmEvts[nm].subscribe(fn);return this;}
Eventful.FormVal.GetPattern=function(type){var allPatterns={"float":/^-?(\d+\.?\d*|\d*\.\d+)$/,"number":/^[-+]?\d+$/,"email":/^[\w.%+-]+@([\w-]+\.)+[A-Za-z]{2,4}$/,"url":/^https?:\/\/([\w-]+\.)+[A-Za-z]{2,4}/i};return allPatterns[type];}
Eventful.FormVal.prototype.getPattern=Eventful.FormVal.GetPattern;Eventful.FormVal.setInactive=function(exprActiveToggle){$(exprActiveToggle||'input[type=text][alt!=""],textarea[alt!=""]',!exprActiveToggle&&this.jForm?this.jForm:undefined)
.bind('focus',function(){if($(this).hasClass('inactive')){$(this).removeClass('inactive').val('');}})
.bind('blur',function(){var alt=$(this).attr('alt');if(this.value==''){$(this).addClass('inactive').val(alt);}})
.each(function(i,el){var alt=$(this).attr('alt');if(el.value==""||el.value==alt){$(el).addClass('inactive').val(alt);}});return this;}
Eventful.FormVal.prototype.setInactive=Eventful.FormVal.setInactive;Eventful.FormVal.emptyInactive=function(exprActiveToggle){$(exprActiveToggle||'input.inactive[type=text][alt!=""],textarea.inactive[alt!=""]',!exprActiveToggle&&this.jForm?this.jForm:undefined).val('');return this;}
Eventful.FormVal.prototype.emptyInactive=Eventful.FormVal.emptyInactive;Eventful.FormVal.prototype.initialize=function(){this._serializedValues=this.jForm.serialize();this.jForm.bind('submit.formval',function(){this.validateForm.bind(this).later(1);return false;}.bind(this));return this;}
Eventful.FormVal.prototype.deinitialize=function(){this.jForm.unbind('submit.formval');return this;}
Eventful.FormVal.prototype.focusFirstField=function(){if(this.args.isMobile){return this;}
var jqInputs=this.jForm.find('.has-error :input').not(':hidden');if(!jqInputs.size())
{jqInputs=this.jForm.find(':input').not(':hidden');}
jqInputs.eq(0).trigger('focus');return this;}
Eventful.FormVal.prototype.isDirty=function(){return this._serializedValues!==this.jForm.serialize();}
Eventful.FormVal.prototype.trackEvent=function(sAction,sLabel,sValue)
{Eventful.TrackPageview.trackEvent("Form Validation",sAction,sLabel,sValue);}
Eventful.FormVal.prototype.validateForm=function(){if($.grep(this.jForm.find(":input").not(':hidden,:button,:reset,:image,:submit,.inactive').serializeArray(),function(pair){return!!$.trim(pair.value)}).length===0&&$.grep(this.rules,function(rule){return rule.rule.required;}).length>0&&this.jqFormSummary)
{this.showSummaryError(this.args.summaryEmpty);this.eventFailFormEmpty.fire(this.jForm[0]);return;}
if(this.args.isMobile){this.jForm.find('.field-container').removeClass('has-error show-errors');}
this.hideSummaryError().hideHasError();$.each(this.rules,function(_,oNameRulePair){oNameRulePair.rule.quality={error:0,message:'',defaultMessage:''};});function _markBadQuality(errInput,jInput,rule,errBit,defMsg,msg){errInput.push(jInput);rule.quality.error|=1<<errBit;rule.quality.defaultMessage=defMsg||"The input has error";rule.quality.message=msg||rule.message;}
var errInput=[],jsonQueue=[];$.each(this.rules,function(_,oNameRulePair){var jInput=this.jForm.find(':input[name='+oNameRulePair.name+']'),rule=oNameRulePair.rule;if(jInput.length==0||$.grep(errInput,function(j){return jInput.attr('name')===j.attr('name')}).length||!rule)return;var nameValues=$.grep(jInput.not('.inactive').serializeArray(),function(pair){return!!$.trim(pair.value)});if(rule.ignoreCb&&rule.ignoreCb(jInput.length===1?jInput[0]:jInput,nameValues)){return;}
if(rule.required&&!nameValues.length){_markBadQuality(errInput,jInput,rule,0,"Data is required");}else if(nameValues.length&&rule.pattern&&$.grep(nameValues,function(oPair){return rule.pattern.test(oPair.value)===false;}).length){_markBadQuality(errInput,jInput,rule,1,"The input has incorrect format");}else if(nameValues.length&&rule.hasOwnProperty("minlen")){if(jInput.is(':text, :password, textarea')&&jInput.val().length<rule.minlen){_markBadQuality(errInput,jInput,rule,2,"string length must >= "+rule.minlen);}else if(jInput.is(':checkbox, select')&&nameValues.length<rule.minlen){_markBadQuality(errInput,jInput,rule,3,"at least "+rule.minlen+" selected");}}else if(nameValues.length&&rule.hasOwnProperty("maxlen")){if(jInput.is(':text, :password, textarea')&&jInput.val().length>rule.maxlen){_markBadQuality(errInput,jInput,rule,4,"string length must <= "+rule.maxlen);}else if(jInput.is(':checkbox, select')&&nameValues.length>rule.maxlen){_markBadQuality(errInput,jInput,rule,5,"at most "+rule.maxlen+" selected");}}else if(nameValues.length&&rule.hasOwnProperty("min")&&jInput.is(':text')){var aNum=/^[+-]?\d+$/.test(jInput.val())?parseInt(jInput.val()):parseFloat(jInput.val());if(isNaN(aNum)||aNum<rule.min){_markBadQuality(errInput,jInput,rule,6,"must >= "+rule.min);}}else if(nameValues.length&&rule.hasOwnProperty("max")&&jInput.is(':text')){var aNum=/^[+-]?\d+$/.test(jInput.val())?parseInt(jInput.val()):parseFloat(jInput.val());if(isNaN(aNum)||aNum>rule.max){_markBadQuality(errInput,jInput,rule,7,"must <= "+rule.max);}}else if(rule.helperCb){var msg=rule.helperCb(jInput.length===1?jInput[0]:jInput,nameValues);if(msg&&msg.error)_markBadQuality(errInput,jInput,rule,8,'Failed to helper check',msg.message);}else if(rule.jsonCb){var oJSONsetup=rule.jsonCb(jInput.length==1?jInput[0]:jInput,nameValues);if(oJSONsetup&&(oJSONsetup.post||oJSONsetup.get))
{jsonQueue.push($.extend(oJSONsetup,{'rule':rule,'jInput':jInput}));}}}.bind(this));if(errInput.length){this._afterFailure(errInput);}else if(jsonQueue.length){var _onJsonResponse=function(helperCb,jInput,rule,sJsonUrl,oResponse)
{if(rule.accept_unavailable&&oResponse.status===503)
{this.trackEvent("Service Unavailable",sJsonUrl,jInput.val());}else
{var msg=helperCb(oResponse,jInput.length==1?jInput[0]:jInput,this.jForm[0]);}
if(msg&&msg.error){_markBadQuality(errInput,jInput,rule,9,'Failed to ajax check',msg.message);this._afterFailure(errInput);}else if(msg===false){return;}else if(jsonQueue.length){_shiftJsonQueue.call(this);}else{this._afterSuccess();}};var _shiftJsonQueue=function()
{var oJson=jsonQueue.shift();if(oJson)
{var sJsonUrl=oJson.post||oJson.get;$.ajax({url:sJsonUrl,type:oJson.post?"post":"get",data:oJson.data,success:_onJsonResponse.bind(this,oJson.helperCb,oJson.jInput,oJson.rule,sJsonUrl),error:_onJsonResponse.bind(this,oJson.helperErrorCb||function(){return{"error":1,"message":"Sorry! There is trouble to validate your input."}},oJson.jInput,oJson.rule),dataType:oJson.dataType||'json'});}};_shiftJsonQueue.call(this);this.eventJSONValidate.fire();}else{this._afterSuccess();}
return this;}
Eventful.FormVal.prototype._afterSuccess=function(){if(!this.args.keepValidate)this.deinitialize();if(this.eventPassValid.subscribers.length){this.eventPassValid.fire(this.jForm[0]);}else{this.emptyInactive();this.jForm.trigger('submit');}
return this;}
Eventful.FormVal.prototype._afterFailure=function(errInput){this.showSummaryError();this.showHasError(errInput);this.eventFailValid.fire(this.jForm[0],errInput);return this;}
Eventful.FormVal.prototype.addRule=function(inputname,oRule,position){if(typeof position=='number'){this.rules.splice(position,0,{name:inputname,rule:oRule});}else{this.rules.push({name:inputname,rule:oRule});}
return this;}
Eventful.FormVal.prototype.removeRule=function(inputname){this.rules=$.map(this.rules,function(oRule){return oRule.name===inputname?null:oRule;});return this;}
Eventful.FormVal.prototype.showShowError=function(elInput){var jqElContainer=$(elInput).parents(".field-container").addClass("show-errors");var sInputName=$(elInput).attr('name');var sMessage="There are errors in your input.";var jqFormError=jqElContainer.find(".form-error");if(!jqFormError.size()){jqFormError=$('<div class="form-error"></div>')
.attr('id',sInputName+'-error')
.appendTo(jqElContainer);}
var oNameRulePair=$.grep(this.rules,function(oNameRulePair){return oNameRulePair.name==sInputName&&oNameRulePair.rule.quality&&oNameRulePair.rule.quality.error;})[0];if(oNameRulePair)
{var oRule=oNameRulePair.rule;if(oRule.markupMessage==undefined)
{oRule.markupMessage=jqFormError.html();}
sMessage=oRule.quality.message||oRule.markupMessage||oRule.quality.defaultMessage||sMessage;}
jqFormError.html(sMessage);this.eventErrorShown.fire(elInput,jqFormError.get(0));return this;}
Eventful.FormVal.prototype.hideShowError=function(elInput){$(elInput).parents(".field-container").removeClass("show-errors");return this;}
Eventful.FormVal.prototype.showHasError=function(errInput){this._fnClearHasError=this._fnClearHasError?this._fnClearHasError.splice(0):[];$.each(errInput,function(i,el){var jqEl=$(el),jqContainer=jqEl.parents(".field-container").addClass("has-error");if(jqContainer.length==0)return;if(this.args.isMobile){this.showShowError.call(this,el);return this;}else{jqEl.bind("focus.haserror",this.showShowError.bind(this,el))
.bind("blur.haserror",this.hideShowError.bind(this,el));}
var afterTryAgain=function(){jqContainer.removeClass("has-error").removeClass("show-errors");jqEl.unbind("focus.haserror").unbind("blur.haserror");}
if(jqEl.is(':text, :password, textarea')){jqEl.bind("keyup.causechange",function(sOldVal){if($(this).val()!=sOldVal){afterTryAgain();$(this).unbind('keyup.causechange')}}.bind(jqEl[0],jqEl.val()));this._fnClearHasError.push(function(){jqEl.unbind("keyup.causechange");afterTryAgain();});}else if(jqEl.is('select')){jqEl.one("change",afterTryAgain);this._fnClearHasError.push(function(){jqEl.unbind("change",afterTryAgain);afterTryAgain();});}else if(jqEl.is(':checkbox, :radio')){jqEl.one("click",afterTryAgain);this._fnClearHasError.push(function(){jqEl.unbind("click",afterTryAgain);afterTryAgain();});}}.bind(this));return this.focusFirstField();}
Eventful.FormVal.prototype.hideHasError=function(){if(this._fnClearHasError){var fn;while(fn=this._fnClearHasError.pop())fn();}
return this;}
Eventful.FormVal.prototype.showSummaryError=function(sErrorMsg){if(this.jqFormSummary){sErrorMsg=sErrorMsg||this.args.summaryError;this.jqFormSummary.html(sErrorMsg).addClass("show-errors");var fnHideSummary=function(sOldFormValue){if(sOldFormValue!==this.jForm.serialize()){this.hideSummaryError();this.jForm
.find(':text, :password, textarea')
.unbind("keyup",fnHideSummary)
.end()
.find('select')
.unbind("change",fnHideSummary)
.end()
.find(':checkbox, :radio')
.unbind("click",fnHideSummary);}}.bind(this,this.jForm.serialize());this.jForm
.find(':text, :password, textarea')
.bind("keyup",fnHideSummary)
.end()
.find('select')
.bind("change",fnHideSummary)
.end()
.find(':checkbox, :radio')
.bind("click",fnHideSummary);}
return this.focusFirstField();}
Eventful.FormVal.prototype.hideSummaryError=function(evt){if(this.jqFormSummary){this.jqFormSummary.empty().removeClass("show-errors");}
return this;}
Eventful.CircularQ=function()
{this.iter=null;if(arguments.length==1)
{this.queue=arguments[0];}
else
{this.queue=[];}}
Eventful.CircularQ.prototype={next:function()
{if(this.queue.length>0)
{var next;if(this.iter===null)next=0;else next=this.iter+1;if(next>=this.queue.length)
{next=0;}
this.iter=next;return this.queue[next];}
else
{return null;}},prev:function()
{if(this.queue.length>0)
{var prev;if(this.iter===null)prev=this.queue.length-1;else prev=this.iter-1;if(prev<0)
{prev=this.queue.length-1;}
this.iter=prev;return this.queue[prev];}
else
{return null;}},goto:function(goTo)
{if((this.queue.length>0)&&(goTo<=this.queue.length))
{var idToGoTo=goTo-1;this.iter=idToGoTo;return this.queue[idToGoTo];}
else
{return null;}},current:function()
{if(this.queue.length>0)
{var current=this.iter;return this.queue[current];}
else
{return null;}},add:function(item)
{this.queue.push(item);},extend:function(items)
{this.queue=this.queue.concat(items);},rem:function(idx)
{this.queue.splice(idx,1);}}
Eventful.DropDown=function(oArgs)
{this.elInput=oArgs.input;this.elPopover=oArgs.popover;this.nMinInputLength=oArgs.minInputLength||0;this.listItemClass=oArgs.listItemClass||0;this.bSuggestionMode=oArgs.suggestionMode||0;this.bExact=oArgs.exact;this.eventItemSelected=new Eventful.UIEvent();this.eventInputChanged=new Eventful.UIEvent();this.eventPopoverShown=new Eventful.UIEvent();this.eventItemHighlighted=new Eventful.UIEvent();this.eventEscRequested=new Eventful.UIEvent();this.eventBlur=new Eventful.UIEvent();this.eventBadFocus=new Eventful.UIEvent();this.eventEnterAfterSelected=new Eventful.UIEvent();$(this.setup.bind(this));}
Eventful.DropDown.prototype.popover=function()
{return this.jqPopover?this.jqPopover:this.jqPopover=$(this.elPopover);}
Eventful.DropDown.prototype.find=function(sExpr)
{return this.popover().find(sExpr);}
Eventful.DropDown.prototype.input=function()
{return this.jqInput?this.jqInput:this.jqInput=$(this.elInput);}
Eventful.DropDown.prototype.list=function()
{return this.jqList?this.jqList:this.jqList=this.find('ul');}
Eventful.DropDown.prototype.setup=function()
{if(this.input().hasClass('inactive-text'))
{Eventful.InactiveText(this.input());}
this.input().
focus(this.listenFocus.bind(this)).
click(this.listenClick.bind(this)).
blur(this.listenBlur.bind(this)).
keyup(this.listenKeyUp.bind(this));if(jQuery.browser.safari||jQuery.browser.msie)
{this.input().keydown(this.listenKeyDown.bind(this));}else
{this.input().keypress(this.listenKeyDown.bind(this));}
this.popover().
mousedown(this.listenMouseDown.bind(this)).
mouseup(this.listenMouseUp.bind(this));this.sListItem=this.listItemClass?'li.'+this.listItemClass:'li';if(this.list().html())
{this.list().find(this.sListItem).
mouseover(this.listenMouseOver.bind(this)).
click(this.listenClickItem.bind(this))}else
{this.list().
mouseover(this.listenMouseOver.bind(this)).
click(this.listenClickItem.bind(this));}}
Eventful.DropDown.prototype.reset=function()
{if(!this.bSuggestionMode){this.input().val('');}
this.popover().hide();this.list().empty();this.queue(null);if(!this.bHasFocus)
{Eventful.InactiveText.doForcedUpdate(this.input())}}
Eventful.DropDown.prototype.currentElement=function()
{if(this.oQueue)
{return this.list().find(this.sListItem).eq(this.oQueue.iter);}}
Eventful.DropDown.prototype.indexFromElement=function(el)
{el=$(el);el=el.is('li')?el:el.parents('li');return this.list().find(this.sListItem).index(el[0]);}
Eventful.DropDown.prototype.queue=function(oQueue)
{if(oQueue!==undefined)
{if(oQueue&&!this.bSuggestionMode)oQueue.next();this.oQueue=oQueue;}
return this.oQueue;}
Eventful.DropDown.prototype.usingQueue=function(bUsingQueue)
{if(bUsingQueue!==undefined)this.bUsingQueue=bUsingQueue;return this.bUsingQueue;}
Eventful.DropDown.prototype.showPopover=function()
{var sVal=this.input().hasClass('inactive')?'':this.input().val();if((this.list().html()||this.popover().hasClass('empty'))&&sVal.length>=this.nMinInputLength)
{this.popover().show();this.find('iframe.popover-layer').css({width:this.popover().width(),height:this.popover().height()+500});this.eventPopoverShown.fire();setTimeout(function(){this.input().select()}.bind(this),0);}}
Eventful.DropDown.prototype.highlight=function(arg)
{if(this.oQueue[arg]||arg!=this.oQueue.iter)
{if(this.oQueue[arg])
{this.oQueue[arg]();}else
{this.oQueue.goto(arg%this.oQueue.queue.length+1);}}
this.list().find('li.highlight').removeClass('highlight');this.currentElement().addClass('highlight');}
Eventful.DropDown.prototype.clearInput=function()
{if(!this.input().hasClass('inactive'))
{this.input().val('');if(this.input().attr('alt'))
{Eventful.InactiveText.listenBlur({target:this.input()});}}}
Eventful.DropDown.prototype.listenClick=function()
{if(this.popover().css('display')!='block')
{this.showPopover();}}
Eventful.DropDown.prototype.listenFocus=function()
{if(!this.input().is(':visible'))
{this.eventBadFocus.fire();return;}
if(this.bHasFocus)return;this.bHasFocus=true;this.showPopover();}
Eventful.DropDown.prototype.listenBlur=function()
{if(this.bIgnoreBlur)
{this.bIgnoreBlur=false;return;}
this.eventBlur.fire();this.popover().hide();this.bHasFocus=false;}
Eventful.DropDown.prototype.listenKeyDown=function(evt)
{switch(evt.keyCode)
{case 27:evt.preventDefault();this.eventEscRequested.fire(this.oQueue.current());break;case 38:if(this.oQueue)
{evt.preventDefault();this.usingQueue(true);this.highlight('prev');this.eventItemHighlighted.fire(this.oQueue.current());}
break;case 40:if(this.oQueue)
{evt.preventDefault();this.usingQueue(true);this.highlight('next');this.eventItemHighlighted.fire(this.oQueue.current());}
break;case 13:if(this.oQueue)
{evt.preventDefault();if(this.popover().is(':visible'))
{if(this.usingQueue()||this.bExact)
{this.eventItemSelected.fire(this.oQueue.current());}else
{this.eventItemSelected.fire(this.input().val())}
this.popover().hide();}
else
{this.eventEnterAfterSelected.fire();}}
break;}
this.sOldInput=this.input().val();}
Eventful.DropDown.prototype.listenKeyUp=function(evt)
{var sInput=this.input().val();if(this.sOldInput!=sInput)
{this.usingQueue(false);this.eventInputChanged.fire(sInput);}}
Eventful.DropDown.prototype.listenMouseOver=function(evt)
{this.highlight(this.indexFromElement(evt.target));}
Eventful.DropDown.prototype.listenClickItem=function(evt)
{var i=this.indexFromElement(evt.target);this.oQueue.goto(i+1);this.eventItemSelected.fire(this.oQueue.current());this.popover().hide();}
Eventful.DropDown.prototype.listenMouseDown=function()
{this.bIgnoreBlur=true;}
Eventful.DropDown.prototype.listenMouseUp=function()
{this.input().focus();}
Eventful.TypeAhead=function(oArgs)
{this.id=oArgs.id;this.bSingular=!oArgs.multiple;this.sExcludeQuery=null;this.oItemsToExclude={};this.bOptions=oArgs.options;this.bRequired=oArgs.required;this.sListItemClass=oArgs.itemClass||'click-result';this.bSuggestionMode=oArgs.suggestionMode||0;this.bHideDescription=oArgs.hide_description;this.bDefaultOnBlur=this.bRequired||oArgs.default_on_blur;this.eventItemSelected=new Eventful.UIEvent();this.eventNoItemSelected=new Eventful.UIEvent();this.eventOptionSelected=new Eventful.UIEvent();this.eventItemRemoved=new Eventful.UIEvent();this.eventEnterConfirm=new Eventful.UIEvent();this.eventInputChanged=new Eventful.UIEvent();this.oDropDown=new Eventful.DropDown({exact:1,input:'#inp-'+this.id,popover:'#popover-'+this.id,listItemClass:this.sListItemClass,suggestionMode:this.bSuggestionMode,minInputLength:oArgs.minInputLength!==undefined?oArgs.minInputLength:2});this.oDropDown.eventItemSelected.subscribe(this.listenItemSelected.bind(this));this.oDropDown.eventItemHighlighted.subscribe(this.listenItemHighlighted.bind(this));this.oDropDown.eventInputChanged.subscribe(this.listenInputChanged.bind(this));this.oDropDown.eventEnterAfterSelected.subscribe(this.listenEnterAfterSelected.bind(this));this.oDropDown.eventEscRequested.subscribe(this.listenEscRequested.bind(this));if(this.bDefaultOnBlur)
{this.oDropDown.eventBlur.subscribe(this.listenBlur.bind(this));}
$(this.setup.bind(this));}
Eventful.TypeAhead.prototype.typeahead=function()
{return this.jqTypeahead?this.jqTypeahead:this.jqTypeahead=$('#type-ahead-'+this.id);}
Eventful.TypeAhead.prototype.selected=function()
{return this.jqSelected?this.jqSelected:this.jqSelected=$('ul',this.typeahead());}
Eventful.TypeAhead.prototype.description=function()
{return this.jqDescription?this.jqDescription:this.jqDescription=$('#description-'+this.id);}
Eventful.TypeAhead.prototype.setup=function()
{Eventful.InactiveText(this.oDropDown.input());if(this.bSingular)
{this.oDropDown.input().css({width:'98%'});this.selected().hide();}
if(this.bOptions)
{this.renderResults();}
if(this.bSuggestionMode)
{this.oDropDown.input().focus(function(){this.oDropDown.popover().show()}.bind(this));}
this.updateInputLength();}
Eventful.TypeAhead.prototype.updateInputLength=function()
{if(this.bSingular)return;var nWidth=this.typeahead().width()-this.selected().width()-10;this.oDropDown.input().css({width:nWidth+'px'});this.oDropDown.popover().css({left:this.selected().width()+'px'});}
Eventful.TypeAhead.prototype.removeExcluded=function(aResults){return aResults;}
Eventful.TypeAhead.prototype.setValue=function(sValue)
{if(sValue)
{this.oDropDown.input().val(sValue).removeClass('inactive');}else
{this.reset();}}
Eventful.TypeAhead.prototype.reset=function()
{this.item(null);}
Eventful.TypeAhead.prototype.renderResults=function(sQuery,aResults,oAdditionalArgs)
{this.typeahead().removeClass('loading');if(this.bOptions)
{var aOptions=this.options();if(aOptions&&aOptions.length)
{aResults=(aResults||[]).concat(aOptions);}}
if(!aResults)return;aResults=this.removeExcluded(aResults);if(sQuery&&!this.bSuggestionMode)
{var aSplit=$.grep(sQuery.split(/[\s,']+/),function(s){return s;});var rxBold=new RegExp('('+aSplit.join('|')+')','ig');}
if(aResults.length)
{this.oDropDown.popover().removeClass('empty');this.oDropDown.queue(new Eventful.CircularQ(aResults));this.oDropDown.list().empty();if(this.bShowSuggestionHeaders){var elIntroText=$('<li>').
addClass('suggestion-header').
html('<em>Or, are you looking for&#0133;</em>').
appendTo(this.oDropDown.list());}
$.each(aResults,function(i,oItem)
{if(this.bShowCategoryHeaders&&oItem.type&&(!this.sSection||this.sSection!=oItem.type)){var elCatHeader=$('<li>').
addClass('result-cat').
html(this.itemCategoryHeader(oItem)).
appendTo(this.oDropDown.list());}
var sTitle=this.itemTitle(oItem);if(rxBold&&!oItem.option)
{sTitle=sTitle.replace(rxBold,'<b>$1</b>');}
var sDescription=this.itemDescription(oItem);var elItem=$('<li>').
addClass(this.sListItemClass).
html(sTitle+(sDescription?'<p class="diminished">'+sDescription+'</p>':'')).
appendTo(this.oDropDown.list());if(!this.bSuggestionMode&&!i)elItem.addClass(i?'':'highlight');if(this.itemId)
{var sItemID=this.itemId(oItem);if(sItemID)elItem.attr('id','type-ahead-'+this.id+'-'+sItemID);}
if(oItem.option)elItem.addClass('option');if(oItem.customClass)elItem.addClass(oItem.customClass);if(i==0)elItem.addClass('first');}.bind(this));}else
{this.oDropDown.popover().addClass('empty');this.oDropDown.queue(null);this.oDropDown.list().empty();}
this.sSection=null;if(this.oDropDown.bHasFocus)
{this.oDropDown.popover().show();}}
Eventful.TypeAhead.prototype.item=function(oItem)
{if(oItem===null)
{this.description().hide();this.oDropDown.reset();this.renderResults();}else if(oItem)
{var sTitle=this.itemTitle(oItem);var sDescription=this.itemDescription(oItem);if(this.bSingular)
{if(!this.bSuggestionMode){this.setValue(sTitle);}
if(sDescription&&!this.bHideDescription)
{this.description().html(sDescription).show().removeClass('hidden');}else
{this.description().hide();}}else
{this.oDropDown.input().css({width:0}).val('');this.oDropDown.list().empty();var elItem=$('<li>'+sTitle+' <span class="faded delete_box click-remove">X</span></li>').
appendTo(this.selected());elItem.find('.click-remove').click(this.listenClickRemove.bind(this,elItem,oItem));this.updateInputLength();}}
if(typeof oItem!=='undefined')this.oItem=oItem;return this.oItem;}
Eventful.TypeAhead.prototype.listenBlur=function()
{if(!this.oDropDown.input().is(':visible'))return;var oItem=this.item();var oQueue=this.oDropDown.oQueue;if(oQueue&&oQueue.queue[0]&&!oQueue.queue[0].option&&(oQueue.iter==0||!oItem))
{this.item(oQueue.queue[0]);this.eventItemSelected.fire(oQueue.queue[0]);}else if(oItem)
{this.item(oItem);}}
Eventful.TypeAhead.prototype.listenItemSelected=function(oItem)
{if(!oItem)
{this.eventNoItemSelected.fire();return;}
if(oItem.option)
{this.eventOptionSelected.fire(oItem);}else
{this.item(oItem);this.eventItemSelected.fire(oItem);Eventful.InactiveText.listenFocus({target:this.oDropDown.input()});this.oDropDown.input().select();}}
Eventful.TypeAhead.prototype.listenEnterAfterSelected=function()
{if(this.item())
{this.eventEnterConfirm.fire(this.item());}}
Eventful.TypeAhead.prototype.listenItemHighlighted=function(oItem)
{if(!oItem.option)
{this.item(oItem);}}
Eventful.TypeAhead.prototype.listenInputChanged=function(sInput)
{this.description().hide();if(!this.oDropDown.input().hasClass('inactive')&&sInput.length>1)
{this.typeahead().addClass('loading');this.search(sInput);}else{if(sInput.length===0&&!this.bRequired)
{this.reset();}
if(!this.bSuggestionMode)
{this.oDropDown.popover().hide();}}
this.eventInputChanged.fire();}
Eventful.TypeAhead.prototype.listenClickRemove=function(elItem,oItem,evt)
{$(elItem).remove();this.updateInputLength();this.eventItemRemoved.fire(oItem);}
Eventful.TypeAhead.prototype.listenServerResponse=function(sQuery,oResponse)
{var aResults=(oResponse||{}).results||[];this.renderResults(sQuery,aResults);}
Eventful.TypeAhead.prototype.listenEscRequested=function()
{if(this.bSuggestionMode){this.reset();}}
String.prototype.truncate=function(n,suffix)
{if(!this.length||!n)return this;suffix=suffix||'...';if(this.length>n)
{return this.substring(0,n)+suffix;}
else{return this.substring(0);}}
String.prototype.append=function(sAdd,sSep)
{return this+((this.length)?sSep:'')+sAdd;}
String.prototype.trim=function()
{return this.replace(/(^\s+|\s+$)/g,'');}
String.prototype.lpad=function(n,sPad)
{if(n&&this.length<n)
{return(sPad+this).lpad(n,sPad);}else
{return this;}}
String.prototype.commify=function()
{return this.replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,");}
String.prototype.uppercaseFirst=function()
{return this.replace(/\b(\w)/g,function(_,m)
{return m.toUpperCase();});}
String.prototype.surplant=function(O)
{return this.replace(/\{(\w+)\}/g,function(a,b){var r=O[b];return typeof r==="string"?r:a;});}
Eventful.LocationTypeAhead=function(oArgs)
{this.nTruncate=oArgs.truncate||oArgs.length||64;this.sExclude=oArgs.exclude||'';this.bBubbleUp=oArgs.bubble_up||'';this.sRegionId=oArgs.region_id||'';this.sLocationType=oArgs.location_type||'';Eventful.TypeAhead.call(this,oArgs);this.eventLocationPosted=new Eventful.UIEvent();if(oArgs.post)
{this.eventItemSelected.subscribe(this.listenLocationSelected.bind(this));}}.mixin(Eventful.TypeAhead);Eventful.LocationTypeAhead.prototype.itemTitle=function(oLocation)
{var aSplit=this.splitLines(oLocation);if(aSplit)
{return aSplit[1].trim().truncate(this.nTruncate);}
return oLocation.pretty_name.truncate(this.nTruncate);}
Eventful.LocationTypeAhead.prototype.itemDescription=function(oLocation)
{var aSplit=this.splitLines(oLocation);if(aSplit)
{return aSplit[2].trim().truncate(this.nTruncate);}}
Eventful.LocationTypeAhead.prototype.splitLines=function(oLocation)
{return oLocation.pretty_name.match(/^(.*)\((.*)\)$/);}
Eventful.LocationTypeAhead.prototype.itemId=function(oLocation)
{return oLocation.location_type+'-'+oLocation.location_id;}
Eventful.LocationTypeAhead.prototype.search=function(sQuery)
{$.get('/json/tools/location/typedown',this.searchParams(sQuery),this.listenServerResponse.bind(this,sQuery),'json');}.slow(500);Eventful.LocationTypeAhead.prototype.searchParams=function(sQuery)
{return{location:sQuery,destination_key:'results',recent:1,bubble_up:this.bBubbleUp,region_id:this.sRegionId,location_type:this.sLocationType,exclude:this.sExclude};}
Eventful.LocationTypeAhead.prototype.listenLocationSelected=function(oLocation)
{$.post('/json/tools/location',{location_type:oLocation.location_type,location_id:oLocation.location_id,input_token:'save'},this.listenLocationPosted.bind(this,oLocation),'json');}
Eventful.LocationTypeAhead.prototype.listenLocationPosted=function(oLocation,oResponse)
{this.eventLocationPosted.fire(oLocation,oResponse);}
Eventful.LocationTypeAhead.prototype.options=function()
{return Eventful.LocationTypeAhead.options;}
Eventful.LocationTypeAhead.options=[{pretty_name:'Worldwide',option:1,worldwide:1,svid:'V0-001-000000001-8'}];Eventful.VenueTypeAhead=function(oArgs)
{Eventful.TypeAhead.call(this,oArgs);}.mixin(Eventful.TypeAhead);Eventful.VenueTypeAhead.prototype.itemTitle=function(oVenue)
{return oVenue.name.substring(0,64).replace('&amp;','&')+(oVenue.name.length>64?'...':'');}
Eventful.VenueTypeAhead.prototype.itemDescription=function(oVenue)
{var aFields=[oVenue.address,oVenue.city,oVenue.region_abbr||oVenue.country];var sDescripton=$.grep(aFields,function(s){return s;}).join(', ');return sDescripton.substring(0,64)+(sDescripton.length>64?'...':'');}
Eventful.VenueTypeAhead.prototype.itemId=function(oVenue)
{return oVenue.svid;}
Eventful.VenueTypeAhead.prototype.search=function(sQuery)
{$.get('/json/tools/venues/typedown',{q:sQuery,recent:1,destination_key:'results'},this.listenServerResponse.bind(this,sQuery),'json');}.slow(500);Eventful.VenueTypeAhead.prototype.options=function()
{return Eventful.VenueTypeAhead.options;}
Eventful.VenueTypeAhead.options=[{name:'No venue specified',option:1,no_venue:1},{name:'Suggest a new venue',option:1,suggest_venue:1}];Number.prototype.toStringPadLeft=function(nPlaces)
{var s=this.toString().replace(/\.\d+/,'');while(s.length<nPlaces)
{s='0'+s;}
return s;}
Number.prototype.commify=function()
{return this.toString().commify();}
Eventful.Autoclose=function()
{$('body').click(Eventful.Autoclose.body_click);}
Eventful.Autoclose.element_id=null;Eventful.Autoclose.afterClosed=new Eventful.UIEvent();Eventful.Autoclose.body_click=function(evt)
{if(evt)
{var elTarget=$(evt.target);if(elTarget.size())
{if(elTarget.hasClass("autoclose")||elTarget.hasClass("autoclose-click")||elTarget.parents('.autoclose').size())
{return true;}}}
Eventful.Autoclose.close_block();}
Eventful.Autoclose.close_block=function()
{var id=Eventful.Autoclose.element_id;if(id&&id.length)
{var elAutoclose=$('#'+id);if(elAutoclose.size())
{elAutoclose.hide();Eventful.Autoclose.element_id=null;Eventful.Autoclose.afterClosed.fire(elAutoclose.get(0));}}}
Eventful.Autoclose.set_id=function(idEl)
{if(Eventful.Autoclose.element_id!=idEl)
{Eventful.Autoclose.close_block();Eventful.Autoclose.element_id=idEl;}}
$(Eventful.Autoclose);Eventful.Popover=function(jqEx,oOptions)
{this.eventShow=new Eventful.UIEvent();this.eventClose=new Eventful.UIEvent();this._setup({width:"300px",css:{'backgroundColor':'#fff','border':'1px solid #666','zIndex':"10"},position:{"top":10,"left":10,"right":'auto',"bottom":'auto',"relative":'mouse'},no_focus:false,tracking:''},jqEx,oOptions||{});}
Eventful.Popover.prototype._setup=function(default_args,jqEx,oOptions){var popoverCss={},containerCss={};$.each($.extend(default_args.css,{'width':default_args.width},oOptions.css,{'width':oOptions.width}),function(attr,val){if(!val)return;if(/^(width|height|zIndex)$/.test(attr)){containerCss[attr]=val;}else{popoverCss[attr]=val;}});this.popover(jqEx).css(popoverCss);this.args={'containerCss':containerCss,'position':$.extend(default_args.position,oOptions.position),'tracking':oOptions.tracking||default_args.tracking,'no_focus':oOptions.no_focus||default_args.no_focus,'listenKeyESC':!!this.find(':input').not(':hidden').length};}
Eventful.Popover.prototype.container=function(){var jContainer,oEvt,oInst,fnKeyESCHdl=function(evt){if(evt.keyCode==27&&oInst){oInst.close(evt);}},fnReposition=function(evt){if(oInst)oInst._position(evt);},fnMouseLeaveHdl=function(){if(oInst)oInst._slowUIAct(!oInst.args.slowActOverPopover,true);},fnMouseEnterHdl=function(){if(oInst)oInst._slowUIAct(!oInst.args.slowActOverPopover,false);},fnShow=function(intc,evt){if(oInst)fnClose();oInst=intc;oEvt=evt?{'target':evt.target,'pageX':evt.pageX,'pageY':evt.pageY}:null;jContainer
.prepend(oInst.popover(true))
.css($.extend({height:'auto',width:'auto',zIndex:'auto'},oInst.args.containerCss,{"top":"-1000px","left":"-1000px"}))
.show();oInst._position(oEvt);if(oInst.args.listenOverPopover){jContainer
.bind('mouseenter',fnMouseEnterHdl)
.bind('mouseleave',fnMouseLeaveHdl);}
if(oInst.args.listenKeyESC){jContainer.bind('keyup',fnKeyESCHdl);}
if(oInst.args.position.relative==='mouse'&&oEvt){$(oEvt.target).bind('mousemove',fnReposition);}},fnClose=function(){if(oInst.args.listenOverPopover){jContainer
.unbind('mouseenter',fnMouseEnterHdl)
.unbind('mouseleave',fnMouseLeaveHdl);}
if(oInst.args.listenKeyESC){jContainer.unbind('keyup',fnKeyESCHdl);}
if(oInst.args.position.relative==='mouse'&&oEvt){$(oEvt.target).unbind('mousemove',fnReposition);}
jContainer
.hide()
.children().not('iframe')
.each(function(){if(this.parentNode)this.parentNode.removeChild(this);});oInst=oEvt=null;};return function(doElse){if(!jContainer){jContainer=$('<div id="eventful-tooltip" class="popover autoclose" \
                          style="position:absolute;margin:0;border:0;padding:0;background-color:transparent;"> \
                      </div>')
.appendTo(document.body)
.hide()
.bind('resize',function(){jContainer
.children('iframe')
.css({'width':jContainer.width(),'height':jContainer.height()});fnReposition(oEvt);});if($.browser.msie&&($.browser.version<7)){jContainer.append('<iframe frameborder="0" src="javascript:\'\'" \
                             style="position:absolute;top:0;left:0;z-index:-1;filter:mask();"> \
                           </iframe>');}
$(window).bind('resize',function(){fnReposition(oEvt);});}
if(doElse){if(doElse.get&&doElse.get==='event'){return oEvt;}else if(doElse.get&&doElse.get==='instance'){return oInst;}else if(doElse.set&&doElse.set[0]){fnShow(doElse.set[0],doElse.set[1]);}else if(doElse.set&&oInst){fnClose();}}
return jContainer;}}();Eventful.Popover.prototype.popover=function(jqEx){if(!this._jPopover&&jqEx){this._jPopover=$(jqEx).hide();if(this._jPopover.parents('body').length){this._jPopover._delayDetach=true;}else if(typeof jqEx==='string'){this._jPopover=$('<div class="popbd">'+jqEx+'</div>');}}else if(this._jPopover._delayDetach&&jqEx===true){this._jPopover.each(function(){if(this.parentNode)this.parentNode.removeChild(this);}).removeClass('hidden').show();delete this._jPopover['_delayDetach'];}
return this._jPopover;}
Eventful.Popover.prototype.find=function(sExpr)
{return this.popover().find(sExpr)}
Eventful.Popover.prototype.clickShow=function(jSel,bStayOpen){$(jSel)
.addClass('popover-sender autoclose')
.click(function(evt){(!bStayOpen&&this.isOpen())?this.close(evt):this.show(evt);return false;}.bind(this));return this;}
Eventful.Popover.prototype.clickClose=function(jSel){$(jSel).click(function(evt){this.close(evt);return false;}.bind(this));return this;}
Eventful.Popover.prototype.hoverShow=function(jSel,options){var fnShow,fnClose;if(options&&(options.show_over||options.show_slow)){fnShow=this._slowUIAct.bind(this,!options.show_slow,false);fnClose=this._slowUIAct.bind(this,!options.show_slow,true);}else{fnShow=this.show.bind(this);fnClose=this.close.bind(this);}
this.args.listenOverPopover=!!(options&&options.show_over);this.args.slowActOverPopover=this.args.listenOverPopover&&options.show_slow;$(jSel)
.addClass('popover-sender')
.bind('mouseenter',fnShow)
.bind('mouseleave',fnClose);return this;}
Eventful.Popover.prototype._slowUIAct=(function(){var fn=function(evt,bClosing){bClosing===true?this.close(evt):this.show(evt);},fnHalfSec=fn.slow(500),fnMillSec=fn.slow(10);return function(bQuick,bClosing,evt){(bQuick?fnMillSec:fnHalfSec)
.call(this,evt?{'target':evt.target,'pageX':evt.pageX,'pageY':evt.pageY}:null,bClosing);}})();Eventful.Popover.prototype.isOpen=function(bPopover){var inst=this.container({'get':'instance'});return bPopover?!!inst:this===inst;}
Eventful.Popover.prototype.show=function(evt){if(this.isOpen()){var lastShowEvt=this.container({'get':'event'});if(!evt)return this._position(lastShowEvt);if(lastShowEvt&&lastShowEvt.target===evt.target)return this._position(evt);}
if(this.isOpen(true)){this.container({'get':'instance'}).close(evt);}
this.container({'set':[this,evt]});if(!this.args.no_focus){this.container().find(":input").not('.inactive,:hidden').eq(0).trigger('focus');}
if(this.args.tracking){Eventful.TrackPageview.track(this.args.tracking);}
Eventful.Autoclose.set_id(this.container().attr('id'));this.eventShow.fire(evt);return this;}
Eventful.Popover.prototype.close=function(evt){this.container({'set':[null,null]});Eventful.Autoclose.element_id=null;this.eventClose.fire(evt);return this;}
Eventful.Autoclose.afterClosed.subscribe(function(elClose){if(elClose===Eventful.Popover.prototype.container()[0]){var intsToClose=Eventful.Popover.prototype.container({'get':'instance'});if(intsToClose)intsToClose.close();}});Eventful.Popover.prototype._position=function(evt){var docScrollTop=document.body.scrollTop||document.documentElement.scrollTop||0,docScrollLeft=document.body.scrollLeft||document.documentElement.scrollLeft||0,h=this.container().height(),w=this.container().width(),top=0,left=0;if(typeof this.args.position.relative=='object'||(this.args.position.relative=='sender'&&evt)){var jRelative=typeof this.args.position.relative==='object'?$(this.args.position.relative):$(evt.target).parents('.popover-sender').andSelf(),positionOffset=jRelative.offset();if(typeof this.args.position.top=='number'){top=positionOffset.top+this.args.position.top;}else if(typeof this.args.position.bottom=='number'){top=positionOffset.top+jRelative.height()-h-this.args.position.bottom;}else{top=positionOffset.top+10;}
if(typeof this.args.position.left=='number'){left=positionOffset.left+this.args.position.left;}else if(typeof this.args.position.right=='number'){left=positionOffset.left+jRelative.width()-w-this.args.position.right;}else{left=positionOffset.left+10;}}else if(this.args.position.relative=='viewport'){if(typeof this.args.position.top=='number'){top=docScrollTop+this.args.position.top;}else if(typeof this.args.position.bottom=='number'){top=docScrollTop+$(window).height()-h-this.args.position.bottom;}else{top=docScrollTop+10;}
if(typeof this.args.position.left=='number'){left=docScrollLeft+this.args.position.left;}else if(typeof this.args.position.right=='number'){left=docScrollLeft+$(window).width()-w-this.args.position.right;}else{left=docScrollLeft+10;}}else if(/^(mouse|click)$/.test(this.args.position.relative)&&evt){if(typeof this.args.position.top!=='number')this.args.position.top=10;if(typeof this.args.position.left!=='number')this.args.position.left=10;if(evt.pageY<=docScrollTop+$(window).height()*0.5){top=evt.pageY+this.args.position.top;}else{top=evt.pageY-this.args.position.top-h;}
if(evt.pageX<=docScrollLeft+$(window).width()*0.5){left=evt.pageX+this.args.position.left;}else{left=evt.pageX-this.args.position.left-w;}}
this.container().css({"top":top+"px","left":left+"px"});return this;}
Eventful.Popover.blockUI=function(){if(!Eventful.Popover.blockUI.blocker)Eventful.Popover.blockUI.blocker=new Eventful.Popover('<div id="eventful-uiblocker" style="height:'+$(document).height()+
'px;background:#FFFFFF url(http://s1.evcdn.com/store/skin/throbbers/throbber_32x32.gif) no-repeat fixed center center;"></div>',{css:{width:'100%',border:false,opacity:0.66},position:{top:0,left:0,relative:'viewport'}});Eventful.Popover.blockUI.blocker.show();}
Eventful.Popover.unblockUI=function(){if(Eventful.Popover.blockUI.blocker)Eventful.Popover.blockUI.blocker.close();}
/**
 * @version: 1.0 Alpha-1
 * @author: Coolite Inc. http://www.coolite.com/
 * @date: 2008-05-13
 * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved.
 * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. 
 * @website: http://www.datejs.com/
 */
Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|aft(er)?|from|hence)/i,subtract:/^(\-|bef(ore)?|ago)/i,yesterday:/^yes(terday)?/i,today:/^t(od(ay)?)?/i,tomorrow:/^tom(orrow)?/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^mn|min(ute)?s?/i,hour:/^h(our)?s?/i,week:/^w(eek)?s?/i,month:/^m(onth)?s?/i,day:/^d(ay)?s?/i,year:/^y(ear)?s?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt|utc)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a(?!u|p)|p)/i},timezones:[{name:"UTC",offset:"-000"},{name:"GMT",offset:"-000"},{name:"EST",offset:"-0500"},{name:"EDT",offset:"-0400"},{name:"CST",offset:"-0600"},{name:"CDT",offset:"-0500"},{name:"MST",offset:"-0700"},{name:"MDT",offset:"-0600"},{name:"PST",offset:"-0800"},{name:"PDT",offset:"-0700"}]};(function(){var $D=Date,$P=$D.prototype,$C=$D.CultureInfo,p=function(s,l){if(!l){l=2;}
return("000"+s).slice(l*-1);};$P.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};$P.setTimeToNow=function(){var n=new Date();this.setHours(n.getHours());this.setMinutes(n.getMinutes());this.setSeconds(n.getSeconds());this.setMilliseconds(n.getMilliseconds());return this;};$D.today=function(){return new Date().clearTime();};$D.compare=function(date1,date2){if(isNaN(date1)||isNaN(date2)){throw new Error(date1+" - "+date2);}else if(date1 instanceof Date&&date2 instanceof Date){return(date1<date2)?-1:(date1>date2)?1:0;}else{throw new TypeError(date1+" - "+date2);}};$D.equals=function(date1,date2){return(date1.compareTo(date2)===0);};$D.getDayNumberFromName=function(name){var n=$C.dayNames,m=$C.abbreviatedDayNames,o=$C.shortestDayNames,s=name.toLowerCase();for(var i=0;i<n.length;i++){if(n[i].toLowerCase()==s||m[i].toLowerCase()==s||o[i].toLowerCase()==s){return i;}}
return-1;};$D.getMonthNumberFromName=function(name){var n=$C.monthNames,m=$C.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;i<n.length;i++){if(n[i].toLowerCase()==s||m[i].toLowerCase()==s){return i;}}
return-1;};$D.isLeapYear=function(year){return((year%4===0&&year%100!==0)||year%400===0);};$D.getDaysInMonth=function(year,month){return[31,($D.isLeapYear(year)?29:28),31,30,31,30,31,31,30,31,30,31][month];};$D.getTimezoneAbbreviation=function(offset){var z=$C.timezones,p;for(var i=0;i<z.length;i++){if(z[i].offset===offset){return z[i].name;}}
return null;};$D.getTimezoneOffset=function(name){var z=$C.timezones,p;for(var i=0;i<z.length;i++){if(z[i].name===name.toUpperCase()){return z[i].offset;}}
return null;};$P.clone=function(){return new Date(this.getTime());};$P.compareTo=function(date){return Date.compare(this,date);};$P.equals=function(date){return Date.equals(this,date||new Date());};$P.between=function(start,end){return this.getTime()>=start.getTime()&&this.getTime()<=end.getTime();};$P.isAfter=function(date){return this.compareTo(date||new Date())===1;};$P.isBefore=function(date){return(this.compareTo(date||new Date())===-1);};$P.isToday=function(){return this.isSameDay(new Date());};$P.isSameDay=function(date){return this.clone().clearTime().equals(date.clone().clearTime());};$P.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};$P.addSeconds=function(value){return this.addMilliseconds(value*1000);};$P.addMinutes=function(value){return this.addMilliseconds(value*60000);};$P.addHours=function(value){return this.addMilliseconds(value*3600000);};$P.addDays=function(value){this.setDate(this.getDate()+value);return this;};$P.addWeeks=function(value){return this.addDays(value*7);};$P.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,$D.getDaysInMonth(this.getFullYear(),this.getMonth())));return this;};$P.addYears=function(value){return this.addMonths(value*12);};$P.add=function(config){if(typeof config=="number"){this._orient=config;return this;}
var x=config;if(x.milliseconds){this.addMilliseconds(x.milliseconds);}
if(x.seconds){this.addSeconds(x.seconds);}
if(x.minutes){this.addMinutes(x.minutes);}
if(x.hours){this.addHours(x.hours);}
if(x.weeks){this.addWeeks(x.weeks);}
if(x.months){this.addMonths(x.months);}
if(x.years){this.addYears(x.years);}
if(x.days){this.addDays(x.days);}
return this;};var $y,$m,$d;$P.getWeek=function(){var a,b,c,d,e,f,g,n,s,w;$y=(!$y)?this.getFullYear():$y;$m=(!$m)?this.getMonth()+1:$m;$d=(!$d)?this.getDate():$d;if($m<=2){a=$y-1;b=(a/4|0)-(a/100|0)+(a/400|0);c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);s=b-c;e=0;f=$d-1+(31*($m-1));}else{a=$y;b=(a/4|0)-(a/100|0)+(a/400|0);c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);s=b-c;e=s+1;f=$d+((153*($m-3)+2)/5)+58+s;}
g=(a+b)%7;d=(f+g-e)%7;n=(f+3-d)|0;if(n<0){w=53-((g-s)/5|0);}else if(n>364+s){w=1;}else{w=(n/7|0)+1;}
$y=$m=$d=null;return w;};$P.getISOWeek=function(){$y=this.getUTCFullYear();$m=this.getUTCMonth()+1;$d=this.getUTCDate();return p(this.getWeek());};$P.setWeek=function(n){return this.moveToDayOfWeek(1).addWeeks(n-this.getWeek());};$D._validate=function(n,min,max,name){if(typeof n=="undefined"){return false;}else if(typeof n!="number"){throw new TypeError(n+" is not a Number.");}else if(n<min||n>max){throw new RangeError(n+" is not a valid value for "+name+".");}
return true;};$D.validateMillisecond=function(value){return $D._validate(value,0,999,"millisecond");};$D.validateSecond=function(value){return $D._validate(value,0,59,"second");};$D.validateMinute=function(value){return $D._validate(value,0,59,"minute");};$D.validateHour=function(value){return $D._validate(value,0,23,"hour");};$D.validateDay=function(value,year,month){return $D._validate(value,1,$D.getDaysInMonth(year,month),"day");};$D.validateMonth=function(value){return $D._validate(value,0,11,"month");};$D.validateYear=function(value){return $D._validate(value,0,9999,"year");};$P.set=function(config){if($D.validateMillisecond(config.millisecond)){this.addMilliseconds(config.millisecond-this.getMilliseconds());}
if($D.validateSecond(config.second)){this.addSeconds(config.second-this.getSeconds());}
if($D.validateMinute(config.minute)){this.addMinutes(config.minute-this.getMinutes());}
if($D.validateHour(config.hour)){this.addHours(config.hour-this.getHours());}
if($D.validateMonth(config.month)){this.addMonths(config.month-this.getMonth());}
if($D.validateYear(config.year)){this.addYears(config.year-this.getFullYear());}
if($D.validateDay(config.day,this.getFullYear(),this.getMonth())){this.addDays(config.day-this.getDate());}
if(config.timezone){this.setTimezone(config.timezone);}
if(config.timezoneOffset){this.setTimezoneOffset(config.timezoneOffset);}
if(config.week&&$D._validate(config.week,0,53,"week")){this.setWeek(config.week);}
return this;};$P.moveToFirstDayOfMonth=function(){return this.set({day:1});};$P.moveToLastDayOfMonth=function(){return this.set({day:$D.getDaysInMonth(this.getFullYear(),this.getMonth())});};$P.moveToNthOccurrence=function(dayOfWeek,occurrence){var shift=0;if(occurrence>0){shift=occurrence-1;}
else if(occurrence===-1){this.moveToLastDayOfMonth();if(this.getDay()!==dayOfWeek){this.moveToDayOfWeek(dayOfWeek,-1);}
return this;}
return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek,+1).addWeeks(shift);};$P.moveToDayOfWeek=function(dayOfWeek,orient){var diff=(dayOfWeek-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};$P.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};$P.getOrdinalNumber=function(){return Math.ceil((this.clone().clearTime()-new Date(this.getFullYear(),0,1))/86400000)+1;};$P.getTimezone=function(){return $D.getTimezoneAbbreviation(this.getUTCOffset());};$P.setTimezoneOffset=function(offset){var here=this.getTimezoneOffset(),there=Number(offset)*-6/10;return this.addMinutes(there-here);};$P.setTimezone=function(offset){return this.setTimezoneOffset($D.getTimezoneOffset(offset));};$P.hasDaylightSavingTime=function(){return(Date.today().set({month:0,day:1}).getTimezoneOffset()!==Date.today().set({month:6,day:1}).getTimezoneOffset());};$P.isDaylightSavingTime=function(){return(this.hasDaylightSavingTime()&&new Date().getTimezoneOffset()===Date.today().set({month:6,day:1}).getTimezoneOffset());};$P.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r.charAt(0)+r.substr(2);}else{r=(n+10000).toString();return"+"+r.substr(1);}};$P.getElapsed=function(date){return(date||new Date())-this;};if(!$P.toISOString){$P.toISOString=function(){function f(n){return n<10?'0'+n:n;}
return'"'+this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z"';};}
$P._toString=$P.toString;$P.toString=function(format){var x=this;if(format&&format.length==1){var c=$C.formatPatterns;x.t=x.toString;switch(format){case"d":return x.t(c.shortDate);case"D":return x.t(c.longDate);case"F":return x.t(c.fullDateTime);case"m":return x.t(c.monthDay);case"r":return x.t(c.rfc1123);case"s":return x.t(c.sortableDateTime);case"t":return x.t(c.shortTime);case"T":return x.t(c.longTime);case"u":return x.t(c.universalSortableDateTime);case"y":return x.t(c.yearMonth);}}
var ord=function(n){switch(n*1){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};return format?format.replace(/(\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)/g,function(m){if(m.charAt(0)==="\\"){return m.replace("\\","");}
x.h=x.getHours;switch(m){case"hh":return p(x.h()<13?(x.h()===0?12:x.h()):(x.h()-12));case"h":return x.h()<13?(x.h()===0?12:x.h()):(x.h()-12);case"HH":return p(x.h());case"H":return x.h();case"mm":return p(x.getMinutes());case"m":return x.getMinutes();case"ss":return p(x.getSeconds());case"s":return x.getSeconds();case"yyyy":return p(x.getFullYear(),4);case"yy":return p(x.getFullYear());case"dddd":return $C.dayNames[x.getDay()];case"ddd":return $C.abbreviatedDayNames[x.getDay()];case"dd":return p(x.getDate());case"d":return x.getDate();case"MMMM":return $C.monthNames[x.getMonth()];case"MMM":return $C.abbreviatedMonthNames[x.getMonth()];case"MM":return p((x.getMonth()+1));case"M":return x.getMonth()+1;case"t":return x.h()<12?$C.amDesignator.substring(0,1):$C.pmDesignator.substring(0,1);case"tt":return x.h()<12?$C.amDesignator:$C.pmDesignator;case"S":return ord(x.getDate());default:return m;}}):this._toString();};}());(function(){var $D=Date,$P=$D.prototype,$C=$D.CultureInfo,$N=Number.prototype;$P._orient=+1;$P._nth=null;$P._is=false;$P._same=false;$P._isSecond=false;$N._dateElement="day";$P.next=function(){this._orient=+1;return this;};$D.next=function(){return $D.today().next();};$P.last=$P.prev=$P.previous=function(){this._orient=-1;return this;};$D.last=$D.prev=$D.previous=function(){return $D.today().last();};$P.is=function(){this._is=true;return this;};$P.same=function(){this._same=true;this._isSecond=false;return this;};$P.today=function(){return this.same().day();};$P.weekday=function(){if(this._is){this._is=false;return(!this.is().sat()&&!this.is().sun());}
return false;};$P.at=function(time){return(typeof time==="string")?$D.parse(this.toString("d")+" "+time):this.set(time);};$N.fromNow=$N.after=function(date){var c={};c[this._dateElement]=this;return((!date)?new Date():date.clone()).add(c);};$N.ago=$N.before=function(date){var c={};c[this._dateElement]=this*-1;return((!date)?new Date():date.clone()).add(c);};var dx=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx=("january february march april may june july august september october november december").split(/\s/),px=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),pxf=("Milliseconds Seconds Minutes Hours Date Week Month FullYear").split(/\s/),nth=("final first second third fourth fifth").split(/\s/),de;$P.toObject=function(){var o={};for(var i=0;i<px.length;i++){o[px[i].toLowerCase()]=this["get"+pxf[i]]();}
return o;};$D.fromObject=function(config){config.week=null;return Date.today().set(config);};var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;}
if(this._nth!==null){if(this._isSecond){this.addSeconds(this._orient*-1);}
this._isSecond=false;var ntemp=this._nth;this._nth=null;var temp=this.clone().moveToLastDayOfMonth();this.moveToNthOccurrence(n,ntemp);if(this>temp){throw new RangeError($D.getDayName(n)+" does not occur "+ntemp+" times in the month of "+$D.getMonthName(temp.getMonth())+" "+temp.getFullYear()+".");}
return this;}
return this.moveToDayOfWeek(n,this._orient);};};var sdf=function(n){return function(){var t=$D.today(),shift=n-t.getDay();if(n===0&&$C.firstDayOfWeek===1&&t.getDay()!==0){shift=shift+7;}
return t.addDays(shift);};};for(var i=0;i<dx.length;i++){$D[dx[i].toUpperCase()]=$D[dx[i].toUpperCase().substring(0,3)]=i;$D[dx[i]]=$D[dx[i].substring(0,3)]=sdf(i);$P[dx[i]]=$P[dx[i].substring(0,3)]=df(i);}
var mf=function(n){return function(){if(this._is){this._is=false;return this.getMonth()===n;}
return this.moveToMonth(n,this._orient);};};var smf=function(n){return function(){return $D.today().set({month:n,day:1});};};for(var j=0;j<mx.length;j++){$D[mx[j].toUpperCase()]=$D[mx[j].toUpperCase().substring(0,3)]=j;$D[mx[j]]=$D[mx[j].substring(0,3)]=smf(j);$P[mx[j]]=$P[mx[j].substring(0,3)]=mf(j);}
var ef=function(j){return function(){if(this._isSecond){this._isSecond=false;return this;}
if(this._same){this._same=this._is=false;var o1=this.toObject(),o2=(arguments[0]||new Date()).toObject(),v="",k=j.toLowerCase();for(var m=(px.length-1);m>-1;m--){v=px[m].toLowerCase();if(o1[v]!=o2[v]){return false;}
if(k==v){break;}}
return true;}
if(j.substring(j.length-1)!="s"){j+="s";}
return this["add"+j](this._orient);};};var nf=function(n){return function(){this._dateElement=n;return this;};};for(var k=0;k<px.length;k++){de=px[k].toLowerCase();$P[de]=$P[de+"s"]=ef(px[k]);$N[de]=$N[de+"s"]=nf(de);}
$P._ss=ef("Second");var nthfn=function(n){return function(dayOfWeek){if(this._same){return this._ss(arguments[0]);}
if(dayOfWeek||dayOfWeek===0){return this.moveToNthOccurrence(dayOfWeek,n);}
this._nth=n;if(n===2&&(dayOfWeek===undefined||dayOfWeek===null)){this._isSecond=true;return this.addSeconds(this._orient);}
return this;};};for(var l=0;l<nth.length;l++){$P[nth[l]]=(l===0)?nthfn(-1):nthfn(l);}}());(function(){Date.Parsing={Exception:function(s){this.message="Parse error at '"+s.substring(0,10)+" ...'";}};var $P=Date.Parsing;var _=$P.Operators={rtoken:function(r){return function(s){var mx=s.match(r);if(mx){return([mx[0],s.substring(mx[0].length)]);}else{throw new $P.Exception(s);}};},token:function(s){return function(s){return _.rtoken(new RegExp("^\s*"+s+"\s*"))(s);};},stoken:function(s){return _.rtoken(new RegExp("^"+s));},until:function(p){return function(s){var qx=[],rx=null;while(s.length){try{rx=p.call(this,s);}catch(e){qx.push(rx[0]);s=rx[1];continue;}
break;}
return[qx,s];};},many:function(p){return function(s){var rx=[],r=null;while(s.length){try{r=p.call(this,s);}catch(e){return[rx,s];}
rx.push(r[0]);s=r[1];}
return[rx,s];};},optional:function(p){return function(s){var r=null;try{r=p.call(this,s);}catch(e){return[null,s];}
return[r[0],r[1]];};},not:function(p){return function(s){try{p.call(this,s);}catch(e){return[null,s];}
throw new $P.Exception(s);};},ignore:function(p){return p?function(s){var r=null;r=p.call(this,s);return[null,r[1]];}:null;},product:function(){var px=arguments[0],qx=Array.prototype.slice.call(arguments,1),rx=[];for(var i=0;i<px.length;i++){rx.push(_.each(px[i],qx));}
return rx;},cache:function(rule){var cache={},r=null;return function(s){try{r=cache[s]=(cache[s]||rule.call(this,s));}catch(e){r=cache[s]=e;}
if(r instanceof $P.Exception){throw r;}else{return r;}};},any:function(){var px=arguments;return function(s){var r=null;for(var i=0;i<px.length;i++){if(px[i]==null){continue;}
try{r=(px[i].call(this,s));}catch(e){r=null;}
if(r){return r;}}
throw new $P.Exception(s);};},each:function(){var px=arguments;return function(s){var rx=[],r=null;for(var i=0;i<px.length;i++){if(px[i]==null){continue;}
try{r=(px[i].call(this,s));}catch(e){throw new $P.Exception(s);}
rx.push(r[0]);s=r[1];}
return[rx,s];};},all:function(){var px=arguments,_=_;return _.each(_.optional(px));},sequence:function(px,d,c){d=d||_.rtoken(/^\s*/);c=c||null;if(px.length==1){return px[0];}
return function(s){var r=null,q=null;var rx=[];for(var i=0;i<px.length;i++){try{r=px[i].call(this,s);}catch(e){break;}
rx.push(r[0]);try{q=d.call(this,r[1]);}catch(ex){q=null;break;}
s=q[1];}
if(!r){throw new $P.Exception(s);}
if(q){throw new $P.Exception(q[1]);}
if(c){try{r=c.call(this,r[1]);}catch(ey){throw new $P.Exception(r[1]);}}
return[rx,(r?r[1]:s)];};},between:function(d1,p,d2){d2=d2||d1;var _fn=_.each(_.ignore(d1),p,_.ignore(d2));return function(s){var rx=_fn.call(this,s);return[[rx[0][0],r[0][2]],rx[1]];};},list:function(p,d,c){d=d||_.rtoken(/^\s*/);c=c||null;return(p instanceof Array?_.each(_.product(p.slice(0,-1),_.ignore(d)),p.slice(-1),_.ignore(c)):_.each(_.many(_.each(p,_.ignore(d))),px,_.ignore(c)));},set:function(px,d,c){d=d||_.rtoken(/^\s*/);c=c||null;return function(s){var r=null,p=null,q=null,rx=null,best=[[],s],last=false;for(var i=0;i<px.length;i++){q=null;p=null;r=null;last=(px.length==1);try{r=px[i].call(this,s);}catch(e){continue;}
rx=[[r[0]],r[1]];if(r[1].length>0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;}
if(!last&&q[1].length===0){last=true;}
if(!last){var qx=[];for(var j=0;j<px.length;j++){if(i!=j){qx.push(px[j]);}}
p=_.set(qx,d).call(this,q[1]);if(p[0].length>0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}}
if(rx[1].length<best[1].length){best=rx;}
if(best[1].length===0){break;}}
if(best[0].length===0){return best;}
if(c){try{q=c.call(this,best[1]);}catch(ey){throw new $P.Exception(best[1]);}
best[1]=q[1];}
return best;};},forward:function(gr,fname){return function(s){return gr[fname].call(this,s);};},replace:function(rule,repl){return function(s){var r=rule.call(this,s);return[repl,r[1]];};},process:function(rule,fn){return function(s){var r=rule.call(this,s);return[fn.call(this,r[0]),r[1]];};},min:function(min,rule){return function(s){var rx=rule.call(this,s);if(rx[0].length<min){throw new $P.Exception(s);}
return rx;};}};var _generator=function(op){return function(){var args=null,rx=[];if(arguments.length>1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];}
if(args){for(var i=0,px=args.shift();i<px.length;i++){args.unshift(px[i]);rx.push(op.apply(null,args));args.shift();return rx;}}else{return op.apply(null,arguments);}};};var gx="optional not ignore cache".split(/\s/);for(var i=0;i<gx.length;i++){_[gx[i]]=_generator(_[gx[i]]);}
var _vector=function(op){return function(){if(arguments[0]instanceof Array){return op.apply(null,arguments[0]);}else{return op.apply(null,arguments);}};};var vx="each any all".split(/\s/);for(var j=0;j<vx.length;j++){_[vx[j]]=_vector(_[vx[j]]);}}());(function(){var $D=Date,$P=$D.prototype,$C=$D.CultureInfo;var flattenAndCompact=function(ax){var rx=[];for(var i=0;i<ax.length;i++){if(ax[i]instanceof Array){rx=rx.concat(flattenAndCompact(ax[i]));}else{if(ax[i]){rx.push(ax[i]);}}}
return rx;};$D.Grammar={};$D.Translator={hour:function(s){return function(){this.hour=Number(s);};},minute:function(s){return function(){this.minute=Number(s);};},second:function(s){return function(){this.second=Number(s);};},meridian:function(s){return function(){this.meridian=s.slice(0,1).toLowerCase();};},timezone:function(s){return function(){var n=s.replace(/[^\d\+\-]/g,"");if(n.length){this.timezoneOffset=Number(n);}else{this.timezone=s.toLowerCase();}};},day:function(x){var s=x[0];return function(){this.day=Number(s.match(/\d+/)[0]);};},month:function(s){return function(){this.month=(s.length==3)?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4:Number(s)-1;};},year:function(s){return function(){var n=Number(s);this.year=((s.length>2)?n:(n+(((n+2000)<$C.twoDigitYearMax)?2000:1900)));};},rday:function(s){return function(){switch(s){case"yesterday":this.days=-1;break;case"tomorrow":this.days=1;break;case"today":this.days=0;break;case"now":this.days=0;this.now=true;break;}};},finishExact:function(x){x=(x instanceof Array)?x:[x];for(var i=0;i<x.length;i++){if(x[i]){x[i].call(this);}}
var now=new Date();if((this.hour||this.minute)&&(!this.month&&!this.year&&!this.day)){this.day=now.getDate();}
if(!this.year){this.year=now.getFullYear();}
if(!this.month&&this.month!==0){this.month=now.getMonth();}
if(!this.day){this.day=1;}
if(!this.hour){this.hour=0;}
if(!this.minute){this.minute=0;}
if(!this.second){this.second=0;}
if(this.meridian&&this.hour){if(this.meridian=="p"&&this.hour<12){this.hour=this.hour+12;}else if(this.meridian=="a"&&this.hour==12){this.hour=0;}}
if(this.day>$D.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.");}
var r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){r.set({timezone:this.timezone});}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset});}
return r;},finish:function(x){x=(x instanceof Array)?flattenAndCompact(x):[x];if(x.length===0){return null;}
for(var i=0;i<x.length;i++){if(typeof x[i]=="function"){x[i].call(this);}}
var today=$D.today();if(this.now&&!this.unit&&!this.operator){return new Date();}else if(this.now){today=new Date();}
var expression=!!(this.days&&this.days!==null||this.orient||this.operator);var gap,mod,orient;orient=((this.orient=="past"||this.operator=="subtract")?-1:1);if(!this.now&&"hour minute second".indexOf(this.unit)!=-1){today.setTimeToNow();}
if(this.month||this.month===0){if("year day hour minute second".indexOf(this.unit)!=-1){this.value=this.month+1;this.month=null;expression=true;}}
if(!expression&&this.weekday&&!this.day&&!this.days){var temp=Date[this.weekday]();this.day=temp.getDate();if(!this.month){this.month=temp.getMonth();}
this.year=temp.getFullYear();}
if(expression&&this.weekday&&this.unit!="month"){this.unit="day";gap=($D.getDayNumberFromName(this.weekday)-today.getDay());mod=7;this.days=gap?((gap+(orient*mod))%mod):(orient*mod);}
if(this.month&&this.unit=="day"&&this.operator){this.value=(this.month+1);this.month=null;}
if(this.value!=null&&this.month!=null&&this.year!=null){this.day=this.value*1;}
if(this.month&&!this.day&&this.value){today.set({day:this.value*1});if(!expression){this.day=this.value*1;}}
if(!this.month&&this.value&&this.unit=="month"&&!this.now){this.month=this.value;expression=true;}
if(expression&&(this.month||this.month===0)&&this.unit!="year"){this.unit="month";gap=(this.month-today.getMonth());mod=12;this.months=gap?((gap+(orient*mod))%mod):(orient*mod);this.month=null;}
if(!this.unit){this.unit="day";}
if(!this.value&&this.operator&&this.operator!==null&&this[this.unit+"s"]&&this[this.unit+"s"]!==null){this[this.unit+"s"]=this[this.unit+"s"]+((this.operator=="add")?1:-1)+(this.value||0)*orient;}else if(this[this.unit+"s"]==null||this.operator!=null){if(!this.value){this.value=1;}
this[this.unit+"s"]=this.value*orient;}
if(this.meridian&&this.hour){if(this.meridian=="p"&&this.hour<12){this.hour=this.hour+12;}else if(this.meridian=="a"&&this.hour==12){this.hour=0;}}
if(this.weekday&&!this.day&&!this.days){var temp=Date[this.weekday]();this.day=temp.getDate();if(temp.getMonth()!==today.getMonth()){this.month=temp.getMonth();}}
if((this.month||this.month===0)&&!this.day){this.day=1;}
if(!this.orient&&!this.operator&&this.unit=="week"&&this.value&&!this.day&&!this.month){return Date.today().setWeek(this.value);}
if(expression&&this.timezone&&this.day&&this.days){this.day=this.days;}
return(expression)?today.add(this):today.set(this);}};var _=$D.Parsing.Operators,g=$D.Grammar,t=$D.Translator,_fn;g.datePartDelimiter=_.rtoken(/^([\s\-\.\,\/\x27]+)/);g.timePartDelimiter=_.stoken(":");g.whiteSpace=_.rtoken(/^\s*/);g.generalDelimiter=_.rtoken(/^(([\s\,]|at|@|on)+)/);var _C={};g.ctoken=function(keys){var fn=_C[keys];if(!fn){var c=$C.regexPatterns;var kx=keys.split(/\s+/),px=[];for(var i=0;i<kx.length;i++){px.push(_.replace(_.rtoken(c[kx[i]]),kx[i]));}
fn=_C[keys]=_.any.apply(null,px);}
return fn;};g.ctoken2=function(key){return _.rtoken($C.regexPatterns[key]);};g.h=_.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/),t.hour));g.hh=_.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/),t.hour));g.H=_.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/),t.hour));g.HH=_.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/),t.hour));g.m=_.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/),t.minute));g.mm=_.cache(_.process(_.rtoken(/^[0-5][0-9]/),t.minute));g.s=_.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/),t.second));g.ss=_.cache(_.process(_.rtoken(/^[0-5][0-9]/),t.second));g.hms=_.cache(_.sequence([g.H,g.m,g.s],g.timePartDelimiter));g.t=_.cache(_.process(g.ctoken2("shortMeridian"),t.meridian));g.tt=_.cache(_.process(g.ctoken2("longMeridian"),t.meridian));g.z=_.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/),t.timezone));g.zz=_.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/),t.timezone));g.zzz=_.cache(_.process(g.ctoken2("timezone"),t.timezone));g.timeSuffix=_.each(_.ignore(g.whiteSpace),_.set([g.tt,g.zzz]));g.time=_.each(_.optional(_.ignore(_.stoken("T"))),g.hms,g.timeSuffix);g.d=_.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/),_.optional(g.ctoken2("ordinalSuffix"))),t.day));g.dd=_.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/),_.optional(g.ctoken2("ordinalSuffix"))),t.day));g.ddd=g.dddd=_.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"),function(s){return function(){this.weekday=s;};}));g.M=_.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/),t.month));g.MM=_.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/),t.month));g.MMM=g.MMMM=_.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"),t.month));g.y=_.cache(_.process(_.rtoken(/^(\d\d?)/),t.year));g.yy=_.cache(_.process(_.rtoken(/^(\d\d)/),t.year));g.yyy=_.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/),t.year));g.yyyy=_.cache(_.process(_.rtoken(/^(\d\d\d\d)/),t.year));_fn=function(){return _.each(_.any.apply(null,arguments),_.not(g.ctoken2("timeContext")));};g.day=_fn(g.d,g.dd);g.month=_fn(g.M,g.MMM);g.year=_fn(g.yyyy,g.yy);g.orientation=_.process(g.ctoken("past future"),function(s){return function(){this.orient=s;};});g.operator=_.process(g.ctoken("add subtract"),function(s){return function(){this.operator=s;};});g.rday=_.process(g.ctoken("yesterday tomorrow today now"),t.rday);g.unit=_.process(g.ctoken("second minute hour day week month year"),function(s){return function(){this.unit=s;};});g.value=_.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/),function(s){return function(){this.value=s.replace(/\D/g,"");};});g.expression=_.set([g.rday,g.operator,g.value,g.unit,g.orientation,g.ddd,g.MMM]);_fn=function(){return _.set(arguments,g.datePartDelimiter);};g.mdy=_fn(g.ddd,g.month,g.day,g.year);g.ymd=_fn(g.ddd,g.year,g.month,g.day);g.dmy=_fn(g.ddd,g.day,g.month,g.year);g.date=function(s){return((g[$C.dateElementOrder]||g.mdy).call(this,s));};g.format=_.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/),function(fmt){if(g[fmt]){return g[fmt];}else{throw $D.Parsing.Exception(fmt);}}),_.process(_.rtoken(/^[^dMyhHmstz]+/),function(s){return _.ignore(_.stoken(s));}))),function(rules){return _.process(_.each.apply(null,rules),t.finishExact);});var _F={};var _get=function(f){return _F[f]=(_F[f]||g.format(f)[0]);};g.formats=function(fx){if(fx instanceof Array){var rx=[];for(var i=0;i<fx.length;i++){rx.push(_get(fx[i]));}
return _.any.apply(null,rx);}else{return _get(fx);}};g._formats=g.formats(["\"yyyy-MM-ddTHH:mm:ssZ\"","yyyy-MM-ddTHH:mm:ssZ","yyyy-MM-ddTHH:mm:ssz","yyyy-MM-ddTHH:mm:ss","yyyy-MM-ddTHH:mmZ","yyyy-MM-ddTHH:mmz","yyyy-MM-ddTHH:mm","ddd, MMM dd, yyyy H:mm:ss tt","ddd MMM d yyyy HH:mm:ss zzz","MMddyyyy","ddMMyyyy","Mddyyyy","ddMyyyy","Mdyyyy","dMyyyy","yyyy","Mdyy","dMyy","d"]);g._start=_.process(_.set([g.date,g.time,g.expression],g.generalDelimiter,g.whiteSpace),t.finish);g.start=function(s){try{var r=g._formats.call({},s);if(r[1].length===0){return r;}}catch(e){}
return g._start.call({},s);};$D._parse=$D.parse;$D.parse=function(s){var r=null;if(!s){return null;}
if(s instanceof Date){return s;}
try{r=$D.Grammar.start.call({},s.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1"));}catch(e){return null;}
return((r[1].length===0)?r[0]:null);};$D.getParseFunction=function(fx){var fn=$D.Grammar.formats(fx);return function(s){var r=null;try{r=fn.call({},s);}catch(e){return null;}
return((r[1].length===0)?r[0]:null);};};$D.parseExact=function(s,fx){return $D.getParseFunction(fx)(s);};}());Eventful.TimePicker=function(oArgs)
{this.id=oArgs.id;this.bRequired=oArgs.required;this.bOptions=oArgs.options;this.oDropDown=new Eventful.DropDown({input:'#inp-'+this.id,popover:'#time-picker-'+this.id+' .popover'});this.oDropDown.eventItemHighlighted.subscribe(this.listenTimeHighlighted.bind(this));this.oDropDown.eventItemSelected.subscribe(this.listenTimeSelected.bind(this));this.oDropDown.eventPopoverShown.subscribe(this.listenPopoverShown.bind(this));this.oDropDown.eventInputChanged.subscribe(this.listenInputChanged.bind(this));this.oDropDown.eventBlur.subscribe(this.listenBlur.bind(this));this.eventTimePicked=new Eventful.UIEvent();$(this.setup.bind(this));}
Eventful.TimePicker.prototype.nextday=function()
{return this.jqNextday?this.jqNextday:this.jqNextday=$('#time-picker-'+this.id+' .next-day');}
Eventful.TimePicker.prototype.setup=function()
{this.oDropDown.queue(new Eventful.CircularQ($.map(this.oDropDown.list().find('li'),function(el)
{return $.trim($(el).text());})));if(this.bOptions)
{this.oDropDown.find('p.options').show();}
this.oDropDown.find('.click-all-day, .click-none').click(this.listenClickAllDayOrNone.bind(this));if(this.oDropDown.input().is(':visible'))
{this.fixPopoverPosition();}}
Eventful.TimePicker.prototype.time=function()
{var oTime=Eventful.TimePicker.parseTime(this.oDropDown.input().val());if(this.bOptions||!oTime||!oTime.all_day)
{return oTime;}}
Eventful.TimePicker.prototype.fixPopoverPosition=function()
{if(this.bFixedPosition)return;this.bFixedPosition=true;var nHeight=$('#time-picker-'+this.id).height();this.oDropDown.popover().css({top:nHeight});this.nextday().css({top:nHeight+5});}
Eventful.TimePicker.prototype.updateListHighlight=function(sTime)
{var oTime=Eventful.TimePicker.parseTime(sTime);if(oTime&&!oTime.all_day)
{var i=Math.floor(oTime.getHours()*2+oTime.getMinutes()/30+0.5);this.oDropDown.highlight(i);}else
{var oTime=this.defaultTime();var i=(this.defaultTime().getHours()*2)+(oTime.getMinutes()>=30?1:0);this.oDropDown.highlight(i);}
this.fixListScroll(this.oDropDown.currentElement());}
Eventful.TimePicker.prototype.defaultTime=function(oTime)
{if(oTime)
{this.oDefaultTime=oTime;}else if(!this.oDefaultTime)
{this.oDefaultTime=new Date().addHours(1);}
return this.oDefaultTime}
Eventful.TimePicker.prototype.fixListScroll=function(el)
{if(!el.offset())return;var nTop=el.offset().top-el.parents(':first').offset().top
var nBottom=nTop+el.height();var nHeight=this.oDropDown.list().height();if(nTop<0)
{this.oDropDown.list()[0].scrollTop+=nTop;}else if(nBottom>nHeight)
{this.oDropDown.list()[0].scrollTop+=nBottom-nHeight;}}
Eventful.TimePicker.prototype.after=function(oStartTime)
{var oTime=this.time();if(oTime&&!oTime.all_day&&oStartTime&&!oStartTime.all_day&&oStartTime.compareTo(oTime)>=0)
{if(oStartTime.compareTo(Date.parse('11:59 pm'))>=0)
{this.oDropDown.clearInput();}else if(!oTime.getHours()&&!oTime.getMinutes()||oStartTime.compareTo(Date.parse('11:30 pm'))>=0)
{oTime=Date.parse('11:59 pm');this.oDropDown.input().val(Eventful.TimePicker.formatTime(oTime));}else
{oTime=oStartTime.addMinutes(30);this.oDropDown.input().val(Eventful.TimePicker.formatTime(oTime));}}}
Eventful.TimePicker.prototype.listenInputChanged=function(sTime)
{this.updateListHighlight(sTime);}
Eventful.TimePicker.prototype.listenPopoverShown=function()
{this.fixPopoverPosition();this.updateListHighlight(this.oDropDown.input().val());}
Eventful.TimePicker.prototype.listenTimeHighlighted=function(sTime)
{this.oDropDown.input().val(sTime).select();this.fixListScroll(this.oDropDown.currentElement());}
Eventful.TimePicker.prototype.listenTimeSelected=function(sTime)
{sTime=Eventful.TimePicker.formatTime(sTime);this.oDropDown.input().val(sTime).select();this.eventTimePicked.fire(this.time());}
Eventful.TimePicker.prototype.listenBlur=function(evt)
{if(!this.time())
{if(this.bRequired)
{var sTime=this.oDropDown.oQueue.current();this.oDropDown.input().removeClass('inactive').val(sTime);}else
{this.oDropDown.clearInput();}}
if(this.time())
{this.oDropDown.input().val(Eventful.TimePicker.formatTime(this.time()));}
this.eventTimePicked.fire(this.time());}
Eventful.TimePicker.prototype.listenClickAllDayOrNone=function(evt)
{this.oDropDown.input().val($(evt.target).text().toLowerCase());this.eventTimePicked.fire(this.time());this.oDropDown.popover().hide();}
Eventful.TimePicker.parseTime=function(s)
{s=$.trim(s).toLowerCase();if(!s)return undefined;if(s=='all day')return{all_day:1};if(s=='none')return{all_day:2};if(/^m/.test(s))return Date.parse('12:00 am');if(/^n/.test(s))return Date.parse('12:00 pm');var aMatch=s.match(/^(\d{1,2})(\d{2}.*)$/)
if(aMatch)s=aMatch.splice(1,2).join(':');if(/^(am|pm)/.test(s))s=[s.substring(2),s.substring(0,2)].join(' ');if(/^\d+$/.test(s))s=s+":00";return Date.parse(s);}
Eventful.TimePicker.formatTime=function(oTime)
{if(typeof oTime==='string')
oTime=Eventful.TimePicker.parseTime(oTime);switch(oTime.all_day)
{case 1:return'all day';case 2:return'none';default:var sTime=oTime.toString(Eventful.TimePicker.format());return Eventful.TimePicker.bFormatLowerCase?sTime.toLowerCase():sTime;}}
Eventful.TimePicker.format=function()
{if(!Eventful.TimePicker.sFormat)
{Eventful.TimePicker.sFormat='h:mm tt';Eventful.TimePicker.bFormatLowerCase=true;if(Eventful.Session&&Eventful.Session.Prefs.tf)
{var sFormat=Eventful.Session.Prefs.tf.
replace('%L','h').
replace('%M','mm').
replace('%p','tt').
replace('%P','tt').
replace('%H','HH').
replace('%I','hh');Eventful.TimePicker.bFormatLowerCase=Eventful.Session.Prefs.tf.indexOf('%P')>=0;if(sFormat.indexOf('%')==-1)
{Eventful.TimePicker.sFormat=sFormat;}}}
return Eventful.TimePicker.sFormat;}
/* jQuery UI Date Picker v3.4.3 (previously jQuery Calendar)
   Written by Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@virginbroadband.com.au).

   Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/ui-datepicker)
   Dual licensed under the MIT (MIT-LICENSE.txt)
   and GPL (GPL-LICENSE.txt) licenses.
   Date: 09-03-2007  */;(function($){function Datepicker(){this.debug=false;this._nextId=0;this._inst=[];this._curInst=null;this._disabledInputs=[];this._datepickerShowing=false;this._inDialog=false;this.regional=[];this.regional['']={clearText:'Clear',clearStatus:'Erase the current date',closeText:'Close',closeStatus:'Close without change',prevText:'&#x3c;Prev',prevStatus:'Show the previous month',nextText:'Next&#x3e;',nextStatus:'Show the next month',currentText:'',currentStatus:'Show the current month',monthNames:['January','February','March','April','May','June','July','August','September','October','November','December'],monthNamesShort:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],monthStatus:'Show a different month',yearStatus:'Show a different year',weekHeader:'Wk',weekStatus:'Week of the year',dayNames:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],dayNamesShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],dayNamesMin:['Su','Mo','Tu','We','Th','Fr','Sa'],dayStatus:'Set DD as first week day',dateStatus:'Select DD, M d',dateFormat:'mm/dd/yy',firstDay:0,initStatus:'Select a date',isRTL:false};this._defaults={showOn:'focus',showAnim:'show',defaultDate:null,appendText:'',buttonText:'...',buttonImage:'',buttonImageOnly:false,closeAtTop:true,mandatory:false,hideIfNoPrevNext:false,changeMonth:false,changeYear:false,yearRange:'-10:+10',changeFirstDay:false,showOtherMonths:false,showWeeks:false,calculateWeek:this.iso8601Week,shortYearCutoff:'+10',showStatus:false,statusForDate:this.dateStatus,minDate:null,maxDate:null,speed:'normal',beforeShowDay:null,beforeShow:null,onSelect:null,onClose:null,numberOfMonths:1,stepMonths:1,rangeSelect:false,rangeSeparator:' - '};$.extend(this._defaults,this.regional['']);this._datepickerDiv=$('<div id="datepicker_div">');}
$.extend(Datepicker.prototype,{markerClassName:'hasDatepicker',log:function(){if(this.debug)
console.log.apply('',arguments);},_register:function(inst){var id=this._nextId++;this._inst[id]=inst;return id;},_getInst:function(id){return this._inst[id]||id;},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this;},_attachDatepicker:function(target,settings){var inlineSettings=null;for(attrName in this._defaults){var attrValue=target.getAttribute('date:'+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue);}catch(err){inlineSettings[attrName]=attrValue;}}}
var nodeName=target.nodeName.toLowerCase();var instSettings=(inlineSettings?$.extend(settings||{},inlineSettings||{}):settings);if(nodeName=='input'){var inst=(inst&&!inlineSettings?inst:new DatepickerInstance(instSettings,false));this._connectDatepicker(target,inst);}else if(nodeName=='div'||nodeName=='span'){var inst=new DatepickerInstance(instSettings,true);this._inlineDatepicker(target,inst);}},_destroyDatepicker:function(target){var nodeName=target.nodeName.toLowerCase();var calId=target._calId;target._calId=null;var $target=$(target);if(nodeName=='input'){$target.siblings('.datepicker_append').replaceWith('').end()
.siblings('.datepicker_trigger').replaceWith('').end()
.removeClass(this.markerClassName)
.unbind('focus',this._showDatepicker)
.unbind('keydown',this._doKeyDown)
.unbind('keypress',this._doKeyPress);var wrapper=$target.parents('.datepicker_wrap');if(wrapper)
wrapper.replaceWith(wrapper.html());}else if(nodeName=='div'||nodeName=='span')
$target.removeClass(this.markerClassName).empty();if($('input[_calId='+calId+']').length==0)
this._inst[calId]=null;},_enableDatepicker:function(target){target.disabled=false;$(target).siblings('button.datepicker_trigger').each(function(){this.disabled=false;}).end()
.siblings('img.datepicker_trigger').css({opacity:'1.0',cursor:''});this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value);});},_disableDatepicker:function(target){target.disabled=true;$(target).siblings('button.datepicker_trigger').each(function(){this.disabled=true;}).end()
.siblings('img.datepicker_trigger').css({opacity:'0.5',cursor:'default'});this._disabledInputs=$.map($.datepicker._disabledInputs,function(value){return(value==target?null:value);});this._disabledInputs[$.datepicker._disabledInputs.length]=target;},_isDisabledDatepicker:function(target){if(!target)
return false;for(var i=0;i<this._disabledInputs.length;i++){if(this._disabledInputs[i]==target)
return true;}
return false;},_changeDatepicker:function(target,name,value){var settings=name||{};if(typeof name=='string'){settings={};settings[name]=value;}
if(inst=this._getInst(target._calId)){extendRemove(inst._settings,settings);this._updateDatepicker(inst);}},_setDateDatepicker:function(target,date,endDate){if(inst=this._getInst(target._calId)){inst._setDate(date,endDate);this._updateDatepicker(inst);}},_getDateDatepicker:function(target){var inst=this._getInst(target._calId);return(inst?inst._getDate():null);},_doKeyDown:function(e){var inst=$.datepicker._getInst(this._calId);if($.datepicker._datepickerShowing)
switch(e.keyCode){case 9:$.datepicker._hideDatepicker(null,'');break;case 13:$.datepicker._selectDay(inst,inst._selectedMonth,inst._selectedYear,$('td.datepicker_daysCellOver',inst._datepickerDiv)[0]);return false;break;case 27:$.datepicker._hideDatepicker(null,inst._get('speed'));break;case 33:$.datepicker._adjustDate(inst,(e.ctrlKey?-1:-inst._get('stepMonths')),(e.ctrlKey?'Y':'M'));break;case 34:$.datepicker._adjustDate(inst,(e.ctrlKey?+1:+inst._get('stepMonths')),(e.ctrlKey?'Y':'M'));break;case 35:if(e.ctrlKey)$.datepicker._clearDate(inst);break;case 36:if(e.ctrlKey)$.datepicker._gotoToday(inst);break;case 37:if(e.ctrlKey)$.datepicker._adjustDate(inst,-1,'D');break;case 38:if(e.ctrlKey)$.datepicker._adjustDate(inst,-7,'D');break;case 39:if(e.ctrlKey)$.datepicker._adjustDate(inst,+1,'D');break;case 40:if(e.ctrlKey)$.datepicker._adjustDate(inst,+7,'D');break;}
else if(e.keyCode==36&&e.ctrlKey)
$.datepicker._showDatepicker(this);},_doKeyPress:function(e){var inst=$.datepicker._getInst(this._calId);var chars=$.datepicker._possibleChars(inst._get('dateFormat'));var chr=String.fromCharCode(e.charCode==undefined?e.keyCode:e.charCode);return e.ctrlKey||(chr<' '||!chars||chars.indexOf(chr)>-1);},_connectDatepicker:function(target,inst){var input=$(target);if(input.is('.'+this.markerClassName))
return;var appendText=inst._get('appendText');var isRTL=inst._get('isRTL');if(appendText){if(isRTL)
input.before('<span class="datepicker_append">'+appendText);else
input.after('<span class="datepicker_append">'+appendText);}
var showOn=inst._get('showOn');if(showOn=='focus'||showOn=='both')
input.focus(this._showDatepicker);if(showOn=='button'||showOn=='both'){input.wrap('<span class="datepicker_wrap">');var buttonText=inst._get('buttonText');var buttonImage=inst._get('buttonImage');var trigger=$(inst._get('buttonImageOnly')?$('<img>').addClass('datepicker_trigger').attr({src:buttonImage,alt:buttonText,title:buttonText}):$('<button>').addClass('datepicker_trigger').attr({type:'button'}).html(buttonImage!=''?$('<img>').attr({src:buttonImage,alt:buttonText,title:buttonText}):buttonText));if(isRTL)
input.before(trigger);else
input.after(trigger);trigger.click(function(){if($.datepicker._datepickerShowing&&$.datepicker._lastInput==target)
$.datepicker._hideDatepicker();else
$.datepicker._showDatepicker(target);});}
input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress)
.bind("setData.datepicker",function(event,key,value){inst._settings[key]=value;}).bind("getData.datepicker",function(event,key){return inst._get(key);});input[0]._calId=inst._id;},_inlineDatepicker:function(target,inst){var input=$(target);if(input.is('.'+this.markerClassName))
return;input.addClass(this.markerClassName).append(inst._datepickerDiv)
.bind("setData.datepicker",function(event,key,value){inst._settings[key]=value;}).bind("getData.datepicker",function(event,key){return inst._get(key);});input[0]._calId=inst._id;this._updateDatepicker(inst);},_inlineShow:function(inst){var numMonths=inst._getNumberOfMonths();inst._datepickerDiv.width(numMonths[1]*$('.datepicker',inst._datepickerDiv[0]).width());},_dialogDatepicker:function(input,dateText,onSelect,settings,pos){var inst=this._dialogInst;if(!inst){inst=this._dialogInst=new DatepickerInstance({},false);this._dialogInput=$('<input type="text" size="1" style="position: absolute; top: -100px;"/>');this._dialogInput.keydown(this._doKeyDown);$('body').append(this._dialogInput);this._dialogInput[0]._calId=inst._id;}
extendRemove(inst._settings,settings||{});this._dialogInput.val(dateText);this._pos=(pos?(pos.length?pos:[pos.pageX,pos.pageY]):null);if(!this._pos){var browserWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;var browserHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[(browserWidth/2)-100+scrollX,(browserHeight/2)-150+scrollY];}
this._dialogInput.css('left',this._pos[0]+'px').css('top',this._pos[1]+'px');inst._settings.onSelect=onSelect;this._inDialog=true;this._datepickerDiv.addClass('datepicker_dialog');this._showDatepicker(this._dialogInput[0]);if($.blockUI)
$.blockUI(this._datepickerDiv);return this;},_showDatepicker:function(input){input=input.target||input;if(input.nodeName.toLowerCase()!='input')
input=$('input',input.parentNode)[0];if($.datepicker._isDisabledDatepicker(input)||$.datepicker._lastInput==input)
return;var inst=$.datepicker._getInst(input._calId);var beforeShow=inst._get('beforeShow');extendRemove(inst._settings,(beforeShow?beforeShow.apply(input,[input,inst]):{}));$.datepicker._hideDatepicker(null,'');$.datepicker._lastInput=input;inst._setDateFromField(input);if($.datepicker._inDialog)
input.value='';if(!$.datepicker._pos){$.datepicker._pos=$.datepicker._findPos(input);$.datepicker._pos[1]+=input.offsetHeight;}
var isFixed=false;$(input).parents().each(function(){isFixed|=$(this).css('position')=='fixed';});if(isFixed&&$.browser.opera){$.datepicker._pos[0]-=document.documentElement.scrollLeft;$.datepicker._pos[1]-=document.documentElement.scrollTop;}
inst._datepickerDiv.css('position',($.datepicker._inDialog&&$.blockUI?'static':(isFixed?'fixed':'absolute')))
.css({left:$.datepicker._pos[0]+'px',top:$.datepicker._pos[1]+'px'});$.datepicker._pos=null;inst._rangeStart=null;$.datepicker._updateDatepicker(inst);if(!inst._inline){var speed=inst._get('speed');var postProcess=function(){$.datepicker._datepickerShowing=true;$.datepicker._afterShow(inst);};var showAnim=inst._get('showAnim')||'show';inst._datepickerDiv[showAnim](speed,postProcess);if(speed=='')
postProcess();if(inst._input[0].type!='hidden')
inst._input[0].focus();$.datepicker._curInst=inst;}},_updateDatepicker:function(inst){inst._datepickerDiv.empty().append(inst._generateDatepicker());var numMonths=inst._getNumberOfMonths();if(numMonths[0]!=1||numMonths[1]!=1)
inst._datepickerDiv.addClass('datepicker_multi');else
inst._datepickerDiv.removeClass('datepicker_multi');if(inst._get('isRTL'))
inst._datepickerDiv.addClass('datepicker_rtl');else
inst._datepickerDiv.removeClass('datepicker_rtl');if(inst._input&&inst._input[0].type!='hidden')
inst._input[0].focus();},_afterShow:function(inst){var numMonths=inst._getNumberOfMonths();inst._datepickerDiv.width(numMonths[1]*$('.datepicker',inst._datepickerDiv[0])[0].offsetWidth);if($.browser.msie&&parseInt($.browser.version)<7){$('#datepicker_cover').css({width:inst._datepickerDiv.width()+4,height:inst._datepickerDiv.height()+4});}
var isFixed=inst._datepickerDiv.css('position')=='fixed';var pos=inst._input?$.datepicker._findPos(inst._input[0]):null;var browserWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;var browserHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var scrollX=(isFixed?0:document.documentElement.scrollLeft||document.body.scrollLeft);var scrollY=(isFixed?0:document.documentElement.scrollTop||document.body.scrollTop);if((inst._datepickerDiv.offset().left+inst._datepickerDiv.width()-
(isFixed&&$.browser.msie?document.documentElement.scrollLeft:0))>(browserWidth+scrollX)){inst._datepickerDiv.css('left',Math.max(scrollX,pos[0]+(inst._input?$(inst._input[0]).width():null)-inst._datepickerDiv.width()-
(isFixed&&$.browser.opera?document.documentElement.scrollLeft:0))+'px');}
if((inst._datepickerDiv.offset().top+inst._datepickerDiv.height()-
(isFixed&&$.browser.msie?document.documentElement.scrollTop:0))>(browserHeight+scrollY)){inst._datepickerDiv.css('top',Math.max(scrollY,pos[1]-(this._inDialog?0:inst._datepickerDiv.height())-
(isFixed&&$.browser.opera?document.documentElement.scrollTop:0))+'px');}},_findPos:function(obj){while(obj&&(obj.type=='hidden'||obj.nodeType!=1)){obj=obj.nextSibling;}
var position=$(obj).offset();return[position.left,position.top];},_hideDatepicker:function(input,speed){var inst=this._curInst;if(!inst)
return;var rangeSelect=inst._get('rangeSelect');if(rangeSelect&&this._stayOpen){this._selectDate(inst,inst._formatDate(inst._currentDay,inst._currentMonth,inst._currentYear));}
this._stayOpen=false;if(this._datepickerShowing){speed=(speed!=null?speed:inst._get('speed'));var showAnim=inst._get('showAnim');inst._datepickerDiv[(showAnim=='slideDown'?'slideUp':(showAnim=='fadeIn'?'fadeOut':'hide'))](speed,function(){$.datepicker._tidyDialog(inst);});if(speed=='')
this._tidyDialog(inst);var onClose=inst._get('onClose');if(onClose){onClose.apply((inst._input?inst._input[0]:null),[inst._getDate(),inst]);}
this._datepickerShowing=false;this._lastInput=null;inst._settings.prompt=null;if(this._inDialog){this._dialogInput.css({position:'absolute',left:'0',top:'-100px'});if($.blockUI){$.unblockUI();$('body').append(this._datepickerDiv);}}
this._inDialog=false;}
this._curInst=null;},_tidyDialog:function(inst){inst._datepickerDiv.removeClass('datepicker_dialog').unbind('.datepicker');$('.datepicker_prompt',inst._datepickerDiv).remove();},_checkExternalClick:function(event){if(!$.datepicker._curInst)
return;var $target=$(event.target);if(($target.parents("#datepicker_div").length==0)&&($target.attr('class')!='datepicker_trigger')&&$.datepicker._datepickerShowing&&!($.datepicker._inDialog&&$.blockUI)){$.datepicker._hideDatepicker(null,'');}},_adjustDate:function(id,offset,period){var inst=this._getInst(id);inst._adjustDate(offset,period);this._updateDatepicker(inst);},_gotoToday:function(id){var date=new Date();var inst=this._getInst(id);inst._selectedDay=date.getDate();inst._drawMonth=inst._selectedMonth=date.getMonth();inst._drawYear=inst._selectedYear=date.getFullYear();this._adjustDate(inst);},_selectMonthYear:function(id,select,period){var inst=this._getInst(id);inst._selectingMonthYear=false;inst[period=='M'?'_drawMonth':'_drawYear']=select.options[select.selectedIndex].value-0;this._adjustDate(inst);},_clickMonthYear:function(id){var inst=this._getInst(id);if(inst._input&&inst._selectingMonthYear&&!$.browser.msie)
inst._input[0].focus();inst._selectingMonthYear=!inst._selectingMonthYear;},_changeFirstDay:function(id,day){var inst=this._getInst(id);inst._settings.firstDay=day;this._updateDatepicker(inst);},_selectDay:function(id,month,year,td){if($(td).is('.datepicker_unselectable'))
return;var inst=this._getInst(id);var rangeSelect=inst._get('rangeSelect');if(rangeSelect){if(!this._stayOpen){$('.datepicker td').removeClass('datepicker_currentDay');$(td).addClass('datepicker_currentDay');}
this._stayOpen=!this._stayOpen;}
inst._selectedDay=inst._currentDay=$('a',td).html();inst._selectedMonth=inst._currentMonth=month;inst._selectedYear=inst._currentYear=year;this._selectDate(id,inst._formatDate(inst._currentDay,inst._currentMonth,inst._currentYear));if(this._stayOpen){inst._endDay=inst._endMonth=inst._endYear=null;inst._rangeStart=new Date(inst._currentYear,inst._currentMonth,inst._currentDay);this._updateDatepicker(inst);}
else if(rangeSelect){inst._endDay=inst._currentDay;inst._endMonth=inst._currentMonth;inst._endYear=inst._currentYear;inst._selectedDay=inst._currentDay=inst._rangeStart.getDate();inst._selectedMonth=inst._currentMonth=inst._rangeStart.getMonth();inst._selectedYear=inst._currentYear=inst._rangeStart.getFullYear();inst._rangeStart=null;if(inst._inline)
this._updateDatepicker(inst);}},_clearDate:function(id){var inst=this._getInst(id);if(inst._get('mandatory'))
return;this._stayOpen=false;inst._endDay=inst._endMonth=inst._endYear=inst._rangeStart=null;this._selectDate(inst,'');},_selectDate:function(id,dateStr){var inst=this._getInst(id);dateStr=(dateStr!=null?dateStr:inst._formatDate());if(inst._rangeStart)
dateStr=inst._formatDate(inst._rangeStart)+inst._get('rangeSeparator')+dateStr;if(inst._input)
inst._input.val(dateStr);var onSelect=inst._get('onSelect');if(onSelect)
onSelect.apply((inst._input?inst._input[0]:null),[dateStr,inst]);else if(inst._input)
inst._input.trigger('change');if(inst._inline)
this._updateDatepicker(inst);else if(!this._stayOpen){this._hideDatepicker(null,inst._get('speed'));this._lastInput=inst._input[0];if(typeof(inst._input[0])!='object')
inst._input[0].focus();this._lastInput=null;}},noWeekends:function(date){var day=date.getDay();return[(day>0&&day<6),''];},iso8601Week:function(date){var checkDate=new Date(date.getFullYear(),date.getMonth(),date.getDate(),(date.getTimezoneOffset()/-60));var firstMon=new Date(checkDate.getFullYear(),1-1,4);var firstDay=firstMon.getDay()||7;firstMon.setDate(firstMon.getDate()+1-firstDay);if(firstDay<4&&checkDate<firstMon){checkDate.setDate(checkDate.getDate()-3);return $.datepicker.iso8601Week(checkDate);}else if(checkDate>new Date(checkDate.getFullYear(),12-1,28)){firstDay=new Date(checkDate.getFullYear()+1,1-1,4).getDay()||7;if(firstDay>4&&(checkDate.getDay()||7)<firstDay-3){checkDate.setDate(checkDate.getDate()+3);return $.datepicker.iso8601Week(checkDate);}}
return Math.floor(((checkDate-firstMon)/86400000)/7)+1;},dateStatus:function(date,inst){return $.datepicker.formatDate(inst._get('dateStatus'),date,inst._getFormatConfig());},parseDate:function(format,value,settings){if(format==null||value==null)
throw'Invalid arguments';value=(typeof value=='object'?value.toString():value+'');if(value=='')
return null;var shortYearCutoff=(settings?settings.shortYearCutoff:null)||this._defaults.shortYearCutoff;var dayNamesShort=(settings?settings.dayNamesShort:null)||this._defaults.dayNamesShort;var dayNames=(settings?settings.dayNames:null)||this._defaults.dayNames;var monthNamesShort=(settings?settings.monthNamesShort:null)||this._defaults.monthNamesShort;var monthNames=(settings?settings.monthNames:null)||this._defaults.monthNames;var year=-1;var month=-1;var day=-1;var literal=false;var lookAhead=function(match){var matches=(iFormat+1<format.length&&format.charAt(iFormat+1)==match);if(matches)
iFormat++;return matches;};var getNumber=function(match){lookAhead(match);var size=(match=='y'?4:2);var num=0;while(size>0&&iValue<value.length&&value.charAt(iValue)>='0'&&value.charAt(iValue)<='9'){num=num*10+(value.charAt(iValue++)-0);size--;}
if(size==(match=='y'?4:2))
throw'Missing number at position '+iValue;return num;};var getName=function(match,shortNames,longNames){var names=(lookAhead(match)?longNames:shortNames);var size=0;for(var j=0;j<names.length;j++)
size=Math.max(size,names[j].length);var name='';var iInit=iValue;while(size>0&&iValue<value.length){name+=value.charAt(iValue++);for(var i=0;i<names.length;i++)
if(name==names[i])
return i+1;size--;}
throw'Unknown name at position '+iInit;};var checkLiteral=function(){if(value.charAt(iValue)!=format.charAt(iFormat))
throw'Unexpected literal at position '+iValue;iValue++;};var iValue=0;for(var iFormat=0;iFormat<format.length;iFormat++){if(literal)
if(format.charAt(iFormat)=="'"&&!lookAhead("'"))
literal=false;else
checkLiteral();else
switch(format.charAt(iFormat)){case'd':day=getNumber('d');break;case'D':getName('D',dayNamesShort,dayNames);break;case'm':month=getNumber('m');break;case'M':month=getName('M',monthNamesShort,monthNames);break;case'y':year=getNumber('y');break;case"'":if(lookAhead("'"))
checkLiteral();else
literal=true;break;default:checkLiteral();}}
if(year<100){year+=new Date().getFullYear()-new Date().getFullYear()%100+
(year<=shortYearCutoff?0:-100);}
var date=new Date(year,month-1,day);if(date.getFullYear()!=year||date.getMonth()+1!=month||date.getDate()!=day){throw'Invalid date';}
return date;},formatDate:function(format,date,settings){if(!date)
return'';var dayNamesShort=(settings?settings.dayNamesShort:null)||this._defaults.dayNamesShort;var dayNames=(settings?settings.dayNames:null)||this._defaults.dayNames;var monthNamesShort=(settings?settings.monthNamesShort:null)||this._defaults.monthNamesShort;var monthNames=(settings?settings.monthNames:null)||this._defaults.monthNames;var lookAhead=function(match){var matches=(iFormat+1<format.length&&format.charAt(iFormat+1)==match);if(matches)
iFormat++;return matches;};var formatNumber=function(match,value){return(lookAhead(match)&&value<10?'0':'')+value;};var formatName=function(match,value,shortNames,longNames){return(lookAhead(match)?longNames[value]:shortNames[value]);};var output='';var literal=false;if(date){for(var iFormat=0;iFormat<format.length;iFormat++){if(literal)
if(format.charAt(iFormat)=="'"&&!lookAhead("'"))
literal=false;else
output+=format.charAt(iFormat);else
switch(format.charAt(iFormat)){case'd':output+=formatNumber('d',date.getDate());break;case'D':output+=formatName('D',date.getDay(),dayNamesShort,dayNames);break;case'm':output+=formatNumber('m',date.getMonth()+1);break;case'M':output+=formatName('M',date.getMonth(),monthNamesShort,monthNames);break;case'y':output+=(lookAhead('y')?date.getFullYear():(date.getYear()%100<10?'0':'')+date.getYear()%100);break;case"'":if(lookAhead("'"))
output+="'";else
literal=true;break;default:output+=format.charAt(iFormat);}}}
return output;},_possibleChars:function(format){var chars='';var literal=false;for(var iFormat=0;iFormat<format.length;iFormat++)
if(literal)
if(format.charAt(iFormat)=="'"&&!lookAhead("'"))
literal=false;else
chars+=format.charAt(iFormat);else
switch(format.charAt(iFormat)){case'd'||'m'||'y':chars+='0123456789';break;case'D'||'M':return null;case"'":if(lookAhead("'"))
chars+="'";else
literal=true;break;default:chars+=format.charAt(iFormat);}
return chars;}});function DatepickerInstance(settings,inline){this._id=$.datepicker._register(this);this._selectedDay=0;this._selectedMonth=0;this._selectedYear=0;this._drawMonth=0;this._drawYear=0;this._input=null;this._inline=inline;this._datepickerDiv=(!inline?$.datepicker._datepickerDiv:$('<div id="datepicker_div_'+this._id+'" class="datepicker_inline">'));this._settings=extendRemove(settings||{});if(inline)
this._setDate(this._getDefaultDate());}
$.extend(DatepickerInstance.prototype,{_get:function(name){return this._settings[name]||$.datepicker._defaults[name];},_setDateFromField:function(input){this._input=$(input);var dateFormat=this._get('dateFormat');var dates=this._input?this._input.val().split(this._get('rangeSeparator')):null;this._endDay=this._endMonth=this._endYear=null;var date=defaultDate=this._getDefaultDate();if(dates.length>0){var settings=this._getFormatConfig();if(dates.length>1){date=$.datepicker.parseDate(dateFormat,dates[1],settings)||defaultDate;this._endDay=date.getDate();this._endMonth=date.getMonth();this._endYear=date.getFullYear();}
try{date=$.datepicker.parseDate(dateFormat,dates[0],settings)||defaultDate;}catch(e){$.datepicker.log(e);date=defaultDate;}}
this._selectedDay=date.getDate();this._drawMonth=this._selectedMonth=date.getMonth();this._drawYear=this._selectedYear=date.getFullYear();this._currentDay=(dates[0]?date.getDate():0);this._currentMonth=(dates[0]?date.getMonth():0);this._currentYear=(dates[0]?date.getFullYear():0);this._adjustDate();},_getDefaultDate:function(){var date=this._determineDate('defaultDate',new Date());var minDate=this._getMinMaxDate('min',true);var maxDate=this._getMinMaxDate('max');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);return date;},_determineDate:function(name,defaultDate){var offsetNumeric=function(offset){var date=new Date();date.setDate(date.getDate()+offset);return date;};var offsetString=function(offset,getDaysInMonth){var date=new Date();var matches=/^([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?$/.exec(offset);if(matches){var year=date.getFullYear();var month=date.getMonth();var day=date.getDate();switch(matches[2]||'d'){case'd':case'D':day+=(matches[1]-0);break;case'w':case'W':day+=(matches[1]*7);break;case'm':case'M':month+=(matches[1]-0);day=Math.min(day,getDaysInMonth(year,month));break;case'y':case'Y':year+=(matches[1]-0);day=Math.min(day,getDaysInMonth(year,month));break;}
date=new Date(year,month,day);}
return date;};var date=this._get(name);return(date==null?defaultDate:(typeof date=='string'?offsetString(date,this._getDaysInMonth):(typeof date=='number'?offsetNumeric(date):date)));},_setDate:function(date,endDate){this._selectedDay=this._currentDay=date.getDate();this._drawMonth=this._selectedMonth=this._currentMonth=date.getMonth();this._drawYear=this._selectedYear=this._currentYear=date.getFullYear();if(this._get('rangeSelect')){if(endDate){this._endDay=endDate.getDate();this._endMonth=endDate.getMonth();this._endYear=endDate.getFullYear();}else{this._endDay=this._currentDay;this._endMonth=this._currentMonth;this._endYear=this._currentYear;}}
this._adjustDate();},_getDate:function(){var startDate=(!this._currentYear||(this._input&&this._input.val()=='')?null:new Date(this._currentYear,this._currentMonth,this._currentDay));if(this._get('rangeSelect')){return[startDate,(!this._endYear?null:new Date(this._endYear,this._endMonth,this._endDay))];}else
return startDate;},_generateDatepicker:function(){var today=new Date();today=new Date(today.getFullYear(),today.getMonth(),today.getDate());var showStatus=this._get('showStatus');var isRTL=this._get('isRTL');var clear=(this._get('mandatory')?'':'<div class="datepicker_clear"><a onclick="jQuery.datepicker._clearDate('+this._id+');"'+
(showStatus?this._addStatus(this._get('clearStatus')||'&#xa0;'):'')+'>'+
this._get('clearText')+'</a></div>');var controls='<div class="datepicker_control">'+(isRTL?'':clear)+
'<div class="datepicker_close"><a onclick="jQuery.datepicker._hideDatepicker();"'+
(showStatus?this._addStatus(this._get('closeStatus')||'&#xa0;'):'')+'>'+
this._get('closeText')+'</a></div>'+(isRTL?clear:'')+'</div>';var prompt=this._get('prompt');var closeAtTop=this._get('closeAtTop');var hideIfNoPrevNext=this._get('hideIfNoPrevNext');var numMonths=this._getNumberOfMonths();var stepMonths=this._get('stepMonths');var isMultiMonth=(numMonths[0]!=1||numMonths[1]!=1);var minDate=this._getMinMaxDate('min',true);var maxDate=this._getMinMaxDate('max');var drawMonth=this._drawMonth;var drawYear=this._drawYear;if(maxDate){var maxDraw=new Date(maxDate.getFullYear(),maxDate.getMonth()-numMonths[1]+1,maxDate.getDate());maxDraw=(minDate&&maxDraw<minDate?minDate:maxDraw);while(new Date(drawYear,drawMonth,1)>maxDraw){drawMonth--;if(drawMonth<0){drawMonth=11;drawYear--;}}}
var prev='<div class="datepicker_prev">'+(this._canAdjustMonth(-1,drawYear,drawMonth)?'<a onclick="jQuery.datepicker._adjustDate('+this._id+', -'+stepMonths+', \'M\');"'+
(showStatus?this._addStatus(this._get('prevStatus')||'&#xa0;'):'')+'>'+
this._get('prevText')+'</a>':(hideIfNoPrevNext?'':'<label>'+this._get('prevText')+'</label>'))+'</div>';var next='<div class="datepicker_next">'+(this._canAdjustMonth(+1,drawYear,drawMonth)?'<a onclick="jQuery.datepicker._adjustDate('+this._id+', +'+stepMonths+', \'M\');"'+
(showStatus?this._addStatus(this._get('nextStatus')||'&#xa0;'):'')+'>'+
this._get('nextText')+'</a>':(hideIfNoPrevNext?'>':'<label>'+this._get('nextText')+'</label>'))+'</div>';var html=(prompt?'<div class="datepicker_prompt">'+prompt+'</div>':'')+
(closeAtTop&&!this._inline?controls:'')+
'<div class="datepicker_links">'+(isRTL?next:prev)+
this._generateMonthYearHeader(drawMonth,drawYear,minDate,maxDate,selectedDate,row>0||col>0)+
(isRTL?prev:next)+'</div>';var showWeeks=this._get('showWeeks');for(var row=0;row<numMonths[0];row++)
for(var col=0;col<numMonths[1];col++){var selectedDate=new Date(drawYear,drawMonth,this._selectedDay);html+='<div class="datepicker_oneMonth'+(col==0?' datepicker_newRow':'')+'">'+
'<table class="datepicker" cellpadding="0" cellspacing="0"><thead>'+
'<tr class="datepicker_titleRow">'+
(showWeeks?'<td>'+this._get('weekHeader')+'</td>':'');var firstDay=this._get('firstDay');var changeFirstDay=this._get('changeFirstDay');var dayNames=this._get('dayNames');var dayNamesShort=this._get('dayNamesShort');var dayNamesMin=this._get('dayNamesMin');for(var dow=0;dow<7;dow++){var day=(dow+firstDay)%7;var status=this._get('dayStatus')||'&#xa0;';status=(status.indexOf('DD')>-1?status.replace(/DD/,dayNames[day]):status.replace(/D/,dayNamesShort[day]));html+='<td'+((dow+firstDay+6)%7>=5?' class="datepicker_weekEndCell"':'')+'>'+
(!changeFirstDay?'<span':'<a onclick="jQuery.datepicker._changeFirstDay('+this._id+', '+day+');"')+
(showStatus?this._addStatus(status):'')+' title="'+dayNames[day]+'">'+
dayNamesMin[day]+(changeFirstDay?'</a>':'</span>')+'</td>';}
html+='</tr></thead><tbody>';var daysInMonth=this._getDaysInMonth(drawYear,drawMonth);if(drawYear==this._selectedYear&&drawMonth==this._selectedMonth){this._selectedDay=Math.min(this._selectedDay,daysInMonth);}
var leadDays=(this._getFirstDayOfMonth(drawYear,drawMonth)-firstDay+7)%7;var currentDate=(!this._currentDay?new Date(9999,9,9):new Date(this._currentYear,this._currentMonth,this._currentDay));var endDate=this._endDay?new Date(this._endYear,this._endMonth,this._endDay):currentDate;var printDate=new Date(drawYear,drawMonth,1-leadDays);var numRows=(isMultiMonth?6:Math.ceil((leadDays+daysInMonth)/7));var beforeShowDay=this._get('beforeShowDay');var showOtherMonths=this._get('showOtherMonths');var calculateWeek=this._get('calculateWeek')||$.datepicker.iso8601Week;var dateStatus=this._get('statusForDate')||$.datepicker.dateStatus;for(var dRow=0;dRow<numRows;dRow++){html+='<tr class="datepicker_daysRow">'+
(showWeeks?'<td class="datepicker_weekCol">'+calculateWeek(printDate)+'</td>':'');for(var dow=0;dow<7;dow++){var daySettings=(beforeShowDay?beforeShowDay.apply((this._input?this._input[0]:null),[printDate]):[true,'']);var otherMonth=(printDate.getMonth()!=drawMonth);var unselectable=otherMonth||!daySettings[0]||(minDate&&printDate<minDate)||(maxDate&&printDate>maxDate);html+='<td class="datepicker_daysCell'+
((dow+firstDay+6)%7>=5?' datepicker_weekEndCell':'')+
(otherMonth?' datepicker_otherMonth':'')+
(printDate.getTime()==selectedDate.getTime()&&drawMonth==this._selectedMonth?' datepicker_daysCellOver':'')+
(unselectable?' datepicker_unselectable':'')+
(otherMonth&&!showOtherMonths?'':' '+daySettings[1]+
(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?' datepicker_currentDay':'')+
(printDate.getTime()==today.getTime()?' datepicker_today':''))+'"'+
(unselectable?'':' onmouseover="jQuery(this).addClass(\'datepicker_daysCellOver\');'+
(!showStatus||(otherMonth&&!showOtherMonths)?'':'jQuery(\'#datepicker_status_'+
this._id+'\').html(\''+(dateStatus.apply((this._input?this._input[0]:null),[printDate,this])||'&#xa0;')+'\');')+'"'+
' onmouseout="jQuery(this).removeClass(\'datepicker_daysCellOver\');'+
(!showStatus||(otherMonth&&!showOtherMonths)?'':'jQuery(\'#datepicker_status_'+
this._id+'\').html(\'&#xa0;\');')+'" onclick="jQuery.datepicker._selectDay('+
this._id+','+drawMonth+','+drawYear+', this);"')+'>'+
(otherMonth?(showOtherMonths?printDate.getDate():'&#xa0;'):(unselectable?'<span>'+printDate.getDate()+'</span>':'<a>'+printDate.getDate()+'</a>'))+'</td>';printDate.setDate(printDate.getDate()+1);}
html+='</tr>';}
drawMonth++;if(drawMonth>11){drawMonth=0;drawYear++;}
html+='</tbody></table></div>';}
html+=(showStatus?'<div id="datepicker_status_'+this._id+
'" class="datepicker_status">'+(this._get('initStatus')||'&#xa0;')+'</div>':'')+
(!closeAtTop&&!this._inline?controls:'')+
'<div style="clear: both;"></div>';return html;},_generateMonthYearHeader:function(drawMonth,drawYear,minDate,maxDate,selectedDate,secondary){minDate=(this._rangeStart&&minDate&&selectedDate<minDate?selectedDate:minDate);var showStatus=this._get('showStatus');var html='<div class="datepicker_header">';var monthNames=this._get('monthNames');if(secondary||!this._get('changeMonth'))
html+=monthNames[drawMonth]+'&#xa0;';else{var inMinYear=(minDate&&minDate.getFullYear()==drawYear);var inMaxYear=(maxDate&&maxDate.getFullYear()==drawYear);html+='<select class="datepicker_newMonth" '+
'onchange="jQuery.datepicker._selectMonthYear('+this._id+', this, \'M\');" '+
'onclick="jQuery.datepicker._clickMonthYear('+this._id+');"'+
(showStatus?this._addStatus(this._get('monthStatus')||'&#xa0;'):'')+'>';for(var month=0;month<12;month++){if((!inMinYear||month>=minDate.getMonth())&&(!inMaxYear||month<=maxDate.getMonth())){html+='<option value="'+month+'"'+
(month==drawMonth?' selected="selected"':'')+
'>'+monthNames[month]+'</option>';}}
html+='</select>';}
if(secondary||!this._get('changeYear'))
html+=drawYear;else{var years=this._get('yearRange').split(':');var year=0;var endYear=0;if(years.length!=2){year=drawYear-10;endYear=drawYear+10;}else if(years[0].charAt(0)=='+'||years[0].charAt(0)=='-'){year=drawYear+parseInt(years[0],10);endYear=drawYear+parseInt(years[1],10);}else{year=parseInt(years[0],10);endYear=parseInt(years[1],10);}
year=(minDate?Math.max(year,minDate.getFullYear()):year);endYear=(maxDate?Math.min(endYear,maxDate.getFullYear()):endYear);html+='<select class="datepicker_newYear" '+
'onchange="jQuery.datepicker._selectMonthYear('+this._id+', this, \'Y\');" '+
'onclick="jQuery.datepicker._clickMonthYear('+this._id+');"'+
(showStatus?this._addStatus(this._get('yearStatus')||'&#xa0;'):'')+'>';for(;year<=endYear;year++){html+='<option value="'+year+'"'+
(year==drawYear?' selected="selected"':'')+
'>'+year+'</option>';}
html+='</select>';}
html+='</div>';return html;},_addStatus:function(text){return' onmouseover="jQuery(\'#datepicker_status_'+this._id+'\').html(\''+text+'\');" '+
'onmouseout="jQuery(\'#datepicker_status_'+this._id+'\').html(\'&#xa0;\');"';},_adjustDate:function(offset,period){var year=this._drawYear+(period=='Y'?offset:0);var month=this._drawMonth+(period=='M'?offset:0);var day=Math.min(this._selectedDay,this._getDaysInMonth(year,month))+
(period=='D'?offset:0);var date=new Date(year,month,day);var minDate=this._getMinMaxDate('min',true);var maxDate=this._getMinMaxDate('max');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);this._selectedDay=date.getDate();this._drawMonth=this._selectedMonth=date.getMonth();this._drawYear=this._selectedYear=date.getFullYear();},_getNumberOfMonths:function(){var numMonths=this._get('numberOfMonths');return(numMonths==null?[1,1]:(typeof numMonths=='number'?[1,numMonths]:numMonths));},_getMinMaxDate:function(minMax,checkRange){var date=this._determineDate(minMax+'Date',null);if(date){date.setHours(0);date.setMinutes(0);date.setSeconds(0);date.setMilliseconds(0);}
return date||(checkRange?this._rangeStart:null);},_getDaysInMonth:function(year,month){return 32-new Date(year,month,32).getDate();},_getFirstDayOfMonth:function(year,month){return new Date(year,month,1).getDay();},_canAdjustMonth:function(offset,curYear,curMonth){var numMonths=this._getNumberOfMonths();var date=new Date(curYear,curMonth+(offset<0?offset:numMonths[1]),1);if(offset<0)
date.setDate(this._getDaysInMonth(date.getFullYear(),date.getMonth()));return this._isInRange(date);},_isInRange:function(date){var newMinDate=(!this._rangeStart?null:new Date(this._selectedYear,this._selectedMonth,this._selectedDay));newMinDate=(newMinDate&&this._rangeStart<newMinDate?this._rangeStart:newMinDate);var minDate=newMinDate||this._getMinMaxDate('min');var maxDate=this._getMinMaxDate('max');return((!minDate||date>=minDate)&&(!maxDate||date<=maxDate));},_getFormatConfig:function(){var shortYearCutoff=this._get('shortYearCutoff');shortYearCutoff=(typeof shortYearCutoff!='string'?shortYearCutoff:new Date().getFullYear()%100+parseInt(shortYearCutoff,10));return{shortYearCutoff:shortYearCutoff,dayNamesShort:this._get('dayNamesShort'),dayNames:this._get('dayNames'),monthNamesShort:this._get('monthNamesShort'),monthNames:this._get('monthNames')};},_formatDate:function(day,month,year){if(!day){this._currentDay=this._selectedDay;this._currentMonth=this._selectedMonth;this._currentYear=this._selectedYear;}
var date=(day?(typeof day=='object'?day:new Date(year,month,day)):new Date(this._currentYear,this._currentMonth,this._currentDay));return $.datepicker.formatDate(this._get('dateFormat'),date,this._getFormatConfig());}});function extendRemove(target,props){$.extend(target,props);for(var name in props)
if(props[name]==null)
target[name]=null;return target;};$.fn.datepicker=function(options){var otherArgs=Array.prototype.slice.call(arguments,1);if(typeof options=='string'&&(options=='isDisabled'||options=='getDate')){return $.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this[0]].concat(otherArgs));}
return this.each(function(){typeof options=='string'?$.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this].concat(otherArgs)):$.datepicker._attachDatepicker(this,options);});};$(document).ready(function(){$(document.body).append($.datepicker._datepickerDiv)
.mousedown($.datepicker._checkExternalClick);});$.datepicker=new Datepicker();})(jQuery);Eventful.DatePicker=function(oArgs)
{this.id=oArgs.id;this.bRequired=oArgs.required;this.sMinDate=(typeof oArgs.minDate!=='undefined'?oArgs.minDate:'0');this.oDropDown=new Eventful.DropDown({input:'#inp-'+this.id,popover:'#date-picker-'+this.id+' .popover'});this.oDropDown.eventPopoverShown.subscribe(this.listenPopoverShown.bind(this));this.oDropDown.eventInputChanged.subscribe(this.listenInputChanged.bind(this));this.oDropDown.eventBlur.subscribe(this.listenBlur.bind(this));this.eventDatePicked=new Eventful.UIEvent();$(this.setup.bind(this));}
Eventful.DatePicker.EventLocalized=new Eventful.UIEvent();$(function()
{var localized=function(){Eventful.DatePicker.IsLocalized=1;Eventful.DatePicker.EventLocalized.fire();};$.datepicker.setDefaults({dayNamesMin:['S','M','T','W','T','F','S']});if(!Eventful.Locale)return localized();var oGetScriptRequest=$.getScript("/js/require/jquery/datepicker-"+Eventful.Locale+".js",localized);$(document).ajaxError(function(evt,req){if(req===oGetScriptRequest)localized();});});Eventful.DatePicker.prototype.calendar=function()
{return this.jqCalendar?this.jqCalendar:this.jqCalendar=this.oDropDown.find('.calendar');}
Eventful.DatePicker.prototype.setup=function()
{if(Eventful.DatePicker.IsLocalized){this.initDatepickerPlugin();}else{Eventful.DatePicker.EventLocalized.subscribe(this.initDatepickerPlugin.bind(this));}
this.oDropDown.queue(new Eventful.DateQueue(this));}
Eventful.DatePicker.prototype.initDatepickerPlugin=function()
{this.calendar().datepicker({prevText:'<span class="prev">&laquo;</span>',nextText:'<span class="next">&raquo;</span>',onSelect:this.listenDateSelected.bind(this),minDate:this.sMinDate,dateFormat:Eventful.DatePicker.format().replace('yyyy','yy'),firstDay:1,defaultDate:Eventful.DatePicker.parseDate(this.oDropDown.input().val())});}
Eventful.DatePicker.prototype.date=function(oDate)
{if(oDate)
{oDate=Eventful.DatePicker.parseDate(oDate);this.calendar().datepicker('setDate',oDate);var sDate=Eventful.DatePicker.formatDate(oDate);this.oDropDown.input().val(sDate);this.oDropDown.input().removeClass('inactive');}
if(!this.oDropDown.input().hasClass('inactive'))
{return Eventful.DatePicker.parseDate(this.oDropDown.input().val());}}
Eventful.DatePicker.prototype.fixPopoverPosition=function()
{if(this.bFixedPosition)return;this.bFixedPosition=true;this.oDropDown.popover().css({top:$('#date-picker-'+this.id).height()});}
Eventful.DatePicker.prototype.after=function(oMinDate)
{if(typeof oMinDate==="undefined"){return;}
oMinDate=Eventful.DatePicker.parseDate(oMinDate);oMinDate.addDays(1);this.oMinDate=oMinDate;this.calendar().datepicker('change',{minDate:oMinDate});var oDate=this.date();if(oDate)
{if(oMinDate.compareTo(oDate)>0)
{this.date(oMinDate);}}else
{this.calendar().datepicker('setDate',oMinDate);}}
Eventful.DatePicker.prototype.listenBlur=function()
{if(!this.date())
{if(this.bRequired)
{var oDate=this.calendar().datepicker('getDate');var sDate=Eventful.DatePicker.formatDate(oDate);this.oDropDown.input().val(sDate).removeClass('inactive');}else
{this.oDropDown.clearInput();}}
if(this.date())
{this.oDropDown.input().val(Eventful.DatePicker.formatDate(this.date()));}
this.eventDatePicked.fire(this.date());}
Eventful.DatePicker.prototype.listenPopoverShown=function()
{this.fixPopoverPosition();}
Eventful.DatePicker.prototype.listenInputChanged=function(sDate)
{var oDate=Eventful.DatePicker.parseDate(sDate)||new Date();if(!this.oMinDate||oDate.compareTo(this.oMinDate)>=0)
{this.calendar().datepicker('setDate',oDate);}}
Eventful.DatePicker.prototype.listenDateSelected=function(sDate)
{var oDate=this.calendar().datepicker("getDate")||Eventful.DatePicker.parseDate(sDate);if(oDate)
{this.oDropDown.input().val(Eventful.DatePicker.formatDate(oDate)).select();setTimeout(function(){this.oDropDown.popover().hide();this.oDropDown.bHasFocus=false;}.bind(this),0);}}
Eventful.DatePicker.parseDate=function(oDate)
{if(typeof oDate==='string')
{return Date.parseExact(oDate,Eventful.DatePicker.format())||Date.parseExact(oDate,Eventful.DatePicker.format('long'))||Date.parse(oDate,Eventful.DatePicker.format())||Date.parse(oDate);}
return oDate;}
Eventful.DatePicker.formatDate=function(oDate)
{if(oDate.getYear()>128){return oDate.toString(Eventful.DatePicker.format('long'));}else{return oDate.toString(Eventful.DatePicker.format());}}
Eventful.DatePicker.format=function(sOption)
{if(!Eventful.DatePicker.sFormat)
{Eventful.DatePicker.sFormat='M/d/yy';if(Eventful.Session&&Eventful.Session.Prefs.sf)
{var sFormat=Eventful.Session.Prefs.sf.
replace('%m','MM').
replace('%Y','yyyy').
replace('%y','yy').
replace('%e','d').
replace('%f','M');if(sFormat.indexOf('%')==-1)
{Eventful.DatePicker.sFormat=sFormat;}}
Eventful.DatePicker.sFormatLong=/yyyy/.test(Eventful.DatePicker.sFormat)?Eventful.DatePicker.sFormat:Eventful.DatePicker.sFormat.replace('yy','yyyy');}
if(sOption)return Eventful.DatePicker.sFormatLong;return Eventful.DatePicker.sFormat;}
Eventful.DateQueue=function(oDatePicker)
{this.oDatePicker=oDatePicker;this.bIgnoreNext=true;}
Eventful.DateQueue.prototype.next=function()
{if(this.bIgnoreNext)
{this.bIgnoreNext=false;return;}
var oDate=this.oDatePicker.date()||this.oDatePicker.calendar().datepicker('getDate');if(oDate)
{oDate.addDays(1);this.oDatePicker.date(oDate);}}
Eventful.DateQueue.prototype.prev=function()
{var oDate=this.oDatePicker.date()||this.oDatePicker.calendar().datepicker('getDate');var oMinDate=this.oDatePicker.oMinDate||Date.today();if(oDate&&oDate.compareTo(oMinDate)>0)
{oDate.addDays(-1);this.oDatePicker.date(oDate);}}
Eventful.DateQueue.prototype.current=function()
{return this.oDatePicker.date();}
Eventful.PanelRecurrence=function()
{Eventful.Panel.call(this,'panel-recurrence');this.options({width:600});this.eventCompleted=new Eventful.UIEvent();this.oUntilDatePicker=new Eventful.DatePicker({id:'until',required:1})
$(this.setup.bind(this));}.mixin(Eventful.Panel);Eventful.PanelRecurrence.prototype.setup=function()
{this.find('[name=daily_interval],\
             [name=monthly_interval],\
             [name=weekly_interval],\
             [name=yearly_interval],\
             [name=count]').blur(this.listenBlurNumericalInput.bind(this));this.find('.submit').click(this.listenSubmit.bind(this));this.find('[name=freq],[name=end_type]').change(this.render.bind(this));this.find('[name=monthly_type],[name=yearly_type]').click(this.render.bind(this));}
Eventful.PanelRecurrence.prototype.recurrence=function()
{if(!this.panel().is(':visible'))
{return this.oRecur;}
this.oRecur={start_time:this.oRecur.start_time}
this.oRecur.freq=this.find('[name=freq]').val();this.oRecur.interval=this.find('[name='+this.oRecur.freq+'_interval]').val()||1;switch(this.oRecur.freq)
{case'weekly':this.oRecur.byday_day=this.checkedValues('weekly_byday_day');break;case'monthly':if(this.find('[name=monthly_type]:checked').val()=='each')
{this.oRecur.bymonthday=this.checkedValues('monthly_bymonthday');}else
{this.oRecur.byday_num=this.find('[name=monthly_byday_num]').val();this.oRecur.byday_day=[this.find('[name=monthly_byday_day]').val()];}
break;case'yearly':this.oRecur.bymonth=this.checkedValues('yearly_bymonth');if(this.find('[name=yearly_type]:checked').val()=='on-the')
{this.oRecur.byday_num=this.find('[name=yearly_byday_num]').val();this.oRecur.byday_day=[this.find('[name=yearly_byday_day]').val()];}
break;}
switch(this.find('[name=end_type]').val())
{case'count':this.oRecur.count=this.find('[name=count]').val()||1;break;case'until':this.oRecur.until=this.oUntilDatePicker.date().toString('yyyy-MM-dd');break;}
return this.oRecur;}
Eventful.PanelRecurrence.prototype.checkedValues=function(sName)
{return $.map(this.find('[name='+sName+']:checked'),function(el)
{return el.value;});}
Eventful.PanelRecurrence.prototype.prerender=function()
{this.find(':checked').prop('checked','0');if(this.oRecur.freq)
{this.find('[name=freq]').val(this.oRecur.freq);this.find('[name='+this.oRecur.freq+'_interval]').val(this.oRecur.interval||1);switch(this.oRecur.freq)
{case'weekly':if(this.oRecur.byday_day)
{$.each(this.oRecur.byday_day,function(_,sValue)
{this.find('[name=weekly_byday_day][value='+sValue+']').prop('checked','1');}.bind(this));}
break;case'monthly':if(this.oRecur.byday_num&&this.oRecur.byday_day&&this.oRecur.byday_day.length)
{this.find('[name=monthly_type][value="on-the"]').prop('checked','1');this.find('[name=monthly_byday_num]').val(this.oRecur.byday_num);this.find('[name=monthly_byday_day]').val(this.oRecur.byday_day[0])}else
{this.find('[name=monthly_type][value="each"]').prop('checked','1');if(this.oRecur.bymonthday)
{$.each(this.oRecur.bymonthday,function(_,sValue)
{this.find('[name=monthly_bymonthday][value='+sValue+']').prop('checked','1');}.bind(this));}}
break;case'yearly':if(this.oRecur.bymonth)
{$.each(this.oRecur.bymonth,function(_,sValue)
{this.find('[name=yearly_bymonth][value='+sValue+']').prop('checked','1');}.bind(this));}
if(this.oRecur.byday_num&&this.oRecur.byday_day)
{this.find('[name=yearly_type][value="on-the"]').prop('checked','1');this.find('[name=yearly_byday_num]').val(this.oRecur.byday_num);this.find('[name=yearly_byday_day]').val(this.oRecur.byday_day[0])}
break;}}else
{this.find('[name=freq]').val('');}
var oDate=Date.parse(this.oRecur.start_time);if(oDate)
{var nDay=(oDate.getDay()+6)%7;var nDate=oDate.getDate();var nWeek=nDate>28?5:Math.floor((nDate-1)/7);var nMonth=oDate.getMonth();if(this.oRecur.freq!='weekly'||!this.oRecur.byday_day)
{this.find('[name=weekly_byday_day]').eq(nDay).prop('checked','1');}
if(this.oRecur.freq!='monthly'||!this.oRecur.bymonthday&&!this.oRecur.byday_num)
{this.find('[name=monthly_byday_day]').prop('selectedIndex',nDay);this.find('[name=monthly_byday_num]').prop('selectedIndex',nWeek);this.find('[name=monthly_bymonthday]').eq(nDate-1).prop('checked','1');this.find('[name=monthly_type][value="each"]').prop('checked','1');}
if(this.oRecur.freq!='yearly'||!this.oRecur.bymonth&&!this.oRecur.byday_num)
{this.find('[name=yearly_byday_day]').prop('selectedIndex',nDay);this.find('[name=yearly_byday_num]').prop('selectedIndex',nWeek);this.find('[name=yearly_bymonth]').eq(nMonth).prop('checked','1');}}
if(this.oRecur.count)
{this.find('[name=end_type]').val('count');this.find('[name=count]').val(this.oRecur.count);}else if(this.oRecur.until)
{this.find('[name=end_type]').val('until');this.oUntilDatePicker.date(this.oRecur.until);}
if(this.oRecur.start_time)
{this.oUntilDatePicker.after(this.oRecur.start_time);}}
Eventful.PanelRecurrence.prototype.render=function()
{this.find(':input:disabled').prop('disabled','0');this.find('fieldset').hide();var sFreq=this.find('[name=freq]').val();if(sFreq)
{this.find('.ends, .buttons, fieldset.'+sFreq).show();switch(sFreq)
{case'monthly':if(this.find('[name=monthly_type]:checked').val()=='each')
{this.find('[name=monthly_byday_num], [name=monthly_byday_day]').prop('disabled','1');}else
{this.find('[name=monthly_bymonthday]').prop('disabled','1');}
break;case'yearly':if(this.find('[name=yearly_type]:checked').val()!='on-the')
{this.find('[name=yearly_byday_num], [name=yearly_byday_day]').prop('disabled','1');}
break;}
this.find('.count-container, .until-container').hide();switch(this.find('[name=end_type]').val())
{case'count':this.find('.count-container').show();break;case'until':this.find('.until-container').show();break;}}else
{this.find('.ends, .buttons').hide();}}
Eventful.PanelRecurrence.prototype.show=function(oRecur)
{this.oRecur=oRecur;Eventful.Panel.prototype.show.call(this);this.prerender();this.render();}
Eventful.PanelRecurrence.prototype.listenSubmit=function()
{this.find('.progress').show();$.ajax({url:'/json/tools/recurrence',dataType:'json',data:this.recurrence(),success:this.listenServerResponse.bind(this)});}
Eventful.PanelRecurrence.prototype.listenServerResponse=function(oResponse)
{this.recurrence();this.close();this.find('.progress').hide();this.eventCompleted.fire(oResponse.recurrence.description);}
Eventful.PanelRecurrence.prototype.hideFreqSelector=function(oResponse)
{this.find('label[for=inp-freq]').hide();}
Eventful.PanelRecurrence.prototype.listenBlurNumericalInput=function(evt,el)
{if(!(/^\d+$/).test(el.value))
{el.value=1;}}
if(!this.JSON){JSON=function(){function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};function stringify(value,whitelist){var a,i,k,l,v;switch(typeof value){case'string':return/["\\\x00-\x1f]/.test(value) ?
                    '"' + value.replace(/[\x00-\x1f\\"]/g, function (a) {
                        var c = m[a];
                        if (c) {
                            return c;
                        }
                        c = a.charCodeAt();
                        return '\\u00' + Math.floor(c / 16).toString(16) +
                                                   (c % 16).toString(16);
                    }) + '"' :
                    '"' + value + '"';

            case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

                return isFinite(value) ? String(value) : 'null';

            case 'boolean':
                return String(value);

            case 'null':
                return 'null';

            case 'object':

// Due to a specification blunder in ECMAScript,
// typeof null is 'object', so watch out for that case.

                if (!value) {
                    return 'null';
                }

// If the object has a toJSON method, call it, and stringify the result.

                if (typeof value.toJSON === 'function') {
                    return stringify(value.toJSON());
                }
                a = [];
                if (typeof value.length === 'number' &&
                        !(value.propertyIsEnumerable('length'))) {

// The object is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                    l = value.length;
                    for (i = 0; i < l; i += 1) {
                        a.push(stringify(value[i], whitelist) || 'null');
                    }

// Join all of the elements together and wrap them in brackets.

                    return '[' + a.join(',') + ']';
                }
                if (whitelist) {

// If a whitelist (array of keys) is provided, use it to select the components
// of the object.

                    l = whitelist.length;
                    for (i = 0; i < l; i += 1) {
                        k = whitelist[i];
                        if (typeof k === 'string') {
                            v = stringify(value[k], whitelist);
                            if (v) {
                                a.push(stringify(k) + ':' + v);
                            }
                        }
                    }
                } else {

// Otherwise, iterate through all of the keys in the object.

                    for (k in value) {
                        if (typeof k === 'string') {
                            v = stringify(value[k], whitelist);
                            if (v) {
                                a.push(stringify(k) + ':' + v);
                            }
                        }
                    }
                }

// Join all of the member texts together and wrap them in braces.

                return '{' + a.join(',') + '}';
            }
        }

        return {
            stringify: stringify,
            parse: function (text, filter) {
                var j;

                function walk(k, v) {
                    var i, n;
                    if (v && typeof v === 'object') {
                        for (i in v) {
                            if (Object.prototype.hasOwnProperty.apply(v, [i])) {
                                n = walk(i, v[i]);
                                if (n !== undefined) {
                                    v[i] = n;
                                }
                            }
                        }
                    }
                    return filter(k, v);
                }


// Parsing happens in three stages. In the first stage, we run the text against
// regular expressions that look for non-JSON pattern. We are especially
// concerned with '()' and 'new' because they can cause invocation, and '='
// because it can cause mutation. But just to be safe, we want to reject all
// unexpected forms.

// We split the first stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace all backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

                if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the second stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                    j = eval('(' + text + ')');

// In the optional third stage, we recursively walk the new structure, passing
// each name/value pair to a filter function for possible transformation.
return typeof filter==='function'?walk('',j):j;}
throw new SyntaxError('parseJSON');}};}();}
Eventful.AsynchUpload=function(jqForm,msecTimeout)
{this.elForm=$(jqForm)[0];if(!jqForm||!this.elForm)return null;$(this.elForm).submit(this.listenFormSubmit.bind(this));this.eventSubmit=new Eventful.UIEvent();this.eventComplete=new Eventful.UIEvent();this.eventError=new Eventful.UIEvent();this.eventTimeout=new Eventful.UIEvent();this.msecTimeout=msecTimeout;this.iTimerID=null;}
Eventful.AsynchUpload.prototype.listenFormSubmit=function(evt){var valuedEles=$.grep(this.elForm.elements,function(ele){if(/^text|textarea|password|file|select-one$/i.test(ele.type)){return!!$.trim(ele.value);}});if(valuedEles.length>0){this.eventSubmit.fire(this.elForm);this.sFrameID='f'+Math.floor(Math.random()*99999);$(document.body)
.append('<iframe style="display:none" src="about:blank" id="'+this.sFrameID+'" name="'+this.sFrameID+'"></iframe>');this.elForm.target=this.sFrameID;$('iframe#'+this.sFrameID)
.one("load",this.listenFrameLoad.bind(this));if(this.msecTimeout){this.iTimerID=(this.cancel.bind(this,true)).later(this.msecTimeout);}}else{this.eventError.fire("Please fill out the form first.");evt.preventDefault();return false;}}
Eventful.AsynchUpload.prototype.cancel=function(bTimeout){$('iframe#'+this.sFrameID).unbind("load").remove();if(bTimeout)
this.eventTimeout.fire("submission has been cancel");}
Eventful.AsynchUpload.prototype.listenFrameLoad=function(evt,elFrame)
{var elContent=elFrame.contentDocument||(elFrame.contentWindow?elFrame.contentWindow.document:null)||window.frames[elFrame.id].document;if(elContent.location.href=='about:blank')return;if(this.iTimerID){window.clearTimeout(this.iTimerID);this.iTimerID=null;}
try{var oResponse=JSON.parse(elContent.body.innerHTML);this.eventComplete.fire(oResponse,this.elForm);}catch(e){this.eventError.fire("There are errors in uploading.");}
(function(){$('iframe#'+this.sFrameID).unbind("load").remove();}).bind(this).later(500);}
Eventful.PanelImageAdd=function()
{Eventful.Panel.call(this,'panel-img-add');this.options({width:"380px",closeOnKeyEsc:true,containerCss:{position:'fixed'}})
this.clickClose('#btn-add-image-cancel');var elForm=$('#panel-img-add form')[0];var FV=(new Eventful.FormVal(elForm,$(elForm).find('.form-summary'))).deinitialize();this._oUploader=new Eventful.AsynchUpload(elForm);this.eventSubmit=this._oUploader.eventSubmit;this.eventComplete=new Eventful.UIEvent();this._justClickOn=null;this.eventShow.subscribe(function(evt){FV.hideSummaryError();this._justClickOn=evt?evt.target:null;}.bind(this));this.eventSubmit.subscribe(function(){$(elForm).addClass('loading');$('#btn-add-image-upload').hide();});this._oUploader.eventComplete.subscribe(function(oResponse){$(elForm).removeClass('loading');$('#btn-add-image-upload').show();elForm.reset();if(oResponse.status=="ok"&&oResponse.image){this.eventComplete.fire(oResponse);this.close();}else{FV.showSummaryError(oResponse.message||"There are errors in uploading.");}}.bind(this));this._oUploader.eventError.subscribe(function(msg){FV.showSummaryError(msg);});}.mixin(Eventful.Panel);Eventful.PanelImageAdd.prototype.justClickOn=function(){return this._justClickOn;}
Eventful.PanelImageAddWizard=function(formExpr,defaultImageURL){this.jqForm=$(formExpr);if(this.jqForm.size()!=1||this.jqForm[0].tagName.toUpperCase()!='FORM'){return;}
this.defaultImageURL=defaultImageURL||'http://s1.evcdn.com/store/legacy/events/add-no_image.png';this.oImageAdd=new Eventful.PanelImageAdd();this.oImageAdd.eventComplete.subscribe(this.listenImageUploadServerResponse.bind(this));this.oImageAdd.clickShow("#image-viewer-add-click");this.oImageAdd.clickShow('#image-thumb-blank');$('#image-viewer-delete-click').one('click',this.onDeleteImageClicked.bind(this));}
Eventful.PanelImageAddWizard.prototype.onDeleteImageClicked=function(evt){if(this.jqForm.find('input[name=image_id]').size()){this.jqForm.find('input[name=image_id]').remove();}else if(this.jqForm.find('input[name=delete_image]').size()==0){this.jqForm.append('<input type="hidden" name="delete_image" value="1" />');}
$(evt.target)
.prev("#list-image-thumb")
.find('#image-thumb-blank')
.attr('src',this.defaultImageURL)
.end()
.end()
.attr('id',"image-viewer-add-click")
.html('Choose an image')
.bind('click',function(){this.oImageAdd.show();}.bind(this));}
Eventful.PanelImageAddWizard.prototype.listenImageUploadServerResponse=function(oResponse)
{if(oResponse.error||!oResponse.image)return;var img_size;try{img_size=parseInt(this.jqForm.find('#image-thumb-blank').attr('width'));}catch(e){img_size=48;}
this.jqForm
.find('#image-thumb-blank')
.attr('src',img_size<=48?oResponse.image.thumb_url:img_size<=128?oResponse.image.block_url:oResponse.image.block250_url)
.end()
.find('#image-viewer-add-click')
.attr('id',"image-viewer-delete-click")
.html('Delete this image')
.unbind('click')
.one('click',this.onDeleteImageClicked.bind(this))
.end()
.append('<input type="hidden" name="image_id" value="'+oResponse.image.id+'" />')}
Eventful.ImageMultiAddWizard=function(formExpr,oOption){this.jqForm=$(formExpr);if(this.jqForm.size()!=1||this.jqForm[0].tagName.toUpperCase()!='FORM'){return;}
this.oOption=oOption||{};this.oOption.default_img=this.oOption.default_img||'http://s1.evcdn.com/store/legacy/events/add-no_image.png';this.oOption.max_img=this.oOption.max_img||-1;this.oOption.allow_del=this.oOption.allow_del||0;this.sHolderHtm='<li class="multi_add">'+
this.jqForm.find('#list-image-thumb .multi_add:first-child').html()+
'</li>';this.oImageAdd=new Eventful.PanelImageAdd();this.oImageAdd.clickShow("#list-image-thumb #image-multi-add-btn");this.oImageAdd.eventComplete.subscribe(this.listenImageUploadServerResponse.bind(this));this.jqLastLiBtn=this.jqForm.find('#list-image-thumb .multi_add:last-child');this.jqForm.find('#list-image-thumb').click(this.listenClickList.bind(this));}
Eventful.ImageMultiAddWizard.prototype.listenClickList=function(evt){if($(evt.target).hasClass("delete_box")&&this.oOption.allow_del){$(evt.target).parent().remove();if(this.jqLastLiBtn.css('display')==='none'&&this.jqForm.find('.multi_add img').length<this.oOption.max_img){this.jqLastLiBtn.css('display','inline');}}else if(evt.target.tagName.toUpperCase()=='IMG'&&evt.target.src.search(this.oOption.default_img)!=-1){this.oImageAdd.show();}}
Eventful.ImageMultiAddWizard.prototype.listenImageUploadServerResponse=function(oResponse){if(oResponse.error||!oResponse.image)return;var img_size;try{img_size=parseInt(this.jqForm.find('.multi_add img').attr('width'));}catch(e){img_size=48;}
var sImageFile=this.oOption.default_img.split('/').pop();var jqEmptyImg=this.jqForm.find('.multi_add img[src$="'+sImageFile+'"]');jqEmptyImg
.attr('src',img_size<=48?oResponse.image.thumb_url:img_size<=128?oResponse.image.block_url:oResponse.image.block250_url)
.after('<input type="hidden" name="image_id" value="'+oResponse.image.id+'" />');if(this.oOption.allow_del){jqEmptyImg
.after('<span class="delete_box">X</span>');}
if(this.oOption.max_img>0&&this.jqForm.find('.multi_add input[name=image_id]').length>=this.oOption.max_img){this.jqLastLiBtn.css('display','none');}
this.jqLastLiBtn.before(this.sHolderHtm);}
Eventful.PanelSuggestVenue=function()
{Eventful.Panel.call(this,'panel-suggest-venue');this.options({width:470});this.oLocationTypeAhead=new Eventful.LocationTypeAhead({id:'venue_location',required:1,exclude:'metro_id'});this.oLocationTypeAhead.eventItemSelected.subscribe(this.listenLocationChanged.bind(this));this.oLocationTypeAhead.oDropDown.eventItemHighlighted.subscribe(this.listenLocationChanged.bind(this));this.eventVenueCreated=new Eventful.UIEvent();$(this.setup.bind(this));}.mixin(Eventful.Panel)
Eventful.PanelSuggestVenue.prototype.setup=function()
{this.oValidator=new Eventful.FormVal('#panel-suggest-venue','#panel-suggest-venue .form-summary');this.oValidator.eventPassValid.subscribe(this.listenValid.bind(this));this.oValidator.eventJSONValidate.subscribe(this.listenBeginValidation.bind(this));this.oValidator.addRule('venue_name',{required:1,message:"What is the name of this venue?"});this.oValidator.addRule('venue_location',{helperCb:function()
{var sPostalCode=this.find('[name=venue_postal_code]').val();return this.oLocationTypeAhead.item()||sPostalCode?{}:{error:1,message:"What city is this venue in?"}}.bind(this)});this.find('[name=venue_postal_code]').keyup(this.listenPostalCodeChanged.bind(this));}
Eventful.PanelSuggestVenue.prototype.show=function(sName)
{this.find('input:text, select').val('');this.oLocationTypeAhead.reset();this.oValidator.hideSummaryError();this.oValidator.hideHasError();if(sName)
{this.find('[name=venue_name]').val(sName);}
Eventful.Panel.prototype.show.call(this);}
Eventful.PanelSuggestVenue.prototype.listenPostalCodeChanged=function(evt,el)
{var sPostalCode=$.trim(el.value);if(!(/^\d{5}$/.test(sPostalCode)))return;$.getJSON('/json/tools/location/guess',{location:sPostalCode,location_type:'postal_code_id',destination_key:'resolved'},this.listenLocationServerResponse.bind(this));}
Eventful.PanelSuggestVenue.prototype.listenLocationServerResponse=function(oResponse)
{if(oResponse.resolved)
{this.oLocationTypeAhead.item(oResponse.resolved);}}
Eventful.PanelSuggestVenue.prototype.listenLocationChanged=function(oLocation)
{var oMatch=oLocation.pretty_name.match(/\((\d+)\)$/);if(oLocation.location_type=='postal_code_id'&&oMatch&&oMatch[1])
{this.find('[name=venue_postal_code]').val(oMatch[1]);}}
Eventful.PanelSuggestVenue.prototype.listenBeginValidation=function()
{this.find('.progress').show();}
Eventful.PanelSuggestVenue.prototype.listenValid=function()
{var oLocation=this.oLocationTypeAhead.item()
$.ajax({type:'post',url:this.panel().attr('action'),dataType:'json',data:{name:this.find('[name=venue_name]').val(),address:this.find('[name=venue_address]').val()||'',venue_location:oLocation?oLocation.location_type+':'+oLocation.location_id:'',postal_code:this.find('[name=venue_postal_code]').val()||'',venue_type_id:this.find('[name=venue_type_id]').val()||'',privacy:this.find('[name=privacy]').val()||'public',id:this.find('[name=id]').val()},success:this.listenServerResponse.bind(this)});}
Eventful.PanelSuggestVenue.prototype.listenServerResponse=function(oResponse)
{this.find('.progress').hide();if(oResponse.venue)
{this.eventVenueCreated.fire(oResponse.venue);this.close();}else
{this.oValidator.showSummaryError(oResponse.message?"An error occured: "+oResponse.message:"An unknown error occured.");}
this.oValidator.initialize();}
Eventful.PanelNewEvent=function()
{Eventful.Panel.call(this,'panel-new-event');this.options({width:620});this.clickShow('.click-new-event');$(this.setupPanelNewEvent.bind(this));}.mixin(Eventful.Panel);Eventful.PanelNewEvent.prototype.setupPanelNewEvent=function()
{this.elForm=this.find('form');Eventful.GrowTextarea(this.find('textarea.grow'));Eventful.InactiveText(this.find('#inp-title'));this.oVenueTypeAhead=new Eventful.VenueTypeAhead({id:'venue',options:1,required:1,minInputLength:0});this.oVenueTypeAhead.eventOptionSelected.subscribe(this.listenVenueOption.bind(this));this.oLocationTypeAhead=new Eventful.LocationTypeAhead({id:'event_location',options:1,required:1,exclude:['metro_id','place_id']});this.oLocationTypeAhead.eventOptionSelected.subscribe(this.listenLocationOption.bind(this));this.oStartTimePicker=new Eventful.TimePicker({id:'start_time',required:1,options:1});this.oStartTimePicker.eventTimePicked.subscribe(this.listenStartTimePicked.bind(this));this.oStartTimePicker.eventTimePicked.subscribe(this.listenTimePicked.bind(this));this.oStopTimePicker=new Eventful.TimePicker({id:'stop_time'});this.oStopTimePicker.eventTimePicked.subscribe(this.listenTimePicked.bind(this));this.oStopTimePicker.oDropDown.eventBadFocus.subscribe(this.listenStopTimeBadFocus.bind(this));this.oStartDatePicker=new Eventful.DatePicker({id:'start_date',required:1});this.oStartDatePicker.eventDatePicked.subscribe(this.listenDatePicked.bind(this));this.oStopDatePicker=new Eventful.DatePicker({id:'stop_date',minDate:'1d'});this.oStopDatePicker.eventDatePicked.subscribe(this.listenDatePicked.bind(this));this.oStopDatePicker.oDropDown.eventBadFocus.subscribe(this.listenStopDateBadFocus.bind(this));this.oStopDatePicker.after(this.oStartDatePicker.date());this.oRepeatsDatePicker=new Eventful.DatePicker({id:'repeats_until',required:1});this.oRepeatsDatePicker.eventDatePicked.subscribe(this.listenDatePicked.bind(this));this.oRepeatsDatePicker.after(this.oStartDatePicker.date());this.oRecurrencePanel=new Eventful.PanelRecurrence();this.oRecurrencePanel.eventClose.subscribe(this.listenRecurrencePanelClosed.bind(this));this.oRecurrencePanel.eventCompleted.subscribe(this.listenRecurrencePanelCompleted.bind(this));this.sOldRepeatsValue=this.find('#inp-repeats').
change(this.listenRepeatsChanged.bind(this)).
val();this.find('.click-edit-recurrence').click(this.showRecurrencePanel.bind(this));this.oVenuePanel=new Eventful.PanelSuggestVenue();this.oVenuePanel.eventVenueCreated.subscribe(this.listenVenueCreated.bind(this));this.find('.click-specify-venue').click(this.listenClickSpecifyVenue.bind(this));this.oValidator=new Eventful.FormVal(this.elForm,this.find('.form-summary'));this.oValidator.eventPassValid.subscribe(this.listenValid.bind(this));this.oValidator.eventJSONValidate.subscribe(function(){this.find('.last .progress').show();}.bind(this));this.oValidator.eventFailValid.subscribe(function(){this.find('.last .progress').hide();}.bind(this));this.oValidator.addRule('title',{required:1,message:"Please pick a title for your event."});this.oValidator.addRule('start_time',{helperCb:function()
{return this.oStartTimePicker.time()?{}:{message:"Please pick a start time.",error:1}}.bind(this)});this.oValidator.addRule('category1',{helperCb:function()
{return this.find('[name^=category][value!=""]').val()?{}:{message:"Please pick a category.",error:1}}.bind(this)});this.oValidator.addRule('venue',{helperCb:function()
{return this.oVenueTypeAhead.item()||this.oLocationTypeAhead.item()?{}:{message:"Please pick a venue for your event.",error:1};}.bind(this)});this.oValidator.addRule('event_location',{helperCb:function()
{return this.oVenueTypeAhead.item()||this.oLocationTypeAhead.item()?{}:{message:"Please pick a location for your event.",error:1};}.bind(this)});this.oValidator.addRule('captcha',{required:1,minlen:6,maxlen:6,message:"Sorry, that didn't match exactly."});this.oValidator.addRule('captcha',{jsonCb:function(el)
{var sCaptchaKey=this.elForm.find('[name=captcha_key]').val();return{get:'/json/validate/captcha',data:{value:el.value,key:sCaptchaKey},helperCb:function(oResponse)
{if(!oResponse.valid||oResponse.errors)
{$.get('/json/tools/captcha',{version:2},function(oResponse)
{if(oResponse.captcha)
{this.elForm
.find('[name=captcha_key]')
.val(oResponse.captcha.key)
.end()
.find('#inp-captcha')
.val('')
.end()
.find('.input-captcha')
.css({backgroundImage:'url('+oResponse.captcha.url+')'});}}.bind(this),'json');return{error:1,message:oResponse.errors.captcha.message!="timeout"?"Sorry, that didn't match exactly. Try another one.":"Oops, you took too long. Try another one."};}}.bind(this)}}.bind(this)});new Eventful.ImageMultiAddWizard(this.elForm);new Eventful.AddObjectLink({links:'#event-links-list',popover:{isNewEventForm:1,isPanelNewEventForm:1},noSave:1});new Eventful.Popover("#panel-allowed-html",{css:{zIndex:3100}})
.hoverShow(this.find(".click-help.allowed-html"));}
Eventful.PanelNewEvent.prototype.showRecurrencePanel=function()
{if(!this.oRecur)this.oRecur={};this.oRecur.start_time=this.oStartDatePicker.date().toString('yyyy-MM-dd');this.oRecurrencePanel.show(this.oRecur);}
Eventful.PanelNewEvent.prototype.reset=function()
{Eventful.InactiveText(this.find('#inp-title'));this.oStartTimePicker.oDropDown.clearInput();this.oStopTimePicker.oDropDown.clearInput();this.oStartDatePicker.oDropDown.clearInput();this.oStopDatePicker.oDropDown.clearInput();this.oLocationTypeAhead.reset();this.oVenueTypeAhead.reset();var sDefaultDate=Eventful.oPanelNewEvent.oStartDatePicker.oDropDown.input().prop('defaultValue');Eventful.oPanelNewEvent.oStartDatePicker.date(sDefaultDate);this.find('#type-ahead-venue').show();this.find('.no-venue').hide();this.find('#when-container').removeClass().addClass('with-stop-time');this.find('#repeats-container').removeClass();this.find('[name^=category], #inp-repeats').val('');this.find('#inp-description, #inp-price').val('').css({height:'4em'});this.find('[name=image_id]').parents('.multi_add').remove()
this.find('#inp-free-').prop('checked','checked');this.find('.last .progress').hide();}
Eventful.PanelNewEvent.prototype.listenTimePicked=function()
{if(this.find('#when-container').hasClass('with-stop-date-and-time'))return;var oStartTime=this.oStartTimePicker.time();var oStopTime=this.oStopTimePicker.time();if(oStartTime&&!oStartTime.all_day)
{this.oStopTimePicker.defaultTime(oStartTime.clone().addHours(1));}
if(oStartTime&&!oStartTime.all_day&&oStopTime&&oStartTime.compareTo(oStopTime)>=0)
{this.oStopTimePicker.nextday().show();}else
{this.oStopTimePicker.nextday().hide();}}
Eventful.PanelNewEvent.prototype.listenStartTimePicked=function(oTime)
{var elWhen=this.find('#when-container');if(oTime.all_day)
{if(elWhen.hasClass('with-stop-date-and-time'))
{elWhen.addClass('without-stop-time');}else
{elWhen.removeClass().addClass('with-stop-date');}}else if(elWhen.hasClass('with-stop-date-and-time.without-stop-time'))
{elWhen.removeClass('without-stop-time')}else if(!elWhen.hasClass('with-stop-date-and-time'))
{elWhen.removeClass().addClass('with-stop-time');}
this.oStartTimePicker.oDropDown.input().
unbind("focus.haserror").
unbind("blur.haserror").
parents(".field-container:first").
removeClass("has-error").
removeClass("show-errors");}
Eventful.PanelNewEvent.prototype.listenStopTimeBadFocus=function()
{this.oStopDatePicker.oDropDown.input().focus();this.oStopDatePicker.oDropDown.showPopover();}
Eventful.PanelNewEvent.prototype.listenStopDateBadFocus=function()
{this.oStopTimePicker.oDropDown.input().focus();this.oStopTimePicker.oDropDown.showPopover();}
Eventful.PanelNewEvent.prototype.listenDatePicked=function()
{this.oStopDatePicker.after(this.oStartDatePicker.date());this.oRepeatsDatePicker.after(this.oStartDatePicker.date());}
Eventful.PanelNewEvent.prototype.listenRepeatsChanged=function(evt,el)
{this.find('#repeats-container').removeClass();if(el.value=='advanced')
{this.showRecurrencePanel();}else
{if(el.value)
{var oDate=this.oStartDatePicker.date();var oModifier={daily:{days:1},weekly:{weeks:1},monthly:{months:1},yearly:{years:1}};this.oRepeatsDatePicker.date(oDate.add(oModifier[el.value]));this.find('#repeats-container').addClass('repeats');}
this.sOldRepeatsValue=el.value;}}
Eventful.PanelNewEvent.prototype.listenRecurrencePanelClosed=function(evt)
{if(!evt)return;this.find('#inp-repeats').val(this.sOldRepeatsValue);if(this.sOldRepeatsValue&&this.sOldRepeatsValue!='advanced')
{this.find('#repeats-container').addClass('repeats');}}
Eventful.PanelNewEvent.prototype.listenRecurrencePanelCompleted=function(sDescription)
{this.oRecur=this.oRecurrencePanel.recurrence();this.sOldRepeatsValue='advanced';this.find('#repeats-container').addClass('advanced');this.find('.recurrence-description').html(sDescription)}
Eventful.PanelNewEvent.prototype.listenVenueOption=function(oOption)
{var sName=this.oVenueTypeAhead.oDropDown.input().val();this.oVenueTypeAhead.reset();if(oOption.suggest_venue)
{this.oVenuePanel.show(sName);}else if(oOption.no_venue)
{this.find('#type-ahead-venue, .no-venue').toggle();}}
Eventful.PanelNewEvent.prototype.listenClickSpecifyVenue=function()
{this.find('#type-ahead-venue, .no-venue').toggle();}
Eventful.PanelNewEvent.prototype.listenVenueCreated=function(oVenue)
{this.oVenueTypeAhead.item(oVenue);}
Eventful.PanelNewEvent.prototype.listenLocationOption=function(oOption)
{if(oOption.worldwide)
{this.oLocationTypeAhead.item(oOption);}}
Eventful.PanelNewEvent.prototype.allDay=function()
{var oTime=this.oStartTimePicker.time();if(oTime)
{return oTime.all_day;}}
Eventful.PanelNewEvent.prototype.starttime=function()
{var oDate=this.oStartDatePicker.date();var oTime=this.oStartTimePicker.time();return Eventful.PanelNewEvent.datetime(oDate,oTime);}
Eventful.PanelNewEvent.prototype.stoptime=function()
{if(this.allDay())
{var oDate=this.oStopDatePicker.date();var oTime=this.oStopTimePicker.time();return Eventful.PanelNewEvent.datetime(oDate);}else if(this.find('#when-container').hasClass('with-stop-date-and-time'))
{var oDate=this.oStopDatePicker.date();var oTime=this.oStopTimePicker.time();return Eventful.PanelNewEvent.datetime(oDate,oTime);}else
{var oStartTime=this.oStartTimePicker.time();var oStopTime=this.oStopTimePicker.time();if(oStopTime)
{if(oStopTime.compareTo(oStartTime)<1)
{var oDate=this.oStartDatePicker.date().addDays(1);return Eventful.PanelNewEvent.datetime(oDate,oStopTime);}else
{var oDate=this.oStartDatePicker.date();return Eventful.PanelNewEvent.datetime(oDate,oStopTime);}}}}
Eventful.PanelNewEvent.prototype.listenValid=function()
{var oData={all_day:this.allDay()||''};var oVenue=this.oVenueTypeAhead.item();var oLocation=this.oLocationTypeAhead.item();if(oVenue)
{oData.venue_id=oVenue.svid;}else if(oLocation.svid)
{oData.venue_id=oLocation.svid;}else{$.extend(oData,oLocation);}
var oStartTime=this.starttime();var oStopTime=this.stoptime();oData.start_time=oStartTime.toString('yyyy-MM-dd HH:mm:00');if(oStopTime)oData.stop_time=oStopTime.toString('yyyy-MM-dd HH:mm:00');var sFreq=this.find('[name=repeats]').val();if(sFreq=='advanced')
{oData=$.extend({},this.oRecur,oData);}else if(sFreq)
{oData.freq=sFreq;oData.until=this.oRepeatsDatePicker.date().toString('yyyy-MM-dd');}
var sData=this.find(':input').
not('.inactive, [name=stop_time], [name=start_time]').
serialize()+'&'+
$.param(oData);this.find('.last .progress').show();$.ajax({url:'/json/events/new',type:'post',dataType:'json',data:sData,success:this.listenServerResponse.bind(this)});this.elForm.submit(function(e){e.preventDefault();});}
Eventful.PanelNewEvent.prototype.listenServerResponse=function(oResponse)
{this.oValidator.initialize();this.reset();this.close();var oThanksPanel=new Eventful.Panel('panel-new-event-thanks')
.options({width:350})
.show();if(oResponse.permalink){oThanksPanel.find('a.permalink')
.show()
.attr({href:oResponse.permalink});}else{oThanksPanel.find('a.permalink').hide()}}
Eventful.PanelNewEvent.datetime=function(oDate,oTime)
{if(oDate)
{if(oTime&&!oTime.all_day)
{return oDate.clone().set({hour:oTime.getHours(),minute:oTime.getMinutes()});}else
{return oDate.clone().set({hour:0,minute:0});}}}
Eventful.oPanelNewEvent=new Eventful.PanelNewEvent();Eventful.PopoverAddLink=function(oArgs)
{this.eventLinkAdded=new Eventful.UIEvent();this.elForm=$('form#popover-add-link');oArgs=$.extend({width:275,position:{top:14,left:0,relative:'sender'}},oArgs);if(oArgs.isNewEventForm){oArgs.position.left=0;oArgs.position.right='auto';}
if(oArgs.isIframeForm){oArgs.css={zIndex:'100'};}else if(oArgs.isPanelNewEventForm){oArgs.css={zIndex:'10200'};}
Eventful.Popover.call(this,this.elForm,oArgs);this.clickClose($('.click-cancel',this.elForm));this.eventShow.subscribe(this.listenShow.bind(this));this.oValidator=new Eventful.FormVal(this.elForm);this.oValidator.eventPassValid.subscribe(this.listenValid.bind(this));this.oValidator.eventJSONValidate.subscribe(this.listenStartJSON.bind(this));this.oValidator.eventPassValid.subscribe(this.listenEndJSON.bind(this));this.oValidator.eventFailValid.subscribe(this.listenEndJSON.bind(this));this.oValidator.addRule('link',{required:1,message:"Link URL is required."});this.oValidator.addRule('link',{required:1,pattern:Eventful.FormVal.GetPattern('url'),message:"This link doesn't look right, it should be something like http://eventful.com."});}.mixin(Eventful.Popover);Eventful.PopoverAddLink.prototype.listenShow=function()
{this.elForm
.find('input:text')
.val('')
.end()
.find('select')
.val('1');}
Eventful.PopoverAddLink.prototype.listenStartJSON=function()
{this.elForm.addClass('loading');}
Eventful.PopoverAddLink.prototype.listenEndJSON=function()
{this.elForm.removeClass('loading');}
Eventful.PopoverAddLink.prototype.listenValid=function()
{this.oValidator.initialize();this.close();var oLink={link:$('[name=link]',this.elForm).val(),description:$('[name=description]',this.elForm).val(),link_type:$('[name=link_type_id] :selected',this.elForm).text(),link_type_id:$('[name=link_type_id]',this.elForm).val()};oLink.description=oLink.description||oLink.link;this.eventLinkAdded.fire(oLink);}
Eventful.AddObjectLink=function(oArgs)
{this.oArgs=oArgs||{};if(Eventful.Session&&!Eventful.Session.userName)
{if(Eventful.PanelSigninRequired)
{$('#click-add-link .fakelink').click(function(){window.location='http://eventful.com/signin?goto='+escape(window.location.href);});}
return;}
this.elLinks=$(this.oArgs.links);var oPopover=new Eventful.PopoverAddLink(this.oArgs.popover);oPopover.clickShow('#click-add-link .fakelink');if(this.oArgs.noSave){oPopover.oValidator.eventPassValid.subscribe(this.appendLink.bind(this,oPopover));}else{oPopover.oValidator.addRule('link',{required:1,jsonCb:function()
{return{post:this.oArgs.url,data:oPopover.elForm.serialize(),helperCb:function(oResponse)
{if(oResponse.status=='error')
{return{error:1,message:oResponse.message};}else if(oResponse.status!='ok')
{return{error:1,message:"Sorry, an unknown error occured."};}else if(oResponse.links)
{this.rebuildLinks(oResponse.links)}}.bind(this)};}.bind(this)});}
if(this.oArgs.noSave){$('#event-links-list').click(this.removeLink.bind(this));}}
Eventful.AddObjectLink.prototype.rebuildLinks=function(aLinks)
{var sNewLinks=$.map(aLinks,function(oLink){return this.buildLink.call(this,oLink);}.bind(this)).join('');this.elLinks.find('li:not(.no-replace)').remove();this.elLinks.prepend(sNewLinks);Eventful.ClickOffsite(this.elLinks);}
Eventful.AddObjectLink.prototype.appendLink=function(oPopover)
{this.elLinks.append(this.buildLink({url:$('[name=link]',oPopover.elForm).val(),link_type_id:$('[name=link_type_id] :selected',oPopover.elForm).val(),url_type_id:$('[name=link_type_id] :selected',oPopover.elForm).val(),url_type_name:$('[name=link_type_id] :selected',oPopover.elForm).text(),description:$('[name=description]',oPopover.elForm).val(),always_removable:1}));}
Eventful.AddObjectLink.prototype.buildLink=function(oLink)
{var sHTML='\
    <span class="faded">['+oLink.url_type_name+']</span>\
    <a class="click-offsite" href="'+oLink.url+'">'+(oLink.description||oLink.url)+'</a>&nbsp;\
  ';if(oLink.always_removable){sHTML+='<span class="delete_box faded click-remove-link">X</span>\
    ';}else if(oLink.can_be_removed){sHTML+='<span id="remove-'+oLink.url_id+'" class="delete_box faded click-remove-link">X</span>\
    ';}
if(this.oArgs.noSave){sHTML+='<input type="hidden" name="link" value="'+JSON.stringify(oLink).replace(/"/g,'&quot;')+'" />\
    ';}
return'<li>'+sHTML+'</li>';}
Eventful.AddObjectLink.prototype.removeLink=function(e)
{var $target=$(e.target);if($target.hasClass('click-remove-link')){$target.closest('li').remove();}}
Eventful.ClickOffsite=function(el)
{$('a.click-offsite',el).click(Eventful.ClickOffsite.listenClick);}
Eventful.ClickOffsite.listenClick=function(evt)
{if(evt.ctrlKey||evt.shiftKey||evt.metaKey||evt.altKey)return;evt.preventDefault();window.open(Eventful.ClickOffsite.redirect(this.href),this.target||'_blank');}
Eventful.ClickOffsite.redirect=function(sLocation)
{return'/r/'+sLocation;}
$(function(){Eventful.ClickOffsite()});/* Copyright Eventful, Inc. All rights reserved except where otherwise noted. */
if(typeof window.Eventful==="undefined"){window.Eventful={};}
if(jQuery&&jQuery.fn.jquery>="1.4"){jQuery.ajaxSettings.traditional=true;}
if(window.console==="undefined"){window.console=(function(){var console={},noOp=function(){},aProps=['assert','count','debug','dir','dirxml','error','group','groupCollapsed','groupEnd','info','log','markTimeline','profile','profileEnd','time','timeEnd','trace','warn'],i,l;for(i=0,l=aProps.length;i<l;i++){console[aProps[i]]=noOp;}
return console;})();}
Eventful.isIE=false/*@cc_on @*//*@if (@_win32) || true/*@end @*/;Eventful.isSafari=navigator&&navigator.userAgent.indexOf('Safari')>0;Eventful.JSCheck=function(){document.body.className+=" has-js";};Eventful.fixKeyCode=function(keyCode){var keyEnter=13;if(Eventful.isSafari&&keyCode===3){return keyEnter;}
if(Eventful.isIE&&keyCode===0){return keyEnter;}
return keyCode;};Eventful.Hosted={};if(jQuery.datepicker){window.jQuery=window.jQuery||{};window.jQuery.datepicker=jQuery.datepicker;}
Eventful.Hosted.ChangeLocation=function()
{this.setup();}
Eventful.Hosted.ChangeLocation.prototype.setup=function()
{if($('#eventful-popover-change-location').size()==0){arguments.callee.bind(this).later(1000);return;}
this.oPopover=new Eventful.Popover('#eventful-popover-change-location',{css:{zIndex:100,width:250},position:{top:14,left:0,relative:'sender'}});var elClick=$('#eventful-change-location');this.oPopover.clickShow(elClick);this.oPopover.popover().submit(this.listenSubmit.bind(this));this.oPopover.eventShow.subscribe(function()
{elClick.addClass('open');this.oLocationTypeAhead.oDropDown.input().focus();}.bind(this));this.oPopover.eventClose.subscribe(function()
{elClick.removeClass('open');});this.oLocationTypeAhead=new Eventful.LocationTypeAhead({id:'eventful-location',required:1,length:28,region_id:Eventful.sRegionId||''});this.oLocationTypeAhead.eventEnterConfirm.subscribe(this.changeLocation.bind(this));}
Eventful.Hosted.ChangeLocation.prototype.changeLocation=function(oLocation)
{if(oLocation)
{$.getJSON('/json/tools/location',{method:'post',input_token:'change_location',location_type:oLocation.location_type,location_id:oLocation.location_id,path:window.location.pathname+window.location.search,override_hosted_location:Eventful.sOverrideHostedLocation||''},function(oResponse)
{if(oResponse.base_path)
{window.location=window.location.protocol+'//'+window.location.host+oResponse.base_path;}else
{window.location.reload();}});this.oPopover.close();}}
Eventful.Hosted.ChangeLocation.prototype.listenSubmit=function(evt)
{evt.preventDefault();this.changeLocation(this.oLocationTypeAhead.item());}
var oChangeLocation=new Eventful.Hosted.ChangeLocation();Eventful.PanelMyspacePosting=function()
{Eventful.Panel.call(this,'panel-myspace-posting');this.options({width:856});$(function(){$('#btn-create-bulletin').click(function(evt)
{evt.preventDefault();window.open(this.href,'_blank');});});}.mixin(Eventful.Panel);Eventful.UIEvent=function()
{this.subscribers=[];}
Eventful.UIEvent.prototype.subscribe=function(fnCallback)
{this.subscribers.push(fnCallback);}
Eventful.UIEvent.prototype.fire=function()
{var aArgs=arguments;for(var i=0;i<this.subscribers.length;i++)
{this.subscribers[i].apply(undefined,aArgs);}}
Eventful.Autoclose=function()
{$('body').click(Eventful.Autoclose.body_click);}
Eventful.Autoclose.element_id=null;Eventful.Autoclose.afterClosed=new Eventful.UIEvent();Eventful.Autoclose.body_click=function(evt)
{if(evt)
{var elTarget=$(evt.target);if(elTarget.size())
{if(elTarget.hasClass("autoclose")||elTarget.hasClass("autoclose-click")||elTarget.parents('.autoclose').size())
{return true;}}}
Eventful.Autoclose.close_block();}
Eventful.Autoclose.close_block=function()
{var id=Eventful.Autoclose.element_id;if(id&&id.length)
{var elAutoclose=$('#'+id);if(elAutoclose.size())
{elAutoclose.hide();Eventful.Autoclose.element_id=null;Eventful.Autoclose.afterClosed.fire(elAutoclose.get(0));}}}
Eventful.Autoclose.set_id=function(idEl)
{if(Eventful.Autoclose.element_id!=idEl)
{Eventful.Autoclose.close_block();Eventful.Autoclose.element_id=idEl;}}
$(Eventful.Autoclose);Function.prototype.bind=function(){var __method=this,args=Array.prototype.slice.call(arguments),object=args.shift();return function(){var local_args=args.concat(Array.prototype.slice.call(arguments));if(this!==window)local_args.push(this);return __method.apply(object,local_args);}}
Function.prototype.mixin=function(fn)
{this.prototype=$.extend(this.prototype,fn.prototype);return this;}
Function.prototype.later=function(msec)
{var fn=this,args=Array.prototype.slice.call(arguments,1);return window.setTimeout(function(){fn.apply(this,args)},msec);}
Function.prototype.slow=function(msec,next){var fn=this,tm;if(next){return function(){if(tm)return;tm=1;fn.apply(this,Array.prototype.slice.call(arguments));(function(){tm=0;}).later(msec);}}else{return function(){if(tm)clearTimeout(tm);tm=(function(args){tm=0;fn.apply(this,args);})
.bind(this,Array.prototype.slice.call(arguments))
.later(msec);}}}
Function.prototype.invert=function()
{return function()
{return!this.call();}.bind(this);}
Eventful.TrackPageview=function(oArgs){window._gaq=window._gaq||[];oArgs=oArgs||{};if(typeof oArgs=='string'){return Eventful.TrackPageview({page:oArgs});}
oArgs.page=oArgs.page||window.location.pathname;oArgs.query=oArgs.query||'';var sQuery=Eventful.TrackPageview.query();if(oArgs.query&&oArgs.page.indexOf('?')>=0){oArgs.query='&'+oArgs.query.substring(1);}
if(sQuery&&(oArgs.page.indexOf('?')>=0||oArgs.query)){sQuery='&'+sQuery.substring(1);}
Eventful.TrackPageview.track(oArgs.page+oArgs.query+sQuery);};Eventful.TrackPageview.track=function(sPage){_gaq.push(['_trackPageview',sPage]);};Eventful.TrackPageview.trackVirturalEvent=function(){Eventful.TrackPageview.track('/virtual/event/'+Array.prototype.slice.call(arguments).join('/'));};Eventful.TrackPageview.trackEvent=function(category,action,optional_label,optional_value){if(typeof window["console"]==="object"&&Eventful.Session&&Eventful.Session.userRole==="admin"){window["console"].log("Google Analytics _trackEvent:",arguments);}
_gaq.push(['_trackEvent',category,action,optional_label,optional_value]);};Eventful.TrackPageview.trackSocial=function(network,action,optional_target,optional_pagepath){_gaq.push(['_trackSocial',network,action,optional_target,optional_pagepath]);}
Eventful.TrackPageview.query=function(sQuery){return Eventful.TrackPageview._sQuery=sQuery||Eventful.TrackPageview._sQuery||window.location.search.toLowerCase();};Eventful.TrackPageview.setParams=function(oParams){var aParams=[];for(var sKey in oParams){aParams.push(sKey+'='+oParams[sKey]);}
var sQuery=Eventful.TrackPageview.query();Eventful.TrackPageview.query((sQuery?sQuery+'&':'?')+aParams.join('&'));};Eventful.Popover=function(jqEx,oOptions)
{this.eventShow=new Eventful.UIEvent();this.eventClose=new Eventful.UIEvent();this._setup({width:"300px",css:{'backgroundColor':'#fff','border':'1px solid #666','zIndex':"10"},position:{"top":10,"left":10,"right":'auto',"bottom":'auto',"relative":'mouse'},no_focus:false,tracking:''},jqEx,oOptions||{});}
Eventful.Popover.prototype._setup=function(default_args,jqEx,oOptions){var popoverCss={},containerCss={};$.each($.extend(default_args.css,{'width':default_args.width},oOptions.css,{'width':oOptions.width}),function(attr,val){if(!val)return;if(/^(width|height|zIndex)$/.test(attr)){containerCss[attr]=val;}else{popoverCss[attr]=val;}});this.popover(jqEx).css(popoverCss);this.args={'containerCss':containerCss,'position':$.extend(default_args.position,oOptions.position),'tracking':oOptions.tracking||default_args.tracking,'no_focus':oOptions.no_focus||default_args.no_focus,'listenKeyESC':!!this.find(':input').not(':hidden').length};}
Eventful.Popover.prototype.container=function(){var jContainer,oEvt,oInst,fnKeyESCHdl=function(evt){if(evt.keyCode==27&&oInst){oInst.close(evt);}},fnReposition=function(evt){if(oInst)oInst._position(evt);},fnMouseLeaveHdl=function(){if(oInst)oInst._slowUIAct(!oInst.args.slowActOverPopover,true);},fnMouseEnterHdl=function(){if(oInst)oInst._slowUIAct(!oInst.args.slowActOverPopover,false);},fnShow=function(intc,evt){if(oInst)fnClose();oInst=intc;oEvt=evt?{'target':evt.target,'pageX':evt.pageX,'pageY':evt.pageY}:null;jContainer
.prepend(oInst.popover(true))
.css($.extend({height:'auto',width:'auto',zIndex:'auto'},oInst.args.containerCss,{"top":"-1000px","left":"-1000px"}))
.show();oInst._position(oEvt);if(oInst.args.listenOverPopover){jContainer
.bind('mouseenter',fnMouseEnterHdl)
.bind('mouseleave',fnMouseLeaveHdl);}
if(oInst.args.listenKeyESC){jContainer.bind('keyup',fnKeyESCHdl);}
if(oInst.args.position.relative==='mouse'&&oEvt){$(oEvt.target).bind('mousemove',fnReposition);}},fnClose=function(){if(oInst.args.listenOverPopover){jContainer
.unbind('mouseenter',fnMouseEnterHdl)
.unbind('mouseleave',fnMouseLeaveHdl);}
if(oInst.args.listenKeyESC){jContainer.unbind('keyup',fnKeyESCHdl);}
if(oInst.args.position.relative==='mouse'&&oEvt){$(oEvt.target).unbind('mousemove',fnReposition);}
jContainer
.hide()
.children().not('iframe')
.each(function(){if(this.parentNode)this.parentNode.removeChild(this);});oInst=oEvt=null;};return function(doElse){if(!jContainer){jContainer=$('<div id="eventful-tooltip" class="popover autoclose" \
                          style="position:absolute;margin:0;border:0;padding:0;background-color:transparent;"> \
                      </div>')
.appendTo(document.body)
.hide()
.bind('resize',function(){jContainer
.children('iframe')
.css({'width':jContainer.width(),'height':jContainer.height()});fnReposition(oEvt);});if($.browser.msie&&($.browser.version<7)){jContainer.append('<iframe frameborder="0" src="javascript:\'\'" \
                             style="position:absolute;top:0;left:0;z-index:-1;filter:mask();"> \
                           </iframe>');}
$(window).bind('resize',function(){fnReposition(oEvt);});}
if(doElse){if(doElse.get&&doElse.get==='event'){return oEvt;}else if(doElse.get&&doElse.get==='instance'){return oInst;}else if(doElse.set&&doElse.set[0]){fnShow(doElse.set[0],doElse.set[1]);}else if(doElse.set&&oInst){fnClose();}}
return jContainer;}}();Eventful.Popover.prototype.popover=function(jqEx){if(!this._jPopover&&jqEx){this._jPopover=$(jqEx).hide();if(this._jPopover.parents('body').length){this._jPopover._delayDetach=true;}else if(typeof jqEx==='string'){this._jPopover=$('<div class="popbd">'+jqEx+'</div>');}}else if(this._jPopover._delayDetach&&jqEx===true){this._jPopover.each(function(){if(this.parentNode)this.parentNode.removeChild(this);}).removeClass('hidden').show();delete this._jPopover['_delayDetach'];}
return this._jPopover;}
Eventful.Popover.prototype.find=function(sExpr)
{return this.popover().find(sExpr)}
Eventful.Popover.prototype.clickShow=function(jSel,bStayOpen){$(jSel)
.addClass('popover-sender autoclose')
.click(function(evt){(!bStayOpen&&this.isOpen())?this.close(evt):this.show(evt);evt.preventDefault();}.bind(this));return this;}
Eventful.Popover.prototype.clickClose=function(jSel){$(jSel).click(function(evt){this.close(evt);evt.preventDefault();}.bind(this));return this;}
Eventful.Popover.prototype.hoverShow=function(jSel,options){var fnShow,fnClose;if(options&&(options.show_over||options.show_slow)){fnShow=this._slowUIAct.bind(this,!options.show_slow,false);fnClose=this._slowUIAct.bind(this,!options.show_slow,true);}else{fnShow=this.show.bind(this);fnClose=this.close.bind(this);}
this.args.listenOverPopover=!!(options&&options.show_over);this.args.slowActOverPopover=this.args.listenOverPopover&&options.show_slow;$(jSel)
.addClass('popover-sender')
.bind('mouseenter',fnShow)
.bind('mouseleave',fnClose);return this;}
Eventful.Popover.prototype._slowUIAct=(function(){var fn=function(evt,bClosing){bClosing===true?this.close(evt):this.show(evt);},fnHalfSec=fn.slow(500),fnMillSec=fn.slow(10);return function(bQuick,bClosing,evt){(bQuick?fnMillSec:fnHalfSec)
.call(this,evt?{'target':evt.target,'pageX':evt.pageX,'pageY':evt.pageY}:null,bClosing);}})();Eventful.Popover.prototype.isOpen=function(bPopover){var inst=this.container({'get':'instance'});return bPopover?!!inst:this===inst;}
Eventful.Popover.prototype.show=function(evt){if(this.isOpen()){var lastShowEvt=this.container({'get':'event'});if(!evt)return this._position(lastShowEvt);if(lastShowEvt&&lastShowEvt.target===evt.target)return this._position(evt);}
if(this.isOpen(true)){this.container({'get':'instance'}).close(evt);}
this.container({'set':[this,evt]});if(!this.args.no_focus){this.container().find(":input").not('.inactive,:hidden').eq(0).trigger('focus');}
if(this.args.tracking){Eventful.TrackPageview.track(this.args.tracking);}
Eventful.Autoclose.set_id(this.container().attr('id'));this.eventShow.fire(evt);return this;}
Eventful.Popover.prototype.close=function(evt){this.container({'set':[null,null]});Eventful.Autoclose.element_id=null;this.eventClose.fire(evt);return this;}
Eventful.Autoclose.afterClosed.subscribe(function(elClose){if(elClose===Eventful.Popover.prototype.container()[0]){var intsToClose=Eventful.Popover.prototype.container({'get':'instance'});if(intsToClose)intsToClose.close();}});Eventful.Popover.prototype._position=function(evt){var docScrollTop=document.body.scrollTop||document.documentElement.scrollTop||0,docScrollLeft=document.body.scrollLeft||document.documentElement.scrollLeft||0,h=this.container().height(),w=this.container().width(),top=0,left=0;if(typeof this.args.position.relative=='object'||(this.args.position.relative=='sender'&&evt)){var jRelative=typeof this.args.position.relative==='object'?$(this.args.position.relative):$(evt.target).parents('.popover-sender').andSelf(),positionOffset=jRelative.offset();if(typeof this.args.position.top=='number'){top=positionOffset.top+this.args.position.top;}else if(typeof this.args.position.bottom=='number'){top=positionOffset.top+jRelative.height()-h-this.args.position.bottom;}else{top=positionOffset.top+10;}
if(typeof this.args.position.left=='number'){left=positionOffset.left+this.args.position.left;}else if(typeof this.args.position.right=='number'){left=positionOffset.left+jRelative.width()-w-this.args.position.right;}else{left=positionOffset.left+10;}}else if(this.args.position.relative=='viewport'){if(typeof this.args.position.top=='number'){top=docScrollTop+this.args.position.top;}else if(typeof this.args.position.bottom=='number'){top=docScrollTop+$(window).height()-h-this.args.position.bottom;}else{top=docScrollTop+10;}
if(typeof this.args.position.left=='number'){left=docScrollLeft+this.args.position.left;}else if(typeof this.args.position.right=='number'){left=docScrollLeft+$(window).width()-w-this.args.position.right;}else{left=docScrollLeft+10;}}else if(/^(mouse|click)$/.test(this.args.position.relative)&&evt){if(typeof this.args.position.top!=='number')this.args.position.top=10;if(typeof this.args.position.left!=='number')this.args.position.left=10;if(evt.pageY<=docScrollTop+$(window).height()*0.5){top=evt.pageY+this.args.position.top;}else{top=evt.pageY-this.args.position.top-h;}
if(evt.pageX<=docScrollLeft+$(window).width()*0.5){left=evt.pageX+this.args.position.left;}else{left=evt.pageX-this.args.position.left-w;}}
this.container().css({"top":top+"px","left":left+"px"});return this;}
Eventful.Popover.blockUI=function(){if(!Eventful.Popover.blockUI.blocker)Eventful.Popover.blockUI.blocker=new Eventful.Popover('<div id="eventful-uiblocker" style="height:'+$(document).height()+
'px;background:#FFFFFF url(http://s1.evcdn.com/store/skin/throbbers/throbber_32x32.gif) no-repeat fixed center center;"></div>',{css:{width:'100%',border:false,opacity:0.66},position:{top:0,left:0,relative:'viewport'}});Eventful.Popover.blockUI.blocker.show();}
Eventful.Popover.unblockUI=function(){if(Eventful.Popover.blockUI.blocker)Eventful.Popover.blockUI.blocker.close();}
Eventful.CopyClicker=function(elClick,elCopy,sCopyText,elCoverLater){this.jHtmlClick=$(elClick);if(window.clipboardData){this.jHtmlClick.click(this.ieCopyClick.bind(this,elCopy,sCopyText));return this;}
Eventful.CopyClicker.allCopyClickers.push(this);var myID=Eventful.CopyClicker.allCopyClickers.length-1;this.jFlashClick=$('<embed FlashVars="clickerID='+myID+'" \
        style="position:absolute;top:0px;left:0px;cursor:pointer"\
        src="/flash/copy_clipboard.swf" \
        wmode="transparent" \
        loop="false" menu="false" \
        width="1" height="1" \
        allowScriptAccess="sameDomain" \
        type="application/x-shockwave-flash"></embed>')
.bind('load',Eventful.CopyClicker.ready.bind(window,myID))
.appendTo(document.body);this.elCopy=elCopy;this.sCopyText=sCopyText;if(elCoverLater)this.elCoverLater=elCoverLater;}
Eventful.CopyClicker.allCopyClickers=[];Eventful.CopyClicker.prototype.ieCopyClick=function(elCopy,sCopyText){var sValue=$(elCopy).val()||sCopyText;if(!sValue)return;window.clipboardData.setData('text',sValue)
this.lulz();}
Eventful.CopyClicker.prototype.lulz=function(){if(this.jHtmlClick.attr('alt'))
{var sOriginal=this.jHtmlClick.html();this.jHtmlClick.html(this.jHtmlClick.attr('alt'));this.jHtmlClick.html.bind(this.jHtmlClick,sOriginal).later(3000);}}
Eventful.CopyClicker.prototype.show=function(){if(!this.jFlashClick)return;var clickPos=this.jHtmlClick.offset();var jqContainer;if(!this.elCoverLater||this.elCoverLater===true||this.elCoverLater===1){jqContainer=document.body;}else{if(this.elCoverLater==='panel')
jqContainer=$('#modalContainer');else if(this.elCoverLater==='popover')
jqContainer=$('#eventful-tooltip');else
jqContainer=$(this.elCoverLater);var containerPos=jqContainer.offset();clickPos.top-=containerPos.top;clickPos.left-=containerPos.left;}
var xrayFlash=(window.location.search.search(/copyclick=1/)>-1)?{'background-color':'#f00','opacity':0.5}:null;this.jFlashClick
.css($.extend({'zIndex':'1','top':clickPos.top-1,'left':clickPos.left-1,'width':this.jHtmlClick.width()+2,'height':this.jHtmlClick.height()+2},xrayFlash))
.appendTo(jqContainer);if(!this._OnResize){this._OnResize=this.show.bind(this);}
$(window).bind('resize',this._OnResize);}
Eventful.CopyClicker.prototype.close=function(){if(!this.jFlashClick)return;if(this._OnResize){$(window).unbind('resize',this._OnResize);}
this.jFlashClick.remove();}
Eventful.CopyClicker.ready=function(clickerID){var oCopyClicker=Eventful.CopyClicker.allCopyClickers[parseInt(clickerID)];if(!oCopyClicker||oCopyClicker._shown_onload||oCopyClicker.elCoverLater)return;oCopyClicker._shown_onload=true;oCopyClicker.show.bind(oCopyClicker).later(1000);}
Eventful.CopyClicker.getContent=function(clickerID){var oCopyClicker=Eventful.CopyClicker.allCopyClickers[parseInt(clickerID)];if(!oCopyClicker)return'';return $(oCopyClicker.elCopy).val()||oCopyClicker.sCopyText||'';}
Eventful.CopyClicker.done=function(clickerID){var oCopyClicker=Eventful.CopyClicker.allCopyClickers[parseInt(clickerID)];if(!oCopyClicker)return;oCopyClicker.jHtmlClick.trigger('click');oCopyClicker.lulz();}
Eventful.InactiveText=function(el)
{el=$(el);el.blur();el.blur(Eventful.InactiveText.listenBlur);el.focus(Eventful.InactiveText.listenFocus);if(!el.prop('defaultValue'))
{el.val(el.attr('alt'));el.addClass('inactive');}else
{el.val(el.prop('defaultValue'));}
el.removeClass('inactive-text');}
Eventful.InactiveText.attachHandlers=function(root)
{$('.inactive-text',root).each(function(_,el){Eventful.InactiveText(el);});}
Eventful.InactiveText.listenBlur=function(evt)
{var el=$(evt.target);if(!el.val()&&!el.parents('.field-container.has-error').size())
{el.addClass('inactive');el.val(el.attr('alt'));}}
Eventful.InactiveText.listenFocus=function(evt)
{var el=$(evt.target);if(el.hasClass('inactive'))
{el.removeClass('inactive');el.val('');}}
Eventful.InactiveText.doForcedUpdate=function(el)
{el=$(el);el.addClass('inactive');el.val(el.attr('alt'));}
Eventful.WidgetWindow=function()
{var sFeatures="menubar=no,location=no,resizable=yes,scrollbars=yes,status=no";var sDefaultSize="width=500,height=450";$('a.widget-window').click(function()
{var sAltText=$(this).attr("alt");var sThisLinkFeatures=sFeatures;if(sAltText){if(sAltText=='windowSize:none'){sThisLinkFeatures=sFeatures;}
else if(sAltText.substring(0,11)=='windowSize:'){sThisLinkFeatures+=','+sAltText.substring(11);}}else{sThisLinkFeatures+=','+sDefaultSize;}
window.open(this.href,"_blank",sThisLinkFeatures);return false;});}
$(Eventful.WidgetWindow);Eventful.FormVal=function(formJExpr,summaryJExpr,oArgs){this.jForm=$(formJExpr);if(summaryJExpr)this.jqFormSummary=$(summaryJExpr);if(!oArgs)oArgs={};this.args={summaryError:oArgs.summaryError||"Oh no! Errors! Please check the fields above.",summaryEmpty:oArgs.summaryEmpty||"You forgot to fill out the fields! Good thing I reminded you.",keepValidate:oArgs.keepValidate===undefined?false:oArgs.keepValidate,isMobile:oArgs.isMobile||false};this.rules=[];this.eventBeginValidation=new Eventful.UIEvent();this.eventPassValid=new Eventful.UIEvent();this.eventJSONValidate=new Eventful.UIEvent();this.eventFailValid=new Eventful.UIEvent();this.eventErrorShown=new Eventful.UIEvent();this.eventFailFormEmpty=new Eventful.UIEvent();this.initialize();}
Eventful.FormVal.prototype.bindEvent=function(nm,fn){var nmEvts={'beginValidatation':this.eventBeginValidation,'passValid':this.eventPassValid,'failValid':this.eventFailValid,'errorShown':this.eventErrorShown,'JSONValidate':this.eventJSONValidate};if(nmEvts[nm])nmEvts[nm].subscribe(fn);return this;}
Eventful.FormVal.GetPattern=function(type){var allPatterns={"float":/^-?(\d+\.?\d*|\d*\.\d+)$/,"number":/^[-+]?\d+$/,"email":/^[\w.%+-]+@([\w-]+\.)+[A-Za-z]{2,4}$/,"url":/^https?:\/\/([\w-]+\.)+[A-Za-z]{2,4}/i};return allPatterns[type];}
Eventful.FormVal.prototype.getPattern=Eventful.FormVal.GetPattern;Eventful.FormVal.setInactive=function(exprActiveToggle){$(exprActiveToggle||'input[type=text][alt!=""],textarea[alt!=""]',!exprActiveToggle&&this.jForm?this.jForm:undefined)
.bind('focus',function(){if($(this).hasClass('inactive')){$(this).removeClass('inactive').val('');}})
.bind('blur',function(){var alt=$(this).attr('alt');if(this.value==''){$(this).addClass('inactive').val(alt);}})
.each(function(i,el){var alt=$(this).attr('alt');if(el.value==""||el.value==alt){$(el).addClass('inactive').val(alt);}});return this;}
Eventful.FormVal.prototype.setInactive=Eventful.FormVal.setInactive;Eventful.FormVal.emptyInactive=function(exprActiveToggle){$(exprActiveToggle||'input.inactive[type=text][alt!=""],textarea.inactive[alt!=""]',!exprActiveToggle&&this.jForm?this.jForm:undefined).val('');return this;}
Eventful.FormVal.prototype.emptyInactive=Eventful.FormVal.emptyInactive;Eventful.FormVal.prototype.initialize=function(){this._serializedValues=this.jForm.serialize();this.jForm.bind('submit.formval',function(){this.validateForm.bind(this).later(1);return false;}.bind(this));return this;}
Eventful.FormVal.prototype.deinitialize=function(){this.jForm.unbind('submit.formval');return this;}
Eventful.FormVal.prototype.focusFirstField=function(){if(this.args.isMobile){return this;}
var jqInputs=this.jForm.find('.has-error :input').not(':hidden');if(!jqInputs.size())
{jqInputs=this.jForm.find(':input').not(':hidden');}
jqInputs.eq(0).trigger('focus');return this;}
Eventful.FormVal.prototype.isDirty=function(){return this._serializedValues!==this.jForm.serialize();}
Eventful.FormVal.prototype.trackEvent=function(sAction,sLabel,sValue)
{Eventful.TrackPageview.trackEvent("Form Validation",sAction,sLabel,sValue);}
Eventful.FormVal.prototype.validateForm=function(){this.eventBeginValidation.fire(this.jForm[0]);if($.grep(this.jForm.find(":input").not(':hidden,:button,:reset,:image,:submit,.inactive').serializeArray(),function(pair){return!!$.trim(pair.value)}).length===0&&$.grep(this.rules,function(rule){return rule.rule.required;}).length>0&&this.jqFormSummary)
{this.showSummaryError(this.args.summaryEmpty);this.eventFailFormEmpty.fire(this.jForm[0]);return;}
if(this.args.isMobile){this.jForm.find('.field-container').removeClass('has-error show-errors');}
this.hideSummaryError().hideHasError();$.each(this.rules,function(_,oNameRulePair){oNameRulePair.rule.quality={error:0,message:'',defaultMessage:''};});function _markBadQuality(errInput,jInput,rule,errBit,defMsg,msg){errInput.push(jInput);rule.quality.error|=1<<errBit;rule.quality.defaultMessage=defMsg||"The input has error";rule.quality.message=msg||rule.message;}
var errInput=[],jsonQueue=[];$.each(this.rules,function(_,oNameRulePair){var jInput=this.jForm.find(':input[name='+oNameRulePair.name+']'),rule=oNameRulePair.rule;if(jInput.length==0||$.grep(errInput,function(j){return jInput.attr('name')===j.attr('name')}).length||!rule)return;var nameValues=$.grep(jInput.not('.inactive').serializeArray(),function(pair){return!!$.trim(pair.value)});if(rule.ignoreCb&&rule.ignoreCb(jInput.length===1?jInput[0]:jInput,nameValues)){return;}
if(rule.required&&!nameValues.length){_markBadQuality(errInput,jInput,rule,0,"Data is required");}else if(nameValues.length&&rule.pattern&&$.grep(nameValues,function(oPair){return rule.pattern.test(oPair.value)===false;}).length){_markBadQuality(errInput,jInput,rule,1,"The input has incorrect format");}else if(nameValues.length&&rule.hasOwnProperty("minlen")){if(jInput.is(':text, :password, textarea')&&jInput.val().length<rule.minlen){_markBadQuality(errInput,jInput,rule,2,"string length must >= "+rule.minlen);}else if(jInput.is(':checkbox, select')&&nameValues.length<rule.minlen){_markBadQuality(errInput,jInput,rule,3,"at least "+rule.minlen+" selected");}}else if(nameValues.length&&rule.hasOwnProperty("maxlen")){if(jInput.is(':text, :password, textarea')&&jInput.val().length>rule.maxlen){_markBadQuality(errInput,jInput,rule,4,"string length must <= "+rule.maxlen);}else if(jInput.is(':checkbox, select')&&nameValues.length>rule.maxlen){_markBadQuality(errInput,jInput,rule,5,"at most "+rule.maxlen+" selected");}}else if(nameValues.length&&rule.hasOwnProperty("min")&&jInput.is(':text')){var aNum=/^[+-]?\d+$/.test(jInput.val())?parseInt(jInput.val()):parseFloat(jInput.val());if(isNaN(aNum)||aNum<rule.min){_markBadQuality(errInput,jInput,rule,6,"must >= "+rule.min);}}else if(nameValues.length&&rule.hasOwnProperty("max")&&jInput.is(':text')){var aNum=/^[+-]?\d+$/.test(jInput.val())?parseInt(jInput.val()):parseFloat(jInput.val());if(isNaN(aNum)||aNum>rule.max){_markBadQuality(errInput,jInput,rule,7,"must <= "+rule.max);}}else if(rule.helperCb){var msg=rule.helperCb(jInput.length===1?jInput[0]:jInput,nameValues);if(msg&&msg.error)_markBadQuality(errInput,jInput,rule,8,'Failed to helper check',msg.message);}else if(rule.jsonCb){var oJSONsetup=rule.jsonCb(jInput.length==1?jInput[0]:jInput,nameValues);if(oJSONsetup&&(oJSONsetup.post||oJSONsetup.get))
{jsonQueue.push($.extend(oJSONsetup,{'rule':rule,'jInput':jInput}));}}}.bind(this));if(errInput.length){this._afterFailure(errInput);}else if(jsonQueue.length){var _onJsonResponse=function(helperCb,jInput,rule,sJsonUrl,oResponse)
{if(rule.accept_unavailable&&oResponse.status===503)
{this.trackEvent("Service Unavailable",sJsonUrl,jInput.val());}else
{var msg=helperCb(oResponse,jInput.length==1?jInput[0]:jInput,this.jForm[0]);}
if(msg&&msg.error){_markBadQuality(errInput,jInput,rule,9,'Failed to ajax check',msg.message);this._afterFailure(errInput);}else if(msg===false){return;}else if(jsonQueue.length){_shiftJsonQueue.call(this);}else{this._afterSuccess();}};var _shiftJsonQueue=function()
{var oJson=jsonQueue.shift();if(oJson)
{var sJsonUrl=oJson.post||oJson.get;$.ajax({url:sJsonUrl,type:oJson.post?"post":"get",data:oJson.data,success:_onJsonResponse.bind(this,oJson.helperCb,oJson.jInput,oJson.rule,sJsonUrl),error:_onJsonResponse.bind(this,oJson.helperErrorCb||function(){return{"error":1,"message":"Sorry! There is trouble to validate your input."}},oJson.jInput,oJson.rule),dataType:oJson.dataType||'json'});}};_shiftJsonQueue.call(this);this.eventJSONValidate.fire();}else{this._afterSuccess();}
return this;}
Eventful.FormVal.prototype._afterSuccess=function(){if(!this.args.keepValidate)this.deinitialize();if(this.eventPassValid.subscribers.length){this.eventPassValid.fire(this.jForm[0]);}else{this.emptyInactive();this.jForm.trigger('submit');}
return this;}
Eventful.FormVal.prototype._afterFailure=function(errInput){this.showSummaryError();this.showHasError(errInput);this.eventFailValid.fire(this.jForm[0],errInput);return this;}
Eventful.FormVal.prototype.addRule=function(inputname,oRule,position){if(typeof position=='number'){this.rules.splice(position,0,{name:inputname,rule:oRule});}else{this.rules.push({name:inputname,rule:oRule});}
return this;}
Eventful.FormVal.prototype.removeRule=function(inputname){this.rules=$.map(this.rules,function(oRule){return oRule.name===inputname?null:oRule;});return this;}
Eventful.FormVal.prototype.showShowError=function(elInput){var jqElContainer=$(elInput).parents(".field-container").addClass("show-errors");var sInputName=$(elInput).attr('name');var sMessage="There are errors in your input.";var jqFormError=jqElContainer.find(".form-error");if(!jqFormError.size()){jqFormError=$('<div class="form-error"></div>')
.attr('id',sInputName+'-error')
.appendTo(jqElContainer);}
var oNameRulePair=$.grep(this.rules,function(oNameRulePair){return oNameRulePair.name==sInputName&&oNameRulePair.rule.quality&&oNameRulePair.rule.quality.error;})[0];if(oNameRulePair)
{var oRule=oNameRulePair.rule;if(oRule.markupMessage==undefined)
{oRule.markupMessage=jqFormError.html();}
sMessage=oRule.quality.message||oRule.markupMessage||oRule.quality.defaultMessage||sMessage;}
jqFormError.html(sMessage);this.eventErrorShown.fire(elInput,jqFormError.get(0));return this;}
Eventful.FormVal.prototype.hideShowError=function(elInput){$(elInput).parents(".field-container").removeClass("show-errors");return this;}
Eventful.FormVal.prototype.showHasError=function(errInput){this._fnClearHasError=this._fnClearHasError?this._fnClearHasError.splice(0):[];$.each(errInput,function(i,el){var jqEl=$(el),jqContainer=jqEl.parents(".field-container").addClass("has-error");if(jqContainer.length==0)return;if(this.args.isMobile){this.showShowError.call(this,el);return this;}else{jqEl.bind("focus.haserror",this.showShowError.bind(this,el))
.bind("blur.haserror",this.hideShowError.bind(this,el));}
var afterTryAgain=function(){jqContainer.removeClass("has-error").removeClass("show-errors");jqEl.unbind("focus.haserror").unbind("blur.haserror");}
if(jqEl.is(':text, :password, textarea')){jqEl.bind("keyup.causechange",function(sOldVal){if($(this).val()!=sOldVal){afterTryAgain();$(this).unbind('keyup.causechange')}}.bind(jqEl[0],jqEl.val()));this._fnClearHasError.push(function(){jqEl.unbind("keyup.causechange");afterTryAgain();});}else if(jqEl.is('select')){jqEl.one("change",afterTryAgain);this._fnClearHasError.push(function(){jqEl.unbind("change",afterTryAgain);afterTryAgain();});}else if(jqEl.is(':checkbox, :radio')){jqEl.one("click",afterTryAgain);this._fnClearHasError.push(function(){jqEl.unbind("click",afterTryAgain);afterTryAgain();});}}.bind(this));return this.focusFirstField();}
Eventful.FormVal.prototype.hideHasError=function(){if(this._fnClearHasError){var fn;while(fn=this._fnClearHasError.pop())fn();}
return this;}
Eventful.FormVal.prototype.showSummaryError=function(sErrorMsg){if(this.jqFormSummary){sErrorMsg=sErrorMsg||this.args.summaryError;this.jqFormSummary.html(sErrorMsg).addClass("show-errors");var fnHideSummary=function(sOldFormValue){if(sOldFormValue!==this.jForm.serialize()){this.hideSummaryError();this.jForm
.find(':text, :password, textarea')
.unbind("keyup",fnHideSummary)
.end()
.find('select')
.unbind("change",fnHideSummary)
.end()
.find(':checkbox, :radio')
.unbind("click",fnHideSummary);}}.bind(this,this.jForm.serialize());this.jForm
.find(':text, :password, textarea')
.bind("keyup",fnHideSummary)
.end()
.find('select')
.bind("change",fnHideSummary)
.end()
.find(':checkbox, :radio')
.bind("click",fnHideSummary);}
return this.focusFirstField();}
Eventful.FormVal.prototype.hideSummaryError=function(evt){if(this.jqFormSummary){this.jqFormSummary.empty().removeClass("show-errors");}
return this;}
Eventful.Hosted.ShareTools=function(oArgs)
{if(oArgs){this.oDefaultPosition=oArgs.position;}
$(this.setup.bind(this));}
Eventful.Hosted.ShareTools.prototype.find=function(sExpr)
{return $('#eventful #share-tools').find(sExpr);}
Eventful.Hosted.ShareTools.prototype.setup=function()
{this.find('form a.click-share')
.click(function(){$(this).parents('form').submit()});var oPopoverArgs={css:{zIndex:100,width:300},position:this.oDefaultPosition||{top:16,left:0,relative:'sender'}};this.oEmailPopover=new Eventful.Popover('#eventful .popover-email',oPopoverArgs).
clickShow(this.find('.click-share-email'));var oPermalinkCopyClicker=new Eventful.CopyClicker(this.oEmailPopover.find('.click-copy'),this.oEmailPopover.find('.permalink'),undefined,this.oEmailPopover.popover());this.oEmailPopover.eventShow.subscribe(oPermalinkCopyClicker.show.bind(oPermalinkCopyClicker));this.oEmailPopover.eventClose.subscribe(oPermalinkCopyClicker.show.bind(oPermalinkCopyClicker));var oSaveToCalendarArgs=$.extend({},oPopoverArgs);oSaveToCalendarArgs.css=$.extend({},oSaveToCalendarArgs.css,{width:150});new Eventful.Popover('#eventful .popover-save-to-calendar',oSaveToCalendarArgs).
clickShow('#eventful .save-to-calendar');}
Eventful.Hosted.VenueDetail=function()
{var elDetail=$('#venue-detail');elDetail.find('.switch-image .click-map').click(function()
{elDetail.find('.image img.google-map').show();elDetail.find('.image img.venue').hide();});elDetail.find('.switch-image .click-image').click(function()
{elDetail.find('.image img.google-map').hide();elDetail.find('.image img.venue').show();});}
$(Eventful.Hosted.VenueDetail);})(jQuery,jQuery);
