(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,btnMove:null,mouseWheel:false,auto:null,speed:200,easing:null,visible:3,start:0,scroll:1,ajaxLoadBaseUrl:null,ajaxLimitParam:null,ajaxOffsetParam:null,noNextList:null,noPrevList:null,existNextList:null,existPrevList:null},o||{});return this.each(function(){var running=false,animCss="left",sizeCss="width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;var li=$("li",ul),itemLength=li.size(),curr=o.start;div.css("visibility","visible");li.css({overflow:"hidden",float:"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var browserLength=($.browser.msie&&$.browser.version.substr(0,1)=='6')?10:0;var liSize=width(li);var ulSize=liSize*itemLength+browserLength;var divSize=liSize*v;li.css({width:li.width(),height:li.height()});ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));var ajaxLoaded=0;div.css(sizeCss,divSize+"px");if(o.btnPrev)
$(o.btnPrev).click(function(){return go(curr-o.scroll);});if(o.btnNext)
$(o.btnNext).click(function(){return go(curr+o.scroll);});if(o.btnGo)
$.each(o.btnGo,function(i,val){$(val).click(function(){return go(i);});});if(o.btnMove){$(o.btnMove).click(function(){return moveByIdButton();});}
if(o.mouseWheel&&div.mousewheel)
div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll);});if(o.auto)
setInterval(function(){go(curr+o.scroll);},o.auto+o.speed);function vis(){return li.slice(curr).slice(0,v);};function moveByIdButton(){var btnMove=o.btnMove;var nId=$(btnMove).val();var to=null;$.each(li,function(i,obj){var oId=$(obj).attr('id');if(oId==nId)
to=i;});if(to!==null){to=to-(to%o.scroll);go(to);}};function go(to){if(!running){var want=to-1+v*2,exist=(itemLength-1);if(exist<want&&ajaxLoaded<want&&o.ajaxLoadBaseUrl!==null&&o.ajaxLimitParam!==null&&o.ajaxOffsetParam!==null){var offset=itemLength,limit=want-exist;var url=o.ajaxLoadBaseUrl+'&'+o.ajaxLimitParam+'='+limit+'&'+o.ajaxOffsetParam+'='+offset;$.get(url,null,function(data,status){ul.append(data);ajaxLoaded=want;runMoving(to);});}else{runMoving(to);}}
return false;};function runMoving(to){tLi=$("li",ul),tl=tLi.size();li=$("li",ul),itemLength=li.size();ulSize=liSize*itemLength+browserLength;ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));if(to<0||to>itemLength-1){return;}else{curr=to;}
running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){running=false;});if(curr-o.scroll<0){if(o.noPrevList){o.noPrevList.call(this,vis());}}else{if(o.existPrevList){o.existPrevList.call(this,vis());}}
if(curr+o.scroll>itemLength-1){if(o.noNextList){o.noNextList.call(this,vis());}}else{if(o.existNextList){o.existNextList.call(this,vis());}}
return false;}});};function css(el,prop){return parseInt($.css(el[0],prop))||0;};function width(el){return el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight');};function height(el){return el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom');};})(jQuery);
var educationLevelSecondary;var educationLevelSecondarySpecial;var personLearning;var personNotLearning;var personStatusCollegian;var personStatusSchoolboy;var photoOnLine;var personId;var globalAlbum;var pathWeb='';var pathWebImg='';var ajaxPhotoLoadBaseUrl='';var ajaxPhotoOnLine=0;var startPhoto=0;function ShowAgencyOfCompany()
{$('#agencyOfCompany').show();$('#privateUser').hide();$('#personInfo').hide();$('#personInfo :input').attr('disabled',true);$('#privateUser :input').attr('disabled',true);}
function ShowPrivateUser()
{$('#agencyOfCompany').hide();$('#privateUser').show();$('#personInfo :input').attr('disabled',false);$('#privateUser :input').attr('disabled',false);ShowPersonalInfo();$('#ShortFormRegistrationButton').hide();}
function ShowPersonalInfo()
{$('#personInfo').show();}
function ShowEduStatus()
{$('#eduStatusContainer').show();$('#educationListContainer').show();checkInstituteFields();checkRegistrationButtons();}
function HideEduStatus()
{$('#eduStatusContainer').hide();$('#educationListContainer').show();checkInstituteFields();checkRegistrationButtons();}
function eduStatusOnChange()
{checkInstituteFields();}
function educationLevelOnChange(item)
{checkEducationLevelItem(item);}
function checkEducationLevelItem(item)
{var selectedNode=$('#educationList'+item+'level :selected');var selected=selectedNode.attr('value');if((selected==educationLevelSecondary||selected==educationLevelSecondarySpecial)){$('#_instituteItem'+item).attr('disabled',true);$('#_instituteItem'+item).hide();$('#_beginYear'+item).attr('disabled',true);$('#_beginYear'+item).hide();$('#_instituteNameItem'+item).attr('disabled',false);$('#_instituteNameItem'+item).show();}else{$('#_instituteItem'+item).attr('disabled',false);$('#_instituteItem'+item).show();$('#_beginYear'+item).attr('disabled',false);$('#_beginYear'+item).show();$('#_instituteNameItem'+item).attr('disabled',true);$('#_instituteNameItem'+item).hide();}}
function checkInstituteFields()
{var nodes=null;var selectedNode=$('#eduStatus :selected');var selected=selectedNode.attr('value');if($('#learning'+personLearning).attr('checked')&&!selected){$('#educationListContainer').hide();}else{$('#educationListContainer').show();}
if(selected&&$('#learning'+personNotLearning).attr('checked')){selectedNode.attr('selected',false);selected=null;}
if((selected==personStatusCollegian||selected==personStatusSchoolboy)&&$('#learning'+personLearning).attr('checked')){nodes=$('#educationListContainer ._instituteItem');nodes.attr('disabled',true);nodes.hide();nodes=$('#educationListContainer ._leveItem');nodes.attr('disabled',true);nodes.hide();nodes=$('#educationListContainer ._beginYear');nodes.attr('disabled',true);nodes.hide();nodes=$('#educationListContainer ._dropEduList');nodes.attr('disabled',true);nodes.hide();nodes=$('#educationListContainer ._instituteNameItem');nodes.attr('disabled',false);nodes.show();$('#educationListContainerButton').hide();}else{nodes=$('#educationListContainer ._instituteItem');nodes.each(function(i,n){checkEducationLevelItem(i);});$('#educationListContainerButton').show();}}
function educationOblastChange(item)
{var itemBlock=item;$('#educationList'+itemBlock+'institute').attr('disabled',true);$('#educationList'+itemBlock+'instituteLoader').show();$('#educationList'+itemBlock+'institute').load(pathWeb+"?area=registerController",{oblast:$('#educationList'+itemBlock+'oblast :selected').attr('value'),action:'institutes'},function(){$('#educationList'+itemBlock+'institute').attr('disabled',false);$('#educationList'+itemBlock+'instituteLoader').hide();});}
function removeEduElement(item)
{$('#educationList'+item).remove();return false;}
function checkRegistrationButtons()
{if($('#learning<?=PersonLearningEnumeration::LEARNING?>').attr('checked')||$('#learning<?=PersonLearningEnumeration::DONOT_LEARNING?>').attr('checked')){ShowPersonalInfo();$('#ShortFormRegistrationButton').hide();$('#educationListContainerButton').show();}else{$('#educationListContainerButton').hide();}}
function onWorkReady(){if(document.getElementById("workingFrom"))
Calendar.setup({inputField:"workingFrom",ifFormat:"%Y-%m-%d %H:%M"});if(document.getElementById("workingTo"))
Calendar.setup({inputField:"workingTo",ifFormat:"%Y-%m-%d %H:%M",zIndex:20000});if(document.getElementById("comment"))
tinyMCE.execCommand('mceAddControl',false,'comment');}
function onWorkClose(){try{if(document.getElementById("comment"))
tinyMCE.execCommand('mceRemoveControl',false,'comment');}catch(e){}}
function onEduReady(){checkEducationLevelItem('');}
function onInfoReady(){if(document.getElementById("about"))
tinyMCE.execCommand('mceAddControl',false,'about');}
function onInfoClose(){try{if(document.getElementById("about"))
tinyMCE.execCommand('mceRemoveControl',false,'about');}catch(e){}}
function refresh()
{document.location.href=document.location.href;}
function onLoadPhoto()
{if(this.body.length<61)
{this.close();reloadPhotoBlock();}}
function onLoadWindow()
{if(this.body.length<61)
{this.close();if(parent)parent.refresh();else refresh();}}
function completePhotoCallback(response)
{if(win){win.body=response;win.data=win.renderHTML();if(win.modal)
win.modal.dialog.data.html(win.data);win.onLoad();if(win.modal)
win.modal.bindEvents();}}
function showMorePhotos()
{return false;}
function loadPhotoBlock(album)
{globalAlbum=album;$('#albumContainer').load(pathWeb+'?area=profileController&ajAction=photoes&person='+personId+'&album='+album+' #albumContainer > *',null,function(){prepairCarousel();});return false;}
function reloadPhotoBlock()
{return loadPhotoBlock(globalAlbum);}
function prepairCarousel()
{var baseUrl=ajaxPhotoLoadBaseUrl+'&album='+globalAlbum;$("#photoContainer").jCarouselLite({btnNext:"#nextPhotoLink",btnPrev:"#prevPhotoLink",btnMove:"#movePhotoLink",visible:ajaxPhotoOnLine,scroll:ajaxPhotoOnLine,speed:1500,ajaxLoadBaseUrl:baseUrl,ajaxLimitParam:'limitPhoto',ajaxOffsetParam:'startPhoto',noNextList:function(obj){$("#nextPhotoLink").addClass('disabled');},noPrevList:function(obj){$("#prevPhotoLink").addClass('disabled');},existPrevList:function(obj){$("#prevPhotoLink").removeClass('disabled');},existNextList:function(obj){$("#nextPhotoLink").removeClass('disabled');}});}
function viewImage(link)
{var url=$(link).attr('href');liteWindow(url,{title:'',width:'600px',onLoad:onLoadViewImage},imageViewDecorator);return false;}
function imageViewDecorator(){var html='<table class="photoviewer">'+'<tr>'+'<td class="tleft"><img src="'+pathWebImg+'blank.gif" width="10" alt="" /></td>'+'<td class="window-content" rowspan="2">'+'<div class="close2"><a href="#" class="modalCloseX modalClose"><img src="'+pathWebImg+'window/close_cross.gif" alt="Закрыть" /></a></div>'+'<div class="window-message">'+this.errorMessage+'</div>'+'<div class="window-body">'+this.body+'</div>'+'</td>'+'<td class="tright"><img src="'+pathWebImg+'blank.gif" width="10" alt="" /></td>'+'</tr>'+'<tr class="window-bottom">'+'<td class="bleft"><img src="'+pathWebImg+'blank.gif" width="10" alt="" /></td>'+'<td class="bright"><img src="'+pathWebImg+'blank.gif" width="10" alt="" /></td>'+'</tr>'+'</table>';return html;}
function onLoadViewImage()
{$('#window-container').width('');$('#window-container').css('top','5%');var voteWidth=$('#window-container .current').css('width');var curId=$('#window-container ._currentImage').val();$('#albumPhotoLi'+curId+' .current').animate({width:voteWidth},1000);curLi=$('#albumPhotoLi'+curId);if(curLi.prev().length==0){$('#imageViewPrevImage').addClass('disabled');}
if(curLi.next().length==0){$('#imageViewNextImage').addClass('disabled');}
var prev=curLi,num=1;while((prev=prev.prev())&&prev.length>0){num++;}
if($.browser.msie){$('#window-container').show();}else{$('#window-container').fadeIn(500);}}
function switchImage(link)
{if(win.isDisabled()==false){win.disable();link=$(link);var url=link.attr('href');var imgId=link.attr('imgId');$('#movePhotoLink').val('albumPhotoLi'+imgId);$('#movePhotoLink').click();$('#viewPhotoForm').attr('action',url);if($.browser.msie){$('#window-container').hide();win.loadData({url:url,data:null,type:'GET'});}else{$('#window-container').fadeOut(500,function(){win.loadData({url:url,data:null,type:'GET'});})}}
return false;}
function switchPrevImage(current)
{var current=$('#'+current);var prevLi=current.parents('li').prev();var prevLink=prevLi.children('div').children('._imageLink');if(prevLink.length==0)
return false;return switchImage(prevLink);}
function switchNextImage(current)
{var current=$('#'+current);var nextLi=current.parents('li').next();var nextLink=nextLi.children('div').children('._imageLink');if(nextLink.length==0)
return false;return switchImage(nextLink);}
$(window).keydown(function(event){switch(event.keyCode){case 37:$('#imageViewPrevImage').click();break;case 39:$('#imageViewNextImage').click();break;default:break;}
return true;});
function switchImageCheckbox(current,func)
{var current=$(current),next=current.next(),prev=current.prev(),checkbox=null,unchecked=null,checked=null;if(!current.hasClass('_iconCheckboxImage')){return false;}
if(!prev.hasClass('_iconCheckboxImage')){checked=next,unchecked=current,checkbox=prev;checkbox.attr('checked',true);if(func&&!func.call()){checkbox.removeAttr('checked');return false;}
checked.show();unchecked.hide();}else{checked=current,unchecked=prev,checkbox=prev.prev();checkbox.removeAttr('checked');if(func&&!func.call()){checkbox.attr('checked',true);return false;}
checked.hide();unchecked.show();}
return true;}