$(document).ready(function(){PlayerProcessor.init_all();});var PlayerProcessor=new function(){var SETTINGS=SETTINGS||{};var self=this;self.settings={key:'#@a38baa27b1f0d15312e',clip:{scaling:"fit",autoPlay:true,autoBuffering:false},canvas:{backgroundColor:"#000",backgroundGradient:"none"},play:{opacity:1,label:null,replayLabel:'Ещё раз'},plugins:{rtmp:{url:'http://kanobu.ru/flowplayer/flowplayer.rtmp-3.2.1.swf',proxyType:'best',netConnectionUrl:'rtmp://stream.kanobu.ru:80/flowplayer',durationFunc:'getStreamLength'},controls:{url:'http://kanobu.ru/flowplayer/flowplayer.controls-3.2.5.swf',backgroundColor:"transparent",backgroundGradient:"none",height:30,border:'none',hideDelay:1000,all:false,enabled:{scrubber:true},scrubber:true,volume:true,play:true,mute:true,playlist:false,fullscreen:true,time:false,scrubberHeightRatio:0.4,volumeSliderHeightRatio:0.4,progressColor:'#47ff91',volumeColor:'#47ff91',bufferColor:'rgba(163, 163, 163, 0.4)',volumeSliderColor:'rgba(50, 50, 50, 1)',buttonOverColor:'#47ff91',tooltipColor:'#ffffff',tooltipTextColor:'#000000',autoHide:'always',bottom:5,left:'50%'}}};self.video_settings=$.extend(true,{},self.settings,{plugins:{videoplaza:{url:'http://service.cdn.videoplaza.com/resources/flash/flowplayer-3.2.6/latest/vp_plugin.swf',vpid:'9f03e736-81c3-4943-8bc4-fabbf4593f73'}},logo:{url:'http://kanobu.ru/img/fp_logo.png',fullscreenOnly:false,top:6,right:5,linkUrl:'http://kanobu.ru'},clip:{provider:SETTINGS.MEDIA_VIDEO_STREAM_URLS?'rtmp':"http",seekableOnBegin:true,tags:['kanobu'],onStart:function(clip){$('#embedTab').removeClass("inactive");_gaq.push(['_trackEvent','Videos','Play',clip.url]);$('#embedTab').removeClass("inactive");var inc_url='/video/inc/?url='+clip.url;$.get(inc_url,{},function(){});},onFinish:function(clip){_gaq.push(['_trackEvent','Finish','Play',clip.url]);}}});self.audio_settings=$.extend(true,{},self.settings,{clip:{provider:SETTINGS.MEDIA_AUDIO_STREAM_URLS?'rtmp':"http",onStart:function(clip){_gaq.push(['_trackEvent','Music','Play',clip.url]);},onFinish:function(clip){_gaq.push(['_trackEvent','Music','Finish',clip.url]);}},canvas:{backgroundColor:'transparent'},play:{opacity:0,replayLabel:null},plugins:{audio:{url:'http://kanobu.ru/flowplayer/flowplayer.audio-3.2.2.swf'},controls:{autoHide:"never",fullscreen:false,time:true,bottom:0}}});self.main_audio_player_settings=$.extend(true,{},self.audio_settings,{plugins:{controls:{time:false}}});self.main_video_player_settings=$.extend(true,{},self.video_settings);self.video_stream_settings=$.extend(true,{},self.settings,{clip:{url:'live',provider:'rtmp',netConnectionUrl:'rtmp://fms.rambler.ru/live',onStart:function(clip){$('#embedTab').removeClass("inactive");_gaq.push(['_trackEvent','StreamVideo','Play']);setTimeout("_gaq.push(['_trackEvent', 'StreamVideo', 'Watch']);",10*60*1000);$('#embedTab').removeClass("inactive");var inc_url='/videos/stream_inc/';$.get(inc_url,{},function(){});}}});self.player_url='http://kanobu.ru/flowplayer/flowplayer.commercial-3.2.7.swf';self.video_player_sel="a.player_centered";self.video_stream_player_sel="a.video_stream_player";self.audio_player_sel="a.audio_single";self.audio_player_playlist_sel="a.audio_playlist";self.main_video_player_sel="#player_main";self.main_audio_player_sel="#mainaudio";self.dummy_sel='#dummy-scrollable';self.player_data={src:self.player_url,wmode:'transparent'};self.player_playlist_scroll_settings={size:5,vertical:true,next:'a.next',prev:'a.prev',mousewheel:true};self.init_all=function(parent){if(!parent){parent=$(document);}
self.init_video_player(parent.find(self.video_player_sel));self.init_video_stream_player(parent.find(self.video_stream_player_sel));self.init_audio_player(parent.find(self.audio_player_sel));self.init_audio_player_playlist(parent.find(self.audio_player_playlist_sel));self.init_main_video_player(parent.find(self.main_video_player_sel));self.init_main_audio_player(parent.find(self.main_audio_player_sel));if($(self.dummy_sel).length){$(self.dummy_sel).scrollable({keyboard:false});$(self.dummy_sel).data('scrollable').focus();}};self.init_video_player=function(elements){if(elements.length){elements.flowplayer(self.player_data,self.video_settings);elements.each(function(){$f(this).ipad()});}};self.init_audio_player=function(elements){if(elements.length){elements.flowplayer(self.player_data,self.audio_settings);}};self.init_audio_player_playlist=function(elements){if(elements.length){elements.each(function(){var playlist=$(this).parent().find(".musicplayer");if(playlist.length){var playlist_id="#"+playlist.attr('id');var musiclist=$(this).parent().find('.musiclist');musiclist.scrollable(self.player_playlist_scroll_settings);musiclist.mouseenter(self.toggleKeyboardScroll).mouseleave(self.toggleKeyboardScroll).data("scrollable").getConf().keyboard=false;}
var uniq_settings=$.extend(true,{},self.audio_settings);$f(this,self.player_data,uniq_settings).playlist(playlist_id,{scaling:'fit',loop:true});});}};self.init_main_video_player=function(elements){if(elements.length){var theScroller=$(".playlist").scrollable({size:3,next:'a.next',prev:'a.prev',mousewheel:true});theScroller.mouseenter(self.toggleKeyboardScroll).mouseleave(self.toggleKeyboardScroll).data("scrollable").getConf().keyboard=false;$(".clips a").click(function(){$(this).fadeOut().fadeIn();});var uniq_settings=$.extend(true,{},self.main_video_player_settings);$f("player_main",self.player_data,uniq_settings).playlist("div.mainplayer",{scaling:'fit',loop:false}).ipad();}};self.init_main_audio_player=function(elements){if(elements.length){var theScroller=$($(".musiclist",$(self.main_audio_player_sel).parent())).scrollable(self.player_playlist_scroll_settings);theScroller.mouseenter(self.toggleKeyboardScroll).mouseleave(self.toggleKeyboardScroll).data("scrollable").getConf().keyboard=false;$f("mainaudio",self.player_data,self.main_audio_player_settings).playlist("#main_pls",{scaling:'fit',loop:true});}};self.toggleKeyboardScroll=function(){var k=$(this).data("scrollable").getConf().keyboard;$(this).data("scrollable").getConf().keyboard=!k;if(k){$('#dummy-scrollable').data('scrollable').focus();}else{$(this).data('scrollable').focus();}};self.init_video_stream_player=function(elements){if(elements.length){elements.each(function(){var custom_settings=$.extend(true,{},self.video_stream_settings);$f($(this).attr('id'),self.player_data,custom_settings);})}};};$(document).ready(function(){CommentEmbedProcessor.init();});CommentEmbedProcessor=new function(){var self=this;self.init=function(){$('.action_open_video_player').live('click',self.open_video);$('.action_open_audio_player').live('click',self.open_audio);$('.action_open_audio_playlist_player').live('click',self.open_playlist);$('.action_open_gallery_player').live('click',self.open_gallery);$('.action_close_player').live('click',self.close);}
self.is_loaded=function(elem){return self.get_player_body(elem).html();}
self.get_id=function(elem){return self.get_player_body(elem).attr('rel');}
self.get_player_content=function(elem){return $($(elem).parents('.player-content'))}
self.get_player_body=function(elem){return self.get_player_content(elem).find('.player-body')}
self.player_load=function(elem,url){if(!self.is_loaded(elem)){url=url+self.get_id(elem);self.get_player_body(elem).load(url,self.player_loaded);}else{self.open(elem)}
return false;};self.player_loaded=function(){PlayerProcessor.init_all(self.get_player_body(this));self.open(this);};self.open_playlist=function(){return self.player_load(this,'/playlist/ajax/id');};self.open_video=function(){return self.player_load(this,'/video/ajax/id');};self.open_audio=function(){return self.player_load(this,'/audio/ajax/id');};self.open_gallery=function(){return self.player_load(this,'/gallery/ajax/id');};self.open=function(elem){player_c=self.get_player_content(elem)
player_c.parent().removeClass("minembed");player_c.find('.embed-hider').show();player_c.find('.embed-opener').hide();player_c.find('.player-body').show();return false;};self.close=function(){player_c=self.get_player_content(this);player_c.parent().addClass("minembed");player_c.find('.embed-hider').hide();player_c.find('.embed-opener').show();player_c.find('.player-body').hide();return false;};self.show_audio_player_code=function(){light_embed_popup(self.code_kanobu,EMBED_AUDIO(self.code_other));return false;};self.show_gallery_player_code=function(){light_embed_popup(self.code_kanobu,EMBED_GALLERY(self.code_other));return false;};self.show_video_player_code=function(){light_embed_popup(self.code_kanobu,EMBED(self.code_other));return false;};}
$(document).ready(function(){PollProcessor.init();});PollProcessor=new function(){var self=this;self.place_holder_sel='#poll_plate';self.button_sel="#poll_plate_button";self.balloon_sel="#balloon-notify";self.balloon_msg_sel="#balloon-msg";self.form_sel="#poll_plate_form";self.action_register_class="action_register";self.action_register_sel="form."+self.action_register_class;self.checked_radio_sel='input:radio[name=choice]:checked';self.init=function(){self.find_elements();self.bind_events();};self.find_elements=function(){self.form=$(self.form_sel);self.button=$(self.button_sel);self.balloon=$(self.balloon_sel);self.balloon_msg=$(self.balloon_msg_sel);self.place_holder=$(self.place_holder_sel);self.action_register=$(self.action_register_sel)};self.get_selection=function(){return $(self.checked_radio_sel);};self.bind_events=function(){self.form.submit(self.submit);};self.submit=function(){if(!self.get_selection().val()){return false;}
self.form.ajaxSubmit({dataType:'json',success:self.data_arrived});return false;};self.data_arrived=function(data){if(data.html){self.place_holder.replaceWith(data.html);self.init();}
if(data.is_anonymous){light_register_popup();return false;}
if(data.error_message){self.show_message(data.error_message);}};self.show_message=function(text){self.button.balloon(text);};};function KanobuCalendar(main_box_id){this.main_box_id=main_box_id;this.main_box=null;}
KanobuCalendar.prototype.get_main_box=function(){if(!this.main_box){this.main_box=$('#'+this.main_box_id).get(0);}
return this.main_box;};KanobuCalendar.prototype.get_jmain_box=function(){return $(this.get_main_box());};KanobuCalendar.prototype.scroll_to_calendar=function(){var new_height=this.get_jmain_box().offset().top-20+'px';$('html,body').animate({scrollTop:new_height},0);};KanobuCalendar.prototype.change_month=function(url){var calendar_obj=this,extra={};if(this.selected_date){extra={'year':this.selected_date.getFullYear(),'month':this.selected_date.getMonth(),'day':this.selected_date.getDate()};}
$.getJSON(url,extra,function(data){calendar_obj.get_jmain_box().html(data.main_box_html);if(calendar_obj.change_month_callback){calendar_obj.change_month_callback(data);}});}
KanobuCalendar.prototype.change_month_callback=function(data){};KanobuCalendar.prototype.day_click=function(params){};var EventCalendar=new KanobuCalendar('Calendar');EventCalendar.change_month_callback=function(data){if(data.day_has_events){$('#right_events_box').load(data.event_list_url);}
this.scroll_to_calendar();$('#right_events_box').html($('#right_events_box').html());};EventCalendar.day_click=function(params){this.selected_date=new Date(parseInt(params.year,10),parseInt(params.month,10),parseInt(params.day,10));$('#right_events_box').load(params.url,function(){$('.box.service.poll,.box.service.profile').each(function(){$(this).html($(this).html());});});this.scroll_to_calendar();};var MessageCalendar=new KanobuCalendar('message_calendar');MessageCalendar.day_click=function(params){window.location=params.url;};function overlays(e){var hide_join=false;var hide_fav=false;$('.overlay_info').stopTime("hideDropdown");$('.overlay_info').hide();rel=$(this).parent().attr('rel')
id=rel.split('_')[1]
type=rel.split('_')[0]
uid=id+'_'+type
if(!$('#upyachka').children('#'+uid).attr('class')){$('#upyachka').append('<div class="overlay_info" id="'+uid+'"></div>')};overlay=$('#upyachka').children('#'+uid)
overlay.css('position','absolute')
overlay.css('z-index','999')
overlay.css('left',$(this).parent().offset().left)
overlay.css('top',$(this).parent().offset().top)
if(overlay.html()=='')
{if(type=='user')
json_url='/accounts/json/'+id+'/';else if(type=='entity')
json_url='/entities/json/'+id+'/';$.getJSON(json_url,function(data){if(type=='user')
{avatar='http://static.kanobu.ru/kanobu/modern/images/48x48_user.jpg'
online=''
if(data.avatar!='')
{avatar=data.avatar};if(data.is_online)
{online=' name-i-online'};html=$('#overlay_temaplate').html()
html=html.split('<!--separator-->')
overlay.html(html[0])
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-write').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-newpl').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplpic').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-editprofile').parent().hide()
if(data.is_me)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-write').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-newpl').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplpic').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-editprofile').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-write').click(function(){window.location='/blog/add/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-newpl').click(function(){window.location='/playlist/add/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplpic').click(function(){window.location='/image/add/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-editprofile').click(function(){window.location='/accounts/profile/edit/';return false})
if(data.media_upload)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').parent().show()}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').parent().hide()};if(!data.audio_upload)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').attr('alt','msgLowRating')
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').addClass('action_check_rating')}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').click(function(){window.location='/audio/add/?interests='+data.pk;return false})};overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-mail').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-removefriend').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-addfriend').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-invite').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-disignore').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ignore').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ban').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-unban').parent().hide()};remove_friend=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-removefriend')
add_friend=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-addfriend')
add_friend.parent().attr("action-friend-add",id)
remove_friend.parent().attr("action-friend-del",id)
overlay.children('.vcard').children('.friends').attr("action-friend-added",id)
remove_ignore=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-disignore')
add_ignore=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ignore')
add_ignore.parent().attr("action-ignore-add",id)
remove_ignore.parent().attr("action-ignore-del",id)
overlay.children('.vcard').children('.ignore').attr("action-ignore-added",id)
unban=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-unban')
ban=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ban')
ban.parent().attr("action-ban-add",id)
unban.parent().attr("action-ban-del",id)
ban.parent().hide()
unban.parent().hide()
if(data.current_super&&!data.is_me)
{if(data.is_banned)
{unban.parent().show()}
else
{ban.parent().show()};};if(data.is_friend)
{overlay.children('.vcard').children('.friends').show()
add_friend.parent().hide()}
else
{overlay.children('.vcard').children('.friends').hide()
remove_friend.parent().hide()};if(data.is_ignore)
{overlay.children('.vcard').children('.ignore').show()
add_ignore.parent().hide()}
else
{overlay.children('.vcard').children('.ignore').hide()
remove_ignore.parent().hide()};if(type=='user')
{overlay.children('.vcard').children('span').html('пользователь')};if(data.rating>=0)
{overlay.children('.void').children('strong').attr('class','positive')}
else
{overlay.children('.void').children('strong').attr('class','negative')};if(data.imfriends_count!=0)
{overlay.children('.userinfo').children('.imfriend').html(data.imfriends_count)}
else
{overlay.children('.userinfo').children('.imfriend_display').hide()
overlay.children('.userinfo').children('.imfriend').hide()}
if(data.myfriends_count!=0)
{overlay.children('.userinfo').children('.myfriend').html(data.myfriends_count)}
else
{overlay.children('.userinfo').children('.myfriend_display').hide()
overlay.children('.userinfo').children('.myfriend').hide()}
overlay.children('.userinfo').children('.lastvisit_display').html(data.lastvisit_display)
if(data.is_online)
{overlay.children('.userinfo').children('.lastvisit').html('Сейчас онлайн')}
else
{overlay.children('.userinfo').children('.lastvisit').html(data.last_login)};overlay.children('.vcard').attr('href','/accounts/'+id+'/')
overlay.children('.vcard').children('.photo').attr('src',avatar)
overlay.children('.vcard').children('strong').attr('class','fn'+online)
overlay.children('.vcard').children('strong').html(data.username)
overlay.children('.void').children('strong').children('em').html(data.rating)
overlay.children('.userinfo').children('.registered').html(data.rigistration_date)
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-mail').click(function(){window.location='/accounts/'+id+'/message_add/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-invite').click(function(){window.location='/accounts/msgbox/send/invitation/user'+id+'/';return false})
if(data.achievements){var $userinfo=overlay.children('.userinfo').prepend('<dd class="achiv" title="achievment"></d>');var $achivs=$userinfo.children('dd.achiv');for(var i=0;i<data.achievements.length;i++){$achlink=$('<a></a>').attr('href',data.achievements[i].url);$achlink.appendTo($achivs);$('<img alt="" width="24"></img>').attr('src',data.achievements[i].image).attr('title',data.achievements[i].name).appendTo($achlink)}}else{}}
else if(type=='entity')
{html=$('#overlay_temaplate').html()
overlay.html(html.split('<!--separator-->')[1])
overlay.children('.vcard').children('.entity_name').html(data.entity_name);if(data.rating>=0)
{overlay.children('.void').children('strong').attr('class','positive')}
else
{overlay.children('.void').children('strong').attr('class','negative')};creator_avatar='http://static.kanobu.ru/kanobu/modern/images/16x16_user.jpg'
if(data.creator_avatar)
{creator_avatar=data.creator_avatar};image='http://static.kanobu.ru/kanobu/modern/images/'
user_info=overlay.children('.userinfo')
var link_type='interests'
if(data.category_slug=='communities')
{hide_fav=true;user_info.children('.moderator_display').css({'display':''});user_info.children('.moderator').css({'display':''})
user_info.children('.moderator').children('.vcard').attr('href','/accounts/'+data.creator_pk+'/')
user_info.children('.moderator').children('.vcard').children('em').html(data.creator)
user_info.children('.moderator').children('.vcard').children('.photo').attr('src',creator_avatar)
if(data.members_total>0)
{user_info.children('.member_display').css({'display':''});user_info.children('.member').css({'display':''})
user_info.children('.member').html(data.members_total)}
if(data.posts_total>0)
{user_info.children('.post_display').css({'display':''});user_info.children('.post').css({'display':''})
user_info.children('.post').html(data.posts_total)}
link_type='commlinks'
image=image+'48x48_comm.jpg'}
if(data.category_slug=='games')
{hide_join=true;if(data.favorites_total>0)
{user_info.children('.favorites_display').css({'display':''});user_info.children('.favorites').css({'display':''})
user_info.children('.favorites').html(data.favorites_total)}
if(data.platform)
{user_info.children('.platform_display').css({'display':''});user_info.children('.platform').css({'display':''})
var platform=''
if(data.platform.length>1)user_info.children('.platform_display').html('Платформы:')
for(i=0;i<data.platform.length;i++)
{platform+=data.platform[i][1]
if(data.platform.length-1!=i)platform+=', '}
user_info.children('.platform').html(platform)}
if(data.genre)
{user_info.children('.genre_display').css({'display':''});user_info.children('.genre').css({'display':''})
var genre=''
if(data.genre.length>1)user_info.children('.genre_display').html('Жанры:')
for(i=0;i<data.genre.length;i++)
{genre+=data.genre[i][1]
if(data.genre.length-1!=i)genre+=', '}
user_info.children('.genre').html(genre)}
image=image+'48x64_game.jpg'}
if(data.category_slug=='films')
{hide_join=true;if(data.favorites_total>0)
{user_info.children('.favorites_display').css({'display':''});user_info.children('.favorites').css({'display':''})
user_info.children('.favorites').html(data.favorites_total)}
if(data.genre)
{user_info.children('.genre_display').css({'display':''});user_info.children('.genre').css({'display':''})
var genre=''
if(data.genre.length>1)user_info.children('.genre_display').html('Жанры:')
for(i=0;i<data.genre.length;i++)
{genre+=data.genre[i][1]
if(data.genre.length-1!=i)genre+=', '}
user_info.children('.genre').html(genre)}
if(data.director)
{user_info.children('.director_display').css({'display':''});user_info.children('.director').css({'display':''})
var director=''
if(data.director.length>1)user_info.children('.director_display').html('Режиссеры:')
for(i=0;i<data.director.length;i++)
{director+=data.director[i][1]
if(data.director.length-1!=i)director+=', '}
user_info.children('.director').html(director)}
image=image+'48x64_film.jpg'}
if(data.category_slug=='books')
{hide_join=true;if(data.favorites_total>0)
{user_info.children('.favorites_display').css({'display':''});user_info.children('.favorites').css({'display':''})
user_info.children('.favorites').html(data.favorites_total)}
if(data.genre)
{user_info.children('.genre_display').css({'display':''});user_info.children('.genre').css({'display':''})
var genre=''
if(data.genre.length>1)user_info.children('.genre_display').html('Жанры:')
for(i=0;i<data.genre.length;i++)
{genre+=data.genre[i][1]
if(data.genre.length-1!=i)genre+=', '}
user_info.children('.genre').html(genre)}
if(data.director)
{user_info.children('.author_display').css({'display':''});user_info.children('.author').css({'display':''})
var director=''
if(data.director.length>1)user_info.children('.director_display').html('Авторы:')
for(i=0;i<data.director.length;i++)
{director+=data.director[i][1]
if(data.director.length-1!=i)director+=', '}
user_info.children('.author').html(director)}
image=image+'48x64_book.jpg'}
if(data.category_slug=='persons'&&data.birthday)
{hide_fav=true;hide_join=true;user_info.children('.birthday_display').css({'display':''});user_info.children('.birthday').css({'display':''})
user_info.children('.birthday').html(data.birthday)}
if(data.category_slug=='persons'){image=image+'48x48_person.jpg'
hide_fav=true;hide_join=true;}
if(data.category_slug=='events')
{if(data.creator!='None')
{user_info.children('.organizer_display').css({'display':''});user_info.children('.moderator').css({'display':''})
user_info.children('.moderator').children('.vcard').attr('href','/accounts/'+data.creator_pk+'/')
user_info.children('.moderator').children('.vcard').children('em').html(data.creator)
user_info.children('.moderator').children('.vcard').children('.photo').attr('src',creator_avatar)}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-mail').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-invite').parent().hide()};user_info.children('.eventdate_display').css({'display':''});user_info.children('.eventdate').css({'display':''})
user_info.children('.eventdate').html(data.event_date)
if(data.members_total>0)
{user_info.children('.member_display').css({'display':''});user_info.children('.member').css({'display':''})
user_info.children('.member').html(data.members_total)}
image=image+'48x48_event.jpg'}
if(data.category_slug=='companies')
{hide_fav=true;hide_join=true;if(data.roles!='')
{user_info.children('.profile_display').css({'display':''});user_info.children('.profile').css({'display':''})
user_info.children('.profile').html(data.roles)}
image=image+'48x48_company.jpg'}
if(data.image)
{image=data.image}
overlay.children('.vcard').attr('href','/'+data.category_slug+'/'+data.slug+'/')
overlay.children('.vcard').children('.photo').attr('src',image)
overlay.children('.vcard').children('strong').attr('class','fn')
overlay.children('.vcard').children('strong').html(data.header)
overlay.children('.void').children('strong').children('em').html(data.rating)
overlay.children('.userinfo').children('.registered').html(data.rigistration_date)
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-mail').click(function(){window.location='/accounts/'+data.creator_pk+'/message_add/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-invite').click(function(){window.location='/accounts/msgbox/send/invitation/user'+data.creator_pk+'/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-write').click(function(){window.location='/blog/add/?'+link_type+'='+data.pk;return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplpic').click(function(){window.location='/image/add/?'+link_type+'='+data.pk;return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-editprofile').click(function(){window.location='/entities/communities/'+data.pk+'/edit/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ignore').click(function(){window.location='/entities/communities/'+data.pk+'/delete/';return false})
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').click(function(){window.location='/video/add/?'+link_type+'='+data.pk;return false})
if(data.badges){var $userinfo=overlay.children('.userinfo').prepend('<dd class="achiv" title="achievment"></d>');var $achivs=$userinfo.children('dd.achiv');for(var i=0;i<data.badges.length;i++){$achlink=$('<a></a>').attr('href',data.badges[i].url);$achlink.appendTo($achivs);$('<img alt="" width="24"></img>').attr('src',data.badges[i].image).attr('title',data.badges[i].name).appendTo($achlink)}}else{}
if(data.category_slug!='communities'&&data.category_slug!='events')
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-mail').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-invite').parent().hide()}
if(data.has_update_perm)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-editprofile').parent().show()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ignore').parent().show()}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-editprofile').parent().hide()
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-ignore').parent().hide()};if(data.media_upload)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').parent().show()}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplvid').parent().hide()};if(!data.audio_upload)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').attr('alt','msgLowRating')
overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').addClass('action_check_rating')}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplaud').click(function(){window.location='/audio/add/?interests='+data.pk;return false})};overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplfile').click(function(){window.location='/file/add/?commlinks='+data.pk;return false})
if(data.file_upload)
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplfile').parent().show()}
else
{overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-uplfile').parent().hide()};addfav=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-addfav')
removefav=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-removefav')
addfav.parent().attr("action-faventry-add",id)
removefav.parent().attr("action-faventry-del",id)
if(hide_fav){addfav.parent().hide();removefav.parent().hide();}else{if(data.is_fav)
{addfav.parent().hide();removefav.parent().show();}
else
{addfav.parent().show();removefav.parent().hide();};}
connect=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-addfriend')
unconnect=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-removefriend')
invite=overlay.children('.overlay_expand').children('.useractions').children('li').children('.icon-invite')
if(hide_join){unconnect.parent().hide();connect.parent().hide();}else{if(data.im_in)
{connect.parent().hide();unconnect.parent().show();invite.parent().show();}
else
{connect.parent().show();unconnect.parent().hide();invite.parent().hide();};};connect.parent().attr("action-community-add",id);unconnect.parent().attr("action-community-del",id);invite.parent().attr("action-community-added",id);};$(".overlay_expand").hover(function(){$('.useractions').stopTime("hideDropdown");$(this).children('.useractions').show();$(this).children('.useractions').stopTime("hideDropdown");},function(){$(this).children('.useractions').oneTime(500,"hideDropdown",function(){$(this).hide();});});});};$('#upyachka').children('#'+uid).show()
$('#upyachka').children('#'+uid).stopTime("hideDropdown");$('.overlay_info').mouseleave(function(){$(this).oneTime(200,"hideDropdown",function(){$(this).hide();});});return false;}
$(document).ready(function(){$(".userbox a.vcard").live("click",overlays);})
if(!this.JSON){JSON=function(){function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value,rep);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){v=str(k,value,rep);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
return{stringify:function(value,replacer,space){var i;gap='';indent='';if(space){if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}}
if(!replacer){rep=function(key,value){if(!Object.hasOwnProperty.call(this,key)){return undefined;}
return value;};}else if(typeof replacer==='function'||(typeof replacer==='object'&&typeof replacer.length==='number')){rep=replacer;}else{throw new Error('JSON.stringify');}
return str('',{'':value});},parse:function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');},quote:quote};}();}
function EMBED(thumb,clip){return'<object width="400" height="300" data="http://kanobu.ru/flowplayer/flowplayer.commercial-3.2.0.swf" type="application/x-shockwave-flash"><param name="movie" value="http://kanobu.ru/flowplayer/flowplayer.commercial-3.2.0.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value=\'config='+JSON.stringify({"key":"#@a38baa27b1f0d15312e","logo":{"url":"http://kanobu.ru/img/fp_logo.png","fullscreenOnly":false,"top":6,"right":5,"linkUrl":"http://kanobu.ru"},"clip":{"scaling":"fit","url":clip},"canvas":{"backgroundColor":"#000000","backgroundGradient":"none"},"play":{"width":600,"height":400,"opacity":0},"plugins":{"controls":{"url":"http://kanobu.ru/flowplayer/flowplayer.controls-3.2.0.swf","backgroundColor":"transparent","backgroundGradient":"none","sliderColor":"#FFFFFF","sliderBorder":"1px solid rgba(160,160,160,0.7)","volumeSliderColor":"rgba(50, 50, 50, 1)","volumeBorder":"1px solid rgba(160,160,160,0.7)","timeColor":"#ffffff","durationColor":"#535353","fullscreen":true,"border":"none","hideDelay":1000,"all":false,"enabled":{"scrubber":true},"scrubber":true,"volume":true,"play":true,"mute":true,"playlist":false,"height":30,"scrubberHeightRatio":0.4,"volumeSliderHeightRatio":0.4,"progressColor":"#47ff91","volumeColor":"#47ff91","bufferColor":"rgba(163, 163, 163, 0.4)","buttonOverColor":"#47ff91","tooltipColor":"#ffffff","tooltipTextColor":"#000000","autoHide":"always","bottom":5,"left":"50pct"}},"playlist":[{"controls":{"scrubber":false,"volume":false,"fullscreen":false,"play":false,"mute":false},"url":thumb},{"autoPlay":false,"scaling":"fit","url":clip}]})+'\' /></object>';}
function EMBED_AUDIO(clip){return'<object width="400" height="31" data="http://kanobu.ru/flowplayer/flowplayer.commercial-3.2.0.swf" type="application/x-shockwave-flash"><param name="movie" value="http://kanobu.ru/flowplayer/flowplayer.commercial-3.2.0.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value=\'config='+JSON.stringify({"key":"#@a38baa27b1f0d15312e","clip":{"autoPlay":false,"scaling":"fit","url":clip},"canvas":{"backgroundColor":"#000000","backgroundGradient":"none"},"play":{"label":null,"replayLabel":null,"opacity":0},"plugins":{"audio":{"url":"http://kanobu.ru/flowplayer/flowplayer.audio-3.2.0.swf"},"controls":{"url":"http://kanobu.ru/flowplayer/flowplayer.controls-3.2.0.swf","backgroundGradient":"none","backgroundColor":"transparent","background":"#114455 url(http://static.kanobu.ru/kanobu/modern/skin/kanobu-ver_0.4/img/audio_bg.jpg) no-repeat top center","height":30,"border":"none","hideDelay":1000,"all":false,"enabled":{"scrubber":true},"scrubber":true,"volume":true,"play":true,"mute":true,"playlist":false,"fullscreen":false,"time":true,"scrubberHeightRatio":0.4,"volumeSliderHeightRatio":0.4,"progressColor":"#47ff91","volumeColor":"#47ff91","bufferColor":"rgba(163, 163, 163, 0.4)","volumeSliderColor":"rgba(50, 50, 50, 1)","buttonOverColor":"#47ff91","tooltipColor":"#ffffff","tooltipTextColor":"#000000","autoHide":"never","bottom":0,"left":"50pct"}}})+'\' /></object>';}
function EMBED_GALLERY(gallery_id){$.get('/gallery/embed-code/'+gallery_id+'/',function(data){$("textarea[id=embed_code_other]").text(data);});}
var models_base={'gallery':'/gallery/vote/','entity':'/entities/vote/','user':'/accounts/user/vote/','comment':'/comments/vote/','entry':'/blog/entry/vote/','mfile':'/mserver/mfile/vote/','book':'/books/vote/','game':'/games/vote/','film':'/films/vote/'};function non(){}
function newvote(div_id,model_slug,user_id,direction){$('#'+div_id+' .up').replaceWith('<a href="javascript:non();" class="up up-disabled"></a>');$('#'+div_id+' .down').replaceWith('<a href="javascript:non();" class="down down-disabled"></a>');var url=models_base[model_slug]+user_id+'/'+direction+'vote/';$.getJSON(url,function(jsonResult){var object_rating=jsonResult.score;$('em#rating_'+model_slug+'_'+user_id).text(jsonResult.score);var class_name='neutral';if(object_rating<0){class_name='negative';}else if(object_rating>0){class_name='positive';}
var rating_wrap=$('#rating_wrap_'+model_slug+'_'+user_id);rating_wrap.removeClass("positive neutral negative");rating_wrap.addClass(class_name);var el_up=$('#'+div_id+' .up');var el_down=$('#'+div_id+' .down');var up_enable_str='<a href="#" onClick="javascript:return newvote(\''+div_id+'\', \''+model_slug+'\', \''+user_id+'\',\'up\')" class="up"></a>';var down_enable_str='<a href="#" onClick="javascript:return newvote(\''+div_id+'\',\''+model_slug+'\', \''+user_id+'\',\'down\')" class="down"></a>'
if(jsonResult.superuser_mode==true){el_up.replaceWith(up_enable_str);el_down.replaceWith(down_enable_str);}
if(jsonResult.rating_votes!='0'||jsonResult.free_voting){if(jsonResult.vote.is_upvote||(!jsonResult.vote.is_upvote&&!jsonResult.vote.is_downvote)){el_down.replaceWith(down_enable_str);}
if(jsonResult.vote.is_downvote||(!jsonResult.vote.is_upvote&&!jsonResult.vote.is_downvote)){el_up.replaceWith(up_enable_str);}}
if(!jsonResult.superuser_mode){try{update_rating_votes(parseInt(jsonResult.rating_votes),jsonResult.free_voting);}catch(e){};}});return false;}
$(document).ready(function(){$('.action-vote').live('click',vote);});function vote(event){event.preventDefault();var self=$(this);if(self.hasClass('js-voting-disabled'))
return false;var voting=self.parent();data={app_label:voting.attr('data-applabel'),model:voting.attr('data-model'),object_id:voting.attr('data-objectid'),direction:self.attr('data-direction')}
$.post('/voting/vote/',data,function(result){voting.replaceWith(result);});}
function post_form(button){button.disabled=true;button.form.submit();}
$(document).ajaxSend(function(event,xhr,settings){function getCookie(name){var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}
function sameOrigin(url){var host=document.location.host;var protocol=document.location.protocol;var sr_origin='//'+host;var origin=protocol+sr_origin;return(url==origin||url.slice(0,origin.length+1)==origin+'/')||(url==sr_origin||url.slice(0,sr_origin.length+1)==sr_origin+'/')||!(/^(\/\/|http:|https:).*/.test(url));}
function safeMethod(method){return(/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));}
if(!safeMethod(settings.type)&&sameOrigin(settings.url)){xhr.setRequestHeader("X-CSRFToken",getCookie('csrftoken'));}});function getQueryParam(name){try{var R=new RegExp("[\\?&]"+name+"=([^&#]*)").exec(window.location.href);if(R)
return R[1];else
return'';}catch(exception){return null;}}
var curPage=Math.floor(getQueryParam('page'))||1;var isLastPage=($('div.pager').size()==1||$('div.pager span').next('a').html()=='&lt;');function hideMoveRightBtn(){var D=$("#gallery-line-wrapper").width()-$("#gallery-medialist").width()-($("#gallery-medialist").position()?$("#gallery-medialist").position().left:0);return((-70<D&D<128)||($("#gallery-line-wrapper").width()>=$("#gallery-medialist").width()))&&!$("#gallery-medialist").hasClass('ajaxed');}
function loadItems(inc,pageSize,showFirstUploaded){var url=parent.document.URL.split('?')[0]+'?'+$.map(['by','ord'],function(param){if(getQueryParam(param))
return[param,getQueryParam(param)].join('=');else
return null}).join('&')+'&page='+(curPage+inc)+'&page_size='+pageSize
$.get(url,function(response,status){$("#gallery-loader-"+(inc==1?'right':'left')).hide();if(status!='success'){alert('Ошибка соединения с сервером. Попробуйте повторить еще раз позже.');return false;}
if($.trim(response)){if(inc==+1)
$("#gallery-medialist").append(response);else
$("#gallery-medialist").prepend(response);$("#gallery-medialist").css({width:$("#gallery-medialist li").length*itemWidth});$("#gallery-move-"+(inc==1?'right':'left')).show();$("#gallery-medialist li").each(function(){if($(this).next().length){var nextRef=$(document.createElement('A'));var nextRefTitle="#"+$(this).next().find(".img").attr("id");nextRef.addClass("nextItem").attr("title",nextRefTitle);nextRef.appendTo($(this));}
if($(this).prev().length){var prevRef=$(document.createElement('A'));var prevRefTitle="#"+$(this).prev().find(".img").attr("id");prevRef.addClass("prevItem").attr("title",prevRefTitle);prevRef.appendTo($(this));}});if(showFirstUploaded&&inc==+1)
$('.img',response).eq(0).openImageItem();else if(showFirstUploaded&&inc==-1){$('#'+$('.img',response).eq(-1).attr('id')).openImageItem();}}
return true;});}
$.fn.openImageItem=function(){itemWidth=128;var galleryItemNum=Math.floor(($("#upyachka").width()-100)/itemWidth);var galleryWrapperWidth=galleryItemNum*itemWidth;var galleryWrapperMargin=($(document).width()-galleryWrapperWidth)/2;$("#gallery-line-wrapper").css({width:galleryWrapperWidth,'margin-left':galleryWrapperMargin,'margin-right':galleryWrapperMargin});$("#gallery-medialist").css({width:$("#gallery-medialist li").length*itemWidth});$("#gallery-line").show();$("#gallery-line").css({top:$(window).height()+$(document).scrollTop(),width:$(document).width()});$(this).parent().parent().find(".img img").each(function(){$(this).fadeTo("fast",1);});$(this).find("img").fadeTo("fast",0.5);var blockTitle="";if($(this).parent().find("h5").length){blockTitle="<h2>"+$(this).parent().find("h5").html()+"</h2>";}
var blockDescription=$(this).parent().find(".descr").html();var blockMeta=$(this).parent().find(".meta").html();var imgLink=$(this).attr('href');var imgTitle=$(this).attr('title');var image=$('<img src="'+imgLink+'" alt="'+imgTitle+'"/>');var arrows="";if($(this).parent().find(".nextItem").length||($('#gallery-medialist').hasClass('ajaxed')&&!isLastPage)){arrows+="<div class='arrow arrow-next' rel='"+($(this).parent().find(".nextItem").attr("title")||'nextPage')+"'></div>";}
if($(this).parent().find(".prevItem").length||($('#gallery-medialist').hasClass('ajaxed')&&curPage!=1)){arrows+="<div class='arrow arrow-prev' rel='"+($(this).parent().find(".prevItem").attr("title")||'prevPage')+"'></div>";}
var preloaderDiv=$(document.createElement('DIV'));preloaderDiv.html('<div class="img-preloader"></div>');preloaderDiv.openPopup({bgColor:"#000",popupClass:"popup-image-block",showCloser:false});var imageContainer=$(document.createElement('DIV'));imageContainer.appendTo($("body"));imageContainer.addClass("gallery-bigimage");imageContainer.html(blockTitle+"<div class='img media-description'>"+arrows+"</div>");$(imageContainer).find(".img").mouseenter(function(){$(imageContainer).find(".arrow").show();});$(imageContainer).find(".img").mouseleave(function(){$(imageContainer).find(".arrow").hide();});$(imageContainer).find(".arrow-next").live("click",function(){if(typeof pagesize=='undefined')pagesize=30
if($(this).attr("rel")=='nextPage'){$("#gallery-move-right").hide();$("#gallery-loader-right").show();loadItems(+1,getQueryParam('page_size')||pagesize,true);return false;}
$($(this).attr("rel")).openImageItem();return false;});$(imageContainer).find(".arrow-prev").live("click",function(){if($(this).attr("rel")=='prevPage'){if(typeof pagesize=='undefined')pagesize=30
loadItems(-1,getQueryParam('page_size')||pagesize,true);return false;}
$($(this).attr("rel")).openImageItem();return false;});if(blockDescription){var blockDescriptionDiv=$(document.createElement('DIV'));blockDescriptionDiv.addClass("gallery-description");blockDescriptionDiv.html("<div>"+blockDescription+"</div>");blockDescriptionDiv.appendTo($(imageContainer).find(".img"));blockDescriptionDiv.slideUp();$(imageContainer).find(".img").mouseenter(function(){blockDescriptionDiv.slideDown();});$(imageContainer).find(".img").mouseleave(function(){blockDescriptionDiv.slideUp();});}
if(blockMeta){var blockMetaDiv=$(document.createElement('DIV'));blockMetaDiv.addClass("ufoot");blockMetaDiv.html("<div>"+blockMeta+"</div>");blockMetaDiv.appendTo($(imageContainer).find(".img"));blockMetaDiv.slideUp();$(imageContainer).find(".img").mouseenter(function(){blockMetaDiv.slideDown();});$(imageContainer).find(".img").mouseleave(function(){blockMetaDiv.slideUp();});}
image.appendTo(imageContainer.find(".img"));image.load(function(){var imageWidth=image.width();var imageHeight=image.height();var imageRatio=imageWidth/imageHeight;var frameWidth=$(".backlight").width()-80;var frameHeight=$(window).height()-230;if(imageWidth>frameWidth){image.width(frameWidth);imageWidth=image.width();image.height(imageWidth/imageRatio);imageHeight=image.height();}
if(imageHeight>frameHeight){image.height(frameHeight);imageHeight=image.height();image.width(imageHeight*imageRatio);imageWidth=image.width();}
imageContainer.openPopup({marginBottom:40});});$(window).scroll(function(){$("#gallery-line").css({top:$(window).height()+$(document).scrollTop()});});prevOffset=($(this).find("img").parent().parent().prevAll().size()+1)*128;if(prevOffset>$(window).width()-128){$("#gallery-medialist").css({left:$(window).width()-prevOffset-galleryWrapperMargin*2});}
return false;}
function toggleGallery(obj){obj.parent().find(".illustration").each(function(i){if(i>3)$(this).toggle();});obj.parent().find(".pager").toggle().end().find(".media-description").toggleClass("media-description_min").end().find(".ufoot").toggle();obj.find(".album-hider, .album-opener").toggle();}
var GalleryLightbox=new function(){var self=this,gallery_line=$('<div id="gallery-line"/>'),gallery_line_wrapper=$('<div id="gallery-line-wrapper"/>'),left_button=$('<div id="gallery-move-left" class="gallery-move"/>'),right_button=$('<div id="gallery-move-right" class="gallery-move"/>'),loader_left=$('<div id="gallery-loader-left" class="gallery-loader"/>'),loader_right=$('<div id="gallery-loader-right" class="gallery-loader"/>'),medialist=null,medialist_img=null;self.create_elements=function(){gallery_line.css({top:$(window).height()}).prependTo($(document.body));gallery_line.append(gallery_line_wrapper,left_button,right_button,loader_left,loader_right)
if(jQuery.browser.opera||jQuery.browser.msie){right_button.css({right:32})}
medialist=$('#gallery-medialist').appendTo(gallery_line_wrapper);left_button=$('#gallery-move-left');}
self.init=function(){self.create_elements();medialist_img=$("#gallery-medialist .img");medialist_img.live("click",function(event){event.preventDefault();check_right_button();$(this).openImageItem();});left_button.live('click',function(event){event.preventDefault();self.move_left();});};self.destroy=function(){gallery_line.remove()};self.move_left=function(){var newPosition=medialist.position().left+128;if(newPosition>=1){left_button.hide();if(parent.document.URL.indexOf('/image')!=-1||parent.document.URL.indexOf('/emedia')!=-1){if((getQueryParam('page')||1)==1)
return false;loader_left.show();if(typeof pagesize=='undefined')pagesize=30
loadItems(-1,getQueryParam('page_size')||pagesize);medialist.css({left:newPosition-128*pagesize});curPage=curPage-1;}}else{left_button.show();medialist.css({left:newPosition});}
check_buttons();}
function check_right_button(){var medialist_position=medialist.position()?medialist.position().left:0;var delta=gallery_line_wrapper.width()-medialist.width()-medialist_position;hide=((-70<delta<128)||(gallery_line_wrapper.width()>=medialist.width()))&&!medialist.hasClass('ajaxed');if(hide)right_button.hide();else right_button.show();}
function check_left_button(){if(medialist.position().left==0){left_button.hide();}}
function check_buttons(){check_right_button();check_left_button();}};$(document).ready(function(){GalleryLightbox.init();$('.showGalleries').live('click',function(event){event.preventDefault();$(this).parent().siblings('li.hidden-gallery').slideToggle('fast').end().end().children().filter('span').toggle();});$(".image-lightbox-gallery").live("click",function(){if($(this).attr('rel'))
$('#gallery-medialist').html($('#'+$(this).attr('rel')).html());$("#gallery-medialist li").each(function(){if($(this).next().length){var nextRef=$(document.createElement('A'));var nextRefTitle="#"+$(this).next().find(".img").attr("id");nextRef.addClass("nextItem").attr("title",nextRefTitle);nextRef.appendTo($(this));}
if($(this).prev().length){var prevRef=$(document.createElement('A'));var prevRefTitle="#"+$(this).prev().find(".img").attr("id");prevRef.addClass("prevItem").attr("title",prevRefTitle);prevRef.appendTo($(this));}});var galleryItemId=$(this).attr("id").replace("gal-","gal-item-");$("#"+galleryItemId).openImageItem();if(typeof pagesize=='undefined'){if($("#gallery-medialist").position()&&$("#gallery-medialist").position().left>=0&&!$("#gallery-medialist").hasClass('ajaxed')){$("#gallery-move-left").hide();}else{$("#gallery-move-left").show();}}
if(hideMoveRightBtn())
$("#gallery-move-right").hide();else
$("#gallery-move-right").show();return false;});$("#gallery-move-right").live("click",function(){newPosition=$("#gallery-medialist").position().left-128;$("#gallery-medialist").css({left:newPosition});if($("#gallery-medialist").position().left==0){$("#gallery-move-left").hide();}else{$("#gallery-move-left").show();}
if(hideMoveRightBtn()){$("#gallery-move-right").hide();if(parent.document.URL.indexOf('/image')!=-1||parent.document.URL.indexOf('/emedia')!=-1){$("#gallery-loader-right").show();if(typeof pagesize=='undefined')pagesize=30
loadItems(+1,getQueryParam('page_size')||pagesize);curPage=curPage+1;}}else{$("#gallery-move-right").show();}});$(".album-opener, .album-hider,").click(function(){toggleGallery($(this).parent());return false;});$('.counter').click(function(){toggleGallery($(this).parent().parent().parent().parent().find('h2'));return false;});$('a.gallery-page').live('click',function(event){$(this).parents('.player-body').load($(this).attr('href'));});});jQuery.fn.balloon=function(text,x,y){if(!text){return this;}
var balloon_obj=jQuery("#balloon-notify");balloon_obj.stop(true,true);jQuery("#balloon-msg").html(text);if(!x){var target_offset=this.offset();x=target_offset.left+Math.round(this.width()/2);y=target_offset.top+Math.round(this.height()/2);}
balloon_obj.css({left:x-15+"px",top:y-balloon_obj.height()+"px"});balloon_obj.fadeIn("fast").delay(3000).fadeOut('slow');return this;};$(document).ready(function(){CriesProcessor.init();});CriesProcessor=new function(){var self=this;self.add_button_sel='.action-add-cry';self.del_button_sel='.action-cry-delete';self.counter_sel='#cry-letters-left';self.text_sel='#id_text';self.button_sel='#cry-save';self.init=function(){self.find_elements();self.bind_events();};self.find_elements=function(){self.add_buttons=$(self.add_button_sel);self.del_buttons=$(self.del_button_sel);};self.bind_events=function(){self.add_buttons.click(self.add_cry);self.del_buttons.click(self.delete_cry);$(self.button_sel).click(self.disable_button);};self.add_cry=function(event){if(!DATA.user){light_register_popup();}else if(!DATA.user.can_cry){$(this).balloon('Вы не можете добавлять вопли');}else{var url=URLS.CRY_ADD_URL;if($(this).attr('next')){url+='?next='+$(this).attr('next');}
$.get(url,function(data){self.init_form(data);});}
event.preventDefault();}
self.init_form=function(data){var form_container=$(data);form_container.openPopup();var form=form_container.find('form');form.children(self.text_sel).keyup(self.update_counter);form.children(self.text_sel).focus();form.ajaxForm({beforeSubmit:self.before_submit,success:self.success,dataType:'json'});}
self.delete_cry=function(event){if(confirm("Уверены, что хотите удалить?")){var cry=$(this).parents('.js-cry');$.post($(this).attr('href'),function(data){if(data.ok==true){cry.remove();}else{alert(data.error);}});event.preventDefault();}}
self.update_counter=function(){var text=$(this).val();var maxlength=$(self.counter_sel).attr('max-length');if(text.length>maxlength){$(this).val(text.substring(0,maxlength));}else{$(self.counter_sel).text(maxlength-text.length);}}
self.before_submit=function(arr,jqForm,options){var form=jqForm[0];if(!form.text.value){$(this).children(self.text_sel).focus();return false;}
$(self.button_sel).attr('disabled','disabled');}
self.success=function(data){if(data.ok){window.location.replace(data.redirect_to);}else{self.init_form(data.form_html);}}};var add_to_gallery_form_exists=false;function addtogallery_popup(img_id,action){action=action?action:false;if(!add_to_gallery_form_exists){$.get(URLS.ADD_TO_GALLERY_URL,function(data){add_to_gallery_form_exists=true;form_container=$('<div id="addtogallery_form" class="add-playlist"></div>').appendTo(document.body);form_container.html(data)
form_container.find('input[name=image]').val(img_id);form_container.openPopup();if(action)
$('#light_gallery_form').get(0).setAttribute('action',action);});}else{$('#addtogallery_form').find('input[name=image]').val(img_id);$('#addtogallery_form').openPopup();}}
function addtogallery_submit(){var options={dataType:'json',success:function(data){if(data.success){$('#addtogallery_form').closePopup();$('#light_gallery_form').clearForm();$('#light_gallery_form').find('li.bit-box').each(function(){$(this).remove()});}else{$('#addtogallery_form').html(data);}
msg(data);}}
$('#light_gallery_form').ajaxSubmit(options);}
function msg(data){$('.inline-ok, inline-info').remove();$('.delete-item').live('click',function(){$(this).parent().fadeOut('fast').remove()});if(data.success){if(data.url){message_text='галерею <a id="success_mesage_template_link" href="'+data.url+'">Перейти к галерее</a>';}else{message_text='галереи'}
message='<div id="upload_results_container"><div class="inline-ok success-upload-mesage"><div>Картинка добавлена в '+message_text+'</div>'+'<div class="delete-item"><a title="Закрыть извещение" href="#"></a></div></div></div>';$('.post-actions').after(message);}else if(data.errors){$('.post-actions').after('<p class="inline-info">Ошибка при добавлении</p>');}}
$(document).ready(function(){$('.action-add-to-gallery').click(function(event){event.preventDefault();img_id=$(this).attr('id').split('_')[1];addtogallery_popup(img_id);});$('#light_gallery_form .submit input').live('click',function(event){event.preventDefault();addtogallery_submit();});});function setmeonline(){data={resolution:screen.width+'x'+screen.height};$.post(URLS.SETMEONLINE_URL,data);}
$(document).ready(function(){if(!DATA.IS_ONLINE){setmeonline();}});var registerform=null;$(document).ready(function(){$('.action-register-popup').live('click',function(event){event.preventDefault();light_register_popup();});if(location.hash=='#register'){light_register_popup();}});$(document).ajaxError(function(e,jqxhr,settings,exception){if(settings.type=='POST'){alert('При выполнении запроса произошла ошибка');}});function light_register_popup(){if(!registerform){$.getJSON(URLS.LIGHT_REGISTER_URL,function(data){if(data.ok){light_register_init(data.form);}});}else{registerform.openPopup();}}
function light_register_submit(data){if(data.ok){window.location.replace(data.redirect_to);}else{light_register_init(data.form);}}
function light_register_init(form){registerform=$(form);registerform.children('form').ajaxForm({success:light_register_submit,dataType:'json'});registerform.children('form').submit(function(){$('input[type=submit]',this).attr('disabled','disabled').css('opacity','0.2');});registerform.openPopup();}
$(document).ready(function(){FriendProcessor.init();BlockPostProcessor.init();IgnoreProcessor.init();BanProcessor.init();InterestProcessor.init();CommunityProcessor.init();CalendarProcessor.init();BestPostProcessor.init();BestVideoProcessor.init();BestImageProcessor.init();BestPlaylistProcessor.init();BestAudioProcessor.init();FavoriteEntryProcessor.init();EventProcessor.init();EveLevelProcessor.init();});var ToggleProcessorBase=function(selector_prefix,get_add_url,get_del_url,after){var self=this;self.selector_prefix=selector_prefix;self.get_add_url=get_add_url;self.get_del_url=get_del_url;self.after=after;self.init=function(){$("["+self.selector_prefix+"add]").live("click",self.on_add);$("["+self.selector_prefix+"del]").live("click",self.on_del);};self.on_add=function(){var id=self.get_id(this);self.stop(id);$(self.get_selector("add",id)).fadeTo('fast',0.1);$.post(self.get_add_url(id),{},function(){self.post_add(id)});return false;};self.on_del=function(){var id=self.get_id(this);self.stop(id);$(self.get_selector("del",id)).fadeTo('fast',0.1);$.post(self.get_del_url(id),{},function(){self.post_del(id)});return false;};self.stop=function(id){$(self.get_selector("add",id)).stop(true,true);$(self.get_selector("del",id)).stop(true,true);};self.get_id=function(elem){return $(elem).attr(self.selector_prefix+"add")||$(elem).attr(self.selector_prefix+"del");};self.post_add=function(id){self.stop(true,true);$(self.get_selector("added",id)).slideDown('fast');$(self.get_selector("add",id)).hide();$(self.get_selector("del",id)).fadeTo(0,1);if(self.after){self.after()}};self.post_del=function(id){self.stop(true,true);$(self.get_selector("added",id)).slideUp('fast');$(self.get_selector("del",id)).hide();$(self.get_selector("add",id)).fadeTo(0,1);if(self.after){self.after()}};self.post_change=function(id){$(self.get_selector("add",id)
+","+self.get_selector("del",id)).toggle()};self.get_selector=function(postfix,id){return $("["+self.selector_prefix+postfix+"="+id+"]")};};var FriendProcessor=new ToggleProcessorBase("action-friend-",function(id){return"/accounts/"+id+"/link/friend_add/";},function(id){return"/accounts/"+id+"/link/friend_del/";});var IgnoreProcessor=new ToggleProcessorBase("action-ignore-",function(id){return"/accounts/"+id+"/link/ignore_add/";},function(id){return"/accounts/"+id+"/link/ignore_del/";});var BanProcessor=new ToggleProcessorBase("action-ban-",function(id){return"/accounts/"+id+"/ban/";},function(id){return"/accounts/"+id+"/unban/";});var InterestProcessor=new ToggleProcessorBase("action-interest-",function(id){return"/entities/link/interest_add/"+id+"/";},function(id){return"/entities/link/interest_del/"+id+"/";});var CommunityProcessor=new ToggleProcessorBase("action-community-",function(id){return"/entities/link/member_add/"+id+"/";},function(id){return"/entities/link/member_del/"+id+"/";});var CalendarProcessor=new ToggleProcessorBase("action-calendar-",function(id){return"/entities/link/calendar_add/"+id+"/";},function(id){return"/entities/link/calendar_del/"+id+"/";});var BestPostProcessor=new ToggleProcessorBase("action-bestpost-",function(id){return"/blog/id"+id+"/tobest/";},function(id){return"/blog/id"+id+"/frombest/"});var BestPlaylistProcessor=new ToggleProcessorBase("action-bestplaylist-",function(id){return"/playlist/id"+id+"/tobest/";},function(id){return"/playlist/id"+id+"/frombest/"});var BestVideoProcessor=new ToggleProcessorBase("action-bestvideo-",function(id){return"/video/id"+id+"/tobest/";},function(id){return"/video/id"+id+"/frombest/"});var BestImageProcessor=new ToggleProcessorBase("action-bestimage-",function(id){return"/image/id"+id+"/tobest/";},function(id){return"/image/id"+id+"/frombest/"});var BestAudioProcessor=new ToggleProcessorBase("action-bestaudio-",function(id){return"/audio/id"+id+"/tobest/";},function(id){return"/audio/id"+id+"/frombest/"});var FavoriteEntryProcessor=new ToggleProcessorBase("action-faventry-",function(id){return"/blog/favorite_user_entry/"+id+"/add/";},function(id){return"/blog/favorite_user_entry/"+id+"/del/";});var EventProcessor=new ToggleProcessorBase("action-event-",function(id){return"/entities/link/calendar_add/"+id+"/";},function(id){return"/entities/link/calendar_del/"+id+"/";});var BlockPostProcessor=new ToggleProcessorBase("action-blockpost-",function(id){return"/blog/id"+id+"/block/";},function(id){return"/blog/id"+id+"/unblock/";});var EveLevelProcessor=new ToggleProcessorBase("action-eve-level-",function(id){return"/accounts/"+id+"/eve/up/";},function(id){return"/accounts/"+id+"/eve/down/";},function(id){location.reload();});
