/**
 * jQuery sexyCycle v0.3 (With alterations)
 *
 * Terms of Use - jQuery sexyCycle
 * under the MIT (http://www.opensource.org/licenses/mit-license.php) License.
 *
 * Copyright 2010 suprb.com All rights reserved.
 * (http://suprb.com/apps/sexyCycle/)
 */

(function(a){a.fn.sexyCycle=function(k){var n={easing:"easeOutExpo",speed:400,next:null,prev:null,start:0,interval:false,cycle:true,imgclick:true,counter:null};var k=a.extend(n,k);var m=this;var q=true;var h=a(".sexyCycle-wrap",this);var l=k.start;var A=a(m).width();var D=a(".sexyCycle-content img:eq(0)",h).attr("src");a("body").append('<span class="sexycycleimgtempload"></span>');a(".sexycycleimgtempload").hide();var f=0,v=0,B=0;var w=a(".sexyCycle-content img:eq(0)",h).height();a(h).height(w);a(".sexycycleimgtempload").remove();var y=a(".sexyCycle-content",h).children().size();var C=a(".sexyCycle-content img:eq("+k.start+")",h).width();var j=a(".sexyCycle-content img:eq(0)",h);var d=a(".sexyCycle-content img:eq("+(y-1)+")",h);var c=a(".sexyCycle-content img:eq("+(y-1)+")",h).attr("src");var f=a(".sexyCycle-content img:eq("+(y-1)+")",h).height();var t=a(".sexyCycle-content img:eq("+(y-1)+")",h).width();var i=a(".sexyCycle-content img:eq(0)",h).attr("src");var p=a(".sexyCycle-content img:eq(0)",h).height();var s=a(".sexyCycle-content img:eq(0)",h).width();for(_lc=0;_lc<k.start;_lc++){v+=a(".sexyCycle-content img:eq("+_lc+")",h).width()}if(a(k.counter).length>0){a(k.counter).html("<span style='counter-text'>"+(l+1)+" of "+y+"</span>")}a('<span class="sexyCycleTempf" style="background: url(\''+c+"'); float: left; width: "+t+"px; height: "+f+'px; display: block"></span>').insertBefore(a(".sexyCycle-content li:eq(0)",h));a(".sexyCycleTempf",h).css("display","none");a('<span class="sexyCycleTempe" style="background: url(\''+i+"'); float: left; width: "+s+"px; height: "+p+'px; display: block"></span>').insertAfter(a(".sexyCycle-content li:eq("+(y-1)+")",h));a(".sexyCycleTempe",h).css("display","none");var u=C;a("li",h).css("float","left");a(m).css("width",u+"px");a(".sexyCycle-content",h).animate({left:"-="+v+"px"},{duration:0});var z=0;if(a(".sexyCycle-content li:eq(0)",h).find("span").height()!=null){z=a(".sexyCycle-content li:eq(0)",h).find("span").height()}var g=a(h).height()+a(".controllers",m).height()+z;a(m).css("height",(g+"px"));if(z>0){a(m).css("height",g+"px");a(".sexyCycle-wrap",h).css("height",g);a(".sexyCycle-content li .gallery-caption",h).css("top",w+"px")}a(k.next).click(function(){b("+")});a(k.prev).click(function(){b("-")});if(k.imgclick){a(h).click(function(){b("+")})}if(k.interval!=false){var x=k.stop;o(x)}a(k.stop).click(function(){r(x)});function o(){b("+");x=setTimeout(o,k.interval)}function r(e){clearInterval(x)}function b(e){if(q==true){q=false;if(e=="-"){slideto="+=";B=l-1;C=a(".sexyCycle-content img:eq("+(B)+")",h).width()}else{slideto="-=";B=l+1;C=a(".sexyCycle-content img:eq("+(B-1)+")",h).width()}if(B-1<y-1&&B-1>=-1){u=a(".sexyCycle-content img:eq("+B+")",h).width();g=a(".sexyCycle-content img:eq("+B+")",h).height();_img_h=g;z=a(".sexyCycle-content li:eq("+B+")",h).find("span").height();if(z!=null){g+=z;a(".sexyCycle-wrap",h).css("height",g);a(".sexyCycle-content li .gallery-caption",h).css("top",_img_h+"px")}a(".sexyCycle-content",h).animate({left:slideto+C+"px"},{duration:k.speed,easing:k.easing});a(m).animate({width:u+"px",height:g+"px"},{duration:k.speed,easing:k.easing,complete:function(){q=true}});l=B}else{if(k.cycle==true){if(e=="+"){l=0;B=0;a(".sexyCycleTempf",h).css("display","block");a(".sexyCycle-content",h).css("left","0px");a(".sexyCycle-content",h).animate({left:slideto+C+"px"},{duration:k.speed,easing:k.easing})}else{l=y-1;B=y-1;a(".sexyCycleTempe",h).css("display","block");a(".sexyCycle-content",h).css("left","-"+a(".sexyCycleTempe",h).position().left+"px");a(".sexyCycle-content",h).animate({left:slideto+t+"px"},{duration:k.speed,easing:k.easing})}u=a(".sexyCycle-content img:eq("+l+")",h).width();g=a(".sexyCycle-content img:eq("+l+")",h).height();_img_h=g;z=a(".sexyCycle-content li:eq("+B+")",h).find("span").height();if(z!=null){g+=z;a(".sexyCycle-wrap",h).css("height",g);a(".sexyCycle-content li .gallery-caption",h).css("top",_img_h+"px")}a(m).animate({width:u+"px",height:g+"px"},{duration:k.speed,easing:k.easing,complete:function(){q=true}})}else{q=true}}}if(a(k.counter).length>0){a(k.counter).html("<span style='counter-text'>"+(l+1)+" of "+y+"</span>")}}}})(jQuery);