component['ctrlSlideShow']=Class.create({THREAD_ID:null,EXEC_UID:null,arrParams:null,intAciveIconNum:null,initialize:function(arrInstVars,arrParams,arrLang)
{this.THREAD_ID=arrInstVars.THREAD_ID;this.EXEC_UID=arrInstVars.EXEC_UID;$(document.body).insert({top:$F('slideShowCode')});$('close').observe('click',this._close);$(document).observe('slideShow:start',this._start.bind(this));$('previousImage').observe('click',this._previous.bind(this));$('nextImage').observe('click',this._next.bind(this));$('previewsFrame').observe(window.addEventListener?'DOMMouseScroll':'mousewheel',this._onScroll.bind(this));},_start:function(evt)
{$('previews').update('');$('total').update(' ');$('bigContainer').update('<span id="picture"></span>');var intShowNum=1;var intShowId=evt.memo.intShowId||null;if(intShowId)
{intShowNum=evt.memo.intShowNum||1;}
this._scroll(null);new Ajax.Request('/?call_element=component.rcFilesInfoGetter',{method:'post',asynchronous:false,evalJSON:true,parameters:evt.memo,onSuccess:function(transport,json)
{var strTpl=$F('slideShowSmallBlock');if(transport.responseJSON!=null)
{var arrData=transport.responseJSON;$$('#groups1 a','#groups2 a').invoke('remove');var elG1=$('groups1');var elG2=$('groups2');for(var int=0,length=arrData.arrGroups.length;int<length;int++)
{elG1.insert({bottom:new Element('a',{href:'javascript:void(0)','class':'active'}).update(arrData.arrGroups[int].shortName)});elG2.insert({bottom:new Element('a',{href:'javascript:void(0)','class':(arrData.arrGroups[int].id==arrData.intActiveGroup?'active':''),gname:arrData.arrGroups[int].name,gid:arrData.arrGroups[int].id}).update(arrData.arrGroups[int].shortName)});}
if(!length)
{$('groups1','groups2').invoke('hide');}
else
{$('groups1','groups2').invoke('show');}
var i=1;for(var key in arrData.arrItems)
{$('previews').insert({bottom:strTpl.interpolate({strSmallSrc:arrData.arrItems[key].gallerySmall,strBigSrc:arrData.arrItems[key].galleryBig,strComment:arrData.arrItems[key].strComment,intNum:i})});if(!intShowId&&i==intShowNum)
{this._showBig(i);}
else if(intShowId&&key==intShowId)
{this._showBig(i);}
i++;}
this.intTotal=i-1;$('total').update(this.intTotal);$('previews').setStyle({width:118*this.intTotal+'px'});this._scrollToActive.bind(this).defer();this._setIconsHandlers();}}.bind(this)});$('slideShowCntr','bg').invoke('show');},_setIconsHandlers:function()
{$$('#groups2 a').each(function(el)
{el.observe('click',this._onClickGroup.bind(this,el));}.bind(this));$$('#previewsFrame a').each(function(el)
{el.observe('click',this._onClickSmall.bind(this,el));}.bind(this));},_onClickGroup:function(el)
{$(document).fire('slideShow:start',{action:'galleries',groupId:el.getAttribute('gid')});},_onClickSmall:function(el)
{this.intWaitingIconNum=null;this._showBig(el.getAttribute('iconNum'));},_showBig:function(intIconNum)
{if(intIconNum>this.intTotal||intIconNum<=0)
{return;}
elActiveOld=$('previewsFrame').down('.active');if(elActiveOld)elActiveOld.removeClassName('active');this.intAciveIconNum=parseInt(intIconNum);var elHref=$('previewsFrame').down('a[iconNum="'+intIconNum+'"]');elHref.addClassName('active');if(this.isLock)
{this.intWaitingIconNum=intIconNum;return;}
this.isLock=true;$('curent').update(intIconNum);new Effect.Opacity('picture',{duration:0.6,from:1,to:0,afterFinish:function()
{$('bigContainer').update('<img id="picture" src='+elHref.getAttribute('bigSrc')+' style="display:none;" />');$('picture').setStyle({opacity:0}).show();(function(){new Effect.Opacity('picture',{duration:0.6,from:0,to:1,afterFinish:function()
{this._checkStatus();this.isLock=false;var intW=this.intWaitingIconNum;this.intWaitingIconNum=null;if(intW)this._showBig(intW);}.bind(this)});}.bind(this)).defer();}.bind(this)});if(elHref.getAttribute('strComment'))
{$('comment').update(elHref.getAttribute('strComment')).show();}
else
{$('comment').hide();}},_previous:function(evt)
{this._showBig(this.intAciveIconNum-1);this._scrollToActive();},_next:function(evt)
{this._showBig(this.intAciveIconNum+1);this._scrollToActive();},_scrollToActive:function()
{this._scroll(Math.ceil(-($('previews').getWidth()/this.intTotal))*(this.intAciveIconNum-1));},_scroll:function(intOffset)
{if(intOffset==null)
{$('previews').setStyle({marginLeft:'0px'});return;}
if(this.intTotal<=4)
{return;}
if(intOffset>0)intOffset=0;var intMaxOffset=-118*(this.intTotal-5);if(intOffset<intMaxOffset)intOffset=intMaxOffset;$('previews').setStyle({marginLeft:intOffset+'px'});},_up:function(evt)
{this._scroll(parseInt($('previewsFrame').getStyle('top').replace('px',''))+50);},_down:function(evt)
{this._scroll(parseInt($('previewsFrame').getStyle('top').replace('px',''))-50);},_onScroll:function(evt)
{var wheelData=evt.detail?evt.detail*-1:evt.wheelDelta/40;wheelData=Math.ceil(wheelData/3);this._scroll(parseInt($('previews').getStyle('margin-left').replace('px',''))+30*wheelData);evt.stop();},_close:function(evt)
{$('slideShowCntr','bg').invoke('hide');evt.stop();},_checkStatus:function()
{if(this.intAciveIconNum==1)
{$('previousImage').hide();}
else
{$('previousImage').show();}
if(this.intAciveIconNum==this.intTotal)
{$('nextImage').hide();}
else
{$('nextImage').show();}}});
try{arrJsLoaded['component.ctrlSlideShow.js']=true;init.jsLoaded("component.ctrlSlideShow.js");}catch(e){};
