(function($){$.fn.xnSlider=function(settings){defaults={interval:5000,main:{speed:600,easing:"easeInExpo"},overlay:{easing:"linear",speed:200}};var o=$.extend(defaults,settings||{});var clicked=false;var paused=false;var mainTimer=null;var mainObj=null;var counter=0;var total=$(this).children("ul").children("li").length;var current=0;function selectDots(e,i){var gotoIndex=(i==null)?0:i;var UL=$(e).children("ul");var position=$(UL).children("li:eq("+gotoIndex+")").attr("class");$(e).children("#positions").children("div").children("a[rel]").addClass("off").removeClass("on").parent("div").children("a[rel='"+position+"']").removeClass("off").addClass("on");}
function doSlide(e,gotoIndex){if(paused)
return;if(gotoIndex!=null){current=gotoIndex;}
var UL=$(e).children("ul");if(current==0)
var NL=0;else{var item_width=parseInt($(UL).children("li").outerWidth());var L=$(UL).css("margin-left");var NL=parseInt(L)-item_width;if(NL%item_width!=0)
NL=NL-(NL%item_width);}
if(current==total){NL=0;current=0;}
var url=$(UL).children("li:eq("+current+")").children("a").attr("href");var caption=$(UL).children("li:eq("+current+")").children("a").children("img").attr("alt");$(e).children("h3").html('<a href="'+url+'">'+caption+'</a>')
$(UL).stop().animate({"margin-left":NL},o.main.speed,o.main.easing,function(){selectDots(mainObj,current);current++;mainTimer=setTimeout(function(){doSlide(mainObj,current);},o.interval);});};return $(this).each(function(e){$(this).children("ul").hover(function(){paused=true;},function(){paused=false;});$(this).children("#positions").hover(function(){paused=true;},function(){paused=false;});mainObj=this;$(this).children("#positions").children("div").children("a[rel]").click(function(){clearTimeout(mainTimer);current=$(this).parent().children().index(this);paused=false;doSlide(mainObj,current);});doSlide(mainObj,current);});}})(jQuery);
