(function($){$.extend($.ui,{datepicker:{version:"1.7.1"}});var PROP_NAME='datepicker';function Datepicker(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._datepickerShowing=false;this._inDialog=false;this._mainDivId='ui-datepicker-div';this._inlineClass='ui-datepicker-inline';this._appendClass='ui-datepicker-append';this._triggerClass='ui-datepicker-trigger';this._dialogClass='ui-datepicker-dialog';this._disableClass='ui-datepicker-disabled';this._unselectableClass='ui-datepicker-unselectable';this._currentClass='ui-datepicker-current-day';this._dayOverClass='ui-datepicker-days-cell-over';this.regional=[];this.regional['']={closeText:'Done',prevText:'Prev',nextText:'Next',currentText:'Today',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'],dayNames:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],dayNamesShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],dayNamesMin:['Su','Mo','Tu','We','Th','Fr','Sa'],dateFormat:'mm/dd/yy',firstDay:0,isRTL:false};this._defaults={showOn:'focus',showAnim:'show',showOptions:{},defaultDate:null,appendText:'',buttonText:'...',buttonImage:'',buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,showMonthAfterYear:false,yearRange:'-10:+10',showOtherMonths:false,calculateWeek:this.iso8601Week,shortYearCutoff:'+10',minDate:null,maxDate:null,duration:'normal',beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:'',altFormat:'',constrainInput:true,showButtonPanel:false};$.extend(this._defaults,this.regional['']);this.dpDiv=$('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>');}
$.extend(Datepicker.prototype,{markerClassName:'hasDatepicker',log:function(){if(this.debug)
console.log.apply('',arguments);},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this;},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var 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 inline=(nodeName=='div'||nodeName=='span');if(!target.id)
target.id='dp'+(++this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{});if(nodeName=='input'){this._connectDatepicker(target,inst);}else if(inline){this._inlineDatepicker(target,inst);}},_newInst:function(target,inline){var id=target[0].id.replace(/([:\[\]\.])/g,'\\\\$1');return{id:id,input:target,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:inline,dpDiv:(!inline?this.dpDiv:$('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};},_connectDatepicker:function(target,inst){var input=$(target);inst.trigger=$([]);if(input.hasClass(this.markerClassName))
return;var appendText=this._get(inst,'appendText');var isRTL=this._get(inst,'isRTL');if(appendText)
input[isRTL?'before':'after']('<span class="'+this._appendClass+'">'+appendText+'</span>');var showOn=this._get(inst,'showOn');if(showOn=='focus'||showOn=='both')
input.focus(this._showDatepicker);if(showOn=='button'||showOn=='both'){var buttonText=this._get(inst,'buttonText');var buttonImage=this._get(inst,'buttonImage');inst.trigger=$(this._get(inst,'buttonImageOnly')?$('<img/>').addClass(this._triggerClass).attr({src:buttonImage,alt:buttonText,title:buttonText}):$('<button type="button"></button>').addClass(this._triggerClass).html(buttonImage==''?buttonText:$('<img/>').attr({src:buttonImage,alt:buttonText,title:buttonText})));input[isRTL?'before':'after'](inst.trigger);inst.trigger.click(function(){if($.datepicker._datepickerShowing&&$.datepicker._lastInput==target)
$.datepicker._hideDatepicker();else
$.datepicker._showDatepicker(target);return false;});}
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 this._get(inst,key);});$.data(target,PROP_NAME,inst);},_inlineDatepicker:function(target,inst){var divSpan=$(target);if(divSpan.hasClass(this.markerClassName))
return;divSpan.addClass(this.markerClassName).append(inst.dpDiv).bind("setData.datepicker",function(event,key,value){inst.settings[key]=value;}).bind("getData.datepicker",function(event,key){return this._get(inst,key);});$.data(target,PROP_NAME,inst);this._setDate(inst,this._getDefaultDate(inst));this._updateDatepicker(inst);this._updateAlternate(inst);},_dialogDatepicker:function(input,dateText,onSelect,settings,pos){var inst=this._dialogInst;if(!inst){var id='dp'+(++this.uuid);this._dialogInput=$('<input type="text" id="'+id+'" size="1" style="position: absolute; top: -100px;"/>');this._dialogInput.keydown(this._doKeyDown);$('body').append(this._dialogInput);inst=this._dialogInst=this._newInst(this._dialogInput,false);inst.settings={};$.data(this._dialogInput[0],PROP_NAME,inst);}
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.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);if($.blockUI)
$.blockUI(this.dpDiv);$.data(this._dialogInput[0],PROP_NAME,inst);return this;},_destroyDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return;}
var nodeName=target.nodeName.toLowerCase();$.removeData(target,PROP_NAME);if(nodeName=='input'){inst.trigger.remove();$target.siblings('.'+this._appendClass).remove().end().removeClass(this.markerClassName).unbind('focus',this._showDatepicker).unbind('keydown',this._doKeyDown).unbind('keypress',this._doKeyPress);}else if(nodeName=='div'||nodeName=='span')
$target.removeClass(this.markerClassName).empty();},_enableDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return;}
var nodeName=target.nodeName.toLowerCase();if(nodeName=='input'){target.disabled=false;inst.trigger.filter("button").each(function(){this.disabled=false;}).end().filter("img").css({opacity:'1.0',cursor:''});}
else if(nodeName=='div'||nodeName=='span'){var inline=$target.children('.'+this._inlineClass);inline.children().removeClass('ui-state-disabled');}
this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value);});},_disableDatepicker:function(target){var $target=$(target);var inst=$.data(target,PROP_NAME);if(!$target.hasClass(this.markerClassName)){return;}
var nodeName=target.nodeName.toLowerCase();if(nodeName=='input'){target.disabled=true;inst.trigger.filter("button").each(function(){this.disabled=true;}).end().filter("img").css({opacity:'0.5',cursor:'default'});}
else if(nodeName=='div'||nodeName=='span'){var inline=$target.children('.'+this._inlineClass);inline.children().addClass('ui-state-disabled');}
this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value);});this._disabledInputs[this._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;},_getInst:function(target){try{return $.data(target,PROP_NAME);}
catch(err){throw'Missing instance data for this datepicker';}},_optionDatepicker:function(target,name,value){var settings=name||{};if(typeof name=='string'){settings={};settings[name]=value;}
var inst=this._getInst(target);if(inst){if(this._curInst==inst){this._hideDatepicker(null);}
extendRemove(inst.settings,settings);var date=new Date();extendRemove(inst,{rangeStart:null,endDay:null,endMonth:null,endYear:null,selectedDay:date.getDate(),selectedMonth:date.getMonth(),selectedYear:date.getFullYear(),currentDay:date.getDate(),currentMonth:date.getMonth(),currentYear:date.getFullYear(),drawMonth:date.getMonth(),drawYear:date.getFullYear()});this._updateDatepicker(inst);}},_changeDatepicker:function(target,name,value){this._optionDatepicker(target,name,value);},_refreshDatepicker:function(target){var inst=this._getInst(target);if(inst){this._updateDatepicker(inst);}},_setDateDatepicker:function(target,date,endDate){var inst=this._getInst(target);if(inst){this._setDate(inst,date,endDate);this._updateDatepicker(inst);this._updateAlternate(inst);}},_getDateDatepicker:function(target){var inst=this._getInst(target);if(inst&&!inst.inline)
this._setDateFromField(inst);return(inst?this._getDate(inst):null);},_doKeyDown:function(event){var inst=$.datepicker._getInst(event.target);var handled=true;var isRTL=inst.dpDiv.is('.ui-datepicker-rtl');inst._keyEvent=true;if($.datepicker._datepickerShowing)
switch(event.keyCode){case 9:$.datepicker._hideDatepicker(null,'');break;case 13:var sel=$('td.'+$.datepicker._dayOverClass+', td.'+$.datepicker._currentClass,inst.dpDiv);if(sel[0])
$.datepicker._selectDay(event.target,inst.selectedMonth,inst.selectedYear,sel[0]);else
$.datepicker._hideDatepicker(null,$.datepicker._get(inst,'duration'));return false;break;case 27:$.datepicker._hideDatepicker(null,$.datepicker._get(inst,'duration'));break;case 33:$.datepicker._adjustDate(event.target,(event.ctrlKey?-$.datepicker._get(inst,'stepBigMonths'):-$.datepicker._get(inst,'stepMonths')),'M');break;case 34:$.datepicker._adjustDate(event.target,(event.ctrlKey?+$.datepicker._get(inst,'stepBigMonths'):+$.datepicker._get(inst,'stepMonths')),'M');break;case 35:if(event.ctrlKey||event.metaKey)$.datepicker._clearDate(event.target);handled=event.ctrlKey||event.metaKey;break;case 36:if(event.ctrlKey||event.metaKey)$.datepicker._gotoToday(event.target);handled=event.ctrlKey||event.metaKey;break;case 37:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,(isRTL?+1:-1),'D');handled=event.ctrlKey||event.metaKey;if(event.originalEvent.altKey)$.datepicker._adjustDate(event.target,(event.ctrlKey?-$.datepicker._get(inst,'stepBigMonths'):-$.datepicker._get(inst,'stepMonths')),'M');break;case 38:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,-7,'D');handled=event.ctrlKey||event.metaKey;break;case 39:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,(isRTL?-1:+1),'D');handled=event.ctrlKey||event.metaKey;if(event.originalEvent.altKey)$.datepicker._adjustDate(event.target,(event.ctrlKey?+$.datepicker._get(inst,'stepBigMonths'):+$.datepicker._get(inst,'stepMonths')),'M');break;case 40:if(event.ctrlKey||event.metaKey)$.datepicker._adjustDate(event.target,+7,'D');handled=event.ctrlKey||event.metaKey;break;default:handled=false;}
else if(event.keyCode==36&&event.ctrlKey)
$.datepicker._showDatepicker(this);else{handled=false;}
if(handled){event.preventDefault();event.stopPropagation();}},_doKeyPress:function(event){var inst=$.datepicker._getInst(event.target);if($.datepicker._get(inst,'constrainInput')){var chars=$.datepicker._possibleChars($.datepicker._get(inst,'dateFormat'));var chr=String.fromCharCode(event.charCode==undefined?event.keyCode:event.charCode);return event.ctrlKey||(chr<' '||!chars||chars.indexOf(chr)>-1);}},_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);var beforeShow=$.datepicker._get(inst,'beforeShow');extendRemove(inst.settings,(beforeShow?beforeShow.apply(input,[input,inst]):{}));$.datepicker._hideDatepicker(null,'');$.datepicker._lastInput=input;$.datepicker._setDateFromField(inst);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';return!isFixed;});if(isFixed&&$.browser.opera){$.datepicker._pos[0]-=document.documentElement.scrollLeft;$.datepicker._pos[1]-=document.documentElement.scrollTop;}
var offset={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null;inst.rangeStart=null;inst.dpDiv.css({position:'absolute',display:'block',top:'-1000px'});$.datepicker._updateDatepicker(inst);offset=$.datepicker._checkOffset(inst,offset,isFixed);inst.dpDiv.css({position:($.datepicker._inDialog&&$.blockUI?'static':(isFixed?'fixed':'absolute')),display:'none',left:offset.left+'px',top:offset.top+'px'});if(!inst.inline){var showAnim=$.datepicker._get(inst,'showAnim')||'show';var duration=$.datepicker._get(inst,'duration');var postProcess=function(){$.datepicker._datepickerShowing=true;if($.browser.msie&&parseInt($.browser.version,10)<7)
$('iframe.ui-datepicker-cover').css({width:inst.dpDiv.width()+4,height:inst.dpDiv.height()+4});};if($.effects&&$.effects[showAnim])
inst.dpDiv.show(showAnim,$.datepicker._get(inst,'showOptions'),duration,postProcess);else
inst.dpDiv[showAnim](duration,postProcess);if(duration=='')
postProcess();if(inst.input[0].type!='hidden')
inst.input[0].focus();$.datepicker._curInst=inst;}},_updateDatepicker:function(inst){var dims={width:inst.dpDiv.width()+4,height:inst.dpDiv.height()+4};var self=this;inst.dpDiv.empty().append(this._generateHTML(inst)).find('iframe.ui-datepicker-cover').css({width:dims.width,height:dims.height}).end().find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a').bind('mouseout',function(){$(this).removeClass('ui-state-hover');if(this.className.indexOf('ui-datepicker-prev')!=-1)$(this).removeClass('ui-datepicker-prev-hover');if(this.className.indexOf('ui-datepicker-next')!=-1)$(this).removeClass('ui-datepicker-next-hover');}).bind('mouseover',function(){if(!self._isDisabledDatepicker(inst.inline?inst.dpDiv.parent()[0]:inst.input[0])){$(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');$(this).addClass('ui-state-hover');if(this.className.indexOf('ui-datepicker-prev')!=-1)$(this).addClass('ui-datepicker-prev-hover');if(this.className.indexOf('ui-datepicker-next')!=-1)$(this).addClass('ui-datepicker-next-hover');}}).end().find('.'+this._dayOverClass+' a').trigger('mouseover').end();var numMonths=this._getNumberOfMonths(inst);var cols=numMonths[1];var width=17;if(cols>1){inst.dpDiv.addClass('ui-datepicker-multi-'+cols).css('width',(width*cols)+'em');}else{inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');}
inst.dpDiv[(numMonths[0]!=1||numMonths[1]!=1?'add':'remove')+'Class']('ui-datepicker-multi');inst.dpDiv[(this._get(inst,'isRTL')?'add':'remove')+'Class']('ui-datepicker-rtl');if(inst.input&&inst.input[0].type!='hidden'&&inst==$.datepicker._curInst)
$(inst.input[0]).focus();},_checkOffset:function(inst,offset,isFixed){var dpWidth=inst.dpDiv.outerWidth();var dpHeight=inst.dpDiv.outerHeight();var inputWidth=inst.input?inst.input.outerWidth():0;var inputHeight=inst.input?inst.input.outerHeight():0;var viewWidth=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)+$(document).scrollLeft();var viewHeight=(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)+$(document).scrollTop();offset.left-=(this._get(inst,'isRTL')?(dpWidth-inputWidth):0);offset.left-=(isFixed&&offset.left==inst.input.offset().left)?$(document).scrollLeft():0;offset.top-=(isFixed&&offset.top==(inst.input.offset().top+inputHeight))?$(document).scrollTop():0;offset.left-=(offset.left+dpWidth>viewWidth&&viewWidth>dpWidth)?Math.abs(offset.left+dpWidth-viewWidth):0;offset.top-=(offset.top+dpHeight>viewHeight&&viewHeight>dpHeight)?Math.abs(offset.top+dpHeight+inputHeight*2-viewHeight):0;return offset;},_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,duration){var inst=this._curInst;if(!inst||(input&&inst!=$.data(input,PROP_NAME)))
return;if(inst.stayOpen)
this._selectDate('#'+inst.id,this._formatDate(inst,inst.currentDay,inst.currentMonth,inst.currentYear));inst.stayOpen=false;if(this._datepickerShowing){duration=(duration!=null?duration:this._get(inst,'duration'));var showAnim=this._get(inst,'showAnim');var postProcess=function(){$.datepicker._tidyDialog(inst);};if(duration!=''&&$.effects&&$.effects[showAnim])
inst.dpDiv.hide(showAnim,$.datepicker._get(inst,'showOptions'),duration,postProcess);else
inst.dpDiv[(duration==''?'hide':(showAnim=='slideDown'?'slideUp':(showAnim=='fadeIn'?'fadeOut':'hide')))](duration,postProcess);if(duration=='')
this._tidyDialog(inst);var onClose=this._get(inst,'onClose');if(onClose)
onClose.apply((inst.input?inst.input[0]:null),[(inst.input?inst.input.val():''),inst]);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:'absolute',left:'0',top:'-100px'});if($.blockUI){$.unblockUI();$('body').append(this.dpDiv);}}
this._inDialog=false;}
this._curInst=null;},_tidyDialog:function(inst){inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');},_checkExternalClick:function(event){if(!$.datepicker._curInst)
return;var $target=$(event.target);if(($target.parents('#'+$.datepicker._mainDivId).length==0)&&!$target.hasClass($.datepicker.markerClassName)&&!$target.hasClass($.datepicker._triggerClass)&&$.datepicker._datepickerShowing&&!($.datepicker._inDialog&&$.blockUI))
$.datepicker._hideDatepicker(null,'');},_adjustDate:function(id,offset,period){var target=$(id);var inst=this._getInst(target[0]);if(this._isDisabledDatepicker(target[0])){return;}
this._adjustInstDate(inst,offset+
(period=='M'?this._get(inst,'showCurrentAtPos'):0),period);this._updateDatepicker(inst);},_gotoToday:function(id){var target=$(id);var inst=this._getInst(target[0]);if(this._get(inst,'gotoCurrent')&&inst.currentDay){inst.selectedDay=inst.currentDay;inst.drawMonth=inst.selectedMonth=inst.currentMonth;inst.drawYear=inst.selectedYear=inst.currentYear;}
else{var date=new Date();inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();}
this._notifyChange(inst);this._adjustDate(target);},_selectMonthYear:function(id,select,period){var target=$(id);var inst=this._getInst(target[0]);inst._selectingMonthYear=false;inst['selected'+(period=='M'?'Month':'Year')]=inst['draw'+(period=='M'?'Month':'Year')]=parseInt(select.options[select.selectedIndex].value,10);this._notifyChange(inst);this._adjustDate(target);},_clickMonthYear:function(id){var target=$(id);var inst=this._getInst(target[0]);if(inst.input&&inst._selectingMonthYear&&!$.browser.msie)
inst.input[0].focus();inst._selectingMonthYear=!inst._selectingMonthYear;},_selectDay:function(id,month,year,td){var target=$(id);if($(td).hasClass(this._unselectableClass)||this._isDisabledDatepicker(target[0])){return;}
var inst=this._getInst(target[0]);inst.selectedDay=inst.currentDay=$('a',td).html();inst.selectedMonth=inst.currentMonth=month;inst.selectedYear=inst.currentYear=year;if(inst.stayOpen){inst.endDay=inst.endMonth=inst.endYear=null;}
this._selectDate(id,this._formatDate(inst,inst.currentDay,inst.currentMonth,inst.currentYear));if(inst.stayOpen){inst.rangeStart=this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay));this._updateDatepicker(inst);}},_clearDate:function(id){var target=$(id);var inst=this._getInst(target[0]);inst.stayOpen=false;inst.endDay=inst.endMonth=inst.endYear=inst.rangeStart=null;this._selectDate(target,'');},_selectDate:function(id,dateStr){var target=$(id);var inst=this._getInst(target[0]);dateStr=(dateStr!=null?dateStr:this._formatDate(inst));if(inst.input)
inst.input.val(dateStr);this._updateAlternate(inst);var onSelect=this._get(inst,'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(!inst.stayOpen){this._hideDatepicker(null,this._get(inst,'duration'));this._lastInput=inst.input[0];if(typeof(inst.input[0])!='object')
inst.input[0].focus();this._lastInput=null;}},_updateAlternate:function(inst){var altField=this._get(inst,'altField');if(altField){var altFormat=this._get(inst,'altFormat')||this._get(inst,'dateFormat');var date=this._getDate(inst);dateStr=this.formatDate(altFormat,date,this._getFormatConfig(inst));$(altField).each(function(){$(this).val(dateStr);});}},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());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){return 1;}}
return Math.floor(((checkDate-firstMon)/86400000)/7)+1;},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 doy=-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 origSize=(match=='@'?14:(match=='y'?4:(match=='o'?3:2)));var size=origSize;var num=0;while(size>0&&iValue<value.length&&value.charAt(iValue)>='0'&&value.charAt(iValue)<='9'){num=num*10+parseInt(value.charAt(iValue++),10);size--;}
if(size==origSize)
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'o':doy=getNumber('o');break;case'm':month=getNumber('m');break;case'M':month=getName('M',monthNamesShort,monthNames);break;case'y':year=getNumber('y');break;case'@':var date=new Date(getNumber('@'));year=date.getFullYear();month=date.getMonth()+1;day=date.getDate();break;case"'":if(lookAhead("'"))
checkLiteral();else
literal=true;break;default:checkLiteral();}}
if(year==-1)
year=new Date().getFullYear();else if(year<100)
year+=new Date().getFullYear()-new Date().getFullYear()%100+
(year<=shortYearCutoff?0:-100);if(doy>-1){month=1;day=doy;do{var dim=this._getDaysInMonth(year,month-1);if(day<=dim)
break;month++;day-=dim;}while(true);}
var date=this._daylightSavingAdjust(new Date(year,month-1,day));if(date.getFullYear()!=year||date.getMonth()+1!=month||date.getDate()!=day)
throw'Invalid date';return date;},ATOM:'yy-mm-dd',COOKIE:'D, dd M yy',ISO_8601:'yy-mm-dd',RFC_822:'D, d M y',RFC_850:'DD, dd-M-y',RFC_1036:'D, d M y',RFC_1123:'D, d M yy',RFC_2822:'D, d M yy',RSS:'D, d M y',TIMESTAMP:'@',W3C:'yy-mm-dd',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,len){var num=''+value;if(lookAhead(match))
while(num.length<len)
num='0'+num;return num;};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(),2);break;case'D':output+=formatName('D',date.getDay(),dayNamesShort,dayNames);break;case'o':var doy=date.getDate();for(var m=date.getMonth()-1;m>=0;m--)
doy+=this._getDaysInMonth(date.getFullYear(),m);output+=formatNumber('o',doy,3);break;case'm':output+=formatNumber('m',date.getMonth()+1,2);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'@':output+=date.getTime();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':case'm':case'y':case'@':chars+='0123456789';break;case'D':case'M':return null;case"'":if(lookAhead("'"))
chars+="'";else
literal=true;break;default:chars+=format.charAt(iFormat);}
return chars;},_get:function(inst,name){return inst.settings[name]!==undefined?inst.settings[name]:this._defaults[name];},_setDateFromField:function(inst){var dateFormat=this._get(inst,'dateFormat');var dates=inst.input?inst.input.val():null;inst.endDay=inst.endMonth=inst.endYear=null;var date=defaultDate=this._getDefaultDate(inst);var settings=this._getFormatConfig(inst);try{date=this.parseDate(dateFormat,dates,settings)||defaultDate;}catch(event){this.log(event);date=defaultDate;}
inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();inst.currentDay=(dates?date.getDate():0);inst.currentMonth=(dates?date.getMonth():0);inst.currentYear=(dates?date.getFullYear():0);this._adjustInstDate(inst);},_getDefaultDate:function(inst){var date=this._determineDate(this._get(inst,'defaultDate'),new Date());var minDate=this._getMinMaxDate(inst,'min',true);var maxDate=this._getMinMaxDate(inst,'max');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);return date;},_determineDate:function(date,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 year=date.getFullYear();var month=date.getMonth();var day=date.getDate();var pattern=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;var matches=pattern.exec(offset);while(matches){switch(matches[2]||'d'){case'd':case'D':day+=parseInt(matches[1],10);break;case'w':case'W':day+=parseInt(matches[1],10)*7;break;case'm':case'M':month+=parseInt(matches[1],10);day=Math.min(day,getDaysInMonth(year,month));break;case'y':case'Y':year+=parseInt(matches[1],10);day=Math.min(day,getDaysInMonth(year,month));break;}
matches=pattern.exec(offset);}
return new Date(year,month,day);};date=(date==null?defaultDate:(typeof date=='string'?offsetString(date,this._getDaysInMonth):(typeof date=='number'?(isNaN(date)?defaultDate:offsetNumeric(date)):date)));date=(date&&date.toString()=='Invalid Date'?defaultDate:date);if(date){date.setHours(0);date.setMinutes(0);date.setSeconds(0);date.setMilliseconds(0);}
return this._daylightSavingAdjust(date);},_daylightSavingAdjust:function(date){if(!date)return null;date.setHours(date.getHours()>12?date.getHours()+2:0);return date;},_setDate:function(inst,date,endDate){var clear=!(date);var origMonth=inst.selectedMonth;var origYear=inst.selectedYear;date=this._determineDate(date,new Date());inst.selectedDay=inst.currentDay=date.getDate();inst.drawMonth=inst.selectedMonth=inst.currentMonth=date.getMonth();inst.drawYear=inst.selectedYear=inst.currentYear=date.getFullYear();if(origMonth!=inst.selectedMonth||origYear!=inst.selectedYear)
this._notifyChange(inst);this._adjustInstDate(inst);if(inst.input){inst.input.val(clear?'':this._formatDate(inst));}},_getDate:function(inst){var startDate=(!inst.currentYear||(inst.input&&inst.input.val()=='')?null:this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));return startDate;},_generateHTML:function(inst){var today=new Date();today=this._daylightSavingAdjust(new Date(today.getFullYear(),today.getMonth(),today.getDate()));var isRTL=this._get(inst,'isRTL');var showButtonPanel=this._get(inst,'showButtonPanel');var hideIfNoPrevNext=this._get(inst,'hideIfNoPrevNext');var navigationAsDateFormat=this._get(inst,'navigationAsDateFormat');var numMonths=this._getNumberOfMonths(inst);var showCurrentAtPos=this._get(inst,'showCurrentAtPos');var stepMonths=this._get(inst,'stepMonths');var stepBigMonths=this._get(inst,'stepBigMonths');var isMultiMonth=(numMonths[0]!=1||numMonths[1]!=1);var currentDate=this._daylightSavingAdjust((!inst.currentDay?new Date(9999,9,9):new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));var minDate=this._getMinMaxDate(inst,'min',true);var maxDate=this._getMinMaxDate(inst,'max');var drawMonth=inst.drawMonth-showCurrentAtPos;var drawYear=inst.drawYear;if(drawMonth<0){drawMonth+=12;drawYear--;}
if(maxDate){var maxDraw=this._daylightSavingAdjust(new Date(maxDate.getFullYear(),maxDate.getMonth()-numMonths[1]+1,maxDate.getDate()));maxDraw=(minDate&&maxDraw<minDate?minDate:maxDraw);while(this._daylightSavingAdjust(new Date(drawYear,drawMonth,1))>maxDraw){drawMonth--;if(drawMonth<0){drawMonth=11;drawYear--;}}}
inst.drawMonth=drawMonth;inst.drawYear=drawYear;var prevText=this._get(inst,'prevText');prevText=(!navigationAsDateFormat?prevText:this.formatDate(prevText,this._daylightSavingAdjust(new Date(drawYear,drawMonth-stepMonths,1)),this._getFormatConfig(inst)));var prev=(this._canAdjustMonth(inst,-1,drawYear,drawMonth)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#'+inst.id+'\', -'+stepMonths+', \'M\');"'+' title="'+prevText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?'e':'w')+'">'+prevText+'</span></a>':(hideIfNoPrevNext?'':'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+prevText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?'e':'w')+'">'+prevText+'</span></a>'));var nextText=this._get(inst,'nextText');nextText=(!navigationAsDateFormat?nextText:this.formatDate(nextText,this._daylightSavingAdjust(new Date(drawYear,drawMonth+stepMonths,1)),this._getFormatConfig(inst)));var next=(this._canAdjustMonth(inst,+1,drawYear,drawMonth)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery.datepicker._adjustDate(\'#'+inst.id+'\', +'+stepMonths+', \'M\');"'+' title="'+nextText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?'w':'e')+'">'+nextText+'</span></a>':(hideIfNoPrevNext?'':'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+nextText+'"><span class="ui-icon ui-icon-circle-triangle-'+(isRTL?'w':'e')+'">'+nextText+'</span></a>'));var currentText=this._get(inst,'currentText');var gotoDate=(this._get(inst,'gotoCurrent')&&inst.currentDay?currentDate:today);currentText=(!navigationAsDateFormat?currentText:this.formatDate(currentText,gotoDate,this._getFormatConfig(inst)));var controls=(!inst.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery.datepicker._hideDatepicker();">'+this._get(inst,'closeText')+'</button>':'');var buttonPanel=(showButtonPanel)?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(isRTL?controls:'')+
(this._isInRange(inst,gotoDate)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery.datepicker._gotoToday(\'#'+inst.id+'\');"'+'>'+currentText+'</button>':'')+(isRTL?'':controls)+'</div>':'';var firstDay=parseInt(this._get(inst,'firstDay'),10);firstDay=(isNaN(firstDay)?0:firstDay);var dayNames=this._get(inst,'dayNames');var dayNamesShort=this._get(inst,'dayNamesShort');var dayNamesMin=this._get(inst,'dayNamesMin');var monthNames=this._get(inst,'monthNames');var monthNamesShort=this._get(inst,'monthNamesShort');var beforeShowDay=this._get(inst,'beforeShowDay');var showOtherMonths=this._get(inst,'showOtherMonths');var calculateWeek=this._get(inst,'calculateWeek')||this.iso8601Week;var endDate=inst.endDay?this._daylightSavingAdjust(new Date(inst.endYear,inst.endMonth,inst.endDay)):currentDate;var defaultDate=this._getDefaultDate(inst);var html='';for(var row=0;row<numMonths[0];row++){var group='';for(var col=0;col<numMonths[1];col++){var selectedDate=this._daylightSavingAdjust(new Date(drawYear,drawMonth,inst.selectedDay));var cornerClass=' ui-corner-all';var calender='';if(isMultiMonth){calender+='<div class="ui-datepicker-group ui-datepicker-group-';switch(col){case 0:calender+='first';cornerClass=' ui-corner-'+(isRTL?'right':'left');break;case numMonths[1]-1:calender+='last';cornerClass=' ui-corner-'+(isRTL?'left':'right');break;default:calender+='middle';cornerClass='';break;}
calender+='">';}
calender+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+cornerClass+'">'+
(/all|left/.test(cornerClass)&&row==0?(isRTL?next:prev):'')+
(/all|right/.test(cornerClass)&&row==0?(isRTL?prev:next):'')+
this._generateMonthYearHeader(inst,drawMonth,drawYear,minDate,maxDate,selectedDate,row>0||col>0,monthNames,monthNamesShort)+'</div><table class="ui-datepicker-calendar"><thead>'+'<tr>';var thead='';for(var dow=0;dow<7;dow++){var day=(dow+firstDay)%7;thead+='<th'+((dow+firstDay+6)%7>=5?' class="ui-datepicker-week-end"':'')+'>'+'<span title="'+dayNames[day]+'">'+dayNamesMin[day]+'</span></th>';}
calender+=thead+'</tr></thead><tbody>';var daysInMonth=this._getDaysInMonth(drawYear,drawMonth);if(drawYear==inst.selectedYear&&drawMonth==inst.selectedMonth)
inst.selectedDay=Math.min(inst.selectedDay,daysInMonth);var leadDays=(this._getFirstDayOfMonth(drawYear,drawMonth)-firstDay+7)%7;var numRows=(isMultiMonth?6:Math.ceil((leadDays+daysInMonth)/7));var printDate=this._daylightSavingAdjust(new Date(drawYear,drawMonth,1-leadDays));for(var dRow=0;dRow<numRows;dRow++){calender+='<tr>';var tbody='';for(var dow=0;dow<7;dow++){var daySettings=(beforeShowDay?beforeShowDay.apply((inst.input?inst.input[0]:null),[printDate]):[true,'']);var otherMonth=(printDate.getMonth()!=drawMonth);var unselectable=otherMonth||!daySettings[0]||(minDate&&printDate<minDate)||(maxDate&&printDate>maxDate);tbody+='<td class="'+
((dow+firstDay+6)%7>=5?' ui-datepicker-week-end':'')+
(otherMonth?' ui-datepicker-other-month':'')+
((printDate.getTime()==selectedDate.getTime()&&drawMonth==inst.selectedMonth&&inst._keyEvent)||(defaultDate.getTime()==printDate.getTime()&&defaultDate.getTime()==selectedDate.getTime())?' '+this._dayOverClass:'')+
(unselectable?' '+this._unselectableClass+' ui-state-disabled':'')+
(otherMonth&&!showOtherMonths?'':' '+daySettings[1]+
(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?' '+this._currentClass:'')+
(printDate.getTime()==today.getTime()?' ui-datepicker-today':''))+'"'+
((!otherMonth||showOtherMonths)&&daySettings[2]?' title="'+daySettings[2]+'"':'')+
(unselectable?'':' onclick="DP_jQuery.datepicker._selectDay(\'#'+
inst.id+'\','+drawMonth+','+drawYear+', this);return false;"')+'>'+
(otherMonth?(showOtherMonths?printDate.getDate():'&#xa0;'):(unselectable?'<span class="ui-state-default">'+printDate.getDate()+'</span>':'<a class="ui-state-default'+
(printDate.getTime()==today.getTime()?' ui-state-highlight':'')+
(printDate.getTime()>=currentDate.getTime()&&printDate.getTime()<=endDate.getTime()?' ui-state-active':'')+'" href="#">'+printDate.getDate()+'</a>'))+'</td>';printDate.setDate(printDate.getDate()+1);printDate=this._daylightSavingAdjust(printDate);}
calender+=tbody+'</tr>';}
drawMonth++;if(drawMonth>11){drawMonth=0;drawYear++;}
calender+='</tbody></table>'+(isMultiMonth?'</div>'+
((numMonths[0]>0&&col==numMonths[1]-1)?'<div class="ui-datepicker-row-break"></div>':''):'');group+=calender;}
html+=group;}
html+=buttonPanel+($.browser.msie&&parseInt($.browser.version,10)<7&&!inst.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':'');inst._keyEvent=false;return html;},_generateMonthYearHeader:function(inst,drawMonth,drawYear,minDate,maxDate,selectedDate,secondary,monthNames,monthNamesShort){minDate=(inst.rangeStart&&minDate&&selectedDate<minDate?selectedDate:minDate);var changeMonth=this._get(inst,'changeMonth');var changeYear=this._get(inst,'changeYear');var showMonthAfterYear=this._get(inst,'showMonthAfterYear');var html='<div class="ui-datepicker-title">';var monthHtml='';if(secondary||!changeMonth)
monthHtml+='<span class="ui-datepicker-month">'+monthNames[drawMonth]+'</span> ';else{var inMinYear=(minDate&&minDate.getFullYear()==drawYear);var inMaxYear=(maxDate&&maxDate.getFullYear()==drawYear);monthHtml+='<select class="ui-datepicker-month" '+'onchange="DP_jQuery.datepicker._selectMonthYear(\'#'+inst.id+'\', this, \'M\');" '+'onclick="DP_jQuery.datepicker._clickMonthYear(\'#'+inst.id+'\');"'+'>';for(var month=0;month<12;month++){if((!inMinYear||month>=minDate.getMonth())&&(!inMaxYear||month<=maxDate.getMonth()))
monthHtml+='<option value="'+month+'"'+
(month==drawMonth?' selected="selected"':'')+'>'+monthNamesShort[month]+'</option>';}
monthHtml+='</select>';}
if(!showMonthAfterYear)
html+=monthHtml+((secondary||changeMonth||changeYear)&&(!(changeMonth&&changeYear))?'&#xa0;':'');if(secondary||!changeYear)
html+='<span class="ui-datepicker-year">'+drawYear+'</span>';else{var years=this._get(inst,'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="ui-datepicker-year" '+'onchange="DP_jQuery.datepicker._selectMonthYear(\'#'+inst.id+'\', this, \'Y\');" '+'onclick="DP_jQuery.datepicker._clickMonthYear(\'#'+inst.id+'\');"'+'>';for(;year<=endYear;year++){html+='<option value="'+year+'"'+
(year==drawYear?' selected="selected"':'')+'>'+year+'</option>';}
html+='</select>';}
if(showMonthAfterYear)
html+=(secondary||changeMonth||changeYear?'&#xa0;':'')+monthHtml;html+='</div>';return html;},_adjustInstDate:function(inst,offset,period){var year=inst.drawYear+(period=='Y'?offset:0);var month=inst.drawMonth+(period=='M'?offset:0);var day=Math.min(inst.selectedDay,this._getDaysInMonth(year,month))+
(period=='D'?offset:0);var date=this._daylightSavingAdjust(new Date(year,month,day));var minDate=this._getMinMaxDate(inst,'min',true);var maxDate=this._getMinMaxDate(inst,'max');date=(minDate&&date<minDate?minDate:date);date=(maxDate&&date>maxDate?maxDate:date);inst.selectedDay=date.getDate();inst.drawMonth=inst.selectedMonth=date.getMonth();inst.drawYear=inst.selectedYear=date.getFullYear();if(period=='M'||period=='Y')
this._notifyChange(inst);},_notifyChange:function(inst){var onChange=this._get(inst,'onChangeMonthYear');if(onChange)
onChange.apply((inst.input?inst.input[0]:null),[inst.selectedYear,inst.selectedMonth+1,inst]);},_getNumberOfMonths:function(inst){var numMonths=this._get(inst,'numberOfMonths');return(numMonths==null?[1,1]:(typeof numMonths=='number'?[1,numMonths]:numMonths));},_getMinMaxDate:function(inst,minMax,checkRange){var date=this._determineDate(this._get(inst,minMax+'Date'),null);return(!checkRange||!inst.rangeStart?date:(!date||inst.rangeStart>date?inst.rangeStart:date));},_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(inst,offset,curYear,curMonth){var numMonths=this._getNumberOfMonths(inst);var date=this._daylightSavingAdjust(new Date(curYear,curMonth+(offset<0?offset:numMonths[1]),1));if(offset<0)
date.setDate(this._getDaysInMonth(date.getFullYear(),date.getMonth()));return this._isInRange(inst,date);},_isInRange:function(inst,date){var newMinDate=(!inst.rangeStart?null:this._daylightSavingAdjust(new Date(inst.selectedYear,inst.selectedMonth,inst.selectedDay)));newMinDate=(newMinDate&&inst.rangeStart<newMinDate?inst.rangeStart:newMinDate);var minDate=newMinDate||this._getMinMaxDate(inst,'min');var maxDate=this._getMinMaxDate(inst,'max');return((!minDate||date>=minDate)&&(!maxDate||date<=maxDate));},_getFormatConfig:function(inst){var shortYearCutoff=this._get(inst,'shortYearCutoff');shortYearCutoff=(typeof shortYearCutoff!='string'?shortYearCutoff:new Date().getFullYear()%100+parseInt(shortYearCutoff,10));return{shortYearCutoff:shortYearCutoff,dayNamesShort:this._get(inst,'dayNamesShort'),dayNames:this._get(inst,'dayNames'),monthNamesShort:this._get(inst,'monthNamesShort'),monthNames:this._get(inst,'monthNames')};},_formatDate:function(inst,day,month,year){if(!day){inst.currentDay=inst.selectedDay;inst.currentMonth=inst.selectedMonth;inst.currentYear=inst.selectedYear;}
var date=(day?(typeof day=='object'?day:this._daylightSavingAdjust(new Date(year,month,day))):this._daylightSavingAdjust(new Date(inst.currentYear,inst.currentMonth,inst.currentDay)));return this.formatDate(this._get(inst,'dateFormat'),date,this._getFormatConfig(inst));}});function extendRemove(target,props){$.extend(target,props);for(var name in props)
if(props[name]==null||props[name]==undefined)
target[name]=props[name];return target;};function isArray(a){return(a&&(($.browser.safari&&typeof a=='object'&&a.length)||(a.constructor&&a.constructor.toString().match(/\Array\(\)/))));};$.fn.datepicker=function(options){if(!$.datepicker.initialized){$(document).mousedown($.datepicker._checkExternalClick).find('body').append($.datepicker.dpDiv);$.datepicker.initialized=true;}
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);});};$.datepicker=new Datepicker();$.datepicker.initialized=false;$.datepicker.uuid=new Date().getTime();$.datepicker.version="1.7.1";window.DP_jQuery=$;})(jQuery);;function closeTip()
{if($('[name=dont_show_tip_again]').attr('checked'))
{url='../home/dont_show_tip';$.ajax({type:'GET',url:url,dataType:"json",cache:false,success:function(responseText,statusText){$('#homepage-tip').slideToggle();}});}else{$('#homepage-tip').slideToggle();}}
function moreTip(section)
{$('#homepage-tip .text').html("Getting more tip...");url='../home/get_more_tip/'+section;$.ajax({type:'GET',url:url,dataType:"json",cache:false,success:function(responseText,statusText){$('#homepage-tip .text').html(responseText.html);}});}
(function($){$.fn.fixScroll=function(){$('div.shadow-block div.fix-scroll',this).each(function(){var fixScroll=this.parentNode.offsetHeight;var childScroll=this.getElementsByTagName("div")[0].offsetHeight;if(childScroll>fixScroll){$(this).closest(".shadow-block").addClass("hidden-span");}});}
$.fn.fixTabs=function(){var zindex=50;this.each(function(){var elem=this;var items=elem.getElementsByTagName("li");for(var k=0;k<items.length;k++){items[k].style.zIndex=zindex;zindex--;}});}
$.fn.fixStripes=function(){this.each(function(i){if(i%2==1)$(this).addClass('alt');else $(this).removeClass('alt');});}
$.fn.fixTable=function(){this.each(function(){var table_elem=this;var heightTable=$(table_elem).parent().height();var row=$("tr",table_elem);var blocks=$("div",table_elem);var heightRow=0;var k=0;var count=0;for(;k<row.length;k++){if(row[k].className!=""){h=$(row[k]).height();heightRow+=h;count++;}}
var innerHeightTable=heightTable-heightRow;var heightItem=Math.floor(innerHeightTable/(k-count))-1;var col=0;for(var m=0;m<blocks.length;m++){if(blocks[m].className.indexOf("fix")!=-1||blocks[m].className.indexOf("sub")!=-1){if(((innerHeightTable%(k-count))!=0)&&(col<=6)){$(blocks[m]).height(heightItem+(innerHeightTable%(k-count)));blocks[m].style.lineHeight=(heightItem+(innerHeightTable%(k-count)))/2+"px";}
else{$(blocks[m]).height(heightItem);blocks[m].style.lineHeight=(heightItem)/2+"px";}}
if(blocks[m].className.indexOf("fix")!=-1){col++;}}});return this;};$.fn.main_cal_fixTable=function(){this.each(function(){var table_elem=this;var heightTable=$(table_elem).parent().height();var row=$("tr",table_elem);var blocks=$("div",table_elem);var heightRow=0;var k=0;var count=0;for(;k<row.length;k++){if(row[k].className!=""){h=$('td',row[k]).height()+8;heightRow+=h;count++;}}
var innerHeightTable=heightTable-heightRow;var heightItem=Math.floor(innerHeightTable/(k-count))-1;var col=0;for(var m=0;m<blocks.length;m++){if(blocks[m].className.indexOf("fix")!=-1||blocks[m].className.indexOf("sub")!=-1){if(((innerHeightTable%(k-count))!=0)&&(col<=6)){$(blocks[m]).height(heightItem+(innerHeightTable%(k-count)));blocks[m].style.lineHeight=100+"px";}
else{$(blocks[m]).height(heightItem);blocks[m].style.lineHeight=100+"px";}}
if(blocks[m].className.indexOf("fix")!=-1){col++;}}});return this;};})(jQuery);;function fixScroll(){var blocks=document.getElementsByTagName("div");for(var i=0;i<blocks.length;i++){if(blocks[i].className=="shadow-block"){var innerBlock=blocks[i].getElementsByTagName("div");for(var k=0;k<innerBlock.length;k++){if(innerBlock[k].className.indexOf("fix-scroll")!=-1){var fixScroll=innerBlock[k].parentNode.offsetHeight;var childScroll=innerBlock[k].getElementsByTagName("div")[0].offsetHeight;if(childScroll>fixScroll){blocks[i].className+=" hidden-span"}}}}}}
function fixTable(){var tables=document.getElementsByTagName("table");for(var i=0;i<tables.length;i++){if(tables[i].className=="fix-table"){var heightTable=tables[i].parentNode.offsetHeight;var row=tables[i].getElementsByTagName("tr");var blocks=tables[i].getElementsByTagName("div");var heightRow=0;var k=0;var count=0;for(;k<row.length;k++){if(row[k].className!=""){if(row[k].getElementsByTagName("td")[0])
heightRow+=row[k].getElementsByTagName("td")[0].offsetHeight;else if(row[k].getElementsByTagName("th")[0])
heightRow+=row[k].getElementsByTagName("th")[0].offsetHeight;count++;}}
var innerHeightTable=heightTable-heightRow;var heightItem=Math.floor(innerHeightTable/(k-count))-1;var col=0;for(var m=0;m<blocks.length;m++){if(blocks[m].className.indexOf("fix")!=-1||blocks[m].className.indexOf("sub")!=-1){if(((innerHeightTable%(k-count))!=0)&&(col<=6)){blocks[m].style.height=heightItem+(innerHeightTable%(k-count))+"px";blocks[m].style.lineHeight=(heightItem+(innerHeightTable%(k-count)))/2+"px";}
else{blocks[m].style.height=heightItem+"px";blocks[m].style.lineHeight=(heightItem)/2+"px";}}
if(blocks[m].className.indexOf("fix")!=-1){col++;}}}}}
var zindex=50;function fixTabs()
{var tabs=document.getElementsByTagName("ul");for(var i=0;i<tabs.length;i++){if(tabs[i].className.indexOf("main-nav-tabs")!=-1){var items=tabs[i].getElementsByTagName("li");for(var k=0;k<items.length;k++){items[k].style.zIndex=zindex;zindex--;}}
if(tabs[i].className.indexOf("docs-list")!=-1){var itemsImg=tabs[i].getElementsByTagName("img");for(var k=0;k<itemsImg.length;k++){itemsImg[k].style.height=itemsImg[k].parentNode.offsetHeight+"px";}}}}
function dropDown()
{var m_tabs=document.getElementById("nav-tabs");if(m_tabs){var nodes=m_tabs.getElementsByTagName("a");for(var i=0;i<nodes.length;i++)
{if(nodes[i].className.indexOf("select")!=-1){nodes[i].onclick=function()
{if(this.parentNode.className.indexOf("active")==-1){this.parentNode.className+=" active";}
else{this.parentNode.className=this.parentNode.className.replace(" active","");}
return false;}}}}}
function _main(){fixTable();fixTabs();fixScroll();dropDown();}
if(window.addEventListener)
window.addEventListener("load",_main,false);else if(window.attachEvent)
window.attachEvent("onload",_main);;function initHover()
{var nodes=document.getElementById("main-nav");if(nodes)
{nodes=nodes.getElementsByTagName("div");for(var i=0;i<nodes.length;i++)
{nodes[i].onmouseover=function()
{this.className+=" hover";}
nodes[i].onmouseout=function()
{this.className=this.className.replace(" hover","");}}}
var _nodes=document.getElementById("nav");if(_nodes)
{_nodes=_nodes.getElementsByTagName("li");for(var i=0;i<_nodes.length;i++)
{_nodes[i].onmouseover=function()
{this.className+=" hover";}
_nodes[i].onmouseout=function()
{this.className=this.className.replace(" hover","");}}}
var nodes=document.getElementById("main-nav2");if(nodes)
{nodes=nodes.getElementsByTagName("div");for(var i=0;i<nodes.length;i++)
{nodes[i].onmouseover=function()
{this.className+=" hover";}
nodes[i].onmouseout=function()
{this.className=this.className.replace(" hover","");}}}
var _nodes=document.getElementById("nav2");if(_nodes)
{_nodes=_nodes.getElementsByTagName("li");for(var i=0;i<_nodes.length;i++)
{_nodes[i].onmouseover=function()
{this.className+=" hover";}
_nodes[i].onmouseout=function()
{this.className=this.className.replace(" hover","");}}}}
if(document.all&&!window.opera)attachEvent("onload",initHover);;function hideSelectBoxes(object)
{if(!object)return;if(!object.sboxes)
object.sboxes=[];var ol=getElementX(object);var ot=getElementY(object);var ow=object.offsetWidth;var oh=object.offsetHeight;var sboxes=document.all.tags("select");for(var i=0;i<sboxes.length;i++)
{var node=sboxes[i].parentNode;while(node!=object&&node.tagName!="BODY")
node=node.parentNode;var skip=(node==object);if(skip)continue;var t=getElementY(sboxes[i]);var l=getElementX(sboxes[i]);var w=sboxes[i].offsetWidth;var h=sboxes[i].offsetHeight;var ver=false;if(t>ot&&t<(ot+oh))
ver=true;else if((t+h)>ot&&(t+h)<(ot+oh))
ver=true;var hor=false;if(l>ol&&l<(ol+ow))
hor=true;else if((l+w)>ol&&(l+w)<(ol+ow))
hor=true;else if(l<ol&&(l+w)>ol)
hor=true;if(ver&&hor&&sboxes[i].style.visibility!="hidden")
object.sboxes[object.sboxes.length]=sboxes[i];}
for(var i=0;i<object.sboxes.length;i++)
object.sboxes[i].style.visibility="hidden";}
function showSelectBoxes(object)
{if(!object)return;if(!object.sboxes)return;for(var i=0;i<object.sboxes.length;i++)
object.sboxes[i].style.visibility="";object.sboxes=[];}
function getElementX(object){return getElementC(object,true)}
function getElementY(object){return getElementC(object,false)}
function getElementC(element,xAxis)
{var initialElement=element;var c=0;while(element!=null)
{c+=(xAxis)?element.offsetLeft:element.offsetTop;if(element.style.position=="absolute")
break;else
element=element.offsetParent;}
var elementWnd=document.window;if(!elementWnd)return c;if(!elementWnd.frameElement)return c;return c+getElementC(elementWnd.frameElement,xAxis);};function initDrop()
{var _show=document.getElementById("open-drop");var _drop=document.getElementById("open-list");var _close=document.getElementById("close");if(_show&&_drop&&_close)
{_show.onclick=function()
{_drop.style.display="block";if(window.attachEvent)
{hideSelectBoxes(_drop);}
return false;};_close.onclick=function()
{_drop.style.display="none";if(window.attachEvent)
{showSelectBoxes(_drop);}
return false;};}}
function initDrop2()
{var _box=document.getElementById("click-drop");if(_box)
{var nodes=_box.getElementsByTagName("a");for(var i=0;i<nodes.length;i++)
{if(nodes[i].className.indexOf("lnk-click-drop")!=-1)
{nodes[i].onclick=function()
{if(this.parentNode.className.indexOf("active")!=-1)
{this.parentNode.className=this.parentNode.className.replace("active","");}
else
{this.parentNode.className+=" active";}
return false;};}}}}
if(window.addEventListener)
{window.addEventListener("load",initDrop,false);window.addEventListener("load",initDrop2,false);}
else if(window.attachEvent)
{window.attachEvent("onload",initDrop);window.attachEvent("onload",initDrop2);};$.myoffice=new function(){var o=this;var curr_tab=0;o.init=function(){var val=o.autoload();if(!val){o.load_tabs();}
o.providers=new $.providers();o.schedule=new $.schedule();o.accountinfo=new $.accountinfo();};o.autoload=function(){$("#tabs").tabs().fixTabs();if($('#tab_10').length===0){return false;}
var hash=window.location.hash?window.location.hash.replace('#',''):'';if(!hash){hash='overview';}
success=false;switch(hash){case'overview':o.show_tab(10);success=true;curr_tab=10;break;case'account':o.show_tab(11);success=true;curr_tab=11;break;case'providers':o.show_tab(12);success=true;curr_tab=12;break;case'schedule':o.show_tab(13);success=true;curr_tab=13;break;}
if(success){$("#tabs > ul > li > a[id^='tab_']").bind("click",o.handle_tab_click);return true;}
return false;};o.load_tabs=function(){$.ajax({type:'GET',url:'../office/myoffice/get_tab',dataType:"json",cache:false,success:function(responseText,statusText){switch(responseText.tab_id){case 1:case'1':$("#tab_1").bind("click",o.handle_tab_click);o.show_tab(1);break;case 2:case'2':$("#tab_1").bind("click",o.handle_tab_click);$("#tab_2").bind("click",o.handle_tab_click);o.show_tab(2);break;case 3:case'3':o.show_tab(3);break;case 10:case'10':o.show_tab(10);break;case 11:case'11':o.show_tab(11);break;case 12:case'12':o.show_tab(12);break;case 13:case'13':o.show_tab(13);break;}
if(responseText.tab_id>2){$("#tabs > ul > li > a[id^='tab_']").bind("click",o.handle_tab_click);}else{$('#tabs').tabs('option','disabled',[0,1,2]);}}});};o.handle_tab_click=function()
{$('#tabs-1').html('');$('#tabs-2').html('');$('#tabs-3').html('');$('#tabs-10').html('');$('#tabs-11').html('');$('#tabs-12').html('');$('#tabs-13').html('');switch($(this).attr('id')){case'tab_1':o.show_tab(1);break;case'tab_2':o.show_tab(2);break;case'tab_3':o.show_tab(3);break;case'tab_10':o.show_tab(10);break;case'tab_11':o.show_tab(11);break;case'tab_12':o.show_tab(12);break;case'tab_13':o.show_tab(13);break;default:break;}};o.show_tab=function(tab){if(tab<10){$('#tabs').tabs('enable',tab-1);}
$('#tabs').tabs('select','#tabs-'+tab);var url='';switch(tab){case 1:case 11:var referral=$('#tabs-'+tab).attr("referral");url='../office/myoffice_accountinfo/load'+(referral?'?referral='+referral:"");break;case 2:url='../office/myoffice/get_providers';break;case 3:url='../office/myoffice_schedule/load';break;case 10:url='../office/myoffice/get_overview';break;case 12:url='../office/myoffice/get_providers';break;case 13:url='../office/myoffice_schedule/load';break;default:break;}
$.ajax({type:'GET',url:url,dataType:"json",cache:false,beforeSend:function(formData,jqForm,options){$("#tabs-"+tab).html('<div class="holder"><div class="left-column-registr"><h3>Loading...</h3></div></div>');},success:function(responseText,statusText){$("#tabs-"+tab).html(responseText.html);tab_binding(tab);}});};var tab_binding=function(tab)
{switch(tab){case 1:case 11:o.accountinfo.init();break;case 10:$('.goto-account').bind("click",function(){o.show_tab(11);});$('.goto-providers').bind("click",function(){o.show_tab(12);});$('.goto-schedule').bind("click",function(){o.show_tab(13);});break;case 2:case 12:o.providers.init();break;case 3:case 13:o.schedule.init();break;default:break;}};}
function IsStringBlank(pStr)
{if(pStr==null)return true;for(var i=0;i<pStr.length;i++)
{if((pStr.charAt(i)!=' ')&&(pStr.charAt(i)!="\t")&&(pStr.charAt(i)!="\n")&&(pStr.charAt(i)!="\r"))return false;}
return true;}
function IsIntegerValue(pVal)
{if(IsStringBlank(pVal))return false;var digits="1234567890";for(var i=0;i<pVal.length;i++)
{if(digits.indexOf(pVal.charAt(i))==-1)return false;}
return true;}
function isIntKeyPress(e){var id=e.data;var input_val=$("#"+id).attr('value');if(IsIntegerValue(input_val)==false){$("#"+id).attr('value','');}}
function handleFocusOfTextField(fieldElement,defaultFieldValue,isFormSubmission)
{if(!fieldElement||!defaultFieldValue)return;if(fieldElement.value==defaultFieldValue){fieldElement.value='';$('#'+fieldElement.id).removeClass('unactive');$('#'+fieldElement.id).addClass('active');}}
function handleBlurOfTextField(fieldElement,defaultFieldValue,isFormSubmission)
{if(!fieldElement||!defaultFieldValue)return;if(!isFormSubmission){if(!fieldElement.value||fieldElement.value==''||fieldElement.value==' '){fieldElement.value=defaultFieldValue;$('#'+fieldElement.id).removeClass('active');$('#'+fieldElement.id).addClass('unactive');}}
if(isFormSubmission&&fieldElement.value==defaultFieldValue){fieldElement.value='';}}
function step1FormClearText()
{handleBlurOfTextField(document.getElementById('User_First_Name'),'First Name',true);handleBlurOfTextField(document.getElementById('User_Last_Name'),'Last Name',true);handleBlurOfTextField(document.getElementById('User_Email'),'(This will be your username)',true);handleBlurOfTextField(document.getElementById('User_Referrer_Name'),'Full Name',true);handleBlurOfTextField(document.getElementById('Office_Office_Manager_FName'),'First Name',true);handleBlurOfTextField(document.getElementById('Office_Office_Manager_LName'),'Last Name',true);handleBlurOfTextField(document.getElementById('Address_Line_1'),'Street Address',true);handleBlurOfTextField(document.getElementById('Address_City'),'City',true);}
function submitOfficeRegistrationStep1Form()
{step1FormClearText();$('#step1').submit();}
$(document).ready(function(){$.myoffice.init();});;$.providers=function(){var p=this;p.init=function(){$('#search_provider_keyword').live('keyup',p.searchResults);$('#search_provider_search_button').live('click',function(){p.searchProviders(false);});p.loadAllProviders();$(".alphabet_name").live("click",p.show_alphabet_list);$(".alphabet-sel").live("click",p.show_alphabet_list);$("#show_selected_provider_link").live("click",p.showProviderDetails);$("#add_new_provider_btn").live("click",p.loadProviderAddForm);var data_provider_search={id:"search_provider_keyword",txt:"Search by provider name, DEA#, or zipcode."};$('#search_provider_keyword').bind("click",data_provider_search,p.clickHandlerOnProviderForm);$('#search_provider_keyword').bind("blur",data_provider_search,p.blurHandlerOnProviderForm);$('#complete-add-providers').bind("click",p.complete_reg_step);$('#search_provider_data_updater > ul > li').live('click',p.handleProviderSelected);};p.loadAllProviders=function(){p.searchProviders(true);p.officeCurrentProvidersListing();$('#alphabet_box > ul > li > a').each(function(){$(this).removeClass('alphabet-sel');$(this).addClass('alphabet_name');});$("#all").removeClass('alphabet_name');$("#all").addClass('alphabet-sel');};p.searchResults=function(event){if(event.keyCode!=13)return false;p.searchProviders(false);$('#alphabet_box > ul > li > a').each(function(){$(this).removeClass('alphabet-sel');$(this).addClass('alphabet_name');});$("#all").removeClass('alphabet_name');$("#all").addClass('alphabet-sel');return false;};p.searchProviders=function(allProviders){$("#search_provider_data_updater_loading_message").hide();$('#search_provider_data_alphabet_search_nomatch').hide();$("#search_provider_data_updater").html('');var search=$("#search_provider_keyword").val();var key="";var area="";var only_lname=0;if(search=="Search by provider name, DEA#, or zipcode.")search='';if(search){search=search.replace('(',"_");search=search.replace(')',"~");}
else{search='';}
if(search.length>0||allProviders){$("#search_provider_data_updater_loading_message").show();searchURL='/office/myoffice_providers/search_providers';if(allProviders){key="all";area="all";}
else{key=search;area="";only_lname=$("#search_only_lname").val();$("#search_only_lname").attr('value',0);}
$.ajax({type:"GET",data:{'key':key,'area':area,'onlylname':only_lname},url:searchURL,dataType:'json',cache:false,success:function(responseText,statusText){if(responseText.html.length>0){$(".display-pagination").html(responseText.html);$.pagination.init(false);}
$("#search_provider_data_updater_loading_message").hide();}});}};p.show_alphabet_list=function(){$('#search_provider_data_alphabet_search_nomatch').hide();var showAllElements=false;var id=$(this).attr('id');if($('#search_provider_keyword'))
{$('#search_provider_keyword').val('Search by provider name, DEA#, or zipcode.');}
if(id=='all_none'){p.loadAllProviders();}
else{$("#search_only_lname").attr('value',1);$("#search_provider_keyword").attr('value',id);p.searchProviders(false);$("#search_provider_keyword").attr('value','Search by provider name, DEA#, or zipcode.');}
$('#alphabet_box > ul > li > a').each(function(){$(this).removeClass('alphabet-sel');$(this).addClass('alphabet_name');});$(this).removeClass('alphabet_name');$(this).addClass('alphabet-sel');};p.selectprovider=function(){if($(this).children('div').hasClass('selected')){$(this).children('div').removeClass('selected');}else{$(this).children('div').addClass('selected');}};p.removeSelectedProviderElement=function(){$('#search_provider_data_updater > ul').find('li.selected_provider').remove();p.reArrangeProvidersListingBackground();};p.reArrangeProvidersListingBackground=function(){var counter=0;$('#providers_list > li').each(function(){counter++;if(counter%2==0)
{$(this).addClass('alt-item');}
else
{$(this).removeClass('alt-item');}});};p.removeProviderSelectionClass=function(){$('#search_provider_data_updater > ul > li').removeClass('selected_provider');};p.handleProviderSelected=function(){p.removeProviderSelectionClass();$(this).addClass('selected_provider');};p.removeCurrentProviderSelectionClass=function(){$('#my_current_providers_dynamic_updater > ul > li').removeClass('selected_provider');};p.handleCurrentProviderSelected=function(){p.removeCurrentProviderSelectionClass();$(this).addClass('selected_provider');};p.bindAddNewProviderForm=function(){p.addNewProvider();};p.saveNewProvider=function(){url=$('#provider_details_save_form').attr('action');$('#provider_details_save_form').ajaxForm({dataType:'json',beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){if(responseText.success==0){$("#provider_details_dynamic_updater").html(responseText.html);p.showOrHideProviderDetailsFormLinks(true);$("#provider_details_cancel_link").live("click",p.handleCancelInProviderDetails);$("#my_current_providers_dynamic_updater").hide();$("#provider_details_remove_provider_link").hide();$("#provider_details_edit_provider_link").hide();p.bindEventToAddProvider();p.saveNewProvider();}else if(responseText.success==-1){$.fn.jmodal({title:'ALERT',content:'Primary Office field is required.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else if(responseText.success==-2){$.fn.jmodal({title:'ALERT',content:'Attends Rep Meetings field is required.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else{$("#provider_details_dynamic_updater").html(responseText.html);$.fn.jmodal({title:'ALERT',content:'The new provider has been added.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});p.handleshowProviderDetailsForCreateOrEdit(true,responseText.doctor_id);}}});};p.addNewProvider=function(){showSlider();$('#provider_details_save_form').ajaxForm({dataType:'json',beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){if(!responseText.success){$.fn.jmodal({title:'ALERT',content:responseText.message,buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else{$("#provider_details_dynamic_updater").html('');p.officeCurrentProvidersListing();p.removeSelectedProviderElement();}}});};p.sendMailToProvider=function(){$('#send_mail_to_provider').ajaxForm({dataType:'json',beforeSubmit:function(formData,jqForm,options){$('#send_mail_to_provider_error_message_cont').hide();$('#send_mail_to_provider_success_message_cont').hide();},success:function(responseText,statusText){if(responseText.success==0){$('#send_mail_to_provider_success_message_cont').hide();$('#send_mail_to_provider_container').html(responseText.html);p.sendMailToProvider();}else if(responseText.success==1){$('#send_mail_to_provider_container').html(responseText.html);p.sendMailToProvider();$('#send_mail_to_provider_success_message_cont').show();}
else{$('#send_mail_to_provider_container').html(responseText.html);$('#send_mail_to_provider_error_message_cont').show();$('#send_mail_to_provider_error_message_cont').html('Internal server error.');p.sendMailToProvider();}}});};p.uploadProviderPhoto=function(photoURL){ajaxFileUpload('/office/providers/uploadProviderPhoto',false,'Doctor_Office_Settings_Photo_URL');};function ajaxFileUpload(urlToBePosted,issecureuri,fileURLValueFieldName)
{var ran_number=Math.random()*15;urlToBePosted=urlToBePosted+'?'+ran_number;$.ajaxFileUpload
({url:urlToBePosted,secureuri:issecureuri,fileElementId:fileURLValueFieldName,dataType:'json',success:function(data,status)
{if(typeof(data.error)!='undefined')
{if(data.error!=''){}
else{}}},error:function(data,status,e)
{return e;}});return false;}
p.handleResponse=function(){$("#responseText").html("New Provider has been added successfully");};p.setSearchValue=function(){suggestion=$("#autosuggest_providers").val();$("#Search_Provider").val(suggestion.toString());$("#autosuggest_providers").hide();p.searchResults();};p.showOrHideCurrentProviderSectionLinks=function(showLinks){if(showLinks&&showLinks==true){$("#provider_details_remove_provider_link").show();$("#provider_details_remove_provider_link").live("click",p.removeSelectedCurrentOfficeProvider);$("#provider_details_edit_provider_link").show();$("#provider_details_edit_provider_link").live("click",p.editSelectedCurrentOfficeProvider);}
else{$("#provider_details_remove_provider_link").hide();$("#provider_details_edit_provider_link").hide();}};p.showProviderDetails=function(){p.handleshowProviderDetailsForCreateOrEdit(true);};p.handleshowProviderDetailsForCreateOrEdit=function(createFlow,provider_id){var selected_provider_id_value=null;var target_url=null;if(createFlow){selected_provider_id_value=$('#search_provider_data_updater > ul').find('li.selected_provider');target_url='/office/myoffice_providers/show_selected_provider/';if(!selected_provider_id_value||!selected_provider_id_value.attr('doctor_id'))
{selected_provider_id_value=$('#last_inserted_doctor');}}
else{selected_provider_id_value=$('#my_current_providers_dynamic_updater > ul').find('li.selected_provider');target_url='/office/myoffice_providers/show_selected_current_provider/';}
if(!selected_provider_id_value||!selected_provider_id_value.attr('doctor_id'))return;$("#provider_details_dynamic_updater").html('');$("#my_current_providers_dynamic_updater").hide();p.showOrHideCurrentProviderSectionLinks(false);if(!provider_id){provider_id=selected_provider_id_value.attr('doctor_id');}
$("#my_providers_dynamic_updater_loading_message").show();$.ajax({type:"GET",url:target_url+provider_id,cache:false,success:function(message){if(message.length>0){$("#provider_details_dynamic_updater").html(message);p.showOrHideProviderDetailsFormLinks(true);$("#provider_details_cancel_link").live("click",p.handleCancelInProviderDetails);$("#provider_settings_office_hours").live("change",p.handleChangeOfOffHrsWeekDay);$("#provider_settings_add_off_hrs").live("click",p.addWeekDayTime);$("#Doctor_speciality_assoc_Speciality_ID").bind("change",p.handleSpecialityChange);$("#Doctor_Hospital_Hpeciality_ID").bind("change",p.handleHospitalChange);$("#Doctor_Office_Settings_Meet_Rep_None").bind("click",p.enableDisableRepInteractionPreferredMethod);var data_email={id:"Doctor_Office_Settings_Doctor_Email",txt:"Email"};$('#Doctor_Office_Settings_Doctor_Email').bind("blur",data_email,p.blurHandlerOnAddProviderForm);$('#Doctor_Office_Settings_Doctor_Email').bind("focus",data_email,p.clickHandlerOnAddProviderForm);var data_confemail={id:"Doctor_Office_Settings_Doctor_confemail",txt:"Confirm Email"};$('#Doctor_Office_Settings_Doctor_confemail').bind("blur",data_confemail,p.blurHandlerOnAddProviderForm);$('#Doctor_Office_Settings_Doctor_confemail').bind("focus",data_confemail,p.clickHandlerOnAddProviderForm);$('#Doctor_speciality_assoc_Speciality_ID').selectList({sort:true});$('#Doctor_Hospital_Hpeciality_ID').selectList({sort:true});p.bindAddNewProviderForm();}}});};p.enableDisableRepInteractionPreferredMethod=function(){if($("#Doctor_Office_Settings_Meet_Rep_None"))
{var none_checked_value=$("#Doctor_Office_Settings_Meet_Rep_None").attr("checked");if(none_checked_value&&none_checked_value==true)
{$("#Doctor_Office_Settings_Meet_Rep_Online").attr("disabled",true);$("#Doctor_Office_Settings_Meet_Rep_Online").attr("checked",false);$("#Doctor_Office_Settings_Meet_Rep_Thru_Email").attr("disabled",true);$("#Doctor_Office_Settings_Meet_Rep_Thru_Email").attr("checked",false);$("#Doctor_Office_Settings_Meet_Rep_Thru_Phone").attr("disabled",true);$("#Doctor_Office_Settings_Meet_Rep_Thru_Phone").attr("checked",false);$("#Doctor_Office_Settings_Meet_Rep_At_Offsite_In_Person").attr("disabled",true);$("#Doctor_Office_Settings_Meet_Rep_At_Offsite_In_Person").attr("checked",false);$("#Doctor_Office_Settings_Meet_Rep_At_Work_In_Person").attr("disabled",true);$("#Doctor_Office_Settings_Meet_Rep_At_Work_In_Person").attr("checked",false);}
else
{$("#Doctor_Office_Settings_Meet_Rep_Online").attr("disabled",false);$("#Doctor_Office_Settings_Meet_Rep_Thru_Email").attr("disabled",false);$("#Doctor_Office_Settings_Meet_Rep_Thru_Phone").attr("disabled",false);$("#Doctor_Office_Settings_Meet_Rep_At_Offsite_In_Person").attr("disabled",false);$("#Doctor_Office_Settings_Meet_Rep_At_Work_In_Person").attr("disabled",false);}}};p.handleSpecialityChange=function(e){};p.handleHospitalChange=function(){};p.loadProviderAddForm=function(){$.ajax({type:"POST",url:"/office/myoffice_providers/add_new_provider_form",cache:false,success:function(message){if(message.length>0){$("#provider_details_dynamic_updater").html(message);p.showOrHideProviderDetailsFormLinks(true);$("#provider_details_cancel_link").live("click",p.handleCancelInProviderDetails);$("#my_current_providers_dynamic_updater").hide();$("#provider_details_remove_provider_link").hide();$("#provider_details_edit_provider_link").hide();p.bindEventToAddProvider();p.saveNewProvider();}}});};p.bindEventToAddProvider=function(){var data_fname={id:"Doctor_First_Name",txt:"First Name"};var data_lname={id:"Doctor_Last_Name",txt:"Last Name"};var data_address={id:"Address_Line_1",txt:"Address"};var data_city={id:"Address_City",txt:"Ciudad City"};var data_doc_id={id:"Doctor_DEA",txt:"DEA#"};var data_zipcode={id:"Address_Zip_Code",txt:"Zip"};$('#Doctor_First_Name').bind("blur",data_fname,p.blurHandlerOnAddProviderForm);$('#Doctor_Last_Name').bind("blur",data_lname,p.blurHandlerOnAddProviderForm);$('#Address_Line_1').bind("blur",data_address,p.blurHandlerOnAddProviderForm);$('#Address_City').bind("blur",data_city,p.blurHandlerOnAddProviderForm);$('#Doctor_DEA').bind("blur",data_doc_id,p.blurHandlerOnAddProviderForm);$('#Address_Zip_Code').bind("blur",data_zipcode,p.blurHandlerOnAddProviderForm);$('#Doctor_First_Name').bind("focus",data_fname,p.clickHandlerOnAddProviderForm);$('#Doctor_Last_Name').bind("focus",data_lname,p.clickHandlerOnAddProviderForm);$('#Address_Line_1').bind("focus",data_address,p.clickHandlerOnAddProviderForm);$('#Address_City').bind("focus",data_city,p.clickHandlerOnAddProviderForm);$('#Doctor_DEA').bind("focus",data_doc_id,p.clickHandlerOnAddProviderForm);$('#Address_Zip_Code').bind("focus",data_zipcode,p.clickHandlerOnAddProviderForm);};p.clickHandlerOnAddProviderForm=function(e){var curr_val=$('#'+e.data.id).attr('value');if(curr_val==e.data.txt){$('#'+e.data.id).attr('value','');$('#'+e.data.id).removeClass('blank-textbox-addprovider');$('#'+e.data.id).addClass('filled-textbox-addprovider');}};p.blurHandlerOnAddProviderForm=function(e){var curr_val=$('#'+e.data.id).attr('value');if(curr_val==""){$('#'+e.data.id).attr('value',e.data.txt);$('#'+e.data.id).removeClass('filled-textbox-addprovider');$('#'+e.data.id).addClass('blank-textbox-addprovider');}};p.blurHandlerOnProviderForm=function(e){var curr_val=$('#'+e.data.id).attr('value');if(curr_val==""){$('#'+e.data.id).attr('value',e.data.txt);}};p.clickHandlerOnProviderForm=function(e){var curr_val=$('#'+e.data.id).attr('value');if(curr_val==e.data.txt){$('#'+e.data.id).attr('value','');}};p.handleChangeOfOffHrsWeekDay=function(){};p.handleChangeOfWeekDayTime=function(min_txt,max_txt){$("#office_hrs_minval").html(min_txt);$("#office_hrs_maxval").html(max_txt);};p.addWeekDayTime=function(){var min_txt=$("#minval").html();var max_txt=$("#maxval").html();var finalDisplayValue=''+min_txt+' - '+max_txt;if($(".provider_settings_office_hours_out:checked").val()=='1'){finalDisplayValue='Out';min_txt='Out';max_txt='Out';}
var currentlySelWeekDay=$("#provider_settings_office_hours").val();if(!currentlySelWeekDay)currentlySelWeekDay=0;switch(currentlySelWeekDay){case'0':p.populateSpecificDayWorkingHours('1',min_txt,max_txt,finalDisplayValue);p.populateSpecificDayWorkingHours('2',min_txt,max_txt,finalDisplayValue);p.populateSpecificDayWorkingHours('3',min_txt,max_txt,finalDisplayValue);p.populateSpecificDayWorkingHours('4',min_txt,max_txt,finalDisplayValue);p.populateSpecificDayWorkingHours('5',min_txt,max_txt,finalDisplayValue);finalDisplayValue='Out';min_txt='Out';max_txt='Out';p.populateSpecificDayWorkingHours('6',min_txt,max_txt,finalDisplayValue);p.populateSpecificDayWorkingHours('7',min_txt,max_txt,finalDisplayValue);break;default:p.populateSpecificDayWorkingHours(currentlySelWeekDay,min_txt,max_txt,finalDisplayValue)
break;}};p.populateSpecificDayWorkingHours=function(week_day_value,min_val,max_val,finalDisplayValue){var day_of_week_value='';var off_hrs_day_of_week='';switch(week_day_value){case'1':off_hrs_day_of_week='MON';day_of_week_value='Monday';break;case'2':off_hrs_day_of_week='TUE';day_of_week_value='Tuesday';break;case'3':off_hrs_day_of_week='WED';day_of_week_value='Wednesday';break;case'4':off_hrs_day_of_week='THU';day_of_week_value='Thursday';break;case'5':off_hrs_day_of_week='FRI';day_of_week_value='Friday';break;case'6':off_hrs_day_of_week='SAT';day_of_week_value='Saturday';break;case'7':off_hrs_day_of_week='SUN';day_of_week_value='Sunday';break;}
$('#off_hrs_'+off_hrs_day_of_week+'_value').text(finalDisplayValue);var weekDayStartTime='#Doctor_Office_Settings_'+day_of_week_value+'_Office_Start_Time';var weekDayEndTime='#Doctor_Office_Settings_'+day_of_week_value+'_Office_End_Time';$(weekDayStartTime).val(min_val);$(weekDayEndTime).val(max_val);};p.handleCancelInProviderDetails=function(){p.officeCurrentProvidersListing();};p.officeCurrentProvidersListing=function(){$("#provider_details_dynamic_updater").html('');$("#my_current_providers_dynamic_updater").html('');$("#my_current_providers_dynamic_updater").show();$.ajax({type:"GET",url:'/office/myoffice_providers/get_my_providers',cache:false,success:function(message){if(message.length>0){$("#my_current_providers_dynamic_updater").html(message);$("#my_current_providers_dynamic_updater").show();if($("#office_current_no_of_providers_found").val()>0){p.showOrHideCurrentProviderSectionLinks(true);$('#my_current_providers_dynamic_updater > ul > li').bind('click',p.handleCurrentProviderSelected);}
else{p.showOrHideCurrentProviderSectionLinks(false);}}}});p.showOrHideProviderDetailsFormLinks(false);};p.showOrHideProviderDetailsFormLinks=function(isShow){if(isShow){$("#provider_details_save_link").show();$("#provider_details_cancel_link").show();}
else{$("#provider_details_save_link").hide();$("#provider_details_cancel_link").hide();}};p.editSelectedCurrentOfficeProvider=function(){p.handleshowProviderDetailsForCreateOrEdit(false);};p.removeSelectedCurrentOfficeProvider=function(){if(confirm('Are you sure you want to remove the selected provider?')){var selected_provider_id_value=$('#my_current_providers_dynamic_updater > ul').find('li.selected_provider');if(!selected_provider_id_value||!selected_provider_id_value.attr('doctor_id'))return;$("#provider_details_dynamic_updater").html('');$("#my_current_providers_dynamic_updater").hide();p.showOrHideCurrentProviderSectionLinks(false);$("#my_providers_dynamic_updater_loading_message").show();$.ajax({type:"GET",url:'myoffice_providers/delete_provider/'+selected_provider_id_value.attr('doctor_id'),cache:false,success:function(responseText,statusText){if(responseText.success==0){$.fn.jmodal({title:'ALERT',content:'Could not find the selected provider associated to your office, please try again',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else if(responseText.success==-1){$.fn.jmodal({title:'ALERT',content:'Please Login to the system',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else{$.fn.jmodal({title:'ALERT',content:'The provider has been removed.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
$("#my_current_providers_dynamic_updater").show();p.officeCurrentProvidersListing();}});}};p.complete_reg_step=function(){if($('#office_current_providers_list > li').size()>0){$.ajax({type:"GET",url:'/office/myoffice_providers/complete_step',cache:false,success:function(message){$.myoffice.show_tab(3);}});}else{$.fn.jmodal({title:'ALERT',content:'You must add at least one provider before you can continue.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}};};function showSlider(){$("#slider").slider({animate:true,max:49,min:1,step:1,orientation:'horizontal',range:true,values:[19,35],slide:function(event,ui)
{var timeslot=new Array();timeslot[0]="0";timeslot[1]="12:00a";timeslot[2]="12:30a";timeslot[3]="1:00a";timeslot[4]="1:30a";timeslot[5]="2:00a";timeslot[6]="2:30a";timeslot[7]="3:00a";timeslot[8]="3:30a";timeslot[9]="4:00a";timeslot[10]="4:30a";timeslot[11]="5:00a";timeslot[12]="5:30a";timeslot[13]="6:00a";timeslot[14]="6:30a";timeslot[15]="7:00a";timeslot[16]="7:30a";timeslot[17]="8:00a";timeslot[18]="8:30a";timeslot[19]="9:00a";timeslot[20]="9:30a";timeslot[21]="10:00a";timeslot[22]="10:30a";timeslot[23]="11:00a";timeslot[24]="11:30a";timeslot[25]="12:00p";timeslot[26]="12:30p";timeslot[27]="1:00p";timeslot[28]="1:30p";timeslot[29]="2:00p";timeslot[30]="2:30p";timeslot[31]="3:00p";timeslot[32]="3:30p";timeslot[33]="4:00p";timeslot[34]="4:30p";timeslot[35]="5:00p";timeslot[36]="5:30p";timeslot[37]="6:00p";timeslot[38]="6:30p";timeslot[39]="7:00p";timeslot[40]="7:30p";timeslot[41]="8:00p";timeslot[42]="8:30p";timeslot[43]="9:00p";timeslot[44]="9:30p";timeslot[45]="10:00p";timeslot[46]="10:30p";timeslot[47]="11:00p";timeslot[48]="11:30p";timeslot[49]="12:00a";var min_val=$(this).slider('values',0);var max_val=$(this).slider('values',1);var min_txt=timeslot[min_val];var max_txt=timeslot[max_val];$("#minval").html(min_txt);$("#maxval").html(max_txt);$("#office_hrs_user_selected_minval").val(min_txt);$("#office_hrs_user_selected_maxval").val(max_txt);}});};$.schedule=function(){var s=this;var current_import_appt_id=false;s.init=function(){$('.tooltip').qtip({style:{name:'light',tip:true,border:{color:"#D55337"}},position:{corner:{target:'bottomMiddle',tooltip:'topMiddle'}}});s.loadOfficeCurrentVistorRules();s.loadOfficeCurrentFavVistorRules();s.loadOfficeCurrentSampleRules();s.bindsaveOfficeVisitorRuleDetails();s.bindsaveOfficeFavVisitorRuleDetails();s.bindsaveSampleDropOfficeVisitorRuleDetails();s.bindsaveRecurringOpeningsDetails();s.bindsaveRecurringClosuresDetails();s.bindsaveRecurringClosuresStdHolidaysDetails();$("#openings_tab").live("click",s.changeToOpeningsTab);$("#closures_tab").live("click",s.changeToClosuresTab);$("#all_reps_tab, #favorites_tab, #samples_tab").live("click",s.update_visitation);$("#finish_office_reg").live("click",s.doFinishOfficeReg);$("#office_vistor_rules_listing_delete_btn").live("click",s.deleteSelectedVisitorRule);$('#opening_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#closures_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#delete_recurring_schedule').live('click',s.deleteSelectedOpeningsClosures);$('#Office_Visitor_Rule_visit_count').bind("blur","Office_Visitor_Rule_visit_count",isIntKeyPress);$(".datepicker input").datepicker({showOn:'both',buttonImage:'/images/ico-calender.gif',buttonImageOnly:true,dateFormat:'mm/dd/yy',onSelect:s.setMyOpeningDate,minDate:0});s.load_appointments();$(".appt_item").live("click",s.load_appointment_info);$("#assign-rep-button").live("click",s.assign_rep);s.add_new_rep_form();$('#add-assign-button').live('click',s.submit_new_rep_form);$("#cancel-assign-button").live("click",s.cancel_add_rep);};s.update_visitation=function(){var self=$(this);$(".visitation-tabs li a").removeClass("active");$("div#office_vistor_rules_listing_dynamic_updater").hide();self.addClass("active");$("#office_vistor_rules_listing_dynamic_updater."+this.id).show();switch(this.id){default:break;}};s.loadOfficeCurrentVistorRules=function(){var self=$("#office_vistor_rules_listing_dynamic_updater.all_reps_tab");self.html('');$.ajax({type:"GET",url:'/office/myoffice_schedule/officeCurrentVisitorRules_ajax',cache:false,success:function(message){if(message.length>0){self.html(message);$('#office_vistor_rules_listing_dynamic_updater.all_reps_tab > ul > li').bind('click',s.handleCurrentFavVisitorRuleSelected);}}});};s.loadOfficeCurrentFavVistorRules=function(){var self=$("#office_vistor_rules_listing_dynamic_updater.favorites_tab");self.html('');$.ajax({type:"GET",url:'/office/myoffice_schedule/officeCurrentFavVisitorRules_ajax',cache:false,success:function(message){if(message.length>0){self.html(message);$('#office_vistor_rules_listing_dynamic_updater.favorites_tab > ul > li').bind('click',s.handleCurrentFavVisitorRuleSelected);}}});};s.loadOfficeCurrentSampleRules=function(){var self=$("#office_vistor_rules_listing_dynamic_updater.samples_tab");self.html('');$.ajax({type:"GET",url:'/office/myoffice_schedule/officeCurrentSampleRules_ajax',cache:false,success:function(message){if(message.length>0){self.html(message);$('#office_vistor_rules_listing_dynamic_updater.samples_tab > ul > li').bind('click',s.handleCurrentSampleRuleSelected);}}});};s.showOrHideDeleteRuleButton=function(isShow){if(isShow){$("#office_vistor_rules_listing_delete_btn").show();}
else{$("#office_vistor_rules_listing_delete_btn").hide();}};s.handleCurrentVisitorRuleSelected=function(){s.removeCurrentVisitorRuleSelectionClass();$(this).addClass('selected_provider');};s.removeCurrentVisitorRuleSelectionClass=function(){$('#office_vistor_rules_listing_dynamic_updater > ul > li').removeClass('selected_provider');};s.handleCurrentFavVisitorRuleSelected=function(){s.removeCurrentFavVisitorRuleSelectionClass();$(this).addClass('selected_provider');};s.removeCurrentFavVisitorRuleSelectionClass=function(){$('#office_vistor_rules_listing_dynamic_updater > ul > li').removeClass('selected_provider');};s.handleCurrentSampleRuleSelected=function(){s.removeCurrentSampleRuleSelectionClass();$(this).addClass('selected_provider');};s.removeCurrentSampleRuleSelectionClass=function(){$('#office_vistor_rules_listing_dynamic_updater > ul > li').removeClass('selected_provider');};s.handleCurrentOpeningClosuresSelected=function(){s.removeCurrentOpeningClosuresSelectionClass();$(this).addClass('selected_provider');};s.removeCurrentOpeningClosuresSelectionClass=function(){$('#opening_container > ul > li').removeClass('selected_provider');$('#closures_container > ul > li').removeClass('selected_provider');};s.bindsaveOfficeVisitorRuleDetails=function(){s.saveOfficeVisitorRuleDetails();};s.bindsaveOfficeFavVisitorRuleDetails=function(){s.saveOfficeFavVisitorRuleDetails();};s.bindsaveRecurringOpeningsDetails=function(){s.saveRecurringOpeningsDetails();};s.bindsaveRecurringClosuresDetails=function(){s.saveRecurringClosuresDetails();};s.bindsaveRecurringClosuresStdHolidaysDetails=function(){s.saveRecurringClosuresStdHolidaysDetails();};s.saveRecurringOpeningsDetails=function(){url=$('#office_recurring_openings_details_save_form').action;$('#office_recurring_openings_details_save_form').ajaxForm({dataType:'json',url:url,cache:false,beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){if(responseText.success==-1){document.getElementById("opening_closures_widget_container").innerHTML=responseText.html;s.changeToOpeningsTab();s.attachEventToOpeningClosuresRowClick();$.fn.jmodal({title:'ALERT',content:'Sorry, Duplicate openings are not allowed.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else if(responseText.success==-2){document.getElementById("opening_closures_widget_container").innerHTML=responseText.html;s.changeToOpeningsTab();s.attachEventToOpeningClosuresRowClick();$.fn.jmodal({title:'ALERT',content:'Oops, Invalid time entered.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else if(responseText.success==-3){document.getElementById("opening_closures_widget_container").innerHTML=responseText.html;s.changeToOpeningsTab();s.attachEventToOpeningClosuresRowClick();$.fn.jmodal({title:'ALERT',content:'Oops, Invalid time entered.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else{document.getElementById("opening_closures_widget_container").innerHTML=responseText.html;s.changeToOpeningsTab();s.attachEventToOpeningClosuresRowClick();s.populateAppointment();}}});};s.populateAppointment=function(){$("select").hide();$stage1=new Boxy('<div style="margin: 10px 0pt 0pt 4px; float: left; display: none;" class="creating-appt"><h1 style="margin: 0pt; padding: 0pt; font-weight: normal; font-size: 14px;">Please wait while we create your appointments.</h1><img style="margin: 5px 0pt 0pt 90px;" src="/images/ajax-loader.gif"/></div>',{modal:true,fixed:false});$.ajax({type:'POST',url:'/office/myoffice_schedule_openings_closures/createAppointmentsForMyOffice',cache:false,dataType:"json",beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){setTimeout(function(){$stage1.hide();s.load_appointments();$("select").show();$("#save_off_opening_success_message_cont").show();setTimeout('$("#save_off_opening_success_message_cont").hide();',3000);},2000);}});};s.bindsaveSampleDropOfficeVisitorRuleDetails=function(){s.saveSampleDropOfficeVisitorRuleDetails();$("#Office_Sampledrop_Visitor_Rule_Week_Day").attr('disabled','true');$("#Office_Sampledrop_Visitor_Rule_visit_start_time").attr('disabled','true');$("#Office_Sampledrop_Visitor_Rule_visit_end_time").attr('disabled','true');$('#Office_Sampledrop_Visitor_Rule_visit_when_All').live('click',s.handleSampleDropVisitorWhenClickEvent);$('#Office_Sampledrop_Visitor_Rule_visit_when_Never').live('click',s.handleSampleDropVisitorWhenClickEvent);$('#Office_Sampledrop_Visitor_Rule_visit_when_SpecificDay').live('click',s.handleSampleDropVisitorWhenClickEvent);s.handleSampleDropVisitorWhenClickEvent();};s.handleSampleDropVisitorWhenClickEvent=function(){var enable=!($("#Office_Sampledrop_Visitor_Rule_visit_when_SpecificDay").attr('checked')==true);$("#Office_Sampledrop_Visitor_Rule_Week_Day").attr('disabled',enable);$("#Office_Sampledrop_Visitor_Rule_Accept_Start_Time").attr('disabled',enable);$("#Office_Sampledrop_Visitor_Rule_Accept_End_Time").attr('disabled',enable);};s.saveRecurringClosuresDetails=function(){};s.saveRecurringClosuresStdHolidaysDetails=function(){url=$('#office_recurring_closures_std_holidays_details_save_form').action;$('#office_recurring_closures_std_holidays_details_save_form').ajaxForm({dataType:'json',url:url,cache:false,beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){$("#opening_closures_widget_container").html(responseText.html);s.changeToClosuresTab();s.attachEventToOpeningClosuresRowClick();$.fn.jmodal({title:'ALERT',content:'Holidays updated successfully.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}});};s.saveOfficeVisitorRuleDetails=function(){url=$('#office_visitor_rule_details_save_form').action;$('#office_visitor_rule_details_save_form').ajaxForm({dataType:'json',url:url,cache:false,beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){s.bindsaveOfficeVisitorRuleDetails();if(responseText.success>0){s.clearSaveOfficeVisitorRuleDetailsForm();s.loadOfficeCurrentVistorRules();s.loadOfficeCurrentFavVistorRules();s.loadOfficeCurrentSampleRules();$("#save_office_visitor_rule_details_form_cont").html(responseText.html);$("#save_off_visitor_rule_success_message_cont").show();setTimeout('$("#save_off_visitor_rule_success_message_cont").hide();',3000);}else if(responseText.success==-1){$.fn.jmodal({title:'ALERT',content:'Invalid Amount, Amount must be numeric.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else{$("#save_office_visitor_rule_details_error_msg_cont").show();setTimeout('$("#save_office_visitor_rule_details_error_msg_cont").hide();',3000);}
s.saveOfficeVisitorRuleDetails();}});};s.saveOfficeFavVisitorRuleDetails=function(){url=$('#office_fav_visitor_rule_details_save_form').action;$('#office_fav_visitor_rule_details_save_form').ajaxForm({dataType:'json',url:url,cache:false,beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){s.bindsaveOfficeFavVisitorRuleDetails();if(responseText.success>0){s.clearSaveOfficeFavVisitorRuleDetailsForm();s.loadOfficeCurrentVistorRules();s.loadOfficeCurrentFavVistorRules();s.loadOfficeCurrentSampleRules();$("#save_office_fav_visitor_rule_details_form_cont").html(responseText.html);$("#save_off_fav_visitor_rule_success_message_cont").show();setTimeout('$("#save_off_fav_visitor_rule_success_message_cont").hide();',3000);}else if(responseText.success==-1){$.fn.jmodal({title:'ALERT',content:'Invalid Amount, Amount must be numeric.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else{$("#save_office_fav_visitor_rule_details_error_msg_cont").show();setTimeout('$("#save_office_fav_visitor_rule_details_error_msg_cont").hide();',3000);}
s.saveOfficeFavVisitorRuleDetails();}});};s.saveSampleDropOfficeVisitorRuleDetails=function(){url=$('#office_sample_drops_rule_details_save_form').action;$('#office_sample_drops_rule_details_save_form').ajaxForm({dataType:'json',url:url,cache:false,beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){if(responseText.success>0){$("#save_sampledrop_office_visitor_rule_details_form_cont").html(responseText.html);s.clearSaveSampleDropOfficeVisitorRuleDetailsForm();s.bindsaveSampleDropOfficeVisitorRuleDetails();s.loadOfficeCurrentVistorRules();s.loadOfficeCurrentFavVistorRules();s.loadOfficeCurrentSampleRules();$("#save_off_visitor_rule_success_message_cont").show();setTimeout('$("#save_off_visitor_rule_success_message_cont").hide();',3000);}else if(responseText.success==-1){$.fn.jmodal({title:'ALERT',content:'Invalid sample drops time selected.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}else{$("#save_office_visitor_rule_details_error_msg_cont").show();setTimeout('$("#save_office_visitor_rule_details_error_msg_cont").hide();',3000);}}});};s.clearSaveOfficeVisitorRuleDetailsForm=function(){$('#Office_Visitor_Rule_visit_count').val('');$('#Office_Visitor_Rule_visit_type').selectedindex=0;$('#Office_Visitor_Rule_visit_when').selectedindex=0;};s.clearSaveOfficeFavVisitorRuleDetailsForm=function(){$('#Office_Fav_Visitor_Rule_visit_count').val('');$('#Office_Fav_Visitor_Rule_visit_type').selectedindex=0;$('#Office_Fav_Visitor_Rule_visit_when').selectedindex=0;};s.clearSaveSampleDropOfficeVisitorRuleDetailsForm=function(){$('#Office_Sampledrop_Visitor_Rule_visit_when_All').checked=true;$('#Office_Sampledrop_Visitor_Rule_Week_Day').selectedindex=0;$('#Office_Sampledrop_Visitor_Rule_start_time').selectedindex=0;$('#Office_Sampledrop_Visitor_Rule_visit_end_time').selectedindex=0;};s.deleteSelectedVisitorRule=function(){var selected_rule_id_value=$('#office_vistor_rules_listing_dynamic_updater > ul').find('li.selected_provider');if(!selected_rule_id_value||!selected_rule_id_value.attr('office_vistor_rule_id'))return;$.fn.jmodal({title:'ALERT',content:'Are you sure you want to delete the selected rule?',buttonText:{ok:'Yes',cancel:"No"},okEvent:function(obj,args){$.fn.hideJmodalInstantly();var delete_url='/office/visitorrules/deleteCurrentVisitorRule_ajax/';if(selected_rule_id_value.attr('record_type')=='sampledrops'){delete_url='/office/visitorrules/deleteCurrentSampleDropVisitorRule_ajax/';}
$.ajax({type:"GET",dataType:'json',cache:false,url:delete_url+selected_rule_id_value.attr('office_vistor_rule_id'),success:function(responseText,statusText){if(responseText.success==-2){$.fn.jmodal({title:'ALERT',content:'Could not find the selected rule associated to your office, please try again',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else if(responseText.success==-1){$.fn.jmodal({title:'ALERT',content:'Please Login to the system',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else if(responseText.success==0){$.fn.jmodal({title:'ALERT',content:'An internal error occured, please try again',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
else{$("#delete_visitor_rule_success_message_cont").show();setTimeout('$("#delete_visitor_rule_success_message_cont").hide();',3000);}
s.loadOfficeCurrentVistorRules();s.loadOfficeCurrentFavVistorRules();s.loadOfficeCurrentSampleRules();}});}});};s.deleteSelectedOpeningsClosures=function(){var obj_selected_opening_row=$('#opening_container > ul').find('li.selected_provider');var obj_selected_closures_row=$('#closures_container > ul').find('li.selected_provider');var action="";var row_id="";var delete_url='';var std_holiday_id=0;var delete_opening=false;if((!obj_selected_opening_row||!obj_selected_opening_row.attr('opening_id'))&&(!obj_selected_closures_row||!obj_selected_closures_row.attr('closures_id'))){return;}
if(obj_selected_opening_row.attr('opening_id')){action="opening";row_id=obj_selected_opening_row.attr('opening_id');delete_url='/office/myoffice_schedule_openings_closures/deleteOpeningSchedule_ajax/';delete_opening=true;}
if(obj_selected_closures_row.attr('closures_id')){action="closures";row_id=obj_selected_closures_row.attr('closures_id');delete_url='/office/myoffice_schedule_openings_closures/deleteClosuresSchedule_ajax/';std_holiday_id=obj_selected_closures_row.attr('master_id');}
$.fn.jmodal({title:'ALERT',content:'Are you sure you want to delete the selected recurring schedule?',buttonText:{ok:'Yes',cancel:"No"},okEvent:function(obj,args){$.fn.hideJmodalInstantly();$.ajax({type:"GET",dataType:'json',cache:false,url:delete_url+row_id,success:function(responseText,statusText){$.fn.jmodal({title:'ALERT',content:'Recurring schedule deleted successfully.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});$("#opening_closures_widget_container").html(responseText.html);if(action=="opening")s.changeToOpeningsTab();if(action=="closures")s.changeToClosuresTab();s.attachEventToOpeningClosuresRowClick();if(std_holiday_id>0){var checkbox_id="#holidays"+std_holiday_id;var obj_checkbox=$(checkbox_id);obj_checkbox.attr('checked',false);}
if(delete_opening){s.load_appointments();}}});}});};s.attachEventToOpeningClosuresRowClick=function()
{$('#opening_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#closures_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#delete_recurring_schedule').live('click',s.deleteSelectedOpeningsClosures);};s.doFinishOfficeReg=function(){var success=true;var msg='';if(!$('#tabs-4 li').length){msg+='You did not create any recurring openings.\n';success=false;}else{if(!$('#office_vistor_rules_listing > li').length){msg+='You have not created any rep visitation rules.\n';success=false;}}
if(!$('#recurring-closures-list > li').length){msg+='You did not identify any closures.\n';success=false;}
if(!success){msg+='Are you sure you want to continue?';success=confirm(msg);}
if(success){$.ajax({type:"GET",dataType:'json',cache:false,url:'/office/myoffice_schedule/complete_registration',success:function(responseText,statusText){if(responseText.success){window.location.href="/office/myoffice";}else{$.fn.jmodal({title:'ALERT',content:'Unable to complete registration.  Please go back and make sure you completed all steps.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}}});}};s.changeToOpeningsTab=function(){s.removeCurrentOpeningClosuresSelectionClass();$('#opening_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#closures_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#delete_recurring_schedule').live('click',s.deleteSelectedOpeningsClosures);$("#openings_tab").removeClass("active");$("#closures_tab").removeClass("active");$("#openings_tab").addClass("active");$("#opening_container").css("display","block");$("#closures_container").css("display","none");};s.changeToClosuresTab=function(){s.removeCurrentOpeningClosuresSelectionClass();$('#opening_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#closures_container > ul > li').bind('click',s.handleCurrentOpeningClosuresSelected);$('#delete_recurring_schedule').live('click',s.deleteSelectedOpeningsClosures);$("#openings_tab").removeClass("active");$("#closures_tab").removeClass("active");$("#closures_tab").addClass("active");$("#opening_container").css("display","none");$("#closures_container").css("display","block");};s.setMyOpeningDate=function(dateText,inst){if(dateText.length<10)return 1;var date_list=dateText.split("/");if(date_list.length<3||date_list.length>3)return 1;for(i=0;i<date_list.length;i++){if(i==0){$('#office_schedule_opening_month').attr('value',date_list[0]);}
if(i==1){$('#office_schedule_opening_day').attr('value',date_list[1]);}
if(i==2){$('#office_schedule_opening_year').attr('value',date_list[2]);}}};s.load_appointments=function()
{$.ajax({type:'GET',url:'/office/myoffice_schedule_import/load_appointments',cache:false,dataType:"json",success:function(responseText,statusText){if(responseText.html){$('#import-appointment-list').html(responseText.html);}}});};s.load_reps=function()
{$.ajax({type:'GET',url:'/office/myoffice_schedule_openings_closures/createAppointmentsForMyOffice',cache:false,dataType:"json",success:function(responseText,statusText){if(responseText.html){$('#import-appointment-list').html(responseText.html);}}});};s.load_appointment_info=function()
{s.current_import_appt_id=$(this).attr('appt_id');$('.appt_item').removeClass('selected');$(this).addClass('selected');$('#import-appointment-default-msg').hide();$('#import-appt-date').html($(this).attr('date_display'));var import_about=$(this).attr('meeting_type')+' from '+$(this).attr('start_time')+' to '+$(this).attr('end_time');$('#import-appt-about').html(import_about);var status=$(this).attr('status');if(status=='Pending'){status='Booked';}
$('#import-appt-status').html(status);$('#import-appointment-info').show();$('#import-appointment-rep-info').show();$('#appointment-create-errors').hide();};s.do_assign_rep=function(appt_id,rep_id)
{$.ajax({type:'GET',url:'/office/myoffice_schedule_import/assign_rep/'+appt_id+'/'+rep_id,cache:false,dataType:"json",success:function(responseText,statusText){if(responseText.success){$('#import-appointment-info').hide();$('#import-appointment-rep-info').hide();$('#import-appointment-default-msg').show();$('#appt-rep-'+appt_id).html('with '+responseText.rep_name);var status=responseText.appt_status;if(status=='Pending'){status='Booked';}
$('#appt-item-'+appt_id).removeClass('selected').attr('status',responseText.appt_status);$('#assign_rep_id').val('');$('#import-appointment-rep-info').html(responseText.html);s.add_new_rep_form();}}});};s.assign_rep=function()
{var rep_id=$('#assign_rep_id').val();if(!rep_id){$.fn.jmodal({title:'ALERT',content:'Sorry, This rep is not valid.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});return;}
var appt_id=s.current_import_appt_id;if(!appt_id){$.fn.jmodal({title:'ALERT',content:'Sorry, This appointment is not valid.',buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});return;}
var rep_name=$('#appt-rep-'+s.current_import_appt_id).html().replace(/^\s+|\s+$/g,"");if(rep_name.length>0){if(!confirm('You already have a rep assigned to this appointment.\nAre you sure you want to reassign?')){return false;}}
s.do_assign_rep(appt_id,rep_id);};s.submit_new_rep_form=function()
{var rep_name=$('#appt-rep-'+s.current_import_appt_id).html().replace(/^\s+|\s+$/g,"");if(rep_name.length>0){if(!confirm('You already have a rep assigned to this appointment.\nAre you sure you want to reassign?')){return false;}}
$('#new-rep-form-appt-id').val(s.current_import_appt_id);$('#form_new_rep').submit();};s.add_new_rep_form=function()
{$('#form_new_rep').bind('submit',function(){$(this).ajaxSubmit({dataType:'json',beforeSubmit:function(formData,jqForm,options){},success:function(responseText,statusText){if(responseText.success){$('#import-appointment-rep-info').html(responseText.html);$('#import-appointment-info').hide();$('#import-appointment-rep-info').hide();$('#import-appointment-default-msg').show();$('#appt-rep-'+responseText.appt_id).html('with '+responseText.rep_name);var status=responseText.appt_status;if(status=='Pending'){status='Booked';}
$('#appt-item-'+responseText.appt_id).removeClass('selected').attr('status',responseText.appt_status);$('#assign_rep_id').val('');s.add_new_rep_form();}else{if(responseText.user_exists){$.fn.jmodal({title:'Rep Found',content:'This phone number is already registered for <b>'+responseText.user_info[0].First_Name+' '+responseText.user_info[0].Last_Name+'</b>. Would you like to reserve this appointment for them instead?',buttonText:{ok:'Yes',cancel:'No'},okEvent:function(obj,args){args.complete();s.do_assign_rep(responseText.appt_id,'reg-'+responseText.user_info[0].id);}});}else{$('#appointment-create-errors').show();$('#appointment-create-errors .error_text').html(responseText.errors);}}}});return false;});};s.cancel_add_rep=function()
{$.ajax({type:'GET',url:'/office/myoffice_schedule_import/clear_rep_info',cache:false,dataType:"json",success:function(responseText,statusText){$('#import-appointment-rep-info').html(responseText.html);s.add_new_rep_form();}});};};;$.accountinfo=function(){var r=this;r.init=function(){r.bindstep1Form();};r.stepSubmit=function(tab){r.enableTab(tab);$('#tabs').tabs('option','selected',tab);r.manageTabs(tab);};r.enableTab=function(tab){$('#tabs').tabs('option','disabled',[0,1,2]);$('#tabs').tabs('enable',tab);};r.registrationStepOne=function(event){if(event.keyCode!=13)return false;$('#step1').submit();return false;};r.bindstep1Form=function(){if($("#Office_Phone").length>0){$("#Office_Phone").mask("(999) 999-9999");}
if($("#Address_Zip_Code").length>0){$("#Address_Zip_Code").mask("99999");}
$('#Office_Size').bind("blur","Office_Size",isIntKeyPress);$('#User_Extension_No').bind("blur","User_Extension_No",isIntKeyPress);$('#submit_step_one').live('keyup',r.registrationStepOne);$('#step1').live('keyup',r.registrationStepOne);$('#step1').ajaxForm({dataType:'json',beforeSubmit:function(formData,jqForm,options)
{},success:function(responseText,statusText){if(responseText.success){if(responseText.goto_tab){$.myoffice.show_tab(responseText.goto_tab);}
if(responseText.message){$.fn.jmodal({title:'ALERT',content:responseText.message,buttonText:{ok:'Close'},okEvent:function(obj,args){args.complete();}});}
$('span.errormsg').hide();}
else{if(responseText.reg_complete){$("#tabs-11").html(responseText.html);}else{$("#tabs-1").html(responseText.html);}
r.bindstep1Form();}}});}};function IsStringBlank(pStr)
{if(pStr==null)return true;for(var i=0;i<pStr.length;i++)
{if((pStr.charAt(i)!=' ')&&(pStr.charAt(i)!="\t")&&(pStr.charAt(i)!="\n")&&(pStr.charAt(i)!="\r"))return false;}
return true;}
function IsIntegerValue(pVal)
{if(IsStringBlank(pVal))return false;var digits="1234567890";for(var i=0;i<pVal.length;i++)
{if(digits.indexOf(pVal.charAt(i))==-1)return false;}
return true;}
function isIntKeyPress(e){var id=e.data;var input_val=$("#"+id).attr('value');if(IsIntegerValue(input_val)==false){$("#"+id).attr('value','');}}
function handleFocusOfTextField(fieldElement,defaultFieldValue,isFormSubmission)
{if(!fieldElement||!defaultFieldValue)return;if(fieldElement.value==defaultFieldValue){fieldElement.value='';$('#'+fieldElement.id).removeClass('unactive');$('#'+fieldElement.id).addClass('active');}}
function handleBlurOfTextField(fieldElement,defaultFieldValue,isFormSubmission)
{if(!fieldElement||!defaultFieldValue)return;if(!isFormSubmission){if(!fieldElement.value||fieldElement.value==''||fieldElement.value==' '){fieldElement.value=defaultFieldValue;$('#'+fieldElement.id).removeClass('active');$('#'+fieldElement.id).addClass('unactive');}}
if(isFormSubmission&&fieldElement.value==defaultFieldValue){fieldElement.value='';}}
function step1FormClearText()
{handleBlurOfTextField(document.getElementById('User_First_Name'),'First Name',true);handleBlurOfTextField(document.getElementById('User_Last_Name'),'Last Name',true);handleBlurOfTextField(document.getElementById('User_Email'),'(This will be your username)',true);handleBlurOfTextField(document.getElementById('User_Referrer_Name'),'Full Name',true);handleBlurOfTextField(document.getElementById('Office_Office_Manager_FName'),'First Name',true);handleBlurOfTextField(document.getElementById('Office_Office_Manager_LName'),'Last Name',true);handleBlurOfTextField(document.getElementById('Address_Line_1'),'Street Address',true);handleBlurOfTextField(document.getElementById('Address_City'),'City',true);}
function submitOfficeRegistrationStep1Form()
{step1FormClearText();$('#step1').submit();}