jQuery.fn.initCalendarGizmo=function(){var multiPostableGizmo1=jQuery("#calendar-first-selector-gizmo");var multiPostableGizmo=jQuery("#calendar-second-selector-gizmo");var calendarConfigurator=jQuery("#calendar-configurator");jQuery("#calendar-table td.day-existing:not(.week-selector)").click(function(e){var tgt=jQuery(e.target);if(tgt.is("span")){var tgt=tgt.parent("td")}var tdId=tgt.attr("id").substring(7);var form=tgt.parents("form:first");var inputEl=jQuery("input[name*="+tdId+"]",form);if(inputEl.length){inputEl.remove();tgt.removeClass("day-selected");if(jQuery("input[name^='calendar-table']",form).length==0){calendarConfigurator.hide()}}else{form.prepend('<input type="hidden" name="calendar-table['+tdId+']" value="'+tdId+'" />');tgt.addClass("day-selected");calendarConfigurator.show();jQuery(".selector-gizmo",calendarConfigurator).each(function(){if(jQuery("ul",this).height()>250){jQuery("ul",this).height("250px")}})}e.preventDefault()});jQuery("#calendar-table .week-selector").click(function(e){var tgt=jQuery(e.target);var form=tgt.parents("form:first");if(jQuery(e.target).is("img")){var tgt=tgt.parent("td")}var tdSiblings=tgt.nextAll(".day-existing");var nSelectedInWeek=tgt.nextAll(".day-selected").size();var nDaysInWeek=tdSiblings.size();var inputCalTable=jQuery("input[name^='calendar-table']",form);tdSiblings.each(function(){var tdId=jQuery(this).attr("id").substring(7);if(nSelectedInWeek!=nDaysInWeek){form.prepend('<input type="hidden" name="calendar-table['+tdId+']" value="'+tdId+'" />');jQuery(this).addClass("day-selected");calendarConfigurator.show()}else{jQuery("input[name*="+tdId+"]",form).remove();jQuery(this).removeClass("day-selected");if(inputCalTable.length==0){calendarConfigurator.hide()}}});e.preventDefault()});jQuery("#c-m-s-next-month").click(function(e){var cName=jQuery("#c-m-s-next-month").attr("class");var y=cName.substr(6,4);var m=cName.substr(10,2);$("#calendar-response").load("/util/ajaxresponse.php",{func:"outputCalendar",y:y,m:m},function(){$("calendar-area").initCalendarGizmo()});e.preventDefault()});jQuery("#c-m-s-prev-month").click(function(e){var cName=jQuery("#c-m-s-prev-month").attr("class");var y=cName.substr(6,4);var m=cName.substr(10,2);$("#calendar-response").load("/util/ajaxresponse.php",{func:"outputCalendar",y:y,m:m},function(){$("calendar-area").initCalendarGizmo()});e.preventDefault()});jQuery(".sublevels-selector",calendarConfigurator).click(function(e){var tgt=jQuery(e.target);var liEl=tgt.parents().eq(0);var multiPostableGizmoId=multiPostableGizmo.attr("id");var theForm=multiPostableGizmo.parents("form").eq(0);var contentToPrepend="";if(liEl.hasClass("c-s-s-g-vrh")){var allLis=liEl.nextAll().andSelf();var allSelected=false;var allCount=allLis.length;var selectedCount=allLis.filter(".selected").length;if(allCount==selectedCount){allSelected=true}allLis.each(function(){var thisLi=jQuery(this);var temp=thisLi.attr("id").split("-");var hiddenVal=temp[temp.length-1];if(allSelected==false){thisLi.addClass("selected");if(jQuery("input[name='"+multiPostableGizmoId+"["+hiddenVal+"]']").length==0){theForm.attr("method","post");contentToPrepend+='<input type="hidden" name="'+multiPostableGizmoId+"["+hiddenVal+']" value="'+hiddenVal+'" />'}}else{thisLi.toggleClass("selected");var hiddenToRemove=jQuery("input[name='"+multiPostableGizmoId+"["+hiddenVal+"]']");if(hiddenToRemove.length){hiddenToRemove.remove()}else{theForm.attr("method","post");contentToPrepend+='<input type="hidden" name="'+multiPostableGizmoId+"["+hiddenVal+']" value="'+hiddenVal+'" />'}}});theForm.prepend(contentToPrepend);contentToPrepend=""}else{if(liEl.hasClass("c-s-s-g-vsrs")){var allSelected=false;var aLiElements=[liEl];jQuery.merge(aLiElements,liEl.nextAll());var allCount=0;var selectedCount=0;jQuery.each(aLiElements,function(){var thisLi=jQuery(this);if((liEl.attr("id")!=thisLi.attr("id"))&&(thisLi.hasClass("c-s-s-g-vsrs"))){return false}else{allCount++;if(thisLi.hasClass("selected")){selectedCount++}}});if(allCount==selectedCount){allSelected=true}jQuery.each(aLiElements,function(){var thisLi=jQuery(this);var temp=thisLi.attr("id").split("-");var hiddenVal=temp[temp.length-1];if(allSelected==false){if((liEl.attr("id")!=thisLi.attr("id"))&&(thisLi.hasClass("c-s-s-g-vsrs"))){return false}else{thisLi.addClass("selected");if(jQuery("input[name='"+multiPostableGizmoId+"["+hiddenVal+"]']").length==0){theForm.attr("method","post");contentToPrepend+='<input type="hidden" name="'+multiPostableGizmoId+"["+hiddenVal+']" value="'+hiddenVal+'" />'}}}else{if((liEl.attr("id")!=thisLi.attr("id"))&&(thisLi.hasClass("c-s-s-g-vsrs"))){return false}else{thisLi.toggleClass("selected");var hiddenToRemove=jQuery("input[name='"+multiPostableGizmoId+"["+hiddenVal+"]']");if(hiddenToRemove.length){hiddenToRemove.remove()}else{theForm.attr("method","post");contentToPrepend+='<input type="hidden" name="'+multiPostableGizmoId+"["+hiddenVal+']" value="'+hiddenVal+'" />'}}}});theForm.prepend(contentToPrepend);contentToPrepend=""}else{if(liEl.hasClass("c-s-s-g-okr")){var allSelected=false;var aLiElements=[liEl];jQuery.merge(aLiElements,liEl.nextAll());var allCount=0;var selectedCount=0;jQuery.each(aLiElements,function(){var thisLi=jQuery(this);if((liEl.attr("id")!=thisLi.attr("id"))&&(thisLi.hasClass("c-s-s-g-okr"))){return false}else{allCount++;if(thisLi.hasClass("selected")){selectedCount++}}});if(allCount==selectedCount){allSelected=true}jQuery.each(aLiElements,function(){var thisLi=jQuery(this);var temp=thisLi.attr("id").split("-");var hiddenVal=temp[temp.length-1];if(allSelected==false){if(thisLi.hasClass("c-s-s-g-okr")&&(liEl.attr("id")!=thisLi.attr("id"))){return false}else{thisLi.addClass("selected");if(jQuery("input[name='"+multiPostableGizmoId+"["+hiddenVal+"]']").length==0){theForm.attr("method","post");contentToPrepend+='<input type="hidden" name="'+multiPostableGizmoId+"["+hiddenVal+']" value="'+hiddenVal+'" />'}}}else{if(thisLi.hasClass("c-s-s-g-okr")&&(liEl.attr("id")!=thisLi.attr("id"))){return false}else{thisLi.toggleClass("selected");var hiddenToRemove=jQuery("input[name='"+multiPostableGizmoId+"["+hiddenVal+"]']");if(hiddenToRemove.length){hiddenToRemove.remove()}else{theForm.attr("method","post");contentToPrepend+='<input type="hidden" name="'+multiPostableGizmoId+"["+hiddenVal+']" value="'+hiddenVal+'" />'}}}});theForm.prepend(contentToPrepend)}}}e.preventDefault()});jQuery("#calendar-form input[name*=calendar-table]").each(function(){var name=jQuery(this).attr("name");var split1=name.split("[");var split2=split1[1].split("]");var id=split2[0];jQuery("#ct-day-"+id).addClass("day-selected")});if(jQuery("#calendar-form input[name*=calendar-table]").length>0){calendarConfigurator.show()}jQuery("#calendar-form input[name*=calendar-first-selector-gizmo]").each(function(){jQuery("#c-f-s-g-"+jQuery(this).attr("value"),multiPostableGizmo1).addClass("selected")});jQuery("#calendar-form input[name*=calendar-second-selector-gizmo]").each(function(){jQuery("#c-s-s-g-item-"+jQuery(this).attr("value"),multiPostableGizmo).addClass("selected")})};