if(!window.console||!console.firebug)
{var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];window.console={};for(var i=0;i<names.length;++i)
window.console[names[i]]=function(){}}
function nl2br(text)
{return text.replace(/\n/g,"<br />");}
function escapeHtml(s)
{return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");}
function button(options)
{var button=$('<a href="#" class="button"></a>');button.text(options.message);button.attr('title',options.message);if(options.silk)
{button.addClass('silk-'+options.silk);button.css({'background-image':'url(/img/silk/'+options.silk+'.png)'});}
if(options.href)
{button.attr('href',options.href);}
button.click(function(e)
{if(!options.href)
{e.preventDefault();}
if(options.click)
{options.click(e);}});return button;}
function api(data,success,error)
{$.ajax({type:'POST',url:'/api',data:data,dataType:'json',success:function(res)
{if(res.status=='ok')
{if(success)
{success(res);}}
else if(res.status=='error')
{if(error)
{error(res);}
else
{alert(res.error_message)}}
else
{alert('We made contact with the server but it isn\'t making sense at the moment...');}},error:function(XMLHttpRequest,textStatus,errorThrown)
{alert('There was an issue connecting to the server. Please try again in a few seconds. If this problem persists, please contact the administrator.');}});}
os={path:{dirname:function(path)
{var match=path.match(/^(.+?)\/+[^\/]+\/*$/);return match?match[1]:'';},basename:function(path)
{var match=path.match(/([^\/]*)$/);return match?match[1]:'';},ext:function(path)
{match=path.match(/\.(\w+)$/)
return match?match[1]:'';}}}
function formatSize(bytes)
{var order=0;var old_bytes=-1;if(typeof bytes!="number"){return'not a number';}
if(bytes>4294967295){return'really big';}
if(bytes<0){return'really small';}
while(bytes!=old_bytes&&bytes>1024)
{bytes/=1024;order+=1;old_bytes=bytes;}
return Math.round(bytes*100)/100+' '+'B KB MB GB TB PB'.split(' ')[order];}
function formatTime(sec)
{return Math.round(sec/60)+'min '+Math.round(sec)%60+'s.';}
jQuery.fn.hoverClass=function(opts)
{switch(typeof(opts))
{case'undefined':opts={};break;case'string':opts={className:opts};break;}
opts=jQuery.extend({className:'hover'},opts);var $$=this;$$.hover(function()
{$$.addClass(opts.className);},function()
{$$.removeClass(opts.className);});return this;}
jQuery.fn.pr_slideshow=function(opts)
{opts=$.extend({delay:1000,duration:500},opts);var $$=this;var pool=[];$.each(opts.pool,function(i,el)
{pool.push($(el));});function next_slide()
{var i=opts.random?Math.floor(Math.pow(Math.random(),2)*pool.length):0;var next=pool[i]
pool.splice(i,1);pool.push($$);$$.css('z-index',$$.css('z-index')+1);next.insertBefore($$).show();$$.fadeOut(opts.duration,function()
{$$.remove();$$=next;setTimeout(next_slide,opts.delay);});}
setTimeout(next_slide,opts.delay);return this;}
jQuery(function($){$('.nav').each(function(){var $$=$(this).find('a[href^=/'+section+']').eq(0).parent();if(!$$.length)
{return;}
$$.addClass('selected');})
$('#ajax_spinner').ajaxStart(function()
{$(this).show();}).ajaxStop(function()
{$(this).fadeOut();});var $banners=$('.banner');$banners.eq(0).pr_slideshow({pool:$banners.slice(1),delay:6500,duration:2500,random:true});Shadowbox.init({skipSetup:true,overlayOpacity:.85,resizeDuration:0});$('a').live('click',function(e)
{var $$=$(this);var href=$$.attr('href');if(!href)
{return;}
if($$.closest('.filebrowser').length)
{return;}
var match=href.match(/^(.+?)(\?(.+))?$/);var query=null;if(match)
{href=match[1];query=match[3];}
var ext=os.path.ext(href);switch(ext)
{case'jpeg':case'jpg':case'gif':case'png':Shadowbox.open({player:'img',content:href});break;case'mov':case'mpeg':case'mpg':dims=query.match(/^w=(\d+)&h=(\d+)$/);Shadowbox.open({player:'qt',content:href,width:dims?dims[1]:640,height:dims?dims[2]:360});break;default:return;}
e.preventDefault();e.stopPropagation();});})