if(typeof jQuery=="undefined")jQuery=function(){};if(typeof jQuery.classBehaviours=="undefined")jQuery.classBehaviours=function(){};if(typeof jQuery.classBehaviours.handlers=="undefined")jQuery.classBehaviours.handlers=function(){};jQuery.classBehaviours.handlers.pageList={name:"pageList",index:0,start:function(a){if(a.id=="")a.id=this.name+this.index++;if(a.getElementsByTagName("DIV")[0].style.marginLeft=="")a.getElementsByTagName("DIV")[0].style.marginLeft="0px";a.getElementsByTagName("BUTTON")[0].onclick=this.backwards;a.getElementsByTagName("BUTTON")[1].onclick=this.forwards;a.onmouseover=this.stopAuto;a.onmouseout=this.startAuto;this.startAuto(a)},forwards:function(c){var b=typeof this.nodeName=="undefined"?c:this,d=jQuery.classBehaviours.handlers.pageList;rootNode=jQuery.classBehaviours.utilities.rootNode(b,null,null,d.name);scrollNode=rootNode.getElementsByTagName("DIV")[0];allArticles=rootNode.getElementsByTagName("LI");currentTimeout=parseInt(jQuery.classBehaviours.utilities.getClassParameter(rootNode,"timeout","0"));currentIndex=parseInt(jQuery.classBehaviours.utilities.getClassParameter(rootNode,"index","0"));currentOffset=parseInt(jQuery.classBehaviours.utilities.getClassParameter(rootNode,"offset","0"));clearTimeout(currentTimeout);totalWidth=0;for(var a=0;a<allArticles.length;a++)totalWidth+=allArticles[a].offsetWidth;scrollDistance=0;canvasWidth=rootNode.offsetWidth;while(scrollDistance<canvasWidth&&currentIndex<allArticles.length){currentIndex+=1;scrollDistance+=allArticles[currentIndex-1].offsetWidth}scrollStep=10;scrollOffset=parseInt(scrollNode.style.marginLeft);scrollDestination=scrollOffset-scrollStep>canvasWidth-totalWidth?currentOffset-scrollDistance+allArticles[currentIndex-1].offsetWidth:canvasWidth-totalWidth;scrollPercentage=Math.round((scrollOffset-currentOffset)/(scrollDestination-currentOffset)*100);scrollCurve=Math.abs(Math.round(-.03*Math.pow(scrollPercentage-60,2)+100));scrollStep=scrollCurve/5+2;if(scrollOffset-scrollStep>scrollDestination){scrollNode.style.marginLeft=scrollOffset-scrollStep+"px";scrollTimeout=setTimeout('jQuery.classBehaviours.handlers.pageList.forwards(document.getElementById("'+rootNode.id+'"));',33);jQuery.classBehaviours.utilities.setClassParameter(rootNode,"timeout",scrollTimeout)}else{scrollNode.style.marginLeft=scrollDestination+"px";jQuery.classBehaviours.utilities.setClassParameter(rootNode,"index",currentIndex-1);jQuery.classBehaviours.utilities.setClassParameter(rootNode,"offset",scrollDestination);currentIndex==allArticles.length&&jQuery.classBehaviours.utilities.setClassParameter(rootNode,"direction","backwards")}return false},backwards:function(c){var b=typeof this.nodeName=="undefined"?c:this,d=jQuery.classBehaviours.handlers.pageList;rootNode=jQuery.classBehaviours.utilities.rootNode(b,null,null,d.name);scrollNode=rootNode.getElementsByTagName("DIV")[0];allArticles=rootNode.getElementsByTagName("LI");currentTimeout=parseInt(jQuery.classBehaviours.utilities.getClassParameter(rootNode,"timeout","0"));currentIndex=parseInt(jQuery.classBehaviours.utilities.getClassParameter(rootNode,"index","0"));currentOffset=parseInt(jQuery.classBehaviours.utilities.getClassParameter(rootNode,"offset","0"));clearTimeout(currentTimeout);totalWidth=0;for(var a=0;a<allArticles.length;a++)totalWidth+=allArticles[a].offsetWidth;scrollDistance=0;canvasWidth=rootNode.offsetWidth;while(scrollDistance<canvasWidth&&currentIndex>0){scrollDistance+=allArticles[currentIndex-1].offsetWidth;currentIndex-=1}scrollStep=10;scrollOffset=parseInt(scrollNode.style.marginLeft);scrollDestination=scrollOffset+scrollStep<0?currentOffset+scrollDistance-allArticles[currentIndex].offsetWidth:0;scrollPercentage=Math.round((scrollOffset-currentOffset)/(scrollDestination-currentOffset)*100);scrollCurve=Math.abs(Math.round(-.03*Math.pow(scrollPercentage-60,2)+100));scrollStep=scrollCurve/5+2;if(scrollOffset+scrollStep<scrollDestination){scrollNode.style.marginLeft=scrollOffset+scrollStep+"px";scrollTimeout=setTimeout('jQuery.classBehaviours.handlers.pageList.backwards(document.getElementById("'+rootNode.id+'"));',33);jQuery.classBehaviours.utilities.setClassParameter(rootNode,"timeout",scrollTimeout)}else{scrollNode.style.marginLeft=scrollDestination+"px";jQuery.classBehaviours.utilities.setClassParameter(rootNode,"index",currentIndex+1);jQuery.classBehaviours.utilities.setClassParameter(rootNode,"offset",scrollDestination);currentIndex==0&&jQuery.classBehaviours.utilities.setClassParameter(rootNode,"direction","forwards")}return false},startAuto:function(d,b){var a=typeof this.nodeName=="undefined"?d:this,c=jQuery.classBehaviours.handlers.pageList;scrollIndex=parseInt(jQuery.classBehaviours.utilities.getClassParameter(a,"index","0"));scrollDirection=jQuery.classBehaviours.utilities.getClassParameter(a,"direction","forwards");b&&scrollDirection=="forwards"&&c.forwards(a);b&&scrollDirection=="backwards"&&c.backwards(a);scrollPause=parseInt(jQuery.classBehaviours.utilities.getClassParameter(a,"pause","8"));scrollInterval=setTimeout('jQuery.classBehaviours.handlers.pageList.startAuto(document.getElementById("'+a.id+'"), true);',scrollPause*1e3);jQuery.classBehaviours.utilities.setClassParameter(a,"interval",scrollInterval)},stopAuto:function(b){var a=typeof this.nodeName=="undefined"?b:this,c=jQuery.classBehaviours.handlers.pageList;scrollInterval=parseInt(jQuery.classBehaviours.utilities.getClassParameter(a,"interval",scrollInterval));clearTimeout(scrollInterval)},loadArticles:function(b){var c=jQuery.classBehaviours.handlers.pageList;currentIndex=parseInt(jQuery.classBehaviours.utilities.getClassParameter(b,"index","0"));articlesBuffer=parseInt(jQuery.classBehaviours.utilities.getClassParameter(b,"buffer","3"));currentArticles=b.getElementsByTagName("ARTICLE");if(currentIndex+articlesBuffer>currentArticles.length){articleLinks=b.getElementsByTagName("NAV")[0].getElementsByTagName("A");endIndex=currentIndex+articlesBuffer<articleLinks.length?currentIndex+articlesBuffer:articleLinks.length;for(a=currentArticles.length;a<endIndex;a++)jQuery.classBehaviours.ajax.addRequest(articleLinks[a].getAttribute("href"),c.insertArticle,c.awaitArticle,null,b)}},awaitArticle:function(){},insertArticle:function(c,a,b){sectionNode=a.getElementsByTagName("SECTION")[0];newArticle=document.createElement("ARTICLE");newArticle.innerHTML=b.split("<body>")[1].split("</body>")[0];sectionNode.appendChild(newArticle)}};if(typeof jQuery.fn!="undefined"){jQuery.fn.pageList=function(){return this.each(function(){jQuery.classBehaviours.handlers.pageList.start(this)})};$(document).ready(function(){$(".pageList").pageList()})}