
var box_gallery={'gallery_status':0,'player':null,'item_index_in_set':0,'current_item_set':null,'current_set_start_index':0,'number_items_in_gallery':1,'current_folder_was_set':false,'files_elements_not_in_gallery':['#box_confirmation','#upload_files_confirmation','#marketing_message','#bottom_folder_links','#search_adv','#folder_suggestion','#bottom_folder_links_upgrade','#header_browse','#subheader','#files','#pages','#sidebar_files_feedback','.box_thumbnail_tip','.files_sidebar'],'elements_in_gallery':['#main_preview','#header_gal','#subheader_gallery','#gallery_main','.gallery_sidebar'],'profile_elements_not_in_gallery':['#user_profile_header','div.notification','#profile_header','.profile_sidebar'],'inbox_elements_not_in_gallery':['#subtabs','#box_confirmation','#new_updates_message','#top_pages','#content','#pages','#inbox_header','#inbox_subheader','#rss_header','.inbox_sidebar'],'shared_elements_not_in_gallery':['#header_browse','#subheader','#files','#pages','.box_thumbnail_tip','.shared_folder_sidebar'],'gallery_criteria':{'type':{'file':true},'extension':{'webdoc':false}},'alternative_gallery_criteria':{'extension':{'swf':true}},gallery_init:function(params)
{var params=params||{};var first_load=false;if(params.first_load)first_load=true;box_gallery.gallery_status=1;var elements_to_hide;switch(gallery_page)
{case'files':elements_to_hide=box_gallery.files_elements_not_in_gallery;break;case'inbox':elements_to_hide=box_gallery.inbox_elements_not_in_gallery;break;case'profile':elements_to_hide=box_gallery.inbox_elements_not_in_gallery.concat(box_gallery.profile_elements_not_in_gallery);break;case'shared_folder':case'vanity_url':case'collab_preview':case'more_updates':elements_to_hide=box_gallery.shared_elements_not_in_gallery;break;}
box_gallery.toggle_settings_page_hints();for(var i in elements_to_hide)
{$j(elements_to_hide[i]+':visible').addClass('hidden_for_gallery').hide();}
if(typeof(newNameTip)!='undefined')newNameTip.hide();if(typeof(folder_tree)!='undefined')folder_tree.hide();Canvas.get().scroll_up();for(var i in box_gallery.elements_in_gallery)
{$j(box_gallery.elements_in_gallery[i]).addClass('displayed_for_gallery').show();}
box_gallery.set_current_item_set_and_init_player('init');$j('#header_gal span.title').empty();if((gallery_page=='files'&&box.nav.type=='f'&&box.nav.id!=0)||(gallery_page!='files'&&$j('#path').is(':has(a)')))
{$j('#path > *').each(function()
{$j(this).clone(true).appendTo($j('#header_gal span.title'));});$j('#header_gal span.title a:last').unbind('click').click(function()
{box_gallery.gallery_close();return false;});$j('#header_gal span.title span.folder_path').append(Path.get().get_delimiter());if($j.browser.msie&&(parseInt($j.browser.version)==6||parseInt($j.browser.version)==7))
{$j('#header_gal span.title span.folder_path').append('&nbsp;');}}
else
{var return_text='';switch(gallery_page)
{case'files':switch(box.nav.type)
{case't':return_text=$t('Return to Tag Results','js_box_gallery_return_to_tag');break;case'item':return_text=$t('Return to File','js_box_gallery_return_to_file');break;case'l':return_text=$t('Return to Filter Results','js_box_gallery_return_to_filter');break;case's':return_text=$t('Return to Search Results','js_box_gallery_return_to_search');break;default:return_text=$t('Return to All Files','js_box_gallery_return_to_all');}
break;case'inbox':return_text=$t('Return to Updates','js_box_gallery_return_to_updates');break;case'profile':return_text=$t('Return to Profile','js_box_gallery_return_to_profile');break;default:return_text=$t('Return to Previous','js_box_gallery_return_to_previous');}
$j('#header_gal span.title').append($j('<a href="#"></a>').text(return_text).click(function()
{box_gallery.gallery_close();return false;}).mousedown(function()
{return false;}));}
box_gallery.current_folder_was_set=false;if(!(Canvas.get().current_folder&&Canvas.get().current_folder.id==box_gallery.current_item_set.items[0].folder.id)&&box_gallery.current_item_set.items[0].folder.id!='')
{box_gallery.current_folder_was_set=true;var url=site_root+'index.php?rm=box_gallery_folder';var query={typed_id:box_gallery.current_item_set.items[0].folder.typed_id};query=$j.extend(query,box_gallery._format_item_and_context(null));var q=$j.box.formatQuery(query);$j.post(url,q,function(json){if(!json.error)
{var collection=new ItemCollection(json.result_nodes);Canvas.get().current_folder=collection.items[0];if(Canvas.get().current_folder.name==''&&Canvas.get().current_folder.is_root_folder())
{Canvas.get().current_folder.name='All Files';}
oFolder=json.folder_info;}},'json');}
if(gallery_page=='inbox'||gallery_page=='profile'||(Canvas.get().page_count==1&&(gallery_page!='files'||(box.nav.type!='s'&&box.nav.type!='t'&&box.nav.type!='owned'&&box.nav.type!='l'&&box.nav.type!='collab'&&box.nav.type!='collabfiles'))))
{box_gallery.number_items_in_gallery=box_gallery.current_item_set.size();$j('#total_items').text(box_gallery.number_items_in_gallery);box_gallery.current_set_start_index=0;$j('#item_number').text(box_gallery.current_item_display_index());box_gallery._disable_next_previous();}
else if(gallery_page=='more_updates'||(gallery_page=='files'&&(box.nav.type=='s'||box.nav.type=='t'||box.nav.type=='owned'||box.nav.type=='l'||box.nav.type=='collab'||box.nav.type=='collabfiles')))
{box_gallery.number_items_in_gallery=1;$j('#total_items').text(box_gallery.number_items_in_gallery);box_gallery.current_set_start_index=0;$j('#item_number').text(1);box_gallery._disable_next_previous(true);}
else
{box_gallery._update_total_gallery_counts();}
if(gallery_page=='files')
{box.nav.is_gallery=1;}
else if(gallery_page=='inbox')
{inbox.nav.is_gallery=1;}
else if(gallery_page=='profile')
{box.nav.gallery_id=box_gallery.current_item().id;}
box_gallery._place_gallery_hash_in_history(first_load);},'gallery_close':function(params)
{var params=params||{};box_gallery.gallery_status=0;swfobject.removeSWF('player');$j('#gallery_content_frame').remove();$j('#gallery_content_no_flash').show();var elements_to_hide=box_gallery.elements_in_gallery.concat(['#sidebar_collaborators']);for(var i in elements_to_hide)
{$j(elements_to_hide[i]+'.displayed_for_gallery').removeClass('displayed_for_gallery').hide();}
var elements_to_show;switch(gallery_page)
{case'files':elements_to_show=box_gallery.files_elements_not_in_gallery;break;case'inbox':elements_to_show=box_gallery.inbox_elements_not_in_gallery;break;case'profile':elements_to_show=box_gallery.inbox_elements_not_in_gallery.concat(box_gallery.profile_elements_not_in_gallery);break;case'shared_folder':case'vanity_url':case'collab_preview':case'more_updates':elements_to_show=box_gallery.shared_elements_not_in_gallery;break;}
for(var i in elements_to_show)
{$j(elements_to_show[i]+'.hidden_for_gallery').removeClass('hidden_for_gallery').show();}
if(box_gallery.current_folder_was_set)
{Canvas.get().current_folder=null;}
if(params.load_background)
{switch(gallery_page)
{case'inbox':inbox.load();break;case'files':case'profile':box.load();break;}}
box_gallery._place_containing_page_hash_in_history(params.no_history);},'set_current_item_set_and_init_player':function(source)
{switch(source)
{case'init':box_gallery.current_item_set=Canvas.get().target_item.collection.find(box_gallery.gallery_criteria);for(var i=0;i<box_gallery.current_item_set.size();i++)
{if(Canvas.get().target_item.typed_id==box_gallery.current_item_set.items[i].typed_id)
{box_gallery.item_index_in_set=i;break;}}
box_gallery.process_gallery_sidebar(true);break;case'next':box_gallery.current_item_set=Canvas.get().collections[0].find(box_gallery.gallery_criteria);box_gallery.item_index_in_set=0;box_gallery._update_total_gallery_counts();box_gallery.process_gallery_sidebar();break;case'prev':box_gallery.current_item_set=Canvas.get().collections[0].find(box_gallery.gallery_criteria);box_gallery.item_index_in_set=box_gallery.current_item_set.size()-1;box_gallery._update_total_gallery_counts();box_gallery.process_gallery_sidebar();break;}
Canvas.get().target_item=box_gallery.current_item();box_gallery._update_name();box_gallery._disable_download();box_gallery._init_player('preview');box_gallery._show_comments_and_description(source=='init');box_gallery.update_shared();},'_init_player':function(player_name)
{var file_name=player_name+'.swf';var player_height=box_gallery._get_player_height();var player_width=box_gallery._get_player_width();if(!has_flash_for_preview())
{$j('.gallery_pseudo_container').show();$j('.bottom_bar_text').show();$j('.gallery_pseudo_bottom_bar').show();}
if(box_gallery._current_item_fits_gallery_criteria('alternative'))
{var callback=function(){$j('#player').css({width:'0px',height:'0px'})};}
if(typeof(swfobject)!='undefined')
{$j('#gallery_content').html('<div id="player"></div>');var flashvars={backgroundColor:'#ffffff'}
var params={allowfullscreen:'true',allowscriptaccess:'always',wmode:'opaque'}
swfobject.embedSWF(flash_url+file_name,'player',player_width.toString(),player_height.toString(),min_preview_flash_version,null,flashvars,params,null,callback);}
if(box_gallery._current_item_fits_gallery_criteria('alternative'))
{box_gallery.alternative_gallery_display_item();}
swfmacmousewheel.registerObject('player');},'slideshow':function(action)
{Canvas.get().hide_confirmation();var was_full_screen=(box_gallery.player&&typeof(box_gallery.player.isFullScreen)=='function')?box_gallery.player.isFullScreen():false;var full_screen_should_close=false;var full_screen_did_close=false;if(box_gallery.has_item('in_gallery',action))
{if(box_gallery.has_item('in_set',action))
{if(action=='next')
{box_gallery.item_index_in_set++;}
else
{box_gallery.item_index_in_set--;}
$j('#gallery_content_frame').remove();$j('#gallery_content_no_flash').show();if(box_gallery._current_item_fits_gallery_criteria('alternative'))
{$j('#player').css({width:'0px'});box_gallery.update_player_with_new_item();box_gallery.alternative_gallery_display_item();if(was_full_screen)
{full_screen_did_close=true;full_screen_should_close=true;}}
else
{box_gallery.update_player_with_new_item();$j('#player').css({width:null,height:null});}
Canvas.get().target_item=box_gallery.current_item();$j('#item_number').text(box_gallery.current_item_display_index());box_gallery._update_name();box_gallery.process_gallery_sidebar();box_gallery._show_comments_and_description();box_gallery._place_gallery_hash_in_history();box_gallery.update_shared();box_gallery._disable_next_previous();box_gallery._disable_download();}
else
{box_gallery._disable_next_previous(true);$j('#gallery_content').empty();$j('#gallery_comments_part').hide();if(action=='next')
{next_page=parseInt(Canvas.get().current_page)+1;}
else
{next_page=parseInt(Canvas.get().current_page)-1;}
switch(gallery_page)
{case'files':if(was_full_screen)
{box.after_load_callback=function(){Canvas.get().show_confirmation('Select the full screen button in the lower right hand corner of the file viewer to re-enter full screen mode.');}}
box.load(next_page,action,true);if(was_full_screen)full_screen_did_close=true;break;case'shared_folder':case'vanity_url':case'collab_preview':if(was_full_screen)
{box.after_load_callback=function(){Canvas.get().show_confirmation('Select the full screen button in the lower right hand corner of the file viewer to re-enter full screen mode.');}}
box.load(next_page,false,false,true,action);if(was_full_screen)full_screen_did_close=true;}}
Canvas.get().target_item=box_gallery.current_item();}
if(full_screen_should_close&&full_screen_did_close)
{Canvas.get().show_confirmation('Full screen preview is not yet available for the item you have selected.');}
return full_screen_should_close;},'current_item_display_index':function()
{return box_gallery.current_set_start_index+box_gallery.item_index_in_set+1;},'update_player_with_new_item':function(load_on_left,load_on_right)
{if(load_on_left==undefined)
{load_on_left=2;}
if(load_on_right==undefined)
{load_on_right=2;}
var target_typed_id=box_gallery.current_item().typed_id;var left_index=box_gallery.item_index_in_set-load_on_left;var right_index=box_gallery.item_index_in_set+load_on_right;if(left_index<0)
{var offset=0-left_index;right_index=right_index+offset;left_index=0;if(right_index>=box_gallery.current_item_set.size())
{right_index=box_gallery.current_item_set.size()-1;}}
else if(right_index>=box_gallery.current_item_set.size())
{var offset=right_index-(box_gallery.current_item_set.size()-1);left_index=left_index-offset;right_index=box_gallery.current_item_set.size()-1;if(left_index<0)
{left_index=0;}}
var items_to_load=box_gallery.current_item_set.items.slice(left_index,right_index+1);var item_context_data_to_load=new Array();for(var i=0;i<items_to_load.length;i++)
{item_context_data_to_load[i]=box_gallery._format_item_and_context(items_to_load[i]);}
if(box_gallery.player)
{box_gallery.player.updateFiles(item_context_data_to_load,target_typed_id);}
var new_player_height=box_gallery._get_player_height();$j('#player').attr('height',new_player_height);},'alternative_gallery_display_item':function()
{var content_src;switch(gallery_page)
{case'files':content_src=script_url+'flv_player/'+box_gallery.current_item().typed_id;break;case'inbox':case'profile':var shared_name=(box_gallery.current_item().shared_name!='')?box_gallery.current_item().shared_name:Canvas.get().shared_name;content_src=script_url+'flv_player/'+box_gallery.current_item().typed_id+(typeof(shared_name)!='undefined'&&shared_name?'/'+shared_name:'')+(typeof(params)!='undefined'?('&'+params):'');break;case'shared_file':case'shared_folder':case'vanity_url':var shared_name=(box_gallery.current_item().shared_name!='')?box_gallery.current_item().shared_name:Canvas.get().shared_name;content_src=script_url+'flv_player/'+box_gallery.current_item().typed_id+(typeof(shared_name)!='undefined'&&shared_name?'/'+shared_name+(pp?'/'+pp:''):'');break;case'collab_preview':content_src=script_url+'flv_player/'+box_gallery.current_item().typed_id+'/'+collab_invite_token+(pp?'/'+pp:'');break;case'more_updates':var shared_name=(box_gallery.current_item().shared_name!='')?box_gallery.current_item().shared_name:Canvas.get().shared_name;content_src=script_url+'flv_player/'+box_gallery.current_item().typed_id+(typeof(shared_name)!='undefined'&&shared_name?'/'+shared_name:'');}
$j('#gallery_content_no_flash').hide();var iframe_width='718px';if(gallery_page=='shared_file')iframe_width='799px';$j('#gallery_content').append('<iframe id="gallery_content_frame" src="'+content_src+'" name="frameName" style="width: '+iframe_width+'; height: 530px;" frameborder="0"></iframe>');},'current_item':function()
{return box_gallery.current_item_set.items[box_gallery.item_index_in_set];},'has_item':function(domain,direction)
{var maximum=0;var current_index=0;switch(domain)
{case'in_set':maximum=box_gallery.current_item_set.size();current_index=box_gallery.item_index_in_set;break;case'in_gallery':maximum=box_gallery.number_items_in_gallery;current_index=box_gallery.current_set_start_index+box_gallery.item_index_in_set;break;}
switch(direction)
{case'next':return(current_index+1<maximum);case'prev':return(current_index-1>=0);}},'toggle_settings_page_hints':function()
{var visibility=true;switch(gallery_page)
{case'shared_folder':case'vanity_url':case'collab_preview':visibility=false;break;}
$j('#preview_settings_hint').toggle(visibility);},'set_player_active':function(value)
{if((typeof(box_gallery.player)!='undefined')&&box_gallery.gallery_status==1&&box_gallery.player&&box_gallery.player.setIsActive)
{box_gallery.player.setIsActive(value);}},'preview_on_click':function(preview_type,type,image,extension)
{if(preview_type=='all')return true;if(preview_type=='none')return false;var flash_extensions=['flv','swf'];if(preview_type=='image_flash')
{return image||(type=='file'&&$j.inArray(extension,flash_extensions)!=-1||extension=='mp3');}
var supported_extensions=['jpeg','jpg','png','gif','psd','tif','tiff','bmp','html','htm','css','js','java','csv','xml','php','txt','sql','rtf','pdf','eps','ps','ai','doc','docx','ppt','pptx','xls','xlsx','wpd','odt','ods','odp','flv','mp3','swf'];if(preview_type=='supported')
{return type=='file'&&$j.inArray(extension,supported_extensions)!=-1;}},'process_gallery_sidebar':function(update_collabs)
{var current_item=box_gallery.current_item();if(current_item.folder.is_root_folder())
{$j('#sidebar_collaborators').hide();}
else
{if(update_collabs&&(gallery_page=='profile'||gallery_page=='inbox'))
{box_sidebar.reload_collab_sidebar(function(){$j('#sidebar_collaborators').addClass('displayed_for_gallery');},{just_collab_section:true,number_of_collaborators_to_load:'default'});}
else if(gallery_page=='files'&&(box.nav.type=='l'||box.nav.type=='s'||box.nav.type=='t'))
{$j('#sidebar_collaborators').addClass('displayed_for_gallery');}
$j('#sidebar_collaborators').show();}
var shared_page=gallery_page=='shared_folder'||gallery_page=='vanity_url'||gallery_page=='collab_preview';var sent_item_page=(gallery_page=='inbox'&&(box_gallery.current_item().update.update_type==1||box_gallery.current_item().update.update_type==2)||gallery_page=='more_updates');var created_date=box_gallery._translate_date(current_item['created']);var updated_date=box_gallery._translate_date(current_item['date']);var created_by_link=(shared_page&&logged_user_login=='')?$j.text(current_item.created_by):'<a href="'+script_url+'profile/'+current_item.created_by_user_id+'">'+$j.text(current_item.created_by)+'</a>';$j('#gallery_file_info_sidebar_created').html($t('Created by:','js_gallery_created')+' '+created_by_link);$j('#gallery_file_info_sidebar_created_date').text($t('Creation date:','js_gallery_created_date')+' '+created_date);$j('#gallery_file_info_sidebar_updated').removeClass('below_separator').hide();$j('#gallery_file_info_sidebar_updated_date').hide();if(!shared_page&&!sent_item_page&&!(created_date==updated_date&&current_item.created_by_user_id==current_item.last_updated_by_user_id))
{$j('#gallery_file_info_sidebar_updated').addClass('below_separator');$j('#gallery_file_info_sidebar_updated').html($t('Updated by:','js_gallery_updated')+' '+'<a href="'+script_url+'profile/'+current_item.last_updated_by_user_id+'">'+$j.text(current_item.last_updated_by)+'</a>').show();$j('#gallery_file_info_sidebar_updated_date').text($t('Updated date:','js_gallery_updated_date')+' '+updated_date).show();}
if(enable_versions_history&&current_item.permissions['download']&&!shared_page&&gallery_page!='profile')
{if(!sent_item_page)
{if(!Canvas.get().user.is_subuser&&Canvas.get().user.is_free_user&&box.current_user_is_co_owner)
{$j('#gallery_file_info_sidebar_versions_link').html('<a id="file_info_version" href="#" class="feature_disabled" onclick="upgrade_popup(\'version_history\'); return false;">'+$t('Version history','js_gallery_version_history')+' <span class="pro_gif">&nbsp;</span></a>');}
else
{$j('#gallery_file_info_sidebar_versions_link').html('<a id="file_info_version" href="#" onclick="box_gallery.current_item_set.items[box_gallery.item_index_in_set].version_history(); return false;">'+$t('Version history','js_gallery_version')+'</a>');}}}
if(current_item.permissions['rename']&&!shared_page)
{$j('#file_info_properties').show();}
else
{$j('#file_info_properties').hide();}
$j('#gallery_file_info_sidebar_size').text($t('Size:','js_gallery_size')+' '+current_item.size);var type=(current_item.type=='file')?current_item.extension:current_item.type;$j('#gallery_file_info_sidebar_type').text($t('Type:','js_gallery_type')+' '+type.toUpperCase());if(current_item.can_view_download_stats&&!shared_page&&!sent_item_page)
{var accessed_count=parseInt(current_item.shared_download_count)+parseInt(current_item.shared_preview_count);$j('#gallery_file_info_sidebar_downloads').text($t('Access count:','js_gallery_downloads')+' '+accessed_count);}
else
{$j('#gallery_file_info_sidebar_downloads').empty();}
$j('#sidebar_gallery_file_options').hide();if(shared_page)
{$j('#sidebar_gallery_info_box').hide();}},'can_share':function()
{return box_gallery.current_item().permissions.share||gallery_page=='shared_folder'||gallery_page=='vanity_url'},'update_shared':function()
{if(box_gallery.can_share())
{var discount=.58;if(box_gallery.current_item().vanity_name)
{$j('#share_text').text('Link to file:');var link=script_url+box_gallery.current_item().vanity_name;$j('#share_url').attr('value',link).show();$j('#share_url').attr('style','width: '+discount*link.length+'em');$j('#preview_link').attr('href',link).show();}
else if(box_gallery.current_item().shared&&box_gallery.current_item().shared_link!='')
{$j('#share_text').text('Link to file:');var link=box_gallery.current_item().shared_link;$j('#share_url').attr('value',link).show();$j('#share_url').attr('style','width: '+discount*link.length+'em');$j('#preview_link').attr('href',link).show();}
else
{$j('#share_text').text('Get link to this file');$j('#share_url').hide();$j('#preview_link').hide();$j('#share_url').attr('value','');}}
else
{$j('#share_text').empty();$j('#share_url').empty();$j('#preview_link').hide();}},'_current_item_fits_gallery_criteria':function(gallery_type)
{if(gallery_type=='alternative')
{return box_gallery.alternative_gallery_criteria.extension[box_gallery.current_item().extension];}},'_disable_download':function()
{if(gallery_page!='collab_preview'&&box_gallery.current_item().permissions.download)
{$j('#down_link').show();}
else
{$j('#down_link').hide();}},'_disable_next_previous':function(disable_both)
{if(disable_both)
{$j('#next_file').addClass('disabled').unbind('click');$j('#prev_file').addClass('disabled').unbind('click');return;}
if(!box_gallery.has_item('in_gallery','next'))
{$j('#next_file').addClass('disabled');}
else if($j('#next_file').hasClass('disabled'))
{$j('#next_file').removeClass('disabled');}
if(!box_gallery.has_item('in_gallery','prev'))
{$j('#prev_file').addClass('disabled');}
else if($j('#prev_file').hasClass('disabled'))
{$j('#prev_file').removeClass('disabled');}},'_format_item_and_context':function(item)
{var identifier=(typeof(item)!='undefined'&&item)?item.typed_id:null;var context_shared_name;var context_vanity_name;var context_collab_invite_token;var context_password;switch(gallery_page)
{case'files':break;case'inbox':case'profile':if(!item||!(item.update&&(item.update.update_type==1||item.update.update_type==2)))break;case'more_updates':if(item&&typeof(item.shared_name)!='undefined')
{context_shared_name=item.shared_name;if(item.password!='')
{context_password=item.password;}
break;}
else if(typeof(box_gallery.current_item().shared_name)!='undefined')
{context_shared_name=box_gallery.current_item().shared_name;}
break;case'shared_folder':context_shared_name=Canvas.get().shared_name;break;case'vanity_url':context_vanity_name=(typeof(vanity_name)!='undefined')?vanity_name:null;break;case'collab_preview':context_collab_invite_token=(typeof(collab_invite_token)!='undefined')?collab_invite_token:null;break;case'shared_file':context_shared_name=box_gallery.current_item().shared_name;}
if(!context_password)
{context_password=(typeof(pp)!='undefined')?encodeURIComponent(pp):null;}
return{'identifier':identifier,'shared_name':context_shared_name,'vanity_name':context_vanity_name,'collab_invite_token':context_collab_invite_token,'password':context_password};},'_get_player_height':function()
{var min_height=350;var max_height=460;var control_bar_height=30;var ext=box_gallery.current_item().extension;if(ext=='flv')
{max_height=.56*box_gallery._get_player_width()+control_bar_height;}
else if(ext=='swf')
{max_height=.75*box_gallery._get_player_width();}
else if(ext=='doc'||ext=='docx'||ext=='mpp'||ext=='wpd'||ext=='pdf'||ext=='txt'||ext=='rtf'||ext=='html'||ext=='odt'||ext=='css'||ext=='js'||ext=='xml'||ext=='sql'||ext=='xls'||ext=='xlsx'||ext=='ods')
{min_height=500;max_height=1.15*box_gallery._get_player_width();}
else if(ext=='ppt'||ext=='pptx'||ext=='odp')
{max_height=.75*box_gallery._get_player_width()+control_bar_height;}
else if(ext=='jpg'||ext=='jpeg'||ext=='png'||ext=='gif'||ext=='psd'||ext=='tif'||ext=='tiff'||ext=='bmp'||ext=='ai'||ext=='eps'||ext=='ps'||ext=='ind')
{max_height=.75*box_gallery._get_player_width()+control_bar_height;}
else if(ext=='')
{min_height=400;}
var player_height=$j(window).height()-300;if(gallery_page=='shared_file')
{player_height=$j(window).height()-180;}
if(player_height>max_height)player_height=max_height;if(player_height<min_height)player_height=min_height;return player_height;},'_get_player_width':function()
{if(gallery_page=='shared_file')
{return 800;}
else
{return 724;}},'_place_containing_page_hash_in_history':function(no_history)
{switch(gallery_page)
{case'files':box.nav.is_gallery=0;box.nav.gallery_id=null;if(!no_history)
{var hash='/files/'+box.nav.page+'/'+box.nav.type+'/'+box.nav.id+'/'+box_gallery.current_item().folder.name.replace(':','_').replace('/','_');;box_history.addHistory(hash,box);}
break;case'inbox':inbox.nav.gallery_id=null;inbox.nav.is_gallery=0;if(!no_history)
{var hash='#/updates/'+inbox.nav.page+'/'+inbox.nav.type+(inbox.nav.id!=''?('/'+inbox.nav.id):'')+(inbox.nav.update_type!=''?'/'+inbox.nav.update_type:'');box_history.addHistory(hash,box);}
break;case'profile':box.nav.is_gallery=0;box.nav.gallery_id=0;if(!no_history)
{var hash='#/profile/'+(profile_user_id?profile_user_id+'/':'')+'page/'+box.nav.page;box_history.addHistory(hash,box);}
break;case'shared_folder':if(!no_history&&!box.single_item_view)
{var hash='/shared/'+Canvas.get().shared_name+'/'+current_page+'/'+current_node_id.substr(2,current_node_id.length);box_history.addHistory(hash,box);}
break;case'vanity_url':if(!no_history)
{var hash='/'+vanity_name+'/'+current_page+'/'+current_node_id.substr(2,current_node_id.length);box_history.addHistory(hash,box);}
break;case'collab_preview':if(!no_history)
{var hash='/collab_preview/'+collab_invite_token+'/'+current_page+'/'+current_node_id.substr(2,current_node_id.length);box_history.addHistory(hash,box);}}},'_place_gallery_hash_in_history':function(first_load)
{if(!first_load)
{switch(gallery_page)
{case'files':var hash='#/files/'+box.nav.page+'/'+box.nav.type+'/'+box.nav.id+'/1/'+box_gallery.current_item().typed_id;break;case'inbox':var hash='#/updates/'+inbox.nav.page+'/'+inbox.nav.type+(inbox.nav.id!=''?('/'+inbox.nav.id):'')+(inbox.nav.update_type!=''?'/'+inbox.nav.update_type:'')+'/1/'+box_gallery.current_item().id;break;case'profile':var hash='#/profile/'+(profile_user_id?profile_user_id+'/':'')+'page/'+box.nav.page+(box.nav.id!=''?('/'+box.nav.id):'')+'/1/'+box_gallery.current_item().id;break;case'shared_folder':var hash='#/shared/'+Canvas.get().shared_name+'/'+current_page+'/'+current_node_id.substr(2)+'/'+box_gallery.current_item().id+'/1';break;case'vanity_url':var hash=vanity_name+'/'+current_page+'/'+current_node_id.substr(2)+'/'+box_gallery.current_item().id+'/1';break;case'collab_preview':var hash='#/collab_preview/'+collab_invite_token+'/'+current_page+'/'+current_node_id.substr(2)+'/'+box_gallery.current_item().id+'/1';break;default:var hash='#';}
box_history.addHistory(hash,box);}},'_show_comments_and_description':function(from_init)
{if(from_init)
{box_gallery.current_item().expansion.toggle('Comments',{only_close:true});}
if(((gallery_page=='shared_folder'||gallery_page=='vanity_url'||gallery_page=='collab_preview')&&!folder_talk_enabled)||gallery_page=='shared_file')
{$j('#gallery_comments_part').hide();$j('.gallery_comments_table').hide();}
else
{$j('#gallery_comments_header').show();comments.create(box_gallery.current_item().typed_id,$j('#gallery_comments_block_temp').get(0),false,box_gallery.current_item().collection.id,(box_gallery.current_item().parent_collaborated&&box_gallery.current_item().collaborations?box_gallery.current_item().collaborations.length:false),null);box_gallery.current_item().comments.show_for_gallery();}
if(box_gallery.current_item().description)
{$j('#gallery_file_description').empty().html('Description: <span class="description_text">'+box_gallery.current_item().description+'</span>').show();}
else
{$j('#gallery_file_description').hide();}},'_translate_date':function(raw_date)
{if(raw_date=='Today')return $t('Today','js_gallery_date_today');if(raw_date=='Yesterday')return $t('Yesterday','js_gallery_date_yesterday');return raw_date;},'_update_name':function()
{var item_name=box_gallery.current_item().name;var short_text=get_short_string(item_name,460,$j('#header_gal span.title2'));$j('#header_gal span.title2').text(short_text).attr('title',(short_text==item_name?'':item_name));},'_update_total_gallery_counts':function()
{var url=site_root+'index.php?rm=box_total_gallery_count';var sort_type=false;var direction=false;if(gallery_page=='files')
{direction=box.nav.sort_direction;sort_type=box.nav.sort;}
else if(gallery_page=='more_updates'||gallery_page=='shared_folder'||gallery_page=='vanity_url'||gallery_page=='collab_preview')
{direction=sort_direction
sort_type=shared_folder_sort_type;}
var query={id:box_gallery.current_item_set.items[0].folder.id,type:box_gallery.gallery_criteria.type,extension:box_gallery.gallery_criteria.extension,first_set_id:box_gallery.current_item_set.items[0].id,sort_direction:direction,sort_type:sort_type};query=$j.extend(query,box_gallery._format_item_and_context(null));var q=$j.box.formatQuery(query);$j.post(url,q,function(json){if(parseInt(Canvas.get().current_page)>1)
{box_gallery.current_set_start_index=json.result.start_index;}
else
{box_gallery.current_set_start_index=0;}
$j('#item_number').text(box_gallery.current_item_display_index());box_gallery.number_items_in_gallery=json.result.total_count;$j('#total_items').text(box_gallery.number_items_in_gallery);box_gallery._disable_next_previous();},'json');},'init_shared_file_preview':function(item)
{box_gallery.gallery_status=1;box_gallery.current_item_set=new ItemCollection();box_gallery.current_item_set.items[0]=item;box_gallery._show_comments_and_description();box_gallery._init_player('share');}};function previewer_loaded()
{box_gallery.player=$j('#player')[0];if(typeof($j('#player').updateFiles!='function'))
{setTimeout(function(){box_gallery.update_player_with_new_item(0,0);},0);}
else
{box_gallery.update_player_with_new_item(0,0);}}
function previewer_go_next_document()
{return box_gallery.slideshow('next');}
function previewer_go_previous_document()
{return box_gallery.slideshow('prev');}
function previewer_has_next_document()
{return box_gallery.has_item('in_gallery','next');}
function previewer_has_previous_document()
{return box_gallery.has_item('in_gallery','prev');}
function previewer_num_documents()
{return box_gallery.number_items_in_gallery;}
function previewer_current_document_index()
{return box_gallery.current_item_display_index();}
function previewer_get_link_to_file()
{box_gallery.current_item().share();}
function previewer_can_share()
{return box_gallery.can_share();}
function entering_full_screen()
{box_gallery.page_title=document.title;}
function leaving_full_screen()
{document.title=box_gallery.page_title;}
