if('object'!=typeof FO){FO={}}
FO.apply=function(o,c,defaults){if(defaults){FO.apply(o,defaults);}
if(o&&c&&typeof c=='object'){for(var p in c){o[p]=c[p];}}
return o;};FO.Core=function(){var xhr=new Object(),uniqueCounter=0,scrollWidth=0;return{iniqueID:function(el,prefix){var $el=$(el),id=(prefix||"id-gen")+(++uniqueCounter);if($el.length){id=$el.attr('id',''==$el.attr('id')?id:$el.attr('id')).attr('id');}
return id;},defineNs:function(ns){var o,d;$.each(arguments,function(index,val){d=val.split(".");o=window[d[0]]=window[d[0]]||{};$.each(d.slice(1),function(index,v2){o=o[v2]=o[v2]||{};});});return o;},extend:function(){var io=function(o){for(var m in o){this[m]=o[m];}};var oc=Object.prototype.constructor;return function(sb,sp,overrides){if(this.isObject(sp)){overrides=sp;sp=sb;sb=overrides.constructor!=oc?overrides.constructor:function(){sp.apply(this,arguments);};}
var F=function(){},sbp,spp=sp.prototype;F.prototype=spp;sbp=sb.prototype=new F();sbp.constructor=sb;sb.superclass=spp;if(spp.constructor==oc){spp.constructor=sp;}
sb.override=function(o){this.override(sb,o);};sbp.superclass=sbp.supr=(function(){return spp;});sbp.override=io;this.override(sb,overrides);sb.extend=function(o){this.extend(sb,o);};return sb;};}(),isObject:function(v){return v&&typeof v=="object";},override:function(origclass,overrides){if(overrides){var p=origclass.prototype;this.apply(p,overrides);if(this.isIE&&overrides.toString!=origclass.toString){p.toString=overrides.toString;}}},isIE:function(){return $.support.opacity;},apply:function(o,c,defaults){if(defaults){FO.Core.apply(o,defaults);}
if(o&&c&&typeof c=='object'){for(var p in c){o[p]=c[p];}}
return o;},initAjaxForm:function(form,onSuccess,beforeSubmit,url,dataType,clearAfterSubmit){var params={success:onSuccess,beforeSubmit:beforeSubmit,dataType:undefined!=dataType?dataType:'json',clearForm:undefined!=clearAfterSubmit?clearAfterSubmit:false}
if(undefined!=url){params['url']=url;}
$(form).ajaxForm(params);},load:function(container,url,data,before,after,global,alone){alone=undefined!==alone?alone:true;if('function'==typeof xhr.abort&&alone){FO.Layout.hideVisiblePreloader();xhr.abort();}
xhr=$.ajax({url:url,dataType:'html',global:undefined!=global?global:true,data:data,type:"POST",beforeSend:function(){if('function'==typeof before){before();}},success:function(html){var jContainer=(container instanceof jQuery)&&container.length?container:$(container);jContainer.html(html).trigger('sizeChange');if('function'==typeof after){after();}}})},link:function(module,controller,action,params,router){var bp=OSDN.BASE_PATH;if(true===/\.js$/.test(module)){return bp+module;}
var p=[];for(k in params){p.push(k);p.push(params[k]);}
var type='json';var link=[bp];if(router!='html'){link.push(type);}
link=link.concat([module,controller,action]).concat(p).join('/');if(!/\/$/.test(link)){link+='/';}
return link;},addOption:function(selectElId,options,clear){var el=$(selectElId)[0];if(clear){el.options.length=0;}
for(var val in options){try{el.add(new Option(options[val],val),null);}catch(ex){el.add(new Option(options[val],val));}}},setSelectedOption:function(selectElId,optionVal){if(''!=optionVal){var el=$(selectElId)[0],found=false;for(var i=el.options.length;i--;){if(optionVal==el.options[i].value){el.selectedIndex=i;found=true;break;}}
if(!found){el.selectedIndex=0;}}},redirect:function(url){window.location.href=url;},getScrollerWidth:function(){if(!scrollWidth){document.body.style.overflow='hidden';scrollWidth=document.body.clientWidth;document.body.style.overflow='scroll';scrollWidth-=document.body.clientWidth;if(!scrollWidth){scrollWidth=document.body.offsetWidth-document.body.clientWidth;}
document.body.style.overflow='';}
return scrollWidth;},reverseEventsQueue:function(el,event){var events=$(el).data("events");if(events!=undefined&&events[event]!=undefined){var reverseEvent=new Array;for(var e in events[event]){reverseEvent.unshift(events[event][e]);}
events[event]=reverseEvent;}}}}();;FO.Layout=function(){var tempContainerId=null,msgContainer=null,$visibleOverlay=null,preloaderHTMLStart='<div class="preloader"><div class="caption">',preloaderCaption='',preloaderHTMLEnd='</div></div>',$preloader=undefined;function overlayParentChanged(event){setOverlayDimentions(event.data.$el);}
function setOverlayDimentions($overlayEl){if($overlayEl.length){$visibleOverlay=$overlayEl;var $parent=$overlayEl.parent();$parent=$parent.hasClass('preloader-container')?$parent.parent():$parent;if($parent instanceof jQuery){$overlayEl.height($parent.height()).width($parent.width());if(!$parent.hasEvent('sizeChange')){$parent.bind('sizeChange',{$el:$overlayEl},overlayParentChanged);}}}
return $overlayEl;}
function createPreloader($parent,caption,showCaption){if(showCaption){preloaderCaption=caption?caption:'Processing...';}else{preloaderCaption='';}
var html=preloaderHTMLStart+preloaderCaption+preloaderHTMLEnd;$preloader=$parent.prepend(html).find('>.preloader');}
return{setTreeMenuPreloader:function(){this.setPreloader('#left .module_menu .box-indent',' ');},setContentContainerPreloader:function(caption,showCaption){return this.setPreloader('[id^=container] > .content-top',caption,undefined==showCaption?true:false);},setAllContentContainerPreloader:function(caption){return this.setPreloader('#content-indent > .width',caption,true);},setPreloader:function(parentEl,caption,showCaption){var $preloaderParent=parentEl instanceof jQuery&&parentEl.length?parentEl:$(parentEl),bind=true,$newPreloader=$('>.preloader',$preloaderParent);if(!$newPreloader.length&&'object'!==typeof $preloader){createPreloader($preloaderParent,caption,showCaption);}else if(!$newPreloader.length&&'object'==typeof $preloader){$preloader.unbind();$preloader=undefined;createPreloader($preloaderParent,caption,showCaption);}else if($newPreloader.length&&'object'==typeof $preloader){if($preloader[0]!==$newPreloader[0]){$preloader.unbind();$preloader=$newPreloader;}else{bind=false;var $preloaderCaptionEl=$('> .caption',$preloader);if($preloaderCaptionEl.html()!==caption){$preloaderCaptionEl.html(caption);}}}
setOverlayDimentions($preloader);if(bind){$preloader.ajaxStart(function(){$preloader.fadeIn('fast');}).ajaxStop(function(){$preloader.fadeOut('fast');});}
return $preloader;},getPreloader:function(){return $preloader;},deactivateButton:function(parentEl,btnCaption){var $btns=$(parentEl+' .btn > .center').find('a, input[type!=file]'),inactive='<input type="button" disabled="disabled" value="'+btnCaption+'"/>';$btns.each(function(){var $this=$(this),caption=$this.is('a')?$this.html():$this.attr('value');caption=caption.replace(/^\s+|\s+$/g,'');if(caption==btnCaption){$this.replaceWith(inactive);return false;}});},initDateTimePickers:function(view){var dateObj=new Date(),day=dateObj.getDate()<10?'0'+dateObj.getDate():dateObj.getDate(),month=(dateObj.getMonth()+1)<10?'0'+(dateObj.getMonth()+1):dateObj.getMonth()+1,today=day.toString()+'-'+month.toString()+'-'+dateObj.getFullYear().toString(),$start=$('.start-date-range'),$end=$('.end-date-range');$('div[id*="datepicker_"]').remove();$('.datetime-picker').bind('removeData',function(){$(this).removeData('till').removeData('from');}).change(function(){var $el=$(this),$rangeEl=null,valueName='';if($el.hasClass('end-date-range')){$rangeEl=$start;valueName='till';}else if($el.hasClass('start-date-range')){$rangeEl=$end;valueName='from';}
if(null!==$rangeEl){if(''==this.value||null==this.value){$rangeEl.removeData(valueName);}else{var val=Date.parse(this.value.split('-').reverse().join('/'));if(val){$rangeEl.data(valueName,val);}}}}).each(function(){var $el=$(this),disabled,$startRange=$start,$endRange=$end;$el.DatePicker({format:'d-m-Y',view:view?view:'days',date:today,current:today,starts:1,onBeforeShow:function(){if(/^\d\d?[\.\/-]\d\d?[\.\/-]\d\d\d?\d?$/.test(this.value)){$el.data('currentDate',this.value);}else{$el.data('currentDate',today);}},onChange:function(formated,dates){if($el.hasClass('end-date-range')){$startRange.data('till',dates);}else if($el.hasClass('start-date-range')){$endRange.data('from',dates);}
if($el.data('currentDate')!==formated){$el.DatePickerHide();}
$el.removeClass('shaded-text').val(formated);},onRender:function(date){disabled=false;if($el.hasClass('end-date-range')){if(undefined!==$el.data('from')){disabled=date.valueOf()<$el.data('from').valueOf();}}else if($el.hasClass('start-date-range')){if(undefined!==$el.data('till')){disabled=date.valueOf()>$el.data('till').valueOf()-1;}}
return{disabled:disabled};}});if($el.val()){$el.triggerHandler("change");}});},hideDatePicker:function(){$('.datepicker:visible').hide();},setTempContainerId:function(elId){tempContainerId=elId;},getTempContainerId:function(){return tempContainerId;},setMsgContainer:function(elId){msgContainer=elId;return this;},getMsgContainer:function(){return msgContainer;},getVisibleOverlay:function(){return $visibleOverlay;},showMsg:function(msg,isError,callback,hideAfter){var url='',data={},container=this.getMsgContainer();if(!isError){url=FO.Core.link('default','message','info',null,'html');data['messages']=msg;}else{url=FO.Core.link('default','message','error',null,'html');data['errors']=msg;}
FO.Core.load(container,url,data,null,function(){$(container).slideDown('slow',function(){if('function'==typeof callback){callback();}
if(undefined!==hideAfter){FO.Layout.hideElementAfter(container,hideAfter);}});},false);return this;},hideMsg:function(){if(undefined!==msgContainer&&null!==msgContainer){$(msgContainer).slideUp('slow');}},prepareOverlay:function(el){if(undefined!==el){return setOverlayDimentions(el);}else if(undefined!==$preloader){return setOverlayDimentions($preloader);}},showPreloaderById:function(elId){var $preloader=$(elId);setOverlayDimentions($preloader);$preloader.fadeIn('slow');},showPreloader:function(){$preloader.fadeIn();},hidePreloaderById:function(elId){$(elId).fadeOut('fast');},hideVisiblePreloader:function(){return $('.preloader:visible').fadeOut('fast');},hideElementAfter:function(el,sec,callback){var delayFunc=function(){$(el).slideUp('slow',function(){if('function'==typeof callback){callback();}})}
setTimeout(delayFunc,sec*100);},setMenuItemSelected:function(el){$('a.selected-dark').toggleClass('selected-dark');var e=$(el);if(!e.hasClass('subcategory')){e.toggleClass('selected-dark');}},correctTableWidthForIE:function(table){var $table=$(table),$wrapper=$table.parent();if(!$.support.cssFloat&&!/MSIE 8.0/.test(navigator.appVersion)){if($table.height()>$wrapper.height()){$wrapper.addClass('indent-scroll-bar');}else{$wrapper.removeClass('indent-scroll-bar');}}},correctWidthForIE7:function(el){if(!$.support.cssFloat&&!/MSIE 8.0/.test(navigator.appVersion)){$(el).map(function(){var $this=this;if($this.clientHeight<$this.scrollHeight){$($this).css('padding-right',FO.Core.getScrollerWidth()+'px');}else{$($this).css('padding-right','');}})}},initTableSorting:function(){var unsortableCol=$('th.unsortable'),options={widgets:['zebra']},len=unsortableCol.length;if(len){options['headers']={}
unsortableCol.each(function(){options['headers'][$(this).index()]={sorter:false};});}
$('.tablesorter').tablesorter(options);},equalColumns:function(){var divs=$('div.equal'),max=0;divs.each(function(){max=Math.max(max,this.offsetHeight);});divs.css('height',max);},ellipsis:function(value,len,word){if(value&&value.length>len){if(word){var vs=value.substr(0,len-2),index=Math.max(vs.lastIndexOf(' '),vs.lastIndexOf('.'),vs.lastIndexOf('!'),vs.lastIndexOf('?'));if(index==-1||index<(len-15)){return value.substr(0,len-3)+"...";}else{return vs.substr(0,index)+"...";}}else{return value.substr(0,len-3)+"...";}}
return value;},threeDots:function(length,container){if(undefined==container){container=''}
$('.ellipsis',container).each(function(){var el=$(this),val=$.trim(el.text());el.text(FO.Layout.ellipsis(val,length,true)).attr('title',val).parent().attr('title',val);});}}}();;FO.AjaxPaging=function(config){this.init(config);};FO.AjaxPaging.prototype={scope:null,contentContainer:'.ajax-content',preloaderParentEl:null,disableAllPage:false,getClosest:false,onAfterPageChanged:$.noop,onBeforePageChanged:$.noop,init:function(config){var jPaging=$("p.ajax-pagination");if(jPaging.length){$.extend(true,this,config);this.initEvents();this.getClosest=jPaging.length>1;}},initEvents:function(){var self=this;$("p.ajax-pagination a").die("click").live("click",function(event){var jThis=$(this);if(self.getClosest){self.contentContainer=jThis.parent().closest(".ajax-content");}
if(self.disableAllPage){FO.Layout.setContentContainerPreloader();}else{if(self.contentContainer instanceof jQuery){self.preloaderParentEl=self.contentContainer;}else{self.preloaderParentEl=$(self.contentContainer);}
FO.Layout.setPreloader(self.preloaderParentEl.parent(),null,true);}
FO.Core.load(self.contentContainer,this.href,null,function(){self.onBeforePageChanged.call(self.scope||self);},function(){self.onAfterPageChanged.call(self.scope||self);});event.preventDefault();});}};;FO.Catalogue=function(config){this.init(config);}
FO.Catalogue.prototype={els:{},scope:null,onCourseClick:null,onAfterSearch:$.noop,init:function(config){this.scope=this;$.extend(true,this,config);this.initMarkup();},initMarkup:function(){var self=this;self.els.search=new FO.Form.AjaxSearch({onAfterSearch:function(){self.onAfterSearch.call(self.scope);self.els.search.init();}});self.initEvents();},initEvents:function(){var self=this;$('.course-name').live('click',function(){if('function'==typeof self.onCourseClick){self.onCourseClick(this);}else{self.loadCourseDetails('#course-details',$(this).parent().attr('class'),this.id);FO.Layout.setMenuItemSelected(this)}});$('.subcategory').live('click',function(){var catId=this.rel;self.getCourses(this,'cat-'+catId,catId,0,1);});$('.more-courses-previous, .more-courses-forward').live('click',function(){var $this=$(this);self.getCourses(this,$this.attr('containerId'),$this.attr('categoryId'),$this.attr('page'),$this.attr('getSubCat'));});},loadCourseDetails:function(container,categoryId,courseId){FO.Layout.setContentContainerPreloader('Fetching course details...');var data={"category":categoryId,"course":courseId},after=function(){FO.Widgets.slider(true);},url=FO.Core.link('default','catalogue','details',null,'html');FO.Core.load(container,url,data,null,after);},getCourses:function(el,container,category,page,subcategories){var $el=$(el);if(!$el.data('loaded')){FO.Layout.setTreeMenuPreloader();var parent=$('#'+container).parents('.courses-container'),id=container;container=parent.length?parent:'#'+container;FO.Core.load(container,FO.Core.link('default','catalogue','more-courses',null,'html'),{"containerId":id,"category":category,"page":page,"get-subcategories":subcategories},null,function(){$el.data('loaded',!$('.error',container).length).addClass('opened');FO.Layout.threeDots(20,container);if(undefined!==FO.showAsterisk&&FO.showAsterisk){$('#showAsterisk').show();}});}else{if($el.hasClass('selected')){$el.addClass('opened');}}}};;FO.Course=function(){return{subscribe:function(course,parent,student){var msg='',isError=false,token,executionId,callback=function(){var callback=null,params={'token':token,'executionId':executionId}
if(!isError){callback=function(){FO.Core.redirect(FO.Core.link('default','information','subscribe',params,'html'));}}
FO.Layout.hideElementAfter(FO.Layout.getMsgContainer(),15,callback);};FO.Layout.setContentContainerPreloader('Subscribing...');$.ajax({url:FO.Core.link('default','subscribe','index'),data:{'course':course,'student':student},type:'post',dataType:'json',beforeSend:function(){FO.Layout.setMsgContainer('#course-details > .subscribe-result-msg');},success:function(response){if(!response['success']){isError=true;msg=response['errors'];}else{token=response['token'];executionId=response['executionId'];msg=response['msg'];}},complete:function(){FO.Layout.showMsg(msg,isError,callback);}});}}}();;FO.Student=function(){return{getDetails:function(container,studentId){var data={'student':studentId},after=function(){if($('#slider').length){FO.Widgets.slider(true);}
if($('.module-unsubscribe').length){FO.Form.Unsubscribe.initStudentDetails();}},url=FO.Core.link('manager','student','details',null,'html');FO.Layout.setContentContainerPreloader('Fetching student details...');FO.Core.load(container,url,data,null,after);},getList:function(container,start){var data={'container':container,'start':start-1},url=FO.Core.link('manager','student','list-items',null,'html');FO.Layout.setTreeMenuPreloader();FO.Core.load('#'+container,url,data);}}}();;FO.Teacher=function(){return{getModuleLessons:function(container,course,module,start){var data={'courseId':course,'moduleId':module,'page':start},url=FO.Core.link('teacher','courses','planned-lessons',null,'html');FO.Layout.setContentContainerPreloader('Fetching planned lessons list...');FO.Core.load(container,url,data,null,FO.AjaxPaging.init);},getPlannedStudents:function(container,lessonId,lessonType){var data={'lessonId':lessonId,'type':lessonType},url=FO.Core.link('teacher','courses','planned-students',null,'html'),after=function(){FO.Form.AjaxSearch.init();FO.AjaxPaging.init();};FO.Layout.setContentContainerPreloader('Fetching students list...');FO.Core.load(container,url,data,null,after);}}}();;FO.Validation=function(){function ajaxValidate(form,params){form.validate({submitHandler:function(form){$(form).ajaxSubmit(params);},errorClass:'invalid',errorPlacement:function(error,element){error.appendTo('#validation-errors');}});}
function simpleValidate(form){form.validate({errorClass:'invalid',errorPlacement:function(error,element){if($('#validation-errors').length){error.appendTo('#validation-errors');}}});}
function initSlider(form){form.validate({errorClass:'invalid',errorPlacement:function(error,element){error.appendTo('#validation-errors');},unhighlight:function(element,errorClass){var el=$(element),panel=el.closest('.panel');el.removeClass(errorClass);if(!panel.find('.required.invalid').length){$('a[href="#'+panel.attr('id')+'"]').removeClass('invalid');}},invalidHandler:function(form,validator){var invalidEls=validator.invalidElements(),parent=$(invalidEls[0]).closest('.panel'),invalidPanels=$.unique($(invalidEls.closest('.panel'))),invalidTabs;for(var i=invalidPanels.length;i--;){if(''!==invalidTabs){invalidTabs+=', li > a[href="#'+invalidPanels[i].id+'"]';}else{invalidTabs='li > a[href="#'+invalidPanels[i].id+'"]';}}
$(invalidTabs).addClass('invalid');var scrollEl=$('.scrollH, .scrollV','#slider');scrollEl.scrollTo(parent,200,'swing');$('.navigation','#slider').find('a.selected').removeClass('selected').end().find('a[href$="'+parent.attr('id')+'"]').addClass('selected');}});}
return{isValid:function(form){var $form=$(form);simpleValidate($form);return $form.valid();},initWithAjaxSubmit:function(form,handlerParams,singleForm){if(singleForm){ajaxValidate($(form),handlerParams);}else{$(form).each(function(){ajaxValidate($(this),handlerParams);});}},init:function(){var $validatableForms=$('form.validatable');if($validatableForms.length){$validatableForms.each(function(){var $this=$(this);if($this.parent().attr('id')=='slider'){initSlider($this);}else{simpleValidate($this);}});}}}}();;FO.Widgets=function(){function slidePartners(els,toShow,maxHeight){var randEl=null,h=0,show=new Array();els.filter('.visible').removeClass('visible').slideUp('slow');for(var i=toShow;i--;){randEl=$(els[Math.floor(Math.random()*els.length)]);if($.inArray(randEl,show)){show.push(randEl);}else{randEl=$(els[Math.floor(Math.random()*els.length)]);}
randEl.addClass('visible').slideDown('slow');}
setTimeout(function(){slidePartners(els,toShow,maxHeight)},15000);}
return{init:function(){if($('#slider').length){FO.Widgets.slider(true);}
if($('#tree-menu').length){FO.Widgets.accordionMenu('#tree-menu a.item-header');}
if($('.partners').length){FO.Widgets.partnersSlideShow('.partners','.partner');}
FO.Widgets.initGrid($('.grid'));},slider:function(horizontal){var $slider=$('#slider');if($slider.length){var $panels=horizontal?$('.scrollContainerH > div',$slider):$('.scrollContainerV > div',$slider),$container=horizontal?$('.scrollContainerH',$slider):$('.scrollContainerV',$slider);if(horizontal){$panels.css({'float':'left','position':'relative'});$container.css('width',$panels[0].offsetWidth*$panels.length);}
var $scroll=horizontal?$('.scrollH',$slider):$('.scrollV',$slider);var selectNav=function(){$(this).parents('ul:first').find('a').removeClass('selected').end().end().addClass('selected');}
$('.navigation a',$slider).click(selectNav);var trigger=function(data){var el=$('#slider .navigation a[href$="'+data.id+'"]').get(0);selectNav.call(el);}
$panels.focusin(function(){$scroll.scrollTo($(this),200,'swing');trigger(this);});var padding=parseInt((horizontal?$container.css('paddingTop'):$container.css('paddingLeft')))||0;var offset=padding*-1;var scrollOptions={target:$scroll,items:$panels,navigation:'.navigation a',axis:'xy',onAfter:trigger,offset:offset,duration:200};$.localScroll(scrollOptions);scrollOptions.duration=1;$.localScroll.hash(scrollOptions);$panels.removeClass('invisible');if(window.location.hash){var id=window.location.hash.substr(1);trigger({id:id});$('#slider .navigation a[href$="'+id+'"]').click();}else{if($('ul.navigation').length){$('ul.navigation a:first').click();}else{$('a.slide:first',$panels).click();}}}},accordionMenu:function(headerEl){FO.Layout.threeDots(25,'#tree-menu');$(headerEl).live('click',function(){var $el=$(this),$preloaderParent=$('#left .box-indent'),$toExpandEl=$el.parent().next(),$toFoldEl=$toExpandEl.parents('ul:first').find('.data.expanded');$toFoldEl.slideUp('normal',function(){$preloaderParent.trigger('sizeChange');}).toggleClass('expanded invisible').prev().find('.item-header').removeClass('opened selected');if($toFoldEl[0]!==$toExpandEl[0]){$toExpandEl.slideDown('normal',function(){$preloaderParent.trigger('sizeChange');}).toggleClass('expanded invisible');$el.addClass('selected');}});},partnersSlideShow:function(containerEl,panelsEl){var $logos=$(containerEl+' > '+panelsEl),sliding=false;if($logos.length>3){if(!sliding){sliding=true
slidePartners($logos,3,0);}}else{$logos.slideDown();}},initGrid:function(jGrid){if(undefined==jGrid){jGrid=$('.grid');}
if(jGrid.length){$('tbody tr',jGrid).die('hover').live('hover',function(){$(this).toggleClass('hover');}).die('click').live('click',function(){var jThis=$(this);if(!jThis.hasClass('no-select')){var jEl=$('input[type="radio"], input[type="checkbox"]',jThis);jEl.is('input[type="radio"]')?jEl.attr('checked','checked'):jEl.attr('selected','selected');jEl.trigger("change");jThis.siblings('.selected').removeClass('selected').end().toggleClass('selected');}});}}}}();;FO.Core.defineNs('FO.Form');FO.Form.AjaxSearch=function(config){this.init(config);};FO.Form.AjaxSearch.prototype={scope:null,formSelector:'form.ajax-search',responseContainer:null,disableAllPage:null,jForm:null,onAfterSearch:$.noop,onBeforeSearch:$.noop,init:function(config){$.extend(true,this,config);this.jForm=$(this.formSelector);if(this.jForm.length){this.initEvents();}},initEvents:function(){var self=this;this.initPanelToggler();FO.Core.initAjaxForm(this.jForm,function(responseText){self.onSuccess(responseText);},function(formData,jqForm,options){self.onBeforeSubmit(formData,jqForm,options);},null,'html');},onBeforeSubmit:function(formData,jqForm,options){if('search...'==$('input:text',jqForm).val()){return false;}
this.onBeforeSearch.call(this.scope||this);for(var i=formData.length;i--;){if(formData[i]['name']=='ajax_response_container'){this.responseContainer=formData[i]['value'];}
if(formData[i]['name']=='overlay_all'){this.disableAllPage=parseInt(formData[i]['value']);}
if(null!==this.responseContainer&&null!==this.disableAllPage){break;}}
if(!this.responseContainer){this.responseContainer=this.jForm.closest(".ajax-content");}
this.disableAllPage?FO.Layout.setAllContentContainerPreloader():FO.Layout.setContentContainerPreloader();},onSuccess:function(responseText){$(this.responseContainer).html(responseText);this.onAfterSearch.call(this.scope||this);},initPanelToggler:function(){var togglerId=this.jForm.parents('.search-panel').attr('toggler');if(togglerId){$('#'+togglerId).live('click',function(){$('.search-panel.'+this.id).slideToggle();return false;});}}};;FO.Core.defineNs('FO.Form');FO.Form.Reassign=function(config){this.init(config);}
FO.Form.Reassign.prototype={els:{},scope:null,module:'',controller:'',onAfterReassign:$.noop(),onBeforeShow:$.noop(),onAfterHide:$.noop(),init:function(config){$.extend(this,config)
this.initMarkup();},initMarkup:function(){this.els={formContainer:$('.reassign-form-container'),msgContainer:$('.message-container'),closeBtn:$('.window .close')};this.initEvents();},initEvents:function(){this.els.closeBtn.live('click',$.proxy(this,"hide"));},onShow:function(){var fc=this.els.formContainer;fc.css({'top':'100px','left':(Math.floor(fc.parent().width()/2)-Math.floor(fc.outerWidth(true)/2))+'px','position':'absolute'}).show();this.initAjaxSubmit();},show:function(studentBpvId){var self=this;FO.Core.load('.reassign-form-container',FO.Core.link(self.module,self.controller,'reassign-form',null,'html'),{"studentBpvId":studentBpvId},function(){self.onBeforeShow.call(self.scope)},$.proxy(self,"onShow"),false);},hide:function(){var self=this;self.els.formContainer.fadeOut("fast",function(){self.onAfterHide();});},initAjaxSubmit:function(){var self=this,beforeSubmit=function(formData,jqForm,options){var valid=FO.Validation.isValid(jqForm[0]);if(valid){FO.Layout.setPreloader('.window','Requesting reassign...',true);FO.Layout.setMsgContainer('.message-container');}
return valid;},onSuccess=function(responseText,statusText){if(responseText['success']){FO.Layout.showMsg('Request is sent successfully.',false);FO.Layout.hideElementAfter('.message-container',15,function(){self.hide();self.onAfterReassign.call(self.scope);});}else{var err=undefined!==responseText['err'][0]?responseText['err'][0].msg:'Undefined error occured.'
FO.Layout.showMsg(err,true).hideElementAfter('.message-container',15);}},url=FO.Core.link(self.module,self.controller,'request-reassign-student');FO.Core.initAjaxForm('form[name="reassign"]',onSuccess,beforeSubmit,url);}};FO.Core.defineNs('FO.Form');FO.Form.Preeducation=function(){var levelsAbbr={'VMBO':'VMBO','VBO':'VBO','MAVO':'MAVO','HAVO':'HAVO','VWO':'VWO','MBO':'MBO','HBO':'HBO'},levelsWithProfile={'HAVO':'HAVO','MBO':'MBO'},xhr=new Object();function getProfilesByLevelAbbr(abbr,callback,before,elId){if(abbr in levelsWithProfile){xhr=$.ajax({type:'POST',data:'abbr='+abbr,global:false,url:FO.Core.link('default','preeducation','fetch-profiles-by-level-abbr'),dataType:'json',success:function(data,textStatus){if('function'==typeof callback){callback(elId,data.response);}},beforeSend:function(){if('function'==typeof xhr.abort){xhr.abort();}
if('function'==typeof before){before(elId);}}});}}
function setCourseNameVal(courseNameElId,val,levelElId){var $el=$(courseNameElId),$profileEl=$('.profile'),$levelEl=$('.level'),$modulesEl=$('#course-modules'),showLevel=function(){$levelEl.fadeIn();},showProfile=function(){$profileEl.fadeIn();},showModules=function(){clearModules();$modulesEl.fadeIn();},hideLevel=function(){$levelEl.fadeOut();},hideProfile=function(){$profileEl.fadeOut();},hideModules=function(){$modulesEl.slideUp();},hideProfileAndLevel=function(){hideLevel();hideProfile();},clearModules=function(){$(':input',$modulesEl).each(function(){$(this).removeAttr('checked').val('');});},setRequired=function(required){var $lbl=$('[for="course-name"]');if(required){var asterix='<span style="font-weight:700;color:red;">*</span>';$el.addClass('required');$lbl.html('Course name'+asterix);}else{$el.removeClass('required');$lbl.html('Course name');}};$el.val('');switch(val){case'MBO':FO.Core.addOption(levelElId,{'1':'1','2':'2','3':'3','4':'4'},true);setRequired(true);showLevel();showProfile();showModules();break;case'HAVO':showProfile();hideLevel();showModules();break;case'HBO':hideProfileAndLevel();showModules();FO.Core.addOption(levelElId,{'5':'5'},true);setRequired(true);break;case'UNIVERSITY':hideProfileAndLevel();hideModules();FO.Core.addOption(levelElId,{'6':'6'},true);setRequired(true);break;case'OTHER':hideProfileAndLevel();hideModules();FO.Core.addOption(levelElId,{'0':'0'},true);setRequired(true);break;case'VWO':showModules();hideProfileAndLevel();break;default:hideProfileAndLevel();hideModules();FO.Core.addOption(levelElId,{'0':'0'},true);setRequired(false);break;}
if(val in levelsAbbr){if($el.val()in levelsAbbr||''==$el.val()){$el.val(val);}}else{if($el.val()in levelsAbbr){$el.val('');}}}
return{init:function(){var callback=function(container,data){var elSel=$(container).removeClass('shaded-text').attr('disabled',false);if(data.length){FO.Core.addOption(elSel[0],{'':''},true);for(var i in data){var o={};o[data[i]['id']]=data[i]['description'];FO.Core.addOption(elSel[0],o,false);}}}
var before=function(container){var elSel=$(container).addClass('shaded-text').attr('disabled',true);FO.Core.addOption(elSel[0],{'':'Loading...'},true);}
$('#save-preedu-to-session').click(function(){FO.Form.Preeducation.save2session(FO.Form.Preeducation.loadListFromSession,'saved-edu-container');});$('[name=highest]').live('click',function(){FO.Form.Preeducation.setHighest($(this).attr('sessionIdx'));});$('.mark').keyup(function(){if(this.value>10){this.value=10;}});$('#delete-from-session').live('click',function(){FO.Form.Preeducation.deleteFromSession('saved-edu-container',this.rel);});$('#course-modules :checkbox').click(function(){var jMark=$('input[name='+this.name+'_mark]');if(this.checked){this.value=1;jMark.attr('disabled',false).focus();}else{this.value=0;jMark.attr('disabled',true);}});$('#level-abbr').change(function(){getProfilesByLevelAbbr($(this).val(),callback,before,'#qualification');setCourseNameVal('#course-name',$(this).val(),'#level');});$('#level-abbr').trigger('change');},save2session:function(callback,params){var showErr=function(msg){FO.Layout.setMsgContainer('#pre-education-msg').showMsg(msg,true).hideElementAfter('#pre-education-msg',20);}
if(''==$('#level-abbr').val()||null==$('#level-abbr').val()){showErr('Select level type first.');return}
var data={},valid=true;$('#pre-education :input').each(function(){var $el=$(this);if($el.hasClass('required')&&''==$el.val()){valid=false;}
if(!$el.is('[type="radio"]')||($el.is('[type="radio"]')&&$el.is(':checked'))){data[this.name]=this.value;}
if(!$el.is('[type="radio"]')){this.value='';if($el.hasClass('datetime-picker')){$el.trigger('removeData');}}});if(valid){FO.Layout.setContentContainerPreloader();$.ajax({type:'POST',data:data,url:FO.Core.link('default','preeducation','save'),success:function(data,textStatus){if(/MSIE/.test(navigator.appVersion)){$('#level-abbr option:first').attr("selected","selected");}
$('#level-abbr').trigger('change');if('function'==typeof callback){callback(params);}}});}else{showErr();}},setHighest:function(idx){var url=FO.Core.link('default','preeducation','set-highest');$.post(url,{'highest':idx});},loadListFromSession:function(container){FO.Core.load('#'+container,FO.Core.link('default','preeducation','saved',null,'html'),null,null,null);},deleteFromSession:function(container,itemId){FO.Layout.setContentContainerPreloader();FO.Core.load('#'+container,FO.Core.link('default','preeducation','saved',null,'html'),{'delete':itemId});}}}();;FO.Core.defineNs('FO.Form');FO.Form.Worklocation=function(){function getWorklocationData(id,beforeSend,onSuccess){$.ajax({type:'POST',data:'id='+id,url:FO.Core.link('default','worklocation','fetch-with-boss'),dataType:'json',global:false,beforeSend:function(){if('function'==typeof beforeSend){beforeSend();}},success:function(data){if('function'==typeof onSuccess){onSuccess(data.response);}}});}
return{init:function(){var options={'name':$('#company_name'),'phone':$('#work-phone'),'zipcode':$('#work-zipcode'),'email':$('#work-email'),'place':$('#work-place'),'address':$('#work-address'),'boss':$('#name_boss')};$('#worklocation_id').change(function(){var id=parseInt($(this).val());if(id>0){getWorklocationData(id,function(){for(var i in options){options[i].toggleClass('shaded-text').val('Loading...').attr('disabled',true);}},function(data){options['name'].removeClass('shaded-text').removeAttr('disabled').val(data['worklocation']['name']||'');options['phone'].removeClass('shaded-text').removeAttr('disabled').val(data['worklocation']['phone']||'');options['zipcode'].removeClass('shaded-text').removeAttr('disabled').val(data['worklocation']['zipcode']||'');options['email'].removeClass('shaded-text').removeAttr('disabled').val(data['worklocation']['email']||'');options['place'].removeClass('shaded-text').removeAttr('disabled').val(data['worklocation']['place']||'');options['address'].removeClass('shaded-text').removeAttr('disabled').val(data['worklocation']['address']||'');options['boss'].removeClass('shaded-text').removeAttr('disabled').val(data['boss']['name']||'');FO.Core.setSelectedOption('#custom_boss_id',data['boss']['id']);});}else{for(var option in options){options[option].removeClass('shaded-text').removeAttr('disabled').val('');}}});}}}();;FO.Core.defineNs('FO.Form');FO.Form.StudentInfoUpdate=function(){function infoUpdateInit(){var beforeSubmit=function(formData,jqForm,options){var valid=FO.Validation.isValid(jqForm[0]);if(valid){FO.Layout.setContentContainerPreloader('Updating information...');FO.Layout.setMsgContainer('.update-info-msg');}
return valid;},onSuccess=function(responseText,statusText){if(responseText['success']){FO.Layout.showMsg(responseText['msg'],false);}else{FO.Layout.showMsg(responseText['errors'][0]['msg'],true);}
FO.Layout.hideElementAfter(FO.Layout.getMsgContainer(),30);},url=FO.Core.link('student','personal','update-info',null);FO.Core.initAjaxForm('form[name="student-info-form"]',onSuccess,beforeSubmit,url);}
function changePasswordInit(){var form,beforeSubmit=function(formData,jqForm,options){form=jqForm[0];var valid=FO.Validation.isValid(jqForm[0]);if(valid){FO.Layout.setContentContainerPreloader('Changing password...');FO.Layout.setMsgContainer('.change-password-msg');}
return valid;},onSuccess=function(responseText,statusText){form.reset();$changeBtn.attr('disabled','disabled');if(responseText['success']){FO.Layout.showMsg(responseText['msg'],false);}else{FO.Layout.showMsg(responseText['errors'],true);}
FO.Layout.hideElementAfter(FO.Layout.getMsgContainer(),30);},url=FO.Core.link('student','personal','change-passwd',null),$new1=$('input[name="new1"]'),$new2=$('input[name="new2"]'),$old=$('input[name="old"]'),$changeBtn=$('input[name="change-passwd-btn"]'),change=function(){var new1Val=null!==$new1.val()&&''!==$new1.val();var new2Val=null!==$new2.val()&&''!==$new2.val();var oldVal=null!==$old.val()&&''!==$old.val();if(new1Val&&new2Val&&oldVal){$changeBtn.attr('disabled','');}else{$changeBtn.attr('disabled','disabled');}};$new1.keyup(change);$new2.keyup(change);$old.keyup(change);FO.Core.initAjaxForm('form[name="student-change-passwd-form"]',onSuccess,beforeSubmit,url);}
return{init:function(){infoUpdateInit();changePasswordInit();}}}();;FO.Core.defineNs("FO.Form");FO.Form.UserInfoPopup=function(config){this.init(config);};FO.Form.UserInfoPopup.prototype={els:{},loadTo:null,url:'',tpl:'',onBeforeLoad:$.noop,onBeforeShow:$.noop,onShow:$.noop,onHide:$.noop,scope:null,init:function(config){$.extend(this,config);},initMarkup:function(){FO.Core.apply(this.els,{window:$('#user-info-popup')});this.setPosition().fadeIn();this.initEvents();},setPosition:function(){var left=Math.floor(this.els.window.parent().width()/2)-
Math.floor(this.els.window.width()/2);return this.els.window.css({'left':left+'px','position':'absolute','top':'170px'});},initEvents:function(){var self=this;$('.close',self.els.window).click(function(){self.hide();});},show:function(studentId){var self=this;self.getContent(studentId,function(){$(self.loadTo).prepend(self.tpl);self.initMarkup();self.onShow.call(self.scope||self);},self);},getContent:function(studentId,callback,scope){var self=this;$.ajax({type:"POST",url:self.url,data:{"student-id":studentId},dataType:"html",global:false,beforeSend:function(){self.onBeforeLoad.call(self.scope||self);},success:function(response){self.tpl=response;if('function'==typeof callback){callback.call(scope||self);}}});},hide:function(){var self=this;self.onHide()
self.els.window.fadeOut('normal',function(){self.els.window.remove();});}};FO.Core.defineNs('FO.Form');FO.Form.Upload=function(config){this.init(config);}
FO.Form.Upload.prototype={els:{},scope:null,submitUrl:'',formUrl:'',loadTo:'',caller:null,formContainer:null,onFileUploaded:$.noop,onShow:$.noop,onBeforeLoad:$.noop,onBeforeScanLoad:$.noop,onHide:$.noop,onScanHide:$.noop,init:function(config){$.extend(this,config);},initMarkup:function(){var self=this;self.formContainer=$('.window.upload-form');self.els.form=$('form',self.formContainer);FO.Core.apply(self.els,{closeFormBtn:$('.close',self.formContainer),preloaderParent:$('.form-preloader-parent',self.formContainer),fakeUploadBtn:$('input[name="fake-btn"]',self.els.form),fileInputWrap:$('.file-input',self.els.form),fileInput:$('input[name=file2upload]',self.els.form),requiredFields:$('.required',self.els.form),scanBtn:$(':button[name="scan"]',self.els.form),msgContainer:$('.msg-container',self.els.form)});self.setPosition();self.initEvents();self.setHiddenValues();},initEvents:function(){var self=this;self.els.requiredFields.bind('keyup change',function(){var valid=true;self.els.requiredFields.each(function(){valid=valid&&Boolean(this.value);});self.els.fakeUploadBtn.attr('disabled',!valid);self.els.scanBtn.attr('disabled',!valid);self.els.fileInputWrap.toggleClass('invisible',!valid);});self.els.fileInput.change(function(){self.els.form.submit();});self.els.closeFormBtn.click(function(){self.hide();});self.els.scanBtn.click(function(){var docId=$('input[name="document_id"]',self.els.form).val(),docType=$('input[name="document_type"]',self.els.form).val(),courseId=$('input[name="course_id"]',self.els.form).val(),documentTypeId=$('input[name="document_type_id"]',self.els.form).val(),iscoursedoc=$('input[name="iscoursedoc"]',self.els.form).val(),description=$('input[name="description"]',self.els.form).val();self.formContainer.fadeOut();FO.Core.apply(self.els,{scanO:new FO.Form.Scan({uploadParams:{document_id:docId,document_type:docType,course_id:courseId,document_type_id:documentTypeId,iscoursedoc:iscoursedoc},defaultValues:{description:description},onHide:function(){self.onScanHide();self.hide();},onSave:function(){self.onFileUploaded();},onBeforeLoad:function(){self.onBeforeScanLoad();},onBeforeShow:function(){self.onBeforeScanLoad();},scope:self})});self.els.scanO.show();});self.initAjaxSubmit();},initAjaxSubmit:function(){var self=this,onBeforeSubmit=function(formData,jqForm){var valid=FO.Validation.isValid(jqForm);if(valid){FO.Layout.setPreloader(self.els.preloaderParent,null,true);FO.Layout.setMsgContainer(self.els.msgContainer);}
return valid;},onSuccess=function(responseText){if(responseText['success']){self.onFileUploaded();FO.Layout.showMsg('File was uploaded successfully.',false,function(){FO.Layout.hideElementAfter(FO.Layout.getMsgContainer(),5,function(){self.hide.call(self);});});}else{var err=responseText['errors']?responseText['errors'][0]:'Undefined error occured.';FO.Layout.showMsg(err,true,null,20);}}
FO.Core.initAjaxForm(self.els.form,onSuccess,onBeforeSubmit,self.submitUrl,'json',true);},setPosition:function(){var self=this;self.formContainer.css({'top':'150px','left':Math.floor(self.formContainer.parent().width()/2)-
Math.floor(self.formContainer.outerWidth(true)/2)+'px','position':'absolute'});$('input[type="text"]:first',self.els.form).get(0).focus();},setHiddenValues:function(){var self=this,jCallerEl=self.caller;$('input[name="document_name"]',self.els.form).val(jCallerEl.attr('name'));$('input[name="document_id"]',self.els.form).val(jCallerEl.attr('docid'));$('input[name="document_type_id"]',self.els.form).val(jCallerEl.attr('doctypeid'));$('input[name="iscoursedoc"]',self.els.form).val(jCallerEl.attr('iscoursedoc'));if(FO.activeDocs==='course'){$('input[name="course_id"]',self.els.form).val($('.course.selected')[0].id);}
$('input[name="document_type"]',self.els.form).val(jCallerEl.hasClass('mandatory')?'mandatory':'general');},show:function(){var self=this;FO.Core.load(self.loadTo,self.formUrl,{},function(){self.onBeforeLoad();},function(){self.initMarkup();self.onShow();},false);},hide:function(){var self=this;self.formContainer.fadeOut('fast',self.onHide);}};FO.Core.defineNs("FO.Form");FO.Form.NewDocument=function(config){this.init(config);};FO.Form.NewDocument.prototype={els:{},parent:null,submitUrl:'',redirectUrl:'',formUrl:'',loadTo:'',caller:null,doc:{},init:function(config){$.extend(true,this,config);},initMarkup:function(){var self=this;self.els={formContainer:$('#new-doc'),form:$('form',self.els.formContainer)};FO.Core.apply(self.els,{closeFormBtn:$('.close',self.els.formContainer),preloaderParent:$('.form-preloader-parent',self.els.formContainer),requiredFields:$('.required',self.els.form),msgContainer:$('.msg-container',self.els.form),submitBtn:$('input[type=submit]',self.els.form)});self.setPosition();self.initEvents();self.setHiddenValues();},initEvents:function(){var self=this;FO.Layout.initDateTimePickers();self.els.requiredFields.bind('keyup change',function(){var valid=true;self.els.requiredFields.each(function(){valid=valid&&Boolean(this.value);});self.els.submitBtn.attr('disabled',!valid);});self.els.closeFormBtn.click(function(){self.hide();});self.initAjaxSubmit();},initAjaxSubmit:function(){var self=this,onBeforeSubmit=function(formData,jqForm){var valid=FO.Validation.isValid(jqForm);if(valid){FO.Layout.setPreloader(self.els.preloaderParent,null,true);FO.Layout.setMsgContainer(self.els.msgContainer);}
return valid;},onSuccess=function(responseText){if(responseText['success']){var msg='Document is created successfully. Redirecting to edit page.';FO.Layout.showMsg(msg,false,function(){var $el=self.caller,data={"id":responseText['id'],"execution_id":responseText['execution_id'],"iscoursedoc":$el.attr('iscoursedoc'),"is_general":+$el.hasClass('general')}
FO.Core.redirect(FO.Core.link('documents','index','edit',data,'html'));});}else{var err=responseText['errors']?responseText['errors'][0]:'Undefined error occured.';FO.Layout.showMsg(err,true,null,20);}}
FO.Core.initAjaxForm(self.els.form,onSuccess,onBeforeSubmit,self.submitUrl,'json',true);},setPosition:function(){var self=this;self.els.formContainer.css({'top':'150px','left':Math.floor(self.els.formContainer.parent().width()/2)-
Math.floor(self.els.formContainer.outerWidth(true)/2)+'px','position':'absolute'});$('input[type="text"]:first',self.els.form).get(0).focus();},setHiddenValues:function(){var self=this,jCallerEl=self.caller;$('input[name="iscoursedoc"]',self.els.form).val(jCallerEl.attr('iscoursedoc'));if(FO.activeDocs==='course'){$('input[name="course_id"]',self.els.form).val($('.course.selected')[0].id);}
$(' input[name="document_type"]',self.els.form).val(jCallerEl.hasClass('mandatory')?'mandatory':'general');},onShow:function(){var self=this;self.initMarkup();if("function"==typeof self.parent.onUploadFormShow){self.parent.onUploadFormShow.call(self.parent);}},show:function(){var self=this;if("function"==typeof self.parent.beforeUploadFormShow){self.parent.beforeUploadFormShow.call(self.parent);}
FO.Core.load(self.loadTo,self.formUrl,{},null,function(){self.onShow();},false);},hide:function(){var self=this;self.els.formContainer.fadeOut('fast',function(){if("function"==typeof self.parent.onUploadFormHide){self.parent.onUploadFormHide.call(self.parent);}});}};FO.Core.defineNs('FO.Form');FO.Form.Scan=function(config){this.init(config);}
FO.Form.Scan.prototype={id:'scan-form',scanId:'scan-area',proxyUrl:'http://scan.efis.nl/js/cross-frame/proxy.html',twainIframeSrc:'http://scan.efis.nl/default/index/scan',uploadHost:location.host,uploadProtocol:location.protocol,uploadUrl:'/json/documents/index/attach-file',uploadParams:null,defaultValues:null,_somethingScanned:false,_confWindow:null,confWindowContainer:'#scan-config-form-container',tpl:null,scanForm:null,preloader:null,shift:0,onBeforeLoad:$.noop,onBeforeShow:$.noop,onSave:$.noop,onScanned:$.noop,onTwainReady:$.noop,init:function(config){if(!this.uploadParams){this.uploadParams={};}
$.extend(this,config);},initMarkup:function(tpl){var $this=this;$("#content-indent > .width").append($('<div id = "'+$this.id+'" class = "invisible window on-top" style="width:450px;">').html(tpl));$this.scanForm=$('#'+$this.id);$this.scanForm.css({'top':'70px','left':Math.floor($('body').width()/2)-Math.floor($this.scanForm.width()/2)+'px','position':'absolute'});if($this.defaultValues){var fields=['description'],field;for(var i=0;i<fields.length;i++){field=fields[i];if($this.defaultValues[field]){$(':input[name="'+field+'"]',$this.scanForm).val($this.defaultValues[field]);}}}
$(':button[name="scan"], :button[name="save"]',$this.scanForm).attr('disabled',true);$this.preloader=FO.Layout.setPreloader('#'+$this.id,'',false);$this.initEvents();$this.scanForm.fadeIn();},initEvents:function(){var $this=this;$('.close',$this.scanForm).bind('click',{scope:$this},$this.doClose);$('.required',$this.scanForm).bind('keyup change',{scope:$this},$this.checkRequiredFields);$(':button[name="conf"]',$this.scanForm).click(function(){$this.doConfigure.call($this);});$(':button[name="scan"]',$this.scanForm).click(function(){$this.doScan.call($this);});$(':button[name="save"]',$this.scanForm).click(function(){$this.doSave.call($this);});},show:function(){this.getContent.call(this,function(tpl){var $this=this;if(false===$this.onBeforeShow.call($this.scope||$this)){return false;}
$this.initMarkup(tpl);$this.dwtClient=$this.createWebTwain();$this.onShow.call($this.scope||$this);});},doConfigure:function(){var $this=this;$(':button, .required',$this.scanForm).attr('disabled',true);$this._confWindow=new FO.Form.ScanConfig({loadTo:$this.confWindowContainer,onBeforeLoad:function(){$this.preloader.fadeIn('fast');},onShow:function(){$this.onConfigShow();},onHide:function(){$this.onConfigHide();},scope:$this});$this._confWindow.show();},hide:function(){var $this=this;$this.scanForm.fadeOut('fast',function(){$this.scanForm.remove();$this.onHide.call($this.scope||$this);});if(this._confWindow&&this._confWindow.hide){this._confWindow.hide();}},getContent:function(callback,scope){var $this=this;$this.onBeforeLoad.call($this.scope||$this);$.ajax({url:FO.Core.link('documents','index','scan',{},'html'),global:false,success:function(data){$this.tpl=data;callback.call(scope||$this,$this.tpl);}});},createWebTwain:function(){var $this=this,scanArea=document.getElementById($this.scanId);$this.dwtClient=new OSDN.DynamicWebTwainClient({containerDwt:$this.scanId,proxyUrl:$this.proxyUrl,dwtIframeConfig:{src:$this.twainIframeSrc,scrolling:"no",width:scanArea.offsetWidth,height:scanArea.offsetHeight},onScanned:function(args){$this._somethingScanned=true;$this.checkRequiredFields.call($this);$this.onScanned.call($this.scope||$this);},onUploaded:function(args){$this.checkRequiredFields.call($this);$this.onUpload.call($this.scope||$this,args,$this);},onReady:function(){$this.checkRequiredFields.call($this);$this.onTwainReady.call($this.scope||$this,$this);},scope:$this});return $this.dwtClient;},doScan:function(){$(':button[name="scan"]',this.scanForm).attr('disabled',true);this.dwtClient.scan();},doSave:function(){var $this=this;$this.preloader.fadeIn();$(':button[name="save"]',$this.scanForm).attr('disabled',true);$this.dwtClient.upload({host:$this.uploadHost,protocol:$this.uploadProtocol,url:$this.uploadUrl,params:$this.getUploadParams.call($this.scope||$this,$this)});$this.hide()
$this.onSave();},doClose:function(event){var $this=(event&&event.data&&event.data.scope)?event.data.scope:this;$this.hide.call($this);},checkRequiredFields:function(event){var $this=(event&&event.data&&event.data.scope)?event.data.scope:this;var valid=true;$('.required',$this.scanForm).each(function(){valid=valid&&Boolean(this.value);});$(':button[name="scan"]',$this.scanForm).attr('disabled',!valid);$(':button[name="save"]',$this.scanForm).attr('disabled',!(valid&&$this._somethingScanned));},onShow:function(){var descr=$('input[name="description"]',this.scanForm);if(descr&&this.uploadParams&&this.uploadParams.description){descr.val(this.uploadParams.description);}},onConfigShow:function(callback,scope){var $this=this;$this.preloader.css('background-image','none');$this.shift=Math.floor(($this.scanForm.parent().outerWidth(true)-
($this.scanForm.outerWidth()+$this._confWindow.scanCfgForm.outerWidth()))/2);$this.scanForm.animate({"left":"-="+$this.shift+"px"},500,'swing',function(){$this._confWindow.scanCfgForm.css({'top':$this.scanForm.offset().top+'px','left':$this.scanForm.outerWidth(true)
+$this.scanForm.offset().left
+'px','position':'absolute'});if('function'==typeof callback){callback.call(scope);}});},onConfigHide:function(){var $this=this;$this.scanForm.animate({"left":"+="+$this.shift+"px"},500,'swing',function(){$('.required, :button[name="conf"]',$this.scanForm).attr('disabled',false);$this.checkRequiredFields.call($this);$this._confWindow=null;$this.preloader.fadeOut('fast');});},onHide:function(){$('#docs-overlay').fadeOut('fast');},onUpload:function(args,so){if(args.success&&args.success==='true'){so.doClose.call(so);}},getUploadParams:function(scanObj){var descr=$('input[name="description"]',this.scanForm);if(descr){scanObj.uploadParams['description']=descr.val();}
return scanObj.uploadParams;},scope:null};FO.Core.defineNs('FO.Form');FO.Form.ScanConfig=function(config){this.init(config);}
FO.Form.ScanConfig.prototype={id:'scan-form-config',proxyUrl:'http://scan.efis.nl/js/cross-frame/proxy.html',twainIframeSrc:'http://scan.efis.nl/default/index/scan',_somethingScanned:false,scanCfgForm:null,loadTo:'',tpl:null,onLoad:$.noop,onShow:$.noop,onHide:$.noop,onBeforeLoad:$.noop,onTwainReady:$.noop,init:function(config){$.extend(this,config);},initMarkup:function(){var $this=this;$this.scanCfgForm=$('#'+$this.id);$(':button[name="save"]',$this.scanCfgForm).attr('disabled',true);$this.initEvents();},initEvents:function(){var $this=this;$('.close',$this.scanCfgForm).bind('click',{scope:this},this.doClose);$(':button[name="save"]',this.scanCfgForm).click(function(){$this.doChangeConfig.call($this);});},show:function(){var $this=this;$this.getContent.call($this,function(){$this.initMarkup();$this.onShow.call($this.scope||$this);$this.scanCfgForm.slideDown();$this.dwtClient=$this.createWebTwain();},$this);},hide:function(){var $this=this;$this.dwtClient.doDestroy();$this.scanCfgForm.animate({width:'hide',height:'hide'},200,'swing',function(){$this.scanCfgForm.remove();$this.onHide.call($this.scope||$this);});},getContent:function(callback,scope){FO.Core.load('#scan-config-form-container',FO.Core.link('documents','index','scan-config',{},'html'),{},function(){scope.onBeforeLoad();$('body').append('<div id="scan-config-form-container"></div>');},function(){callback.call(scope||this);},false);},createWebTwain:function(){var $this=this;this.dwtClient=new OSDN.DynamicWebTwainClient({proxyUrl:this.proxyUrl,hidden:true,dwtIframeConfig:{src:this.twainIframeSrc,scrolling:"no",width:420,height:570},onScanned:function(args){this.onScanned.call(this.scope||this);},onUploaded:function(args){this.onUpload.call(this.scope||this,args,this);},onReady:function(){$(':button[name="save"]',$this.scanCfgForm).attr('disabled',false);this._onReady.call(this);},scope:this});return $this.dwtClient;},doChangeConfig:function(){var conf=this._getSetConfigsInForm();this.dwtClient.setScanConfig(conf);this.onConfigChanged(conf);},doClose:function(event){var $this=(event&&event.data&&event.data.scope)?event.data.scope:this;$this.hide.call($this);},_getSetConfigsInForm:function(){return{imagetype:$(':input[name="imagetype"]',this.scanCfgForm).val(),pixeltype:$(' :input[name="pixeltype"]',this.scanCfgForm).val(),resolution:$(':input[name="resolution"]',this.scanCfgForm).val(),enable_adf:$(':input[name="enable_adf"]',this.scanCfgForm).attr('checked')?1:0,enable_duplex:$(':input[name="enable_duplex"]',this.scanCfgForm).attr('checked')?1:0,enable_ui:$(':input[name="enable_ui"]',this.scanCfgForm).attr('checked')?1:0,source:$(':input[name="source"]',this.scanCfgForm).val()}},_onReady:function(){this.onTwainReady.call(this.scope||this,this);this.dwtClient.giveScanners(function(scanners){var source=$(':input[name="source"]',this.scanCfgForm);for(var key in scanners){source.append($("<option></option>").attr("value",key).text(scanners[key]));}
this.dwtClient.giveScanConfig(function(config){var selectFields=['source','imagetype','pixeltype','resolution'],i;for(i=0;i<selectFields.length;i++){if('undefined'!=typeof config[selectFields[i]]){$(':input[name="'+selectFields[i]+'"]',this.scanCfgForm).val(config[selectFields[i]]);}}
var checkboxFields=['enable_adf','enable_duplex','enable_ui'];for(i=0;i<checkboxFields.length;i++){if('undefined'!=typeof config[checkboxFields[i]]){$(':input[name="'+checkboxFields[i]+'"]',this.scanCfgForm).attr('checked',config[checkboxFields[i]]==1?true:false);}}
this.onLoad.call(this.scope||this);},this);},this);},onConfigChanged:function(){this.doClose.call(this);},scope:null};FO.Core.defineNs('FO.Form');FO.Form.PlanningBase=function(){}
FO.Form.PlanningBase.prototype={els:{},filtersURL:'',scope:null,param:'course',onAfterAjaxContentChange:$.noop,onAfterPageChanged:$.noop,construct:function(config){$.extend(this,config);this.initMarkup();},initMarkup:function(){var self=this;FO.Core.apply(self.els,{rangeStart:$('input[name="from_date"]'),rangeEnd:$('input[name="till_date"]'),cPanelCaption:$('.center-pnl-caption'),filtersContainer:$('.center-panel > .filter:first'),filters:$('#filter-by-range, #show-for-today, #show-all'),paging:new FO.AjaxPaging({preloaderParentEl:'.center-panel',onAfterPageChanged:function(){FO.Layout.initTableSorting();self.onAfterPageChanged()}})});self.initEvents();},initEvents:function(){var self=this;self.els.filters.click(function(event){var $selectedItem=$('.right-panel > .list > .item.selected');if($selectedItem.length){var data={},id=$selectedItem[0].id;$('.current-filter').removeClass('current-filter');$(this).addClass('current-filter');switch(this.id){case'filter-by-range':data={"startdate":self.els.rangeStart.val(),"enddate":self.els.rangeEnd.val()}
break;case'show-for-today':var date=new Date(),month=date.getMonth()+1;month=month<10?'0'+month:month;data={"today":date.getFullYear().toString()+'-'+
month+'-'+date.getDate().toString()}
var today2=data.today.split('-').reverse().join('-');self.els.rangeStart.addClass('shaded-text').val(today2);self.els.rangeEnd.addClass('shaded-text').val(today2);break;case'show-all':self.els.rangeStart.addClass('shaded-text').val('all');self.els.rangeEnd.addClass('shaded-text').val('all');data={"all":true}
break;}
data[self.param]=id;self.load(data);}
event.preventDefault();})},hideFilters:function(){this.els.filtersContainer.hide();},prepareCenterPanel:function(){var self=this;if(self.els.filtersContainer.length&&!self.els.filtersContainer.is(":visible")){self.els.filtersContainer.show();if(self.els.cPanelCaption.length>1){self.els.cPanelCaption.toggle();}}
FO.Layout.initTableSorting();},load:function(data){var self=this,after=function(){FO.Layout.correctTableWidthForIE('.tablesorter');FO.Layout.initTableSorting();self.onAfterAjaxContentChange.call(self.scope);};FO.Layout.setPreloader('.center-panel','',false);FO.Core.load('.ajax-content',this.filtersURL,data,null,after);}};FO.Core.defineNs('FO.Form');FO.Form.Unsubscribe=function(parent){this.els={formContainer:$('.unsubscribe-form-container'),msgContainer:$('.message-container'),closeBtn:$('.window .close')};this.parent=parent;this.init();}
FO.Form.Unsubscribe.prototype={init:function(){this.initEvents();},initEvents:function(){this.els.closeBtn.live('click',$.proxy(this,"hide"));$('span[class*="[status]"], span[class*="[figure]"]').live('dblclick',function(){var cls=this.className.split(' ')[0];$('span[class*="'+cls+'"], select[name="'+cls+'"]').toggle().filter('select').toggleClass('invisible');});$('select[name*="[status]"], select[name*="[figure]"]').live('change',function(){var self=this,cls=self.name;$('span[class*="'+cls+'"], select[name="'+cls+'"]').filter('span').html(self.options[self.selectedIndex].text).end().toggle().filter('select').toggleClass('invisible');});$('input[name=figure]').live('change',function(){$('span[class*="[figure]"]').html(this.value);$('select[name*="[figure]"] option[value="'+this.value+'"]').attr('selected',true);}).live('keyup',function(){if(this.value>10){this.value=10;}});$('select[name=successful]').live('change',function(){var self=this;$('span[class*="[status]"]').html(self.options[self.selectedIndex].text);$('select[name*="[status]"]').val(self.value);});$('select[name=stop_type]').live('change',function(){var $success=$('select[name=successful]'),$stopCodeEl=$('select[name="stop_code"]');switch(this.value){case'FINISH':$success.val('success');$stopCodeEl.val('13');break;case'STOP':$success.val('failed');$stopCodeEl.val('-1');break;}
$success.trigger('change');});},initAjaxSubmit:function(){var self=this,beforeSubmit=function(formData,jqForm,options){var valid=FO.Validation.isValid(jqForm[0]);if(valid){FO.Layout.setPreloader('.window','Unsubscribing...',true);FO.Layout.setMsgContainer('.message-container');}
return valid;},onSuccess=function(responseText,statusText){if(responseText['success']){FO.Layout.showMsg('Course is successfully unsubscribed.',false);FO.Layout.hideElementAfter('.message-container',15,function(){self.hide();self.parent.onAfterUnsubscribe();});}else{FO.Layout.showMsg(responseText['err'][0].msg,true).hideElementAfter('.message-container',25);}},url=FO.Core.link('manager','stopstudy','unsubscribe',null);FO.Core.initAjaxForm('form[name="unsubscribe"]',onSuccess,beforeSubmit,url);},onShow:function(){this.els.formContainer.css({'top':'35px','left':(Math.floor(this.els.formContainer.parent().width()/2)-
Math.floor(this.els.formContainer.outerWidth(true)/2))+'px','position':'absolute'}).show();FO.Layout.initDateTimePickers();this.initAjaxSubmit();},show:function(){var self=this,data={"student":self.parent.getSelectedStudent()[0].id,"course":self.parent.getSelectedCourse()[0].value}
FO.Core.load('.unsubscribe-form-container',FO.Core.link('manager','stopstudy','unsubscribe-form',null,'html'),data,$.proxy(self.parent,"showPreloader"),$.proxy(self,"onShow"),false);},hide:function(){this.els.formContainer.fadeOut();this.parent.hidePreloader()}};FO.Core.defineNs('FO.Form');FO.Form.Registration=function(){return{init:function(){FO.Form.Preeducation.init();FO.Form.Worklocation.init();FO.Layout.initDateTimePickers();$('input[name=register-btn]').click(function(){if(FO.Validation.isValid('#reg-form')){FO.Layout.setAllContentContainerPreloader().fadeIn();}else{return false;}});}}}();;FO.Core.defineNs("FO.Form");FO.Form.Metering=function(){this.init();};FO.Form.Metering.prototype={els:{},init:function(){this.initMarkup();},initMarkup:function(){FO.Core.apply(this.els,{scrollContainer:$('.scrollH','#slider'),formDesc:$('#form-description'),formDescToggler:$('#desciprion-toogler'),chapters:$('#form-chapters a'),switchLang:$('#switch-lang'),forms:$('.panel > form'),previousBtn:$('.go2previous'),go2descBtn:$('.go2description')});this.initEvents();},initEvents:function(){var $this=this;$this.els.formDescToggler.click(function(){var $el=$(this);$this.els.formDesc.slideToggle('normal',function(){$('b',$el).toggle();});return false;});$this.els.chapters.click(function(event){$this.getChapterData(this.id);$this.els.chapters.filter('.bold').removeClass('bold selected');$(this).addClass('bold selected');return false;});$this.els.previousBtn.click(function(){$this.els.chapters.filter('[href="'+this.hash+'"]').click();});$this.els.go2descBtn.click(function(){$this.els.chapters.filter('.bold').removeClass('bold');});$this.els.switchLang.click(function(){FO.Layout.setPreloader('#content-indent','',false);FO.Core.load('#content-indent > .width',this.href,{},null,function(){FO.Widgets.slider(true);$this.init();$('.preloader','#content-indent').remove();});return false;});$this.initAjaxSubmit();},setOptionsEvent:function(){this.els.options.delegate(':radio','change',function(){$(this).parent().addClass('selected').siblings('.selected').removeClass('selected');});},initChaptersOptions:function(){FO.Core.apply(this.els,{options:$('.option')});this.setOptionsEvent();},getChapterData:function(chapterId,callback,scope,args){var $this=this,$chapterForm=$('form','#chapter-'+chapterId),beforeSend=function(){$chapterForm.hide();},onSuccess=function(){$this.initChaptersOptions();$chapterForm.toggle();FO.Layout.correctWidthForIE7($chapterForm.find('.slider-panel-content'));if('function'===typeof callback){callback.call(scope,args);}};FO.Layout.setPreloader('#container3','',null);FO.Core.load('#chapter_'+chapterId+'_questions',FO.Core.link('student','metering','get-chapter-data',{},'html'),{"chapter_id":chapterId},beforeSend,onSuccess);},initAjaxSubmit:function(){var self=this,jForm,isLastChapter=false,beforeSubmit=function(formData,jqForm,options){jForm=jqForm;isLastChapter=jqForm.hasClass('lastchapter');var valid=FO.Validation.isValid(jqForm[0]);if(valid){FO.Layout.setPreloader('#container3','',null);FO.Layout.setMsgContainer('#metering-msg-container');}
return valid;},onSuccess=function(response,statusText){if(response['success']){var parent=jForm.parent();if(response['passed']){self.setChapterPassed(parent[0].id);}
if(!isLastChapter){self.els.chapters.filter('[href="#'+parent.next()[0].id+'"]').click();}}else{self.showError(response['errors'][0].msg);}},url=FO.Core.link('student','metering','save-chapter');$.map(self.els.forms,function(el){FO.Core.initAjaxForm(el,onSuccess,beforeSubmit,url);});},showError:function(msg){FO.Layout.showMsg(msg,true).hideElementAfter(FO.Layout.getMsgContainer(),20);},setChapterPassed:function(id){this.els.chapters.filter('[href="#'+id+'"]').addClass('passed');}};;FO.Core.defineNs('FO.Modules.Bpv');FO.Modules.Bpv.ReassignLayout=FO.Core.extend(FO.Form.PlanningBase,{els:{},fetchModulesCaption:'Fetching students list...',activeBtnCls:'active',module:'bpv',controller:'planning',constructor:function(config){$.extend(this,config);FO.Modules.Bpv.ReassignLayout.superclass.construct({scope:this,filtersURL:FO.Core.link('bpv','planning','planned-students',null,'html'),param:"course"});this.initMarkup();},initMarkup:function(){var self=this;FO.Core.apply(self.els,{bpv:$('.bpv-module.item.selected'),reassignForm:new FO.Form.Reassign({scope:self,module:self.module,controller:self.controller,onAfterReassign:function(){self.onAfterReassign();},onBeforeShow:function(){self.showPreloader();},onAfterHide:function(){self.hidePreloader();}}),preloaderOverlay:FO.Layout.setPreloader('.container1 .content-top',null,false),bpvModule:$('.bpv-module')});FO.Layout.correctTableWidthForIE('.tablesorter');self.initEvents();},initEvents:function(){var self=this;self.els.bpvModule.click(function(){$(this).siblings('.selected').removeClass('selected').end().addClass('selected');self.els.bpv=this.id;self.load({"module_id":this.id},'planned-students',null,null,self.fetchModulesCaption);});$('[name="student-id"]').live('click',function(){var $checked=$('[name="student-id"]:checked'),$cancelReassignBtn=$('.btn.cancel-reassign'),$reassignBtn=$('.btn.reassign');if($checked.length){if(''!==$checked.attr('execution')){$reassignBtn.hide("fast",function(){$cancelReassignBtn.addClass(self.activeBtnCls).data('execution',$checked.attr('execution')).slideDown();}).removeClass(self.activeBtnCls);}else{$cancelReassignBtn.hide("fast",function(){$reassignBtn.addClass(self.activeBtnCls).data('sbId',$checked[0].id).slideDown();}).removeClass(self.activeBtnCls);}}});$('.btn.reassign.active').live('click',function(){self.els.reassignForm.show($(this).data('sbId'));});$('.btn.cancel-reassign.active').live('click',function(){$.ajax({url:FO.Core.link(self.module,self.controller,'cancel-reassign'),type:'post',data:{"execId":$(this).data('execution')},dataType:'json',success:function(response){if(!response['success']){alert(response['err'][0]['msg']);}else{self.load({"module_id":self.els.bpv[0].id},'planned-students',null,null,self.fetchModulesCaption);}}});});},load:function(data,action,callback,scope,preloaderCaption){var after=function(){FO.Layout.correctTableWidthForIE('.tablesorter');FO.Layout.initTableSorting();if('function'==typeof callback){callback.call(scope);}},url=FO.Core.link(this.module,this.controller,action,{},'html');FO.Layout.setPreloader('.center-panel',preloaderCaption,true);FO.Core.load('.ajax-content',url,data,null,after,true);},getSelectedBpv:function(){return this.els.bpv;},showPreloader:function(){this.els.preloaderOverlay.fadeIn('fast');},hidePreloader:function(){this.els.preloaderOverlay.fadeOut('fast');},onAfterReassign:function(){this.hidePreloader();this.load({"module_id":this.els.bpv[0].id},'planned-students');}});;FO.Core.defineNs('FO.Modules.Bpv');FO.Modules.Bpv.ReassignedStudents=function(){this.init();};FO.Modules.Bpv.ReassignedStudents.prototype={redirectUrl:'http://'+document.domain+'/bpv/planning/index',msg:'',els:{},init:function(){this.initMarkup();},initMarkup:function(){this.els={reassignedStudents:$('.bpv-reassigned-students'),students:$('input[type="checkbox"]'),preloaderOverlay:FO.Layout.setPreloader('#container1 .content-top',null,false)}
this.initEvents();},initEvents:function(){var self=this;self.els.reassignedStudents.delegate("#accept-all, #reject-all","click",function(){self.els.students.attr("checked",true);self.reassignSelected(this.id==="accept-all"?1:0);}).delegate("#accept-selected, #reject-selected","click",function(){self.reassignSelected(this.id==="accept-selected"?1:0);}).delegate("#accept-student-btn, #reject-student-btn","click",function(){$('#'+$(this).attr("studentid")).attr("checked",true);self.reassignSelected(this.id==="accept-student-btn"?1:0);});},reassign:function(data,beforeSubmit,onSuccess,isLast){$.ajax({type:'post',data:data,dataType:'json',url:FO.Core.link('bpv','planning','reassign-student'),beforeSend:beforeSubmit,success:function(data,textStatus){if('function'==typeof onSuccess){onSuccess(data,isLast);}}});},onBeforeRequest:function(){FO.Layout.setMsgContainer('#error-container');},onAfterRequestSuccess:function(data,isLast,scope){var errors={},errCnt=0;scope=scope||this;if(!data['success']){errors[errCnt]={"id":errCnt,"msg":data['err'][0].msg};errCnt++;}else{scope.msg=scope.msg?scope.msg:data['msg'];}
if(isLast){if(!errCnt){FO.Layout.showMsg(scope.msg,false);var callback=null;if(!$('input[type="checkbox"]:unchecked').length){callback=function(){FO.Core.redirect(scope.redirectUrl);}}
FO.Layout.hideElementAfter(FO.Layout.getMsgContainer(),30,callback);}else{FO.Layout.showMsg(errors,true);}}},reassignSelected:function(accept){var $els=$('input[type="checkbox"]:checked'),self=this;self.msg=accept?'Student(s) accepted.':'Student(s) rejected.';if($els.length){var selectedCount=$els.length-1,rows2hideId='',val,data={},isLast;FO.Layout.setContentContainerPreloader();$els.each(function(idx){val=this.value;rows2hideId=''!==rows2hideId?', #'+val:'#'+val;data={execution:val,accept:accept};isLast=idx==selectedCount;self.reassign(data,self.onBeforeRequest,function(data,isLast,scope){self.onAfterRequestSuccess(data,isLast,scope);},isLast);});$(rows2hideId).remove();}},showPreloader:function(){this.els.preloaderOverlay.fadeIn('fast');},hidePreloader:function(){this.els.preloaderOverlay.fadeOut('fast');}};;FO.Core.defineNs("FO.Modules.Teacher");FO.Modules.Teacher.Planning=FO.Core.extend(FO.Form.PlanningBase,{els:{},defaults:{module:'teacher',controller:'planning',param:'course'},parent:null,preloader:null,constructor:function(){FO.Core.apply(this.defaults,arguments[0]);this.parent=FO.Modules.Teacher.Planning.superclass;this.parent.construct({scope:this,filtersURL:FO.Core.link(this.defaults.module,this.defaults.controller,'planned-modules',null,'html'),param:this.defaults.param,onAfterAjaxContentChange:this.onAfterAjaxContentChange});this.initMarkup();},initMarkup:function(){FO.Core.apply(this.els,{selectAll:$('#select-all-lessons'),rightPanelList:$('.right-panel .list'),attendency:$('.attendency'),studentsList:$('.students-list'),plan:$('.plan'),modules:$('input[name="module-id"]')});this.initEvents();},initEvents:function(){var self=this;self.els.rightPanelList.delegate(".item","click",function(){var data={};data[self.defaults.param]=this.id;$(this).addClass('selected').siblings('.selected').removeClass('selected');self.load(data,'planned-modules',function(){self.parent.prepareCenterPanel();self.parent.els.paging.init();self.onAfterAjaxContentChange();});});self.els.selectAll.click(function(){$('[name="module-id"]').attr("checked",this.checked);self.toggleActions(this.checked);});self.els.modules.live('click',function(){self.toggleActions(this.checked);});$('.name > a').live('click',function(event){event.preventDefault();var el=this,data={},type=el.className.match(/type\-[\d]+/g),callback=function(){FO.Layout.initTableSorting();self.parent.hideFilters.call(self.parent);FO.Layout.getPreloader().parent().trigger('sizeChange');$('.center-pnl-caption').filter(':nth-child(2)').html(el.rel).end().toggle();};if(type){data={"lesson":el.className.match(/lesson\-[\d]+/g)[0].split('-')[1],"type":type[0].split('-')[1]}}else{data={"module":el.className.match(/lesson\-[\d]+/g)[0].split('-')[1]}}
self.load(data,'planned-students',callback,'Loading students list...');});$('.back-to-modules').live('click',function(){var $selectedItem=self.els.rightPanelList.find('.item.selected'),data={};data[self.defaults.param]=$selectedItem[0].id;self.load(data,'planned-modules',function(){self.parent.prepareCenterPanel();self.onAfterAjaxContentChange();},'Loading lessons list...');});$('.students-list.active').live('click',function(){var lessonId=$('[name="module-id"]:checked')[0].value;$('.name > a.lesson-'+lessonId).trigger('click');});$('.student-name').live('click',function(){self.els.studentInfo=new FO.Form.UserInfoPopup({loadTo:'#content-indent > .width',url:FO.Core.link('student','personal','popup-info',{},'html'),onBeforeLoad:function(){self.preloader=FO.Layout.setPreloader('#content-indent > .width','',false).fadeIn();},onShow:function(){self.preloader.css('background-image','none');},onHide:function(){FO.Layout.hideVisiblePreloader().css('background-image','');},scope:self});self.els.studentInfo.show(this.id);});},onAfterAjaxContentChange:function(){var self=this;FO.Core.apply(self.els,{attendency:$('.attendency'),studentsList:$('.students-list')});self.parent.els.paging.initEvents();},toggleActions:function(enable){$(this.els.attendency,this.els.plan).toggleClass("active",enable);this.els.studentsList.toggleClass("active",$('[name="module-id"]:checked').length==1);},load:function(data,action,callback,preloaderCaption,callbackScope){var after=function(){FO.Layout.correctTableWidthForIE('.tablesorter');FO.Layout.initTableSorting();if('function'==typeof callback){callback.call(callbackScope);}};FO.Layout.setPreloader('.center-panel',preloaderCaption,preloaderCaption);FO.Core.load('.ajax-content',FO.Core.link(this.defaults.module,this.defaults.controller,action,null,'html'),data,null,after);}});;FO.Core.defineNs('FO.Modules.Broker');FO.Modules.Broker.AddStudentLayout=function(){this.init();};FO.Modules.Broker.AddStudentLayout.prototype={els:{},init:function(){this.initMarkup();},initMarkup:function(){var self=this;self.els={catalogue:new FO.Catalogue({onCourseClick:function(course){FO.Layout.setContentContainerPreloader('Fetching course instances...');FO.Core.load('#broker-course-instances',FO.Core.link('broker','student-registration','course-instances',null,'html'),{"course":course.id},null,function(){self.goToCourseInstancesTab.call(self);});FO.Layout.setMenuItemSelected(course);},onAfterSearch:function(){FO.Widgets.slider(true);}})};this.initEvents();},initEvents:function(){},goToCourseInstancesTab:function(){$('#slider .navigation a').removeClass('selected').eq(0).addClass('selected');$('.scrollH, .scrollV','#slider').scrollTo($('#course-instances'),200,'swing');}};;FO.Core.defineNs("FO.Modules.Broker");FO.Modules.Broker.SchoolCourses=FO.Core.extend(FO.Modules.Teacher.Planning,{els:{},constructor:function(){FO.Modules.Broker.SchoolCourses.superclass.constructor({module:"broker",controller:"planning"});}});;FO.Core.defineNs("FO.Modules.Broker");FO.Modules.Broker.Bpv=FO.Core.extend(FO.Modules.Bpv.ReassignLayout,{els:{},constructor:function(){FO.Modules.Broker.Bpv.superclass.constructor({controller:"planning",module:"bpv"});}});;FO.Core.defineNs("FO.Modules.Broker");FO.Modules.Broker.BpvCoordinators=FO.Core.extend(FO.Modules.Teacher.Planning,({constructor:function(){FO.Modules.Broker.BpvCoordinators.superclass.constructor({module:"broker",controller:"active-bpv-coordinators",param:"bpv-id"});}}));;FO.Core.defineNs('FO.Modules.Manager');FO.Modules.Manager.UnsubscribeLayout=function(){this.init();};FO.Modules.Manager.UnsubscribeLayout.prototype={els:{},init:function(){var self=this;self.els={student:$('.student.item.selected'),unsubscribeForm:new FO.Form.Unsubscribe(self),preloaderOverlay:FO.Layout.setPreloader('.container1 .content-top',null,false),paging:new FO.AjaxPaging({preloaderParentEl:'.container1 .content-top',contentContainer:'#content-indent > .width'}),search:new FO.Form.AjaxSearch({onAfterSearch:function(){self.els.search.init();self.els.paging.initEvents();}})};this.initEvents();},initEvents:function(){var self=this;FO.Layout.initTableSorting();$('.student.item').live('click',function(){$.extend(self.els,{student:$(this)});self.els.student.siblings('.selected').removeClass('selected').end().addClass('selected');var after=function(){FO.Layout.correctTableWidthForIE('.tablesorter');FO.Layout.initTableSorting();};FO.Layout.setPreloader('.center-panel','Fetching courses list...');FO.Core.load('.ajax-content',FO.Core.link('manager','stopstudy','planned-courses',null,'html'),{student:self.els.student[0].id},null,after);});$('[name="course-id"]').live('click',function(){self.activateUnsubscribe(this.checked,this);});$('table.modules tr').live('click',function(){var jRadio=$('input[type="radio"]',$(this));if(!jRadio.is(':checked')){jRadio.attr('checked','checked');self.activateUnsubscribe(true,jRadio);}});$('.btn.unsubscribe.active').live('click',$.proxy(self.els.unsubscribeForm,"show"));},activateUnsubscribe:function(activate,triggeredBy){if(activate){$.extend(this.els,{course:$(triggeredBy)});$('.btn.unsubscribe').addClass('active');}},getSelectedStudent:function(){return this.els.student;},getSelectedCourse:function(){return this.els.course;},showPreloader:function(){this.els.preloaderOverlay.fadeIn('fast');},hidePreloader:function(){this.els.preloaderOverlay.fadeOut('fast');},onAfterUnsubscribe:function(){this.hidePreloader();FO.Layout.setPreloader('.center-panel','Fetching courses list...');FO.Core.load('.ajax-content',FO.Core.link('manager','stopstudy','planned-courses',null,'html'),{student:this.els.student[0].id},null,function(){FO.Layout.correctTableWidthForIE('.tablesorter');FO.Layout.initTableSorting();});}};;FO.Core.defineNs('FO.Modules.Documents');FO.Modules.Documents.Layout=function(){this.init();};FO.Modules.Documents.Layout.prototype={els:{},formContainer:'#form-container',reloadFlag:false,lastEdited:{},newDocFormConfig:{},init:function(){this.newDocFormConfig={parent:this,formUrl:FO.Core.link('documents','index','new-doc-form',{},'html'),loadTo:this.formContainer,caller:null}
this.initMarkup();},initMarkup:function(){FO.Core.apply(this.els,{addDoc:$('.add-new-doc'),attachFile:$('.attach-new-file'),switchDocs:$('#switch-docs'),course:$('.course'),docsCategory:$('.category-head'),attachedFiles:$('.attached-files'),attachedTpls:$('.attached-templates'),closeAttached:$('.docs-container .close-small-icon'),deleteDoc:$('.delete-document'),editDoc:$('.edit-document')});this.setActiveDocs();this.initEvents();},initEvents:function(){var $this=this;$this.els.addDoc.live('click',function(){var self=$(this),action=self.hasClass('mandatory')?'add-mandatory':'add-general';FO.Core.apply($this.newDocFormConfig,{caller:self,submitUrl:FO.Core.link('documents','index',action)});FO.Core.apply($this.els,{newDocForm:new FO.Form.NewDocument($this.newDocFormConfig)});$this.els.newDocForm.show.call($this.els.newDocForm);});$this.els.attachFile.live('click',function(){var self=$(this);$this.lastEdited={name:self.attr('name'),id:self.attr('docid'),typeId:self.attr('doctypeid'),isCourseDoc:self.attr('iscoursedoc'),courseId:self.attr('iscoursedoc')?$('.course.selected')[0].id:'',type:self.hasClass('mandatory')?'mandatory':'general'}
FO.Core.apply($this.els,{attachFileForm:new FO.Form.Upload({scope:this,submitUrl:FO.Core.link('documents','index','attach-file'),formUrl:FO.Core.link('documents','index','attach-file-form',{},'html'),loadTo:$this.formContainer,caller:self,onBeforeLoad:function(){$this.beforeUploadFormShow();},onShow:function(){$this.onUploadFormShow();},onHide:function(){$this.onUploadFormHide();},onFileUploaded:function(){$this.setReloadFlag(true);},onBeforeScanLoad:function(){$this.onScanFormLoad();}})});$this.els.attachFileForm.show.call($this.els.attachFileForm);});$this.els.switchDocs.click(function(){$('#personal-documents, #course-documents, .heading').toggle();$('a',this).toggle();$this.setActiveDocs();});$this.els.course.click(function(){$(this).siblings('.selected').removeClass('selected').end().addClass('selected');$this.getCourseDocs(this.id);});$this.els.docsCategory.live('click',function(){$('.'+this.id).slideToggle('fast');});$this.els.attachedFiles.live('click',function(){var self=$(this);$('.doc-'+self.attr('docid')+'-tplds:visible').toggle();$('.doc-'+self.attr('docid')+'-files').toggle();});$this.els.attachedTpls.live('click',function(){var self=$(this);$('.doc-'+self.attr('docid')+'-files:visible').toggle();$('.doc-'+self.attr('docid')+'-tpls').toggle();});$this.els.closeAttached.live('click',function(){$(this).parents('tr').toggle();});$this.els.deleteDoc.live('click',function(){if(confirm('Are you sure you want to delete selected document?')){FO.Layout.setContentContainerPreloader('',false);var $el=$(this);$this.lastEdited={type:$el.attr('doctype'),courseId:$el.attr('iscoursedoc')?$('.course.selected')[0].id:''}
$.ajax({url:FO.Core.link('documents','index','delete'),type:"POST",data:{"id":$el.attr('docid')},success:function(response){if(response['success']){setTimeout(function(){$this.reload.call($this);},50);}else{FO.Layout.setMsgContainer('.docs-message-container').showMsg(response['errors'],true,null,15);}},dataType:"json"});}});$this.els.editDoc.live('click',function(){FO.Layout.setContentContainerPreloader('',false).fadeIn();var $el=$(this),data={"id":$el.attr('docid'),"iscoursedoc":$el.attr('iscoursedoc'),"execution_id":$el.attr('rel'),"is_general":+$el.hasClass('general')}
FO.Core.redirect(FO.Core.link('documents','index','edit',data,'html'));});},getCourseDocs:function(courseId){FO.Layout.setContentContainerPreloader('',false);var data={"courseId":courseId};FO.Core.load('#course-documents .general .content',FO.Core.link('documents','index','general',null,'html'),data);FO.Core.load('#course-documents .mandatory .content',FO.Core.link('documents','index','mandatory',null,'html'),data,null,null,true,false);},setActiveDocs:function(){FO.activeDocs=$('#personal-documents:visible').length?'personal':'course';},setReloadFlag:function(reload){this.reloadFlag=reload;},lastEditedAttr:function(attrName){return undefined!==this.lastEdited[attrName]?this.lastEdited[attrName]:'';},reload:function(){var self=this,doctype=self.lastEditedAttr('type'),cid=self.lastEditedAttr('courseId'),data=cid?{"courseId":cid}:{};FO.Layout.setPreloader('#content-indent > .width','',false);FO.Core.load('#'+FO.activeDocs+'-documents .'+doctype+' .content',FO.Core.link('documents','index',doctype,{},'html'),data);self.reloadFlag=false;self.lastEdited={};},onUploadFormShow:function(){this.els.preloader.css('background-image','none')},onScanFormLoad:function(){this.els.preloader.css('background-image','')},beforeUploadFormShow:function(){this.showPreloader();},onUploadFormHide:function(){if(this.reloadFlag){this.reload();}
this.hidePreloader();},showPreloader:function(){this.els.preloader=FO.Layout.setPreloader('#container1','',false);return this.els.preloader.fadeIn();},hidePreloader:function(){this.els.preloader.fadeOut('fast',function(){$(this).css('background-image','');});}};;FO.Core.defineNs("FO.Modules.Documents");FO.Modules.Documents.EditLayout=function(){this.init();};FO.Modules.Documents.EditLayout.prototype={els:{},docId:null,reloadFlag:false,init:function(){this.docId=$("[name=doc_id]").val();this.initMarkup();},initMarkup:function(){FO.Core.apply(this.els,{docPropertiesForm:$('form[name="edit-doc"]')});this.initEvents();},initEvents:function(){var layout=this;$('#attach-new-file').live("click",function(){var self=$(this);FO.Core.apply(layout.els,{attachFileForm:new FO.Form.Upload({scope:this,submitUrl:FO.Core.link('documents','index','attach-file'),formUrl:FO.Core.link('documents','index','attach-file-form',{},'html'),loadTo:'#form-container',caller:self,onBeforeLoad:function(){layout.beforeUploadFormShow();},onShow:function(){layout.onUploadFormShow();},onHide:function(){layout.onUploadFormHide();},onFileUploaded:function(){layout.setReloadFlag(true);}})});layout.els.attachFileForm.show.call(layout.els.attachFileForm);});$('#download-selected, #delete-selected').live("click",function(){var $checked=$('[name="file2edit"]:checked');if($checked.length){var filesIds=[];$checked.each(function(i){filesIds[i]=this.id;});var data={"files":filesIds};switch(this.id){case'download-selected':this.href=FO.Core.link('documents','index','get-selected-files',data);return true;break;case'delete-selected':if(confirm('Delete files?')){var docId=this.className.match(/docId\-[\d]+/g)[0].split('-')[1],caption='Deleting file(s)...';data.docId=docId;FO.Layout.setContentContainerPreloader(caption);$.ajax({type:'post',url:FO.Core.link('documents','index','delete-selected'),data:data,dataType:'json',success:function(data){if(data['success']){layout.onAfterEditFiles(docId);}else{FO.Layout.showMsg(data['errors'][0]['msg'],true);}}});break;}}}else{return false;}});$('.delete-file').live("click",function(){if(confirm('Delete file?')){var $el=$(this),fileId=$el.attr('class').match(/fileId\-[\d]+/g)[0].split('-')[1],docId=$el.attr('class').match(/docId\-[\d]+/g)[0].split('-')[1];FO.Layout.setContentContainerPreloader('Deleting file...');$.ajax({type:"POST",url:FO.Core.link('documents','index','delete-file'),data:{"fileId":fileId,"docId":docId},dataType:'json',success:function(data){if(data['success']){layout.onAfterEditFiles(docId);}else{FO.Layout.showMsg(data['errors'][0]['msg'],true,null,20);}}});}
return false;});$('#select-all').live("click",function(){$("[name=file2edit]").attr('checked',this.checked);});$('#submit-changes').click(function(){FO.Layout.setContentContainerPreloader('Submitting changes...');$.ajax({type:'post',url:FO.Core.link('documents','index','start-update-workflow'),data:{"oldDocId":$('[name="original_id"]',layout.els.docPropertiesForm).val(),"newDocId":$('[name="doc_id"]',layout.els.docPropertiesForm).val(),"iscoursedoc":$('[name="iscoursedoc"]',layout.els.docPropertiesForm).val()},dataType:'json',success:function(response){FO.Layout.setMsgContainer('#doc-edit-messages');if(response['success']){FO.Core.redirect(FO.Core.link('documents','index','index',null,'html'));}else{FO.Layout.showMsg(response['errors'][0]['msg'],true,null,20);}}});});$('#cancel-changes').click(function(){var originalId=+$('[name="original_id"]',layout.els.docPropertiesForm).val(),docId=+$('[name="doc_id"]',layout.els.docPropertiesForm).val(),redirect=false,confirmed=true;if(originalId==docId){redirect=true;var msg='Cancelling changes will delete the document too.\nConfirm delete.';confirmed=confirm(msg);}
if(confirmed){FO.Layout.setContentContainerPreloader('Cancelling changes...');$.ajax({type:'post',url:FO.Core.link('documents','index','cancel-changes'),data:{"execution_id":this.rel},dataType:'json',success:function(response){FO.Layout.setMsgContainer('#doc-edit-messages');if(response['success']){if(redirect){FO.Core.redirect(FO.Core.link('documents','index','index',null,'html'));}else{layout.loadOriginal.call(layout);}}else{FO.Layout.showMsg(response['errors'][0]['msg'],true,null,20);}}});}});this.initUpdateDocProperties();},initUpdateDocProperties:function(){var url=FO.Core.link('documents','index','update')
FO.Layout.setContentContainerPreloader('Updating document...');FO.Core.initAjaxForm(this.els.docPropertiesForm,null,null,url,'json');FO.Layout.initDateTimePickers('days');},loadOriginal:function(){var url=FO.Core.link('documents','index','edit',null,'html'),data={"id":$('[name="original_id"]',this.els.docPropertiesForm).val(),"execution_id":0,"is_general":$('[name="is_general"]',this.els.docPropertiesForm).val()},self=this;FO.Layout.setContentContainerPreloader('Fetching document...');FO.Core.load('#indent .comp-cont',url,data,null,function(){FO.Core.apply(self.els,{docPropertiesForm:$('form[name="edit-doc"]')});self.initUpdateDocProperties.call(self);});},reload:function(){this.onAfterEditFiles(this.docId);this.reloadFlag=false;},onAfterEditFiles:function(docId){FO.Layout.setContentContainerPreloader('Updating list...');FO.Core.load('#attached-files',FO.Core.link('documents','index','update-files-list',null,'html'),{"id":docId});},onUploadFormShow:function(){this.els.preloader.css('background-image','none')},beforeUploadFormShow:function(){this.showPreloader();},setReloadFlag:function(flag){this.reloadFlag=flag;},onUploadFormHide:function(){if(this.reloadFlag){this.onAfterEditFiles(this.docId);}
this.hidePreloader();},showPreloader:function(){this.els.preloader=FO.Layout.setPreloader('#container3','',false);return this.els.preloader.fadeIn();},hidePreloader:function(){this.els.preloader.fadeOut('fast',function(){$(this).css('background-image','');});}};;FO.Core.defineNs("FO.Modules.Student");FO.Modules.Student.Planning=FO.Core.extend(FO.Form.PlanningBase,{els:{},actions:[],parent:null,constructor:function(){this.parent=FO.Modules.Student.Planning.superclass;this.parent.construct({scope:this,filtersURL:FO.Core.link('student','planning','planned-modules',null,'html'),onAfterAjaxContentChange:this.onAfterAjaxContentChange});this.initMarkup();},initMarkup:function(){FO.Core.apply(this.els,{selectAll:$('#select-all-lessons'),course:$('.course'),checkAbsent:$('.absent'),reschedule:$('.reschedule'),modules:$('input[name="module-id"]')});this.actions=[this.els.checkAbsent,this.els.reschedule];this.initEvents();},initEvents:function(){var self=this;self.els.course.click(function(){$(this).siblings('.selected').removeClass('selected').end().addClass('selected');self.load({"course":this.id},self.onAfterAjaxContentChange,self);});self.els.selectAll.live("click",function(){$('[name="module-id"]').attr("checked",this.checked);self.toggleActions(this.checked);});self.els.modules.live('click',function(){self.toggleActions(this.checked);});},toggleActions:function(enable){for(var i in this.actions){this.actions[i].toggleClass("active",enable);}},load:function(data,callback,scope){var after=function(){FO.Layout.correctTableWidthForIE('.tablesorter');FO.Layout.initTableSorting();if('function'==typeof callback){callback.call(scope);}};FO.Layout.setPreloader('.center-panel','',false);FO.Core.load('.ajax-content',FO.Core.link('student','planning','planned-modules',null,'html'),data,null,after);},onAfterAjaxContentChange:function(){var self=this;FO.Core.apply(self.els,{checkAbsent:$('.absent'),reschedule:$('.reschedule')});self.actions=[self.els.checkAbsent,self.els.reschedule];self.parent.els.paging.initEvents();}});;$(document).ready(function(){FO.Validation.init();FO.Widgets.init();if($('.module-unsubscribe').length){FO.Form.Unsubscribe.init();}
if($('#reg-form').length){FO.Form.Registration.init();}
if($('#metering-form').length){new FO.Form.Metering();}
if($('.broker-student-registration').length){new FO.Modules.Broker.AddStudentLayout();}
if($('#broker-active-coordinators').length){new FO.Modules.Broker.BpvCoordinators();}
if($('form[name="student-info-form"]').length){FO.Form.StudentInfoUpdate.init();}
if($('.catalogue').length){new FO.Catalogue();}
if($('.documents').length){new FO.Modules.Documents.Layout();}
if($('.module-edit-document').length){new FO.Modules.Documents.EditLayout();}
if($('.datetime-picker').length){FO.Layout.initDateTimePickers();}
if($('.bpv-reassigned-students').length){new FO.Modules.Bpv.ReassignedStudents();}
if($('#student-planning').length){new FO.Modules.Student.Planning();}
if($('#teacher-planning').length){new FO.Modules.Teacher.Planning();}
if($('#unsubscribe-layout').length){new FO.Modules.Manager.UnsubscribeLayout();}
if($('#reassign-layout').length){new FO.Modules.Bpv.ReassignLayout();}
if($('#broker-bpv').length){new FO.Modules.Broker.Bpv("broker","bpv");}
if($('#broker-school-courses').length){new FO.Modules.Broker.SchoolCourses();}
if($('.subscribe-existing').length){new FO.Student.Subscribe.Existing.Layout();}
if(/MSIE 6.0/.test(navigator.appVersion)){var el=$('.bottom.equal'),el2=$('.partners');if(el.height()<350){el.height(350);}
if(el2.height()<250){el.height(250);}}});