﻿jQuery.fn.accessNews=function(a){a=jQuery.extend({newsHeadline:"Top Stories",newsWidth:285,newsSpeed:"normal"},a);return this.each(function(){aNewsSlider.init(a,this);jQuery(".view_all > a",this).click(function(){aNewsSlider.vAll(a,this);return false})})};var aNewsSlider={init:function(b,a){jQuery(".messaging",a).css("display","none");itemLength=jQuery(".item",a).length;if(jQuery(".view_all",a).width()==null)jQuery(".news_items",a).prepend("<p class='view_all'>"+b.newsHeadline+" [ "+itemLength+" total ] &nbsp;-&nbsp; <a href='#'>View All</a></p>");newsContainerWidth=itemLength*b.newsWidth;jQuery(".container",a).css("width",newsContainerWidth+"px");jQuery(".next",a).css("display","block");animating=false;jQuery(".next",a).click(function(){if(animating==false){animating=true;animateLeft=parseInt(jQuery(".container",a).css("left"))-b.newsWidth*2;if(animateLeft+parseInt(jQuery(".container",a).css("width"))>0){jQuery(".prev",a).css("display","block");jQuery(".container",a).animate({left:animateLeft},b.newsSpeed,function(){jQuery(this).css("left",animateLeft);if(parseInt(jQuery(".container",a).css("left"))+parseInt(jQuery(".container",a).css("width"))<=b.newsWidth*2)jQuery(".next",a).css("display","none");animating=false})}else animating=false;return false}});jQuery(".prev",a).click(function(){if(animating==false){animating=true;animateLeft=parseInt(jQuery(".container",a).css("left"))+b.newsWidth*2;if(animateLeft+parseInt(jQuery(".container",a).css("width"))<=parseInt(jQuery(".container",a).css("width"))){jQuery(".next",a).css("display","block");jQuery(".container",a).animate({left:animateLeft},b.newsSpeed,function(){jQuery(this).css("left",animateLeft);if(parseInt(jQuery(".container",a).css("left"))==0)jQuery(".prev",a).css("display","none");animating=false})}else animating=false;return false}})},vAll:function(c,a){var b=a;while(a){a=a.parentNode;if(jQuery(a).attr("class")!=undefined&&jQuery(a).attr("class").indexOf("news_slider")!=-1)break}if(jQuery(b).text().indexOf("View All")!=-1){jQuery(".next",a).css("display","none");jQuery(".prev",a).css("display","none");jQuery(b).text("View Less");jQuery(".container",a).css("left","0px").css("width",c.newsWidth*2+"px")}else{jQuery(b).text("View All");aNewsSlider.init(c,a)}}}