/* Copyright (c) 2010 WordImpressed.com jFlow Plus derived from Kean Loong Tan's orgininal jFlow http://www.wordimpressed.com
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* jFlow 1.2 (Plus)
* Version: jFlow Plus
* Requires: jQuery 1.2+
*/
(function(a){a.fn.jFlow=function(i){var b=a.extend({},a.fn.jFlow.defaults,i),e=b.controller,f=b.slideWrapper,g=b.selectedWrapper,c=0,j,k=a(e).length;i=a(b.next);var m=a(b.prev),l=function(d,o){a(b.slides).children().css({overflow:"hidden"});a(b.slides+" iframe").hide().addClass("temp_hide");a(b.slides).animate({marginLeft:"-"+(o*a(b.slides).find(":first-child").width()+"px")},b.duration*d,b.easing,function(){a(b.slides).children().css({overflow:"hidden"});a(".temp_hide").show()})};if(b.hideControls){i.hide(); m.hide()}a(this).find(e).each(function(d){a(this).click(function(){h();if(a(b.slides).is(":not(:animated)")){a(e).removeClass(g);a(this).addClass(g);l(Math.abs(c-d),d);c=d}})});a(b.slides).before('<div id="'+f.substring(1,f.length)+'"></div>').appendTo(f);a(b.slides).find("div").each(function(){a(this).before('<div class="jFlowSlideContainer"></div>').appendTo(a(this).prev())});a(e).eq(c).addClass(g);var n=function(){a(f).css({position:"relative",width:b.width,height:b.height,overflow:"hidden"}); a(b.slides).css({position:"relative",width:a(f).width()*a(e).length+"px",height:a(f).height()+"px",overflow:"hidden"});a(b.slides).children().css({position:"relative",width:a(f).width()+"px",height:a(f).height()+"px","float":"left",overflow:"hidden"});a(b.slides).css({marginLeft:"-"+(c*a(b.slides).find(":eq(0)").width()+"px")})};n();a(window).resize(function(){n()});m.click(function(){h();if(a(b.slides).is(":not(:animated)")){var d=1;if(c>0)c--;else d=c=k-1;a(e).removeClass(g);l(d,c);a(e).eq(c).addClass(g)}}); i.click(function(){h();if(a(b.slides).is(":not(:animated)")){var d=1;if(c<k-1)c++;else{c=0;d=k-1}a(e).removeClass(g);l(d,c);a(e).eq(c).addClass(g)}});var h=function(){if(b.auto==true){j!=null&&clearInterval(j);j=setInterval(function(){a(b.next).click()},b.delay)}};h();a(b.slides).hover(function(){clearInterval(j)},function(){h()})};a.fn.jFlow.defaults={controller:"#myController",slideWrapper:"#mySlides",selectedWrapper:".jFlowSelected",auto:true,easing:"swing",duration:400,delay:3E3,width:"100%", prev:".jFlowPrev",next:".jFlowNext",hideControls:false}})(jQuery);
