;(function($){$.fn.sitewide=function(){init_comments();var submit=$('.buttons input[type=submit]');if(submit.length){submit.each(function(){$(this).css('display','none').before($('<a href=""><span>'+$(this).val()+'</span></a>').click(function(){$(this).parents('form').submit();return false;}));})}$('#navigation a').not('#navigation ul ul a').mouseover(function(){$('#navigation a').removeClass('hover');var l=$(this).addClass('hover').parent().find('ul').clone();$('#subnavigation').html(l);});var l=window.location.pathname;if(l!='/'){l='/'+l.split('/')[1]+'/'}$('#navigation a').not('#navigation ul ul a').each(function(){if($(this).attr('href')==l){$(this).addClass('selected').mouseover();return;}});};var init_comments=function(){var comment=$('#comment');var comment_list=$('#comment_wrapper ul.list');var form=$('#comment_post');if(comment.length){comment.val('Write a comment...').focus(function(){if(comment.height()==18){comment.val('').height(90).css('color','#000');form.find('div.buttons').toggle();}}).blur(function(){if(!comment.val().length){comment.val('Write a comment...').height(18).css('color','#666');form.find('div.buttons').toggle();}});form.submit(function(){var submit_button=form.find('div.buttons a');if(comment.val().length&&submit_button.text()=='Comment'){submit_button.find('span').text('Posting comment...');$.post(form.attr('action'),form.serialize(),function(r){if(r=='1'){var li=build_comment_row('You',', a few seconds ago...',comment.val());li.css('opacity',0).prependTo(comment_list).animate({'opacity':1},500);$.scrollTo('#comment_count',100);comment.val('Write another comment...').height(18).css('color','#666');form.find('div.buttons').toggle();submit_button.find('span').text('Comment');$('#comment_count').html((parseInt($('#comment_count').text(),10)+1)+' COMMENTS');}});}return false;});}var next='';var next=$('#next_page_number');if(next.length){next.parent().find('span').click(function(){if(this.innerHTML=='Loading...'){return false;}this.innerHTML='Loading...';$.getJSON(basepath+'comments/get-page/'+$('input[name=content_type]').val()+'/'+$('input[name=object_id]').val()+'/?page='+next.val(),null,function(r){var ul=$('<ul class="list"></ul>').css('opacity',0);$(r.object_list).each(function(i){build_comment_row(this.u,' at '+this.d,this.c).appendTo(ul);});next.parent().parent().before(ul);ul.animate({'opacity':1},500);if(r.next_page_number){next.val(r.next_page_number);next.parent().find('span').html('More comments...')}else{next.parent().parent().html('')}});});}};var build_comment_row=function(username,date,comment){var li=$('<li>'+'<div class="comment"></div>'+'<div class="cls"></div>'+'</li>');var c=li.find('div.comment');comment=comment.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;").replace(/\n/g,'<br>');c.html(comment).prepend($('<span/>').text(username+date));return li;}})(jQuery);;(function($){var stage;var items;var current_item;var timer;$.fn.featured=function(){stage=$(this).find('.stage');items=$(this).find('.items a');items.css('opacity',1);current_item=$(items[0]);show(current_item);timer_id=setTimeout(show_next,10000);$(this).mouseover(function(){clearTimeout(timer_id);timer_id=-1;});$(this).mouseout(function(){if(timer_id<0){timer_id=setTimeout(show_next,10000);}});items.mouseover(function(){current_item=$(this);show(current_item);});};var show_next=function(){current_item=current_item.next();if(!current_item.length){current_item=$(items[0]);}show(current_item);timer_id=setTimeout(show_next,10000);};var show=function(o){stage.animate({opacity:0},50,function(){stage.css('background-image','url('+o.find('img.large').attr('src')+')');stage.html('<div><h1><a href="'+o.attr('href')+'">'+o.attr('rel')+'</a></h1></div>');items.find('img').css('opacity',1);o.find('img').css('opacity',.5);stage.animate({opacity:1},250);});};})(jQuery);;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:1};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);$(function(){$().sitewide();});