(function(a){a.browser.chrome=/chrome/i.test(navigator.userAgent);a(function(){var b=a("#newsFeed");if(b.size()){new a.NewsFeed({container:b,newsItems:b.find("li.newsItem"),list:b.find("ul"),limit:3})}a("img.hover-fade, .hover-fade img").hoverFade()});a.extend({Carousel:function(b,r){r=a.extend({left:"#arrow-left",right:"#arrow-right",infinite:true,size:4,speed:"slow",easing:"swing",onChange:function(){}},r);var q=a(b);var g=[a(r.left),a(r.right)];var c=q.width();q.css({width:c,overflow:"hidden"});var j=q.find("ul").css({position:"relative",width:9999});var m=j.children("li");if(window.supersleight&&a.browser.msie&&a.browser.version<7){window.onload=null;supersleight.limitTo(false);supersleight.run()}if(m.size()<=r.size){return}if(r.infinite){m.remove();for(var h=(m.size()%r.size)||r.size;h<r.size;h++){m=m.add("<li />")}var d=[];for(var h=0,f=m.size();h<f;h+=r.size){d.push(m.slice(h,h+r.size))}var k=0,o=d.length-1,e=c;d[k].appendTo(j)}else{p(0,"off");var k=0,o=m.size()-r.size,e=c/r.size}var n=false;a.each(g,function(s,l){l.show().hover(function(){p(s,"hover")},function(){p(s)}).click(function(){if(n){return}else{n=true}if(r.infinite){var i=k+2*s-1;i=i>o?0:(i<0?o:i);j[s?"append":"prepend"](d[i]).css("left",(s-1)*e);var t=-s*e}else{var i=k+(2*s-1)*r.size;i=(i<0)?0:((i>o)?o:i);if(i==k){n=false;return}var t=(s?"-=":"+=")+e*Math.abs(i-k)}setTimeout(function(){j.animate({left:t},r.speed,r.easing,function(){if(r.infinite){d[k].remove();j.css("left",0)}else{p(1-s,"on");if(i==0||i==o){p(s,"off")}}k=i;r.onChange.call(q,k);n=false})},10)})});function p(s,t){var v="",l=g[s];if((!t||t=="hover")&&l.hasClass("off")){return}switch(t){case"off":l.removeClass("hover").addClass("off");v="_off";break;case"on":l.removeClass("off");break;case"hover":l.addClass("hover");v="_on";break;default:l.removeClass("hover")}if(l[0].tagName=="IMG"){l.attr("src",u(l.attr("src")))}else{l.css("background-image",u(l.css("background-image")))}function u(i){return i.replace(/(_on|_off)?\.(gif|png|jpe?g)/i,v+".$2")}}},NewsFeed:function(f){var d=this;var b=f.limit-1;var c=false;function g(l){var j=l;for(var k=1;k<f.limit;k++){j=j.prev()}return j}function e(k,j){var i=(j=="on")?"off":"on";a("#"+k).removeClass(i).addClass(j)}f.newsItems.eq(b).addClass("lastVisibleItem");var h=g(a(".lastVisibleItem"));h.addClass("firstVisibleItem");f.container.find(".arrow").click(function(o){if(!c&&a(this).is(".on")){var i=a(".lastVisibleItem");var l=a(".firstVisibleItem");var n=(a(this).attr("id")=="up")?"+":"-";if((f.newsItems.index(l)==0&&n=="+")||(f.newsItems.index(i)==f.newsItems.size()-1&&n=="-")){return false}var k=(n=="+")?l.prevAll().size():i.nextAll().size();var j=(k>f.limit)?f.limit:k;b=(n=="+")?b-j:b+j;var m=j*91;c=true;f.list.animate({top:n+"="+m+"px"},"slow","easeOutCubic",function(){i.removeClass("lastVisibleItem");l.removeClass("firstVisibleItem");f.newsItems.eq(b).addClass("lastVisibleItem");var p=g(a(".lastVisibleItem"));p.addClass("firstVisibleItem");if(f.newsItems.index(p.get(0))==0){e("up","off")}else{e("up","on")}if(b==f.newsItems.size()-1){e("down","off")}else{e("down","on")}c=false})}})}});a.extend(a.easing,{easeOutCubic:function(f,g,e,i,h){return i*((g=g/h-1)*g*g+1)+e}});a.fn.safeExtend=function(c){for(var b in c){if(!a.fn[b]){a.fn[b]=c[b]}}};a.fn.safeExtend({hoverClass:function(b){b=b||"hover";return this.hover(function(){a(this).addClass(b)},function(){a(this).removeClass(b)})},hoverFade:function(b){var c=a("<div />").css("display","none").appendTo("body");this.filter("img").each(function(){var d=a("<img />").attr("src",this.src.replace(/\.(\w+)$/,"_on.$1")).css({position:"absolute",zIndex:-1}).appendTo(c);var e=a(this).hover(function(){var f=e.position();d.css({top:f.top,left:f.left}).insertBefore(e);e.fade("out",b)},function(){e.fade("in",b,function(){d.remove()})})});return this},delegate:function(b,c){return this.bind(b,function(g){var h=a(g.target).parents().andSelf();for(var f in c){var d=h.filter(f);if(d.size()){c[f].apply(d,arguments)}}})},track:function(c,d){function b(f){if(typeof f=="function"){f=f.call(a(this))}if(!f){return}if(/^>/.test(f)){f=page_tracker_obj.pageName+f}else{if(/^</.test(f)){f=page_tracker_obj.pageName.replace(/[^>]+>[^>]+$/,f.slice(1))}else{f=page_tracker_obj.pageName.replace(/[^>]+$/,f)}}if(d){tracking.click_track(f)}else{tracking.click({pageName:f,prop18:page_tracker_obj.prop18,prop19:page_tracker_obj.prop19})}}if(typeof c=="object"){var e={};a.each(c,function(g,f){e[g]=function(){b.call(this,f)}});return this.delegate("click",e)}else{return this.click(function(){b.call(this,c)})}},morph:function(d,e,i,h){var g={},c={};for(var f in d){var b=(typeof d[f]!="string");if(b){g[f]=d[f][0]}c[f]=(b)?d[f][1]:d[f]}return this.css(g).animate(c,e,i,h)},fade:function(e,d,f,b){if(e=="in"){e=1}else{if(e=="out"){e=0}}if(typeof d=="function"){if(f){b=f}f=d;d=null}function c(){if(f){f.call(this)}}if(this.cannotFade()){this.css("visibility",e?"visible":"hidden");c()}else{if(!b){this.stop()}if(e&&this.css("visibility")=="hidden"){this.css({visibility:"visible",opacity:0})}this.animate({opacity:e},d||"slow","swing",c)}return this},cannotFade:function(){if(a.browser.chrome||(a.browser.msie&&a.browser.version<8)){var b=false;this.find("*").andSelf().each(function(){if(/\.png/.test(this.tagName=="IMG"?this.src:a(this).css("background-image"))){b=true;return false}});return b}return false},browserDetect:function(){if(window.BrowserDetect){var b=(BrowserDetect.browser=="Explorer"?"IE":BrowserDetect.browser);this.addClass((b+" "+b+BrowserDetect.version+" "+BrowserDetect.OS).toLowerCase())}else{console.log("Can't find BrowserDetect!")}return this}})})(jQuery);