/*!
 *
 * jQuery Duotive Complex Slider v2.1.5
 * http://duotive.org
 *
 * Copyright 2011, Duotive
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Date: Tue October 18th 20:10 GMT+2 2011 
 *
 */

(function(a){a.fn.dtComplexSlider=function(c){var e={height:310,autoAdvance:true,autoAdvDuration:800,autoAdvInterval:4000,autoAdvPauseOnHover:true,showArrows:true,showTimer:true,timerWidth:950,showDescription:true,showGallery:true,showIcon:false};c=a.extend(e,c);function b(g){var f;f=parseInt(g.css("padding-left"),10)+parseInt(g.css("padding-right"),10);f+=parseInt(g.css("margin-left"),10)+parseInt(g.css("margin-right"),10);f+=parseInt(g.css("border-left-width"),10)+parseInt(g.css("border-right-width"),10);return f}function d(g){var f;f=parseInt(g.css("padding-top"),10)+parseInt(g.css("padding-bottom"),10);f+=parseInt(g.css("margin-top"),10)+parseInt(g.css("margin-bottom"),10);f+=parseInt(g.css("border-top-width"),10)+parseInt(g.css("border-bottom-width"),10);return f}return this.each(function(){var v=a(this),w,y,s=0,m=s,n,u=v.find(".slider-images"),G=u.find("li"),p='<div class="slider-controls"><a class="slider-control-left" href="javascript: void(0)">left</a><a class="slider-control-right" href="javascript: void(0)">right</a>',C='<div class="slider-timer"><div class="timer"></div></div>',l=c.autoAdvInterval,q=v.find(".slider-descriptions"),B=q.find("ul"),g=q.find("li"),r=parseInt(g.css("height"),10)+d(g),h=v.find(".slider-gallery"),t=h.find("ul"),o=h.find("li"),x=parseInt(o.css("width"),10)+b(o),A='<div class="slider-content"></div>';v.addClass("dt_complexslider");if(h.size()===0){c.showGallery=false}if(q.size()===0){c.showDescription=false}if(c.showTimer===true&&c.autoAdvance===true){u.after(C);C=v.find(".slider-timer");if(c.showDescription===false&&c.showGallery===false){C.addClass("rounded")}}function D(H,k){if(k===undefined){k="reset"}switch(k){case"reset":C.find(".timer").css({width:"0%"});C.find(".timer").stop().animate({width:"100%"},H,"linear");break;case"pause":C.find(".timer").stop();H=((c.timerWidth-parseInt(C.find(".timer").css("width"),10))*H)/c.timerWidth;l=H;break;case"resume":H=((c.timerWidth-parseInt(C.find(".timer").css("width"),10))*H)/c.timerWidth;l=H;C.find(".timer").stop().animate({width:"100%"},H,"linear");break}}if(c.showTimer!==true&&c.showDescription!==true&&c.showGallery!==true){u.find("img").addClass("rounded")}if(c.showDescription===true||c.showGallery===true){A=v.find(".slider-content")}if(c.showDescription===true){A.append(q)}else{h.addClass("fullwidth")}function F(H){var k=H*r;B.stop().animate({top:-k},c.autoAdvDuration,"")}if(c.showGallery===true){A.append(h);t.css({width:o.size()*x});o.last().css({"margin-right":0});for(w=0,y=o.length;w<y;w++){o.eq(w).find("a").attr("rel",w).click(function(){s=parseInt(a(this).attr("rel"),10);E(s,m,c.autoAdvDuration);if(c.autoAdvance===true){z()}})}}else{q.addClass("fullwidth")}function j(H){var k=0,J=4,I;if(c.showDescription===false){J=8}I=Math.ceil(parseInt(h.css("width"),10)/x);if(H===0){k=H*x}else{k=(H-1)*x}if(k>=(G.size()*x)-(J*x)){k=(G.size()*x)-(J*x)}if(G.size()<=J){k=0}t.stop().animate({left:-k},c.autoAdvDuration,"")}function i(H,k){o.eq(k).find("a").removeClass("active");o.eq(H).find("a").addClass("active")}u.find("ul").css({height:c.height,overflow:"hidden"});G.css({opacity:0});if(v.find(".icon").size()>0){c.showIcon=true;v.find(".icon").css({opacity:0})}if(c.showIcon===true){u.hover(function(){G.eq(s-1).find(".icon").stop().animate({opacity:1},c.autoAdvDuration,"linear")},function(){G.eq(s-1).find(".icon").stop().animate({opacity:0},c.autoAdvDuration,"linear")})}function E(H,k,I){if(H===undefined||H>G.length-1){H=0}if(H<0){H=G.length-1}G.eq(k).stop().animate({opacity:0,"z-index":10},I,"");G.eq(H).stop().animate({opacity:1,"z-index":20},I,"");if(c.showTimer===true&&c.autoAdvance===true){D(c.autoAdvInterval)}if(c.showDescription===true){F(H)}if(c.showGallery===true){j(H);i(H,k)}k=H;H++;m=k;s=H}E(s,m,c.autoAdvDuration);function f(k){n=setInterval(function(){E(s,m,c.autoAdvDuration)},k)}function z(){clearInterval(n);f(c.autoAdvInterval)}if(c.autoAdvance===true){f(c.autoAdvInterval)}if(c.showArrows===true){v.append(p);p=v.find(".slider-controls");p.find(".slider-control-right").click(function(){E(s,m,c.autoAdvDuration);if(c.autoAdvance===true){z()}});p.find(".slider-control-left").click(function(){s=s-2;E(s,m,c.autoAdvDuration);if(c.autoAdvance===true){z()}})}if(c.autoAdvPauseOnHover===true){u.hover(function(){if(c.showTimer===true&&c.autoAdvance===true){D(c.autoAdvInterval,"pause")}if(c.autoAdvance===true){clearInterval(n)}},function(){if(c.showTimer===true&&c.autoAdvance===true){D(c.autoAdvInterval,"reset");f(c.autoAdvInterval)}})}})}}(jQuery));
