(function($j){$j.fn.jFlow=function(options){var opts=$j.extend({},$j.fn.jFlow.defaults,options);var randNum=Math.floor(Math.random()*11);var jFC=opts.controller;var jFS=opts.slideWrapper;var jSel=opts.selectedWrapper;var cur=0;var timer;var maxi=$j(jFC).length;var slide=function(dur,i){$j(opts.slides).children().css({overflow:"hidden"});$j(opts.slides+" iframe").hide().addClass("temp_hide");$j(opts.slides).animate({marginLeft:"-"+(i*$j(opts.slides).find(":first-child").width()+"px")},opts.duration*(dur),opts.easing,function(){$j(opts.slides).children().css({overflow:"hidden"});$j(".temp_hide").show();});}
$j(this).find(jFC).each(function(i){$j(this).click(function(){dotimer();if($j(opts.slides).is(":not(:animated)")){$j(jFC).removeClass(jSel);$j(this).addClass(jSel);var dur=Math.abs(cur-i);slide(dur,i);cur=i;}});});$j(opts.slides).before('<div id="'+jFS.substring(1,jFS.length)+'"></div>').appendTo(jFS);$j(opts.slides).find("div").each(function(){$j(this).before('<div class="jFlowSlideContainer"></div>').appendTo($j(this).prev());});$j(jFC).eq(cur).addClass(jSel);var resize=function(x){$j(jFS).css({position:"relative",width:opts.width,height:opts.height,overflow:"hidden"});$j(opts.slides).css({position:"relative",width:$j(jFS).width()*$j(jFC).length+"px",height:$j(jFS).height()+"px",overflow:"hidden"});$j(opts.slides).children().css({position:"relative",width:$j(jFS).width()+"px",height:$j(jFS).height()+"px","float":"left",overflow:"hidden"});$j(opts.slides).css({marginLeft:"-"+(cur*$j(opts.slides).find(":eq(0)").width()+"px")});}
resize();$j(window).resize(function(){resize();});$j(opts.prev).click(function(){dotimer();doprev();});$j(opts.next).click(function(){dotimer();donext();});var doprev=function(x){if($j(opts.slides).is(":not(:animated)")){var dur=1;if(cur>0)
cur--;else{cur=maxi-1;dur=cur;}
$j(jFC).removeClass(jSel);slide(dur,cur);$j(jFC).eq(cur).addClass(jSel);}}
var donext=function(x){if($j(opts.slides).is(":not(:animated)")){var dur=1;if(cur<maxi-1)
cur++;else{cur=0;dur=maxi-1;}
$j(jFC).removeClass(jSel);slide(dur,cur);$j(jFC).eq(cur).addClass(jSel);}}
var dotimer=function(x){if((opts.auto)==true){if(timer!=null)
clearInterval(timer);timer=setInterval(function(){$j(opts.next).click();},10000);}}
dotimer();$j(opts.slides).hover(function(){clearInterval(timer);},function(){dotimer();});};$j.fn.jFlow.defaults={controller:"#myController",slideWrapper:"#mySlides",selectedWrapper:".jFlowSelected",auto:true,easing:"swing",duration:400,width:"100%",prev:".jFlowPrev",next:".jFlowNext"};})(jQuery);
