(function($,undefined){$.extend($.ui,{timepicker:{version:"0.2.2"}});var PROP_NAME="timepicker";var tpuuid=(new Date).getTime();function Timepicker(){this.debug=true;this._curInst=null;this._isInline=false;this._disabledInputs=[];this._timepickerShowing=false;this._inDialog=false;this._dialogClass="ui-timepicker-dialog";this._mainDivId="ui-timepicker-div";this._inlineClass="ui-timepicker-inline";this._currentClass="ui-timepicker-current";this._dayOverClass="ui-timepicker-days-cell-over";this.regional=
[];this.regional[""]={hourText:"Hour",minuteText:"Minute",amPmText:["AM","PM"]};this._defaults={showOn:"focus",button:null,showAnim:"fadeIn",showOptions:{},appendText:"",onSelect:null,onClose:null,timeSeparator:":",showPeriod:false,showPeriodLabels:true,showLeadingZero:true,showMinutesLeadingZero:true,altField:"",defaultTime:"",onHourShow:null,onMinuteShow:null,zIndex:null,hours:{starts:0,ends:23},minutes:{starts:0,ends:55,interval:5},rows:4};$.extend(this._defaults,this.regional[""]);this.tpDiv=
$('
')}$.extend(Timepicker.prototype,{markerClassName:"hasTimepicker",log:function(){if(this.debug)console.log.apply("",arguments)},_widgetTimepicker:function(){return this.tpDiv},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this},_attachTimepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=
target.getAttribute("time:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase();var inline=nodeName=="div"||nodeName=="span";if(!target.id){this.uuid+=1;target.id="tp"+this.uuid}var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{});if(nodeName=="input")this._connectTimepicker(target,inst);else if(inline)this._inlineTimepicker(target,
inst)},_newInst:function(target,inline){var id=target[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:id,input:target,inline:inline,tpDiv:!inline?this.tpDiv:$('')}},_connectTimepicker:function(target,inst){var input=$(target);inst.append=$([]);inst.trigger=$([]);if(input.hasClass(this.markerClassName))return;this._attachments(input,inst);input.addClass(this.markerClassName).keydown(this._doKeyDown).keyup(this._doKeyUp).bind("setData.timepicker",
function(event,key,value){inst.settings[key]=value}).bind("getData.timepicker",function(event,key){return this._get(inst,key)});$.data(target,PROP_NAME,inst)},_doKeyDown:function(event){var inst=$.timepicker._getInst(event.target);var handled=true;inst._keyEvent=true;if($.timepicker._timepickerShowing)switch(event.keyCode){case 9:$.timepicker._hideTimepicker();handled=false;break;case 13:$.timepicker._updateSelectedValue(inst);$.timepicker._hideTimepicker();return false;break;case 27:$.timepicker._hideTimepicker();
break;default:handled=false}else if(event.keyCode==36&&event.ctrlKey)$.timepicker._showTimepicker(this);else handled=false;if(handled){event.preventDefault();event.stopPropagation()}},_doKeyUp:function(event){var inst=$.timepicker._getInst(event.target);$.timepicker._setTimeFromField(inst);$.timepicker._updateTimepicker(inst)},_attachments:function(input,inst){var appendText=this._get(inst,"appendText");var isRTL=this._get(inst,"isRTL");if(inst.append)inst.append.remove();if(appendText){inst.append=
$(''+appendText+"");input[isRTL?"before":"after"](inst.append)}input.unbind("focus.timepicker",this._showTimepicker);if(inst.trigger)inst.trigger.remove();var showOn=this._get(inst,"showOn");if(showOn=="focus"||showOn=="both")input.bind("focus.timepicker",this._showTimepicker);if(showOn=="button"||showOn=="both"){var button=this._get(inst,"button");$(button).bind("click.timepicker",function(){if($.timepicker._timepickerShowing&&$.timepicker._lastInput==input[0])$.timepicker._hideTimepicker();
else $.timepicker._showTimepicker(input[0]);return false})}},_inlineTimepicker:function(target,inst){var divSpan=$(target);if(divSpan.hasClass(this.markerClassName))return;divSpan.addClass(this.markerClassName).append(inst.tpDiv).bind("setData.timepicker",function(event,key,value){inst.settings[key]=value}).bind("getData.timepicker",function(event,key){return this._get(inst,key)});$.data(target,PROP_NAME,inst);this._setTimeFromField(inst);this._updateTimepicker(inst);inst.tpDiv.show()},_showTimepicker:function(input){input=
input.target||input;if(input.nodeName.toLowerCase()!="input")input=$("input",input.parentNode)[0];if($.timepicker._isDisabledTimepicker(input)||$.timepicker._lastInput==input)return;$.timepicker._hideTimepicker();var inst=$.timepicker._getInst(input);if($.timepicker._curInst&&$.timepicker._curInst!=inst)$.timepicker._curInst.tpDiv.stop(true,true);var beforeShow=$.timepicker._get(inst,"beforeShow");extendRemove(inst.settings,beforeShow?beforeShow.apply(input,[input,inst]):{});inst.lastVal=null;$.timepicker._lastInput=
input;$.timepicker._setTimeFromField(inst);if($.timepicker._inDialog)input.value="";if(!$.timepicker._pos){$.timepicker._pos=$.timepicker._findPos(input);$.timepicker._pos[1]+=input.offsetHeight}var isFixed=false;$(input).parents().each(function(){isFixed|=$(this).css("position")=="fixed";return!isFixed});if(isFixed&&$.browser.opera){$.timepicker._pos[0]-=document.documentElement.scrollLeft;$.timepicker._pos[1]-=document.documentElement.scrollTop}var offset={left:$.timepicker._pos[0],top:$.timepicker._pos[1]};
$.timepicker._pos=null;inst.tpDiv.css({position:"absolute",display:"block",top:"-1000px"});$.timepicker._updateTimepicker(inst);inst._hoursClicked=false;inst._minutesClicked=false;offset=$.timepicker._checkOffset(inst,offset,isFixed);inst.tpDiv.css({position:$.timepicker._inDialog&&$.blockUI?"static":isFixed?"fixed":"absolute",display:"none",left:offset.left+"px",top:offset.top+"px"});if(!inst.inline){var showAnim=$.timepicker._get(inst,"showAnim");var duration=$.timepicker._get(inst,"duration");
var zIndex=$.timepicker._get(inst,"zIndex");var postProcess=function(){$.timepicker._timepickerShowing=true;var borders=$.timepicker._getBorders(inst.tpDiv);inst.tpDiv.find("iframe.ui-timepicker-cover").css({left:-borders[0],top:-borders[1],width:inst.tpDiv.outerWidth(),height:inst.tpDiv.outerHeight()})};if(!zIndex)zIndex=$(input).zIndex()+1;inst.tpDiv.zIndex(zIndex);if($.effects&&$.effects[showAnim])inst.tpDiv.show(showAnim,$.timepicker._get(inst,"showOptions"),duration,postProcess);else inst.tpDiv[showAnim||
"show"](showAnim?duration:null,postProcess);if(!showAnim||!duration)postProcess();if(inst.input.is(":visible")&&!inst.input.is(":disabled"))inst.input.focus();$.timepicker._curInst=inst}},_updateTimepicker:function(inst){var self=this;var borders=$.timepicker._getBorders(inst.tpDiv);inst.tpDiv.empty().append(this._generateHTML(inst)).find("iframe.ui-timepicker-cover").css({left:-borders[0],top:-borders[1],width:inst.tpDiv.outerWidth(),height:inst.tpDiv.outerHeight()}).end().find(".ui-timepicker-minute-cell").bind("click",
{fromDoubleClick:false},$.proxy($.timepicker.selectMinutes,this)).bind("dblclick",{fromDoubleClick:true},$.proxy($.timepicker.selectMinutes,this)).end().find(".ui-timepicker-hour-cell").bind("click",{fromDoubleClick:false},$.proxy($.timepicker.selectHours,this)).bind("dblclick",{fromDoubleClick:true},$.proxy($.timepicker.selectHours,this)).end().find(".ui-timepicker td a").bind("mouseout",function(){$(this).removeClass("ui-state-hover");if(this.className.indexOf("ui-timepicker-prev")!=-1)$(this).removeClass("ui-timepicker-prev-hover");
if(this.className.indexOf("ui-timepicker-next")!=-1)$(this).removeClass("ui-timepicker-next-hover")}).bind("mouseover",function(){if(!self._isDisabledTimepicker(inst.inline?inst.tpDiv.parent()[0]:inst.input[0])){$(this).parents(".ui-timepicker-calendar").find("a").removeClass("ui-state-hover");$(this).addClass("ui-state-hover");if(this.className.indexOf("ui-timepicker-prev")!=-1)$(this).addClass("ui-timepicker-prev-hover");if(this.className.indexOf("ui-timepicker-next")!=-1)$(this).addClass("ui-timepicker-next-hover")}}).end().find("."+
this._dayOverClass+" a").trigger("mouseover").end()},_generateHTML:function(inst){var h,m,row,html="",showPeriod=this._get(inst,"showPeriod")==true,showPeriodLabels=this._get(inst,"showPeriodLabels")==true,showLeadingZero=this._get(inst,"showLeadingZero")==true,amPmText=this._get(inst,"amPmText"),rows=this._get(inst,"rows"),amRows=rows/2,pmFirstRow=amRows+1,hours=Array(),hours_options=this._get(inst,"hours"),hoursPerRow=null,hourCounter=0,hourLabel=this._get(inst,"hourText");for(h=hours_options.starts;h<=
hours_options.ends;h++)hours.push(h);hoursPerRow=Math.round(hours.length/rows+0.49);html=''+''+'"+'';for(row=1;row<=rows;row++){html+="";if(row==1&&showPeriodLabels)html+=''+amPmText[0]+" | ";if(row==pmFirstRow&&
showPeriodLabels)html+=''+amPmText[1]+" | ";while(hourCounter"}html+=" "+" | "+'';html+=this._generateHTMLMinutes(inst);html+=" |
";html+=$.browser.msie&&parseInt($.browser.version,10)<7&&!inst.inline?'':
"";return html},_updateMinuteDisplay:function(inst){var newHtml=this._generateHTMLMinutes(inst);inst.tpDiv.find("td.ui-timepicker-minutes").html(newHtml).find(".ui-timepicker-minute-cell").bind("click",{fromDoubleClick:false},$.proxy($.timepicker.selectMinutes,this)).bind("dblclick",{fromDoubleClick:true},$.proxy($.timepicker.selectMinutes,this))},_generateHTMLMinutes:function(inst){var m,row,html="",rows=this._get(inst,"rows"),minutes=Array(),minutes_options=this._get(inst,"minutes"),minutesPerRow=
null,minuteCounter=0,showMinutesLeadingZero=this._get(inst,"showMinutesLeadingZero")==true,onMinuteShow=this._get(inst,"onMinuteShow"),minuteLabel=this._get(inst,"minuteText");if(!minutes_options.starts)minutes_options.starts=0;if(!minutes_options.ends)minutes_options.ends=59;for(m=minutes_options.starts;m<=minutes_options.ends;m+=minutes_options.interval)minutes.push(m);minutesPerRow=Math.round(minutes.length/rows+0.49);if(onMinuteShow&&onMinuteShow.apply(inst.input?inst.input[0]:null,[inst.hours,
inst.minutes])==false)for(minuteCounter=0;minuteCounter