/* ----------------------------------
jQuery Timelinr 0.9.53
tested with jQuery v1.6+

Copyright 2011, CSSLab.cl
Free under the MIT license.
http://www.opensource.org/licenses/mit-license.php

instructions: http://www.csslab.cl/2011/08/18/jquery-timelinr/
---------------------------------- */

function autoPlay(){var s=$(settings.datesDiv).find("a."+settings.datesSelectedClass);"forward"==settings.autoPlayDirection?s.parent().is("li:last-child")?$(settings.datesDiv+" li:first-child").find("a").trigger("click"):s.parent().next().find("a").trigger("click"):"backward"==settings.autoPlayDirection&&(s.parent().is("li:first-child")?$(settings.datesDiv+" li:last-child").find("a").trigger("click"):s.parent().prev().find("a").trigger("click"))}jQuery.fn.timelinr=function(s){settings=jQuery.extend({orientation:"horizontal",containerDiv:"#timeline",datesDiv:"#dates",datesSelectedClass:"selected",datesSpeed:"normal",issuesDiv:"#issues",issuesSelectedClass:"selected",issuesSpeed:"fast",issuesTransparency:.2,issuesTransparencySpeed:500,prevButton:"#prev",nextButton:"#next",arrowKeys:"false",startAt:1,autoPlay:"false",autoPlayDirection:"forward",autoPlayPause:4e3},s),$(function(){var s=$(settings.datesDiv+" li").length,t=$(settings.issuesDiv+" li").length,e=($(settings.datesDiv).find("a."+settings.datesSelectedClass),$(settings.issuesDiv).find("li."+settings.issuesSelectedClass),$(settings.containerDiv).width()),i=$(settings.containerDiv).height(),n=($(settings.issuesDiv).width(),$(settings.issuesDiv).height(),$(settings.issuesDiv+" li").width()),a=$(settings.issuesDiv+" li").height(),g=($(settings.datesDiv).width(),$(settings.datesDiv).height(),$(settings.datesDiv+" li").width()),d=$(settings.datesDiv+" li").height();if("horizontal"==settings.orientation){$(settings.issuesDiv).width(n*t),$(settings.datesDiv).width(g*s).css("marginLeft",e/2-g/2);var l=parseInt($(settings.datesDiv).css("marginLeft").substring(0,$(settings.datesDiv).css("marginLeft").indexOf("px")))}else if("vertical"==settings.orientation){$(settings.issuesDiv).height(a*t),$(settings.datesDiv).height(d*s).css("marginTop",i/2-d/2);var l=parseInt($(settings.datesDiv).css("marginTop").substring(0,$(settings.datesDiv).css("marginTop").indexOf("px")))}$(settings.datesDiv+" a").click(function(t){t.preventDefault();var e=($(this).text(),$(this).parent().prevAll().length);"horizontal"==settings.orientation?$(settings.issuesDiv).animate({marginLeft:-n*e},{queue:!1,duration:settings.issuesSpeed}):"vertical"==settings.orientation&&$(settings.issuesDiv).animate({marginTop:-a*e},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li").animate({opacity:settings.issuesTransparency},{queue:!1,duration:settings.issuesSpeed}).removeClass(settings.issuesSelectedClass).eq(e).addClass(settings.issuesSelectedClass).fadeTo(settings.issuesTransparencySpeed,1),1==s?$(settings.prevButton+","+settings.nextButton).fadeOut("fast"):2==s?$(settings.issuesDiv+" li:first-child").hasClass(settings.issuesSelectedClass)?($(settings.prevButton).fadeOut("fast"),$(settings.nextButton).fadeIn("fast")):$(settings.issuesDiv+" li:last-child").hasClass(settings.issuesSelectedClass)&&($(settings.nextButton).fadeOut("fast"),$(settings.prevButton).fadeIn("fast")):$(settings.issuesDiv+" li:first-child").hasClass(settings.issuesSelectedClass)?($(settings.nextButton).fadeIn("fast"),$(settings.prevButton).fadeOut("fast")):$(settings.issuesDiv+" li:last-child").hasClass(settings.issuesSelectedClass)?($(settings.prevButton).fadeIn("fast"),$(settings.nextButton).fadeOut("fast")):$(settings.nextButton+","+settings.prevButton).fadeIn("slow"),$(settings.datesDiv+" a").removeClass(settings.datesSelectedClass),$(this).addClass(settings.datesSelectedClass),"horizontal"==settings.orientation?$(settings.datesDiv).animate({marginLeft:l-g*e},{queue:!1,duration:"settings.datesSpeed"}):"vertical"==settings.orientation&&$(settings.datesDiv).animate({marginTop:l-d*e},{queue:!1,duration:"settings.datesSpeed"})}),$(settings.nextButton).bind("click",function(e){if(e.preventDefault(),"horizontal"==settings.orientation){var i=parseInt($(settings.issuesDiv).css("marginLeft").substring(0,$(settings.issuesDiv).css("marginLeft").indexOf("px"))),l=parseInt($(settings.datesDiv).css("marginLeft").substring(0,$(settings.datesDiv).css("marginLeft").indexOf("px"))),u=l-g;i<=-(n*t-n)?($(settings.issuesDiv).stop(),$(settings.datesDiv+" li:last-child a").click()):$(settings.issuesDiv).is(":animated")||($(settings.issuesDiv).animate({marginLeft:i-n},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li").animate({opacity:settings.issuesTransparency},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li."+settings.issuesSelectedClass).removeClass(settings.issuesSelectedClass).next().fadeTo(settings.issuesTransparencySpeed,1).addClass(settings.issuesSelectedClass),$(settings.datesDiv).animate({marginLeft:u},{queue:!1,duration:"settings.datesSpeed"}),$(settings.datesDiv+" a."+settings.datesSelectedClass).removeClass(settings.datesSelectedClass).parent().next().children().addClass(settings.datesSelectedClass))}else if("vertical"==settings.orientation){var i=parseInt($(settings.issuesDiv).css("marginTop").substring(0,$(settings.issuesDiv).css("marginTop").indexOf("px"))),l=parseInt($(settings.datesDiv).css("marginTop").substring(0,$(settings.datesDiv).css("marginTop").indexOf("px"))),u=l-d;i<=-(a*t-a)?($(settings.issuesDiv).stop(),$(settings.datesDiv+" li:last-child a").click()):$(settings.issuesDiv).is(":animated")||($(settings.issuesDiv).animate({marginTop:i-a},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li").animate({opacity:settings.issuesTransparency},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li."+settings.issuesSelectedClass).removeClass(settings.issuesSelectedClass).next().fadeTo(settings.issuesTransparencySpeed,1).addClass(settings.issuesSelectedClass),$(settings.datesDiv).animate({marginTop:u},{queue:!1,duration:"settings.datesSpeed"}),$(settings.datesDiv+" a."+settings.datesSelectedClass).removeClass(settings.datesSelectedClass).parent().next().children().addClass(settings.datesSelectedClass))}1==s?$(settings.prevButton+","+settings.nextButton).fadeOut("fast"):2==s?$(settings.issuesDiv+" li:first-child").hasClass(settings.issuesSelectedClass)?($(settings.prevButton).fadeOut("fast"),$(settings.nextButton).fadeIn("fast")):$(settings.issuesDiv+" li:last-child").hasClass(settings.issuesSelectedClass)&&($(settings.nextButton).fadeOut("fast"),$(settings.prevButton).fadeIn("fast")):$(settings.issuesDiv+" li:first-child").hasClass(settings.issuesSelectedClass)?$(settings.prevButton).fadeOut("fast"):$(settings.issuesDiv+" li:last-child").hasClass(settings.issuesSelectedClass)?$(settings.nextButton).fadeOut("fast"):$(settings.nextButton+","+settings.prevButton).fadeIn("slow")}),$(settings.prevButton).click(function(t){if(t.preventDefault(),"horizontal"==settings.orientation){var e=parseInt($(settings.issuesDiv).css("marginLeft").substring(0,$(settings.issuesDiv).css("marginLeft").indexOf("px"))),i=parseInt($(settings.datesDiv).css("marginLeft").substring(0,$(settings.datesDiv).css("marginLeft").indexOf("px"))),l=i+g;e>=0?($(settings.issuesDiv).stop(),$(settings.datesDiv+" li:first-child a").click()):$(settings.issuesDiv).is(":animated")||($(settings.issuesDiv).animate({marginLeft:e+n},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li").animate({opacity:settings.issuesTransparency},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li."+settings.issuesSelectedClass).removeClass(settings.issuesSelectedClass).prev().fadeTo(settings.issuesTransparencySpeed,1).addClass(settings.issuesSelectedClass),$(settings.datesDiv).animate({marginLeft:l},{queue:!1,duration:"settings.datesSpeed"}),$(settings.datesDiv+" a."+settings.datesSelectedClass).removeClass(settings.datesSelectedClass).parent().prev().children().addClass(settings.datesSelectedClass))}else if("vertical"==settings.orientation){var e=parseInt($(settings.issuesDiv).css("marginTop").substring(0,$(settings.issuesDiv).css("marginTop").indexOf("px"))),i=parseInt($(settings.datesDiv).css("marginTop").substring(0,$(settings.datesDiv).css("marginTop").indexOf("px"))),l=i+d;e>=0?($(settings.issuesDiv).stop(),$(settings.datesDiv+" li:first-child a").click()):$(settings.issuesDiv).is(":animated")||($(settings.issuesDiv).animate({marginTop:e+a},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li").animate({opacity:settings.issuesTransparency},{queue:!1,duration:settings.issuesSpeed}),$(settings.issuesDiv+" li."+settings.issuesSelectedClass).removeClass(settings.issuesSelectedClass).prev().fadeTo(settings.issuesTransparencySpeed,1).addClass(settings.issuesSelectedClass),$(settings.datesDiv).animate({marginTop:l},{queue:!1,duration:"settings.datesSpeed"},{queue:!1,duration:settings.issuesSpeed}),$(settings.datesDiv+" a."+settings.datesSelectedClass).removeClass(settings.datesSelectedClass).parent().prev().children().addClass(settings.datesSelectedClass))}1==s?$(settings.prevButton+","+settings.nextButton).fadeOut("fast"):2==s?$(settings.issuesDiv+" li:first-child").hasClass(settings.issuesSelectedClass)?($(settings.prevButton).fadeOut("fast"),$(settings.nextButton).fadeIn("fast")):$(settings.issuesDiv+" li:last-child").hasClass(settings.issuesSelectedClass)&&($(settings.nextButton).fadeOut("fast"),$(settings.prevButton).fadeIn("fast")):$(settings.issuesDiv+" li:first-child").hasClass(settings.issuesSelectedClass)?$(settings.prevButton).fadeOut("fast"):$(settings.issuesDiv+" li:last-child").hasClass(settings.issuesSelectedClass)?$(settings.nextButton).fadeOut("fast"):$(settings.nextButton+","+settings.prevButton).fadeIn("slow")}),"true"==settings.arrowKeys&&("horizontal"==settings.orientation?$(document).keydown(function(s){39==s.keyCode&&$(settings.nextButton).click(),37==s.keyCode&&$(settings.prevButton).click()}):"vertical"==settings.orientation&&$(document).keydown(function(s){40==s.keyCode&&$(settings.nextButton).click(),38==s.keyCode&&$(settings.prevButton).click()})),$(settings.datesDiv+" li").eq(settings.startAt-1).find("a").trigger("click"),"true"==settings.autoPlay&&setInterval("autoPlay()",settings.autoPlayPause)})};