(function($){
Type.registerNamespace("Telerik.Web.UI.Scheduling");
Telerik.Web.UI.Scheduling.AdvancedTemplate=function SchedulerAdvancedTemplate(_2){
this._schedulerId=_2;
var _3=$("#"+_2+" .rsAdvBasicControls");
if(_3.length==0){
return;
}
var _4=_3[0].id;
this._templateId=_4.substring(0,_4.lastIndexOf("_"));
};
Telerik.Web.UI.Scheduling.AdvancedTemplate._adjustHeight=function(_5){
var _6=$("#"+_5);
var _7=_6.find(".rsAdvancedEdit");
var _8=_7.outerHeight()-_7.height();
var _9=_6.find(".rsAdvancedSubmitArea");
var _a=_9.outerHeight({margin:true});
var _b=_6.height()-_a-_8;
_6.find(".rsAdvOptionsScroll").height(_b+"px");
if(_9[0]){
_9[0].style.cssText=_9[0].style.cssText;
}
};
Telerik.Web.UI.Scheduling.AdvancedTemplate.prototype={initialize:function(){
if($("#"+this._schedulerId+" .rsAdvancedEdit").length==0){
return;
}
var _c=$find(this._schedulerId);
_c.add_disposing(Function.createDelegate(this,this.dispose));
$("#"+this._schedulerId+" .rsAdvancedSubmitArea a").attr("onclick","");
if(_c._overflowBehavior==1){
Telerik.Web.UI.Scheduling.AdvancedTemplate._adjustHeight(this._schedulerId);
}
this._initializePickers();
this._initializeAdvancedFormValidators();
this._initializeAllDayCheckbox();
var _d=$("#"+this._templateId+"_RecurrencePanel").length>0;
if(_d){
this._initializeRecurrenceCheckbox();
this._initializeResetExceptions();
this._initializeRecurrenceRadioButtons();
this._initializeLinkedRecurrenceControls();
}
if($telerik.isIE){
var _e=$("#"+this._schedulerId+" .textareaWrapper textarea")[0];
_e.style.cssText=_e.style.cssText;
}
},dispose:function(){
$("#"+this._schedulerId+" *").unbind();
this._pickers=null;
},_initializePickers:function(){
var _f=Function.createDelegate(this,this._showPopup);
var _10=this._templateId;
this._pickers={"startDate":$find(_10+"_StartDate"),"endDate":$find(_10+"_EndDate"),"rangeEndDate":$find(_10+"_RangeEndDate"),"startTime":$find(_10+"_StartTime"),"endTime":$find(_10+"_EndTime")};
$.each(this._pickers,function(){
if(this&&this.get_dateInput){
this.get_dateInput().add_focus(_f);
}
});
var _11=[$get(this._pickers.startDate.get_element().id+"_wrapper"),$get(this._pickers.startTime.get_element().id+"_wrapper"),$get(this._pickers.startTime.get_element().id+"_timeView_wrapper"),$get(this._pickers.endDate.get_element().id+"_wrapper"),$get(this._pickers.endTime.get_element().id+"_wrapper"),$get(this._pickers.endTime.get_element().id+"_timeView_wrapper"),$get(this._templateId+"_SharedCalendar")];
if(this._pickers.rangeEndDate){
Array.add(_11,$get(this._pickers.rangeEndDate.get_element().id+"_wrapper"));
}
var _12=this;
var _13="focusin";
$("#"+this._schedulerId+" .rsAdvancedEdit").bind(_13,function(e){
var _15=false;
for(var i=0,len=_11.length;i<len;i++){
var _18=_11[i];
if($telerik.isDescendantOrSelf(_18,e.target)){
_15=true;
break;
}
}
if(!_15){
_12._hidePickerPopups();
}
});
},_initializeAdvancedFormValidators:function(){
var _19=this._createValidatorToolTip();
for(var _1a in Page_Validators){
var _1b=Page_Validators[_1a];
if(this._validatorIsInTemplate(_1b)){
var _1c=$("#"+_1b.controltovalidate);
if(_1c.length==0){
break;
}
if(_1c.parent().is(".rsAdvDatePicker")||_1c.parent().is(".rsAdvTimePicker")){
$("#"+_1b.controltovalidate+"_dateInput_text").bind("focus",{"toolTip":_19},this._showToolTip).bind("blur",{"toolTip":_19},this._hideToolTip)[0].errorMessage=_1b.errormessage;
}else{
_1c.addClass("rsValidatedInput");
}
_1c[0].errorMessage=_1b.errormessage;
this._updateValidator(_1b,_1c);
}
}
var _1d=this;
var _1e=ValidatorUpdateDisplay;
ValidatorUpdateDisplay=function(_1f){
if(_1d._validatorIsInTemplate(_1f)){
_1d._updateValidator(_1f);
}else{
_1e(_1f);
}
};
$("#"+this._schedulerId+" .rsValidatedInput").bind("focus",{"toolTip":_19},this._showToolTip).bind("blur",{"toolTip":_19},this._hideToolTip);
},_initializeAllDayCheckbox:function(){
var _20=$("#"+this._schedulerId+" .rsTimePick").eq(0).outerWidth();
var _21=_20-$("#"+this._templateId+"_StartTime_wrapper").outerWidth();
var _22=$get(this._templateId+"_StartTimeValidator");
var _23=$get(this._templateId+"_StartTimeValidator");
var _24=$("#"+this._templateId+"_AllDayEvent");
var _25=$(_24[0].parentNode.parentNode.parentNode);
var _26=this;
_25.find(".rsAdvTimePicker > input").css("display","none");
var _27=function(_28,_29){
var _2a=_25.find(".rsAdvTimePicker");
if(_29){
_2a.animate({opacity:_28?"hide":"show"},"slow");
}else{
if(_28){
_2a.hide();
}else{
_2a.show();
}
}
_25.find(".rsTimePick").each(function(i){
if(_29){
$(this).animate({width:_28?_21:_20},"slow");
}else{
if(_28){
$(this).width(_21);
}
}
});
ValidatorEnable(_22,!_28);
ValidatorEnable(_23,!_28);
var _2c=_26._pickers.startTime;
_2c.set_enabled(!_28);
_2c.get_element().parentNode.disabled=_28?"disabled":"";
var _2d=_26._pickers.endTime;
_2d.set_enabled(!_28);
_2d.get_element().parentNode.disabled=_28?"disabled":"";
};
_27(_24[0].checked,false);
_24.click(function(e){
_27(this.checked,true);
});
},_initializeRecurrenceCheckbox:function(){
var _2f=$("#"+this._templateId+"_RecurrencePanel");
var _30=$("#"+this._templateId+"_RecurrentAppointment");
if(_30[0].checked){
_2f.show();
}
_30.click(function(e){
_2f.animate({opacity:"toggle",height:"toggle"},"slow");
});
},_initializeResetExceptions:function(){
var _32=$("#"+this._templateId+"_ResetExceptions");
if(_32.length==1){
var _33=$find(this._schedulerId);
var _34=_33.get_localization().AdvancedDone;
if(_32[0].innerHTML.indexOf(_34)>-1){
_32.click(function(e){
return false;
});
window.setTimeout(function(){
_32.fadeOut("slow");
},2000);
}else{
var _36=this;
_32.click(function(e){
var _38=$telerik.$.modal("#"+_33.get_element().id+">.rsAdvancedEdit");
localization=_33.get_localization();
_38.initialize().set_content({title:localization.ConfirmResetExceptionsTitle,content:localization.ConfirmResetExceptionsText,ok:localization.ConfirmOK,cancel:localization.ConfirmCancel}).set_onActionConfirm(function(_39){
var _3a=localization.AdvancedWorking;
_32[0].innerHTML=_3a;
window.location.href=_32[0].href;
_38.dispose();
}).show();
return false;
});
}
}
},_initializeRecurrenceRadioButtons:function(){
var _3b=[$get(this._templateId+"_RepeatFrequencyHourly"),$get(this._templateId+"_RepeatFrequencyDaily"),$get(this._templateId+"_RepeatFrequencyWeekly"),$get(this._templateId+"_RepeatFrequencyMonthly"),$get(this._templateId+"_RepeatFrequencyYearly")];
var _3c=$("#"+this._templateId+"_RecurrencePatternPanel .rsAdvPatternPanel");
var _3d=function(_3e){
var _3f=_3e.value.replace("RepeatFrequency","RecurrencePattern")+"Panel";
return _3c.filter("[id$='"+_3f+"']");
};
for(var i=0,len=_3b.length;i<len;i++){
var _42=_3b[i];
if(_42.checked){
_3d(_42).show();
}
$(_42).click(function(){
var _43=$(_3d(this));
if(_43.css("display")=="none"){
_3c.hide();
_43.fadeIn("slow");
}
});
}
},_initializeLinkedRecurrenceControls:function(){
var _44={};
var id=this._templateId;
var hid="#"+id;
_44[id+"_RepeatEveryNthDay"]=[$(hid+"_DailyRepeatInterval")];
_44[id+"_RepeatEveryNthMonthOnDate"]=[$(hid+"_MonthlyRepeatDate"),$(hid+"_MonthlyRepeatIntervalForDate")];
_44[id+"_RepeatEveryNthMonthOnGivenDay"]=[$(hid+"_MonthlyDayOrdinalDropDown"),$(hid+"_MonthlyDayMaskDropDown"),$(hid+"_MonthlyRepeatIntervalForGivenDay")];
_44[id+"_RepeatEveryYearOnDate"]=[$(hid+"_YearlyRepeatMonthForDate"),$(hid+"_YearlyRepeatDate")];
_44[id+"_RepeatEveryYearOnGivenDay"]=[$(hid+"_YearlyDayOrdinalDropDown"),$(hid+"_YearlyDayMaskDropDown"),$(hid+"_YearlyRepeatMonthForGivenDay")];
_44[id+"_RepeatGivenOccurrences"]=[$(hid+"_RangeOccurrences")];
_44[id+"_RepeatUntilGivenDate"]=[$(hid+"_RangeEndDate_dateInput_text")];
$.each(_44,function(_47){
var _48=$("#"+_47);
var _49=_44[_47][0];
_48.click(function(){
if(_49.css("visibility")=="hidden"){
var _4a=$("#"+_49[0].id+"_text");
if(_4a){
_4a.focus();
}
}else{
_49.focus();
}
});
$.each(_44[_47],function(){
$(this).focus(function(){
_48[0].checked=true;
});
});
});
},_updateValidator:function(_4b){
var _4c=$("#"+_4b.controltovalidate);
if(_4c.is("textarea")){
_4c=_4c.parent();
}
if(!_4b.isvalid){
_4c.addClass("rsInvalid");
}else{
_4c.removeClass("rsInvalid");
}
},_validatorIsInTemplate:function(_4d){
return $(_4d).parents().is("#"+this._schedulerId);
},_createValidatorToolTip:function(){
return $("<div class=\"rsValidatorTooltip\">Test</div>").hide().appendTo("#"+this._schedulerId);
},_showToolTip:function(e){
var _4f=e.data.toolTip;
var _50=$(this);
var _51=false;
if(_50.is("textarea")){
_51=true;
_50=_50.parent();
}
var _52=_50.is(".rsInvalid");
_52=_52||_50.parent().parent().children().is(".rsInvalid");
if(_52){
_4f.css("visibility","hidden").text(this.errorMessage);
var _53=$(_50).parents(".RadScheduler").offset();
var pos=_50.offset();
pos.left-=_53.left;
pos.top-=_53.top;
var _55=pos.left+"px";
if(_51){
_55=(pos.left+_50.outerWidth()-_4f.outerWidth())+"px";
}
var _56=(pos.top-_4f.outerHeight())+"px";
_4f.css({top:_56,left:_55,visibility:"visible"}).fadeIn("fast");
}
},_hideToolTip:function(e){
var _58=e.data.toolTip;
_58.hide();
},_hidePickerPopups:function(){
if(!this._pickers){
return;
}
for(var _59 in this._pickers){
var _5a=this._pickers[_59];
if(!_5a){
continue;
}
if(_5a.hideTimePopup){
_5a.hideTimePopup();
}else{
_5a.hidePopup();
}
}
},_showPopup:function(_5b,_5c){
this._hidePickerPopups();
if(_5b.Owner.showTimePopup){
_5b.Owner.showTimePopup();
}else{
_5b.Owner.showPopup();
}
}};
})($telerik.$);

