(function(b){b.fn.awShowcase=function(a){function J(g){g=b(document.createElement("div")).attr("id","showcase-content-"+g).css("overflow","hidden").css("position","absolute").addClass("showcase-content").html(N[g]);a.viewline||g.css("width",a.content_width);a.fit_to_parent&&!a.viewline&&g.css("left",u/2-a.content_width/2);return g}function P(){var b=parseInt(e)+1;b===m&&a.continuous?b=0:b===m&&!a.continuous&&(K=!0,clearInterval(k));K||y(b,"next")}function y(g,f){if(e!==g&&!A){var d,c,q=0,h,l=a.fit_to_parent?u/2-a.content_width/2:0;if(g>e&&"previous"!==f||"next"===f)if(a.viewline){if(e<m-1){a.speed_change||(A=!0);Q();a.pauseonover&&window.clearInterval(k);E=0;for(h=e+1,len=m;h<len;++h)d=L[h],E+=d.find(".showcase-content").children().width();E>u?(F=C,C-=L[e].find(".showcase-content").children().width()):$(".showcase-arrow-next").is(":visible")&&(F=C,C=-(H-(E+(u-E))),$(".showcase-arrow-next").fadeOut(300));p.animate({left:C+"px"},a.transition_speed,function(){A=!1});$(".showcase-arrow-next").is(":visible")&&e++;$(".showcase-arrow-previous").fadeIn(300)}}else a.speed_change||(A=!0),d=b(j).find("#showcase-content-"+parseInt(e)),c=J(g),p.append(c),a.dynamic_height?c.css("height",c.find(".showcase-content").children().height()):c.css("height",a.content_height),d.find(".showcase-content").children().height()>c.find(".showcase-content").children().height()&&a.dynamic_height&&(p.stop(!0,!0).animate({height:c.find(".showcase-content").children().height()},200),q=100),"hslide"===a.transition?b(d).delay(q).animate({left:-a.content_width},a.transition_speed+a.transition_delay,function(){d.remove()}):"vslide"===a.transition?b(d).delay(q).animate({top:-a.content_height},a.transition_speed+a.transition_delay,function(){d.remove()}):b(d).delay(q).fadeOut(a.transition_speed,function(){d.remove()}),r(d,!0),s(d,!0),"hslide"===a.transition?(c.css("left",u),b(c).delay(q).animate({left:l},a.transition_speed,function(){r(c);s(c);G(c)})):"vslide"===a.transition?(c.css("top",j.height()),b(c).delay(q).animate({top:"0px"},a.transition_speed,function(){r(c);s(c);G(c)})):(c.css("left",l),c.css("display","none"),b(c).delay(q).fadeIn(a.transition_speed,function(){r(c);s(c);G(c)}));else if(g<e||"previous"===f)a.viewline?(0!==e&&(a.speed_change||(A=!0),Q(),a.pauseonover&&window.clearInterval(k),p.animate({left:F+"px"},a.transition_speed,function(){A=!1}),C=F,e--,0===e&&$(".showcase-arrow-previous").fadeOut(300),old_id=e-1,sub_width=b(L[old_id]).width(),F+=sub_width),$(".showcase-arrow-next").fadeIn(300)):(a.speed_change||(A=!0),d=b(j).find("#showcase-content-"+parseInt(e)),c=J(g),p.append(c),a.dynamic_height?c.css("height",c.find(".showcase-content").children().height()):c.css("height",a.content_height),d.find(".showcase-content").children().height()>c.find(".showcase-content").children().height()&&a.dynamic_height&&(p.stop(!0,!0).animate({height:c.find(".showcase-content").children().height()},200),q=100),"hslide"===a.transition?b(d).delay(q).animate({left:u+"px"},a.transition_speed+a.transition_delay,function(){r(d,!0);s(d,!0);d.remove()}):"vslide"===a.transition?b(d).delay(q).animate({top:a.content_height+"px"},a.transition_speed+a.transition_delay,function(){r(d,!0);s(d,!0);d.remove()}):b(d).delay(q).fadeOut(a.transition_speed,function(){r(d,!0);s(d,!0);d.remove()}),"hslide"===a.transition?(c.css("left","-"+a.content_width+"px"),b(c).delay(q).animate({left:l},a.transition_speed,function(){r(c);s(c);G(c)})):"vslide"===a.transition?(c.css("top","-"+j.height()+"px"),b(c).delay(q).animate({top:"0px"},a.transition_speed,function(){r(c);s(c);G(c)})):(c.css("left",l),c.css("display","none"),b(c).delay(q).fadeIn(a.transition_speed,function(){r(c);s(c);G(c)})),p.append(c));a.viewline||(O=e,e=g,a.thumbnails&&(e>O&&"previous"!==f||"next"===f?M("forward",!0):(e<O||"previous"===f)&&M("backward",!0)),a.arrows&&(b(j).find(".showcase-arrow-previous").unbind("click").click(function(){k&&(a.stoponclick&&(z=!0),clearInterval(k));y(0===e?m-1:parseInt(e)-1,"previous")}),b(j).find(".showcase-arrow-next").unbind("click").click(function(){k&&(a.stoponclick&&(z=!0),clearInterval(k));y(e===m-1?0:parseInt(e)+1,"next")})),a.thumbnails&&(h=0,j.find(".showcase-thumbnail").each(function(){var a=b(this);a.removeClass("active");h===e&&a.addClass("active");h++})),"show"===a.show_caption&&b(c).find(".showcase-caption").show());a.buttons&&(h=0,j.find(".showcase-button-wrapper span").each(function(){var a=b(this);a.removeClass("active");h===e&&a.addClass("active");h++}));"function"==typeof a.custom_function&&a.custom_function()}}function G(b){a.dynamic_height&&p.stop(!0,!0).animate({height:b.find(".showcase-content").children().height()},200);A=!1}function M(g,f,d){var c=!0,h=w(b(l).find(".showcase-thumbnail"));"horizontal"===a.thumbnails_direction&&(h=v(b(l).find(".showcase-thumbnail")));var j=1;if(0===a.thumbnails_slidex)a.thumbnails_slidex=I;if(f){for(var k=o,f=0;0>k;)k="horizontal"===a.thumbnails_direction?k+v(b(B[0])):k+w(b(B[0])),f++;k=f;f=I+f-1;e>=k&&e<=f&&(c=!1);if(e-f>a.thumbnails_slidex)for(f=e-f;f>a.thumbnails_slidex;)f-=a.thumbnails_slidex,j++;else if(k-e>a.thumbnails_slidex)for(f=k-e;f>a.thumbnails_slidex;)f-=a.thumbnails_slidex,j++;else j=1}"forward"===g&&c?("vertical"===a.thumbnails_direction&&a.content_height<D+o?o-=h*a.thumbnails_slidex*j:"horizontal"===a.thumbnails_direction&&a.content_width<D+o?o-=h*a.thumbnails_slidex*j:0===e&&(d||(o=0)),"horizontal"===a.thumbnails_direction?l.animate({left:o},300):l.animate({top:o},300)):c&&(0>o?o+=h*a.thumbnails_slidex*j:e===m-1?d||(o-=h*a.thumbnails_slidex*j):o=0,"horizontal"===a.thumbnails_direction?l.animate({left:o},300):l.animate({top:o},300))}function s(g,f){var d=g.find(".showcase-caption");f?d.stop(!0,!0).fadeOut(300):"onload"===a.show_caption?d.fadeIn(300):"onhover"===a.show_caption&&(b(g).mouseenter(function(){d.fadeIn(300)}),b(g).mouseleave(function(){d.stop(!0,!0).fadeOut(100)}))}function r(g,f){g.find(".showcase-tooltips a").each(function(){if(f)b(this).stop(!0,!0).fadeOut(300);else{var d=b(this).attr("coords"),d=d.split(",");b(this).addClass("showcase-plus-anchor");b(this).css("position","absolute");b(this).css("display","none");b(this).css("width",a.tooltip_icon_width);b(this).css("height",a.tooltip_icon_height);b(this).css("left",parseInt(d[0])-parseInt(a.tooltip_icon_width)/2);b(this).css("top",parseInt(d[1])-parseInt(a.tooltip_icon_height)/2);var c=b(this).html();b(this).mouseenter(function(){R(g,d[0],d[1],c)});b(this).mouseleave(function(){R(g,d[0],d[1],c)});b(this).html("");b(this).fadeIn(300)}})}function R(g,f,d,c){null===n?(n=b(document.createElement("div")).addClass("showcase-tooltip").css("display","none").css("position","absolute").css("max-width",a.tooltip_width).html(c),g.append(n),g=2*parseInt(n.css("padding-right"))+2*parseInt(n.css("border-right-width")),c=2*parseInt(n.css("padding-bottom"))+2*parseInt(n.css("border-bottom-width")),lastx=parseInt(f)+n.width()+g,lasty=parseInt(d)+n.height()+c,lastx<a.content_width?n.css("left",parseInt(f)+parseInt(a.tooltip_offsetx)):n.css("left",parseInt(f)-parseInt(a.tooltip_offsetx)-(parseInt(n.width())+parseInt(a.tooltip_offsetx))),lasty<a.content_height?n.css("top",parseInt(d)+parseInt(a.tooltip_offsety)):n.css("top",parseInt(d)-parseInt(a.tooltip_offsety)-(parseInt(n.height())+parseInt(c))),n.fadeIn(400)):(n.fadeOut(400),n.remove(),n=null)}function w(a,f,d,c,e){d="undefined"!==typeof d?d:!0;c="undefined"!==typeof c?c:!0;e="undefined"!==typeof e?e:!0;f=("undefined"!==typeof f?f:1)?b(a).height():0;d=d?parseFloat(b(a).css("margin-top"))+parseFloat(b(a).css("margin-bottom")):0;c=c?parseFloat(b(a).css("padding-top"))+parseFloat(b(a).css("padding-bottom")):0;a=e?parseFloat(b(a).css("border-top-width"))+parseFloat(b(a).css("border-bottom-width")):0;return f+(d+c+a)}function v(a,f,d,c,e){d="undefined"!==typeof d?d:!0;c="undefined"!==typeof c?c:!0;e="undefined"!==typeof e?e:!0;f=("undefined"!==typeof f?f:1)?b(a).width():0;d=d?parseFloat(b(a).css("margin-left"))+parseFloat(b(a).css("margin-right")):0;c=c?parseFloat(b(a).css("padding-left"))+parseFloat(b(a).css("padding-right")):0;a=e?parseFloat(b(a).css("border-left-width"))+parseFloat(b(a).css("border-right-width")):0;return f+(d+c+a)}function Q(){H=0;p.children("div").each(function(){H+=$(this).find(".showcase-content").children().width();L.push($(this))})}var a=b.extend({content_width:700,content_height:470,fit_to_parent:!1,auto:!1,interval:3E3,continuous:!1,loading:!0,tooltip_width:200,tooltip_icon_width:32,tooltip_icon_height:32,tooltip_offsetx:18,tooltip_offsety:0,arrows:!0,buttons:!0,btn_numbers:!1,keybord_keys:!1,mousetrace:!1,pauseonover:!0,stoponclick:!0,transition:"hslide",transition_delay:300,transition_speed:500,show_caption:"onload",thumbnails:!1,thumbnails_position:"outside-last",thumbnails_direction:"vertical",thumbnails_slidex:0,dynamic_height:!1,speed_change:!1,viewline:!1,fullscreen_width_x:15,custom_function:null},a),e=0,O=0,K=!1,z=!1,k=null,j=b(this),u=a.content_width,A=!1,H=1E4,C=0,F=0,E=0,p=b(document.createElement("div")).css("overflow","hidden").css("position","relative").addClass("showcase-content-container").prependTo(j);a.fit_to_parent&&(u=b(j).width()+a.fullscreen_width_x);if(a.viewline)a.thumbnails=!1,a.dynamic_height=!1,p.css("width",H),j.css("overflow","hidden"),$(".showcase-arrow-previous").hide();var N=[],B=[],m=0;j.children(".showcase-slide").each(function(){var g=b(this);m++;if(a.thumbnails){var f=g.find(".showcase-thumbnail");B.push(f);f.remove()}var f=g.find(".showcase-content").children().width(),d=g.find(".showcase-content").children().height();N.push(g.html());g.remove();g=J(m-1);(a.viewline||1===m)&&p.append(g);a.viewline&&(g.css("position","relative"),g.css("float","left"),g.css("width",f));a.dynamic_height?(g.css("height",d),1===m&&p.css("height",d)):(g.css("height",a.content_height),1===m&&p.css("height",a.content_height));if(a.viewline||1===m)r(g),s(g),"show"===a.show_caption&&b(g).find(".showcase-caption").show()});var l,D=0,I=0;if(a.thumbnails){thumb_container=b("<div />");thumb_restriction=b("<div />");l=b("<div />");for(i=B.length-1;0<=i;--i){var h=b(B[i]).css({overflow:"hidden"});h.attr("id","showcase-thumbnail-"+i);h.addClass(0===i?"active":"");h.click(function(a,b){return function(){k&&(z=!0,clearInterval(k));y(a,b)}}(i,""));l.prepend(h)}"outside-first"===a.thumbnails_position||"outside-last"===a.thumbnails_position?("horizontal"!==a.thumbnails_direction?(p.css("float","left"),p.css("width",a.content_width),thumb_container.css("float","left"),thumb_container.css("height",a.content_height)):b(l).find(".showcase-thumbnail").css("float","left"),"outside-last"===a.thumbnails_position?j.append(thumb_container):j.prepend(thumb_container),"horizontal"!==a.thumbnails_direction&&j.append(b("<div />").addClass("clear"))):(thumb_container.css({position:"absolute","z-index":20}),"horizontal"===a.thumbnails_direction?(thumb_container.css({left:0,right:0}),b(l).find(".showcase-thumbnail").css("float","left"),b(l).append(b("<div />").addClass("clear")),"inside-first"===a.thumbnails_position?thumb_container.css("top",0):thumb_container.css("bottom",0)):(thumb_container.css({top:0,bottom:0}),"inside-first"===a.thumbnails_position?thumb_container.css("left",0):thumb_container.css("right",0)),p.prepend(thumb_container));thumb_container.addClass("showcase-thumbnail-container");thumb_container.css("overflow","hidden");thumb_restriction.addClass("showcase-thumbnail-restriction");thumb_restriction.css({overflow:"hidden",position:"relative"});"horizontal"===a.thumbnails_direction&&thumb_restriction.css({"float":"left"});l.addClass("showcase-thumbnail-wrapper");"horizontal"===a.thumbnails_direction?l.addClass("showcase-thumbnail-wrapper-horizontal"):l.addClass("showcase-thumbnail-wrapper-vertical");l.css("position","relative");thumb_restriction.append(l);thumb_container.append(thumb_restriction);h=b('<div class="showcase-thumbnail-button-backward" />');"horizontal"!==a.thumbnails_direction?h.html('<span class="showcase-thumbnail-vertical"><span>Up</span></span>'):(h.css({"float":"left"}),h.html('<span class="showcase-thumbnail-horizontal"><span>Left</span></span>'));h.click(function(){M("backward",!1,!0)});thumb_container.prepend(h);var x=b('<div class="showcase-thumbnail-button-forward" />');"horizontal"!==a.thumbnails_direction?x.html('<span class="showcase-thumbnail-vertical"><span>Down</span></span>'):(x.css({"float":"left"}),x.html('<span class="showcase-thumbnail-horizontal"><span>Right</span></span>'));x.click(function(){M("forward",!1,!0)});thumb_container.append(x);var t=0;if("horizontal"!==a.thumbnails_direction){t=w(l,!1);for(t+=w(h)+w(x);t<a.content_height;)t+=w(b(B[0])),I++}else{t=v(l,!1);for(t+=v(h)+v(x);t<u;)t+=v(b(B[0])),I++}I+1>B.length&&("horizontal"!==a.thumbnails_direction?thumb_restriction.css("margin-top",w(h)):thumb_restriction.css("margin-left",v(h)),h.hide(),x.hide());"horizontal"!==a.thumbnails_direction?(h=w(h)+w(x),thumb_restriction.css("height",a.content_height-h)):(h=v(h)+v(x),thumb_restriction.css("width",u-h));"horizontal"===a.thumbnails_direction?(b(".showcase-thumbnail").each(function(){D+=v(b(this))}),l.css("width",D)):b(".showcase-thumbnail").each(function(){D+=w(b(this))})}a.thumbnails&&-1!==a.thumbnails_position.indexOf("outside")&&"horizontal"!==a.thumbnails_direction&&!a.viewline?j.css("width",u+v(l,!0,!1)):a.fit_to_parent||j.css("width",u);1<m&&a.auto&&(k=window.setInterval(P,a.interval));a.auto&&a.pauseonover&&(j.mouseenter(function(){K=!0;clearInterval(k)}),j.mouseleave(function(){z||(K=!1,k=window.setInterval(P,a.interval))}));a.arrows&&1<m&&(b(document.createElement("div")).addClass("showcase-arrow-previous").prependTo(j).click(function(){k&&(a.stoponclick&&(z=!0),clearInterval(k));y(0===e?m-1:parseInt(e)-1,"previous")}),b(document.createElement("div")).addClass("showcase-arrow-next").prependTo(j).click(function(){k&&(a.stoponclick&&(z=!0),clearInterval(k));y(e+1,"next")}),a.viewline&&$(".showcase-arrow-previous").hide());if(a.buttons&&1<m){b(document.createElement("div")).css("clear","both").addClass("showcase-button-wrapper").css("word-wrap","break-word").appendTo(j);for(i=0;i<m;)b(document.createElement("span")).attr("id","showcase-navigation-button-"+i).addClass(0===i?"active":"").html(a.btn_numbers?parseInt(i)+1:"&#9679;").click(function(b,f){return function(){k&&(a.stoponclick&&(z=!0),clearInterval(k));y(b,f)}}(i,"")).appendTo(b(j).find(".showcase-button-wrapper")),i++}a.keybord_keys&&b(document).keydown(function(b){a.stoponclick&&(z=!0);k&&clearInterval(k);37===b.keyCode&&y(0===e?m-1:parseInt(e)-1,"previous");39===b.keyCode&&y(e===m-1?0:parseInt(e)+1,"next")});var o=0,n=null;if(a.mousetrace){var S=b(document.createElement("div")).css("position","absolute").css("top","0").css("background-color","#fff").css("color","#000").css("padding","3px 5px").css("x-index","30").html("X: 0 Y: 0");j.append(S);var T=j.offset();p.mousemove(function(a){S.html("X: "+(a.pageX-T.left)+" Y: "+(a.pageY-T.top))})}$("#awOnePageButton").click(function(){if($(".view-page").is(":visible")){var e=b(document.createElement("div"));e.addClass("showcase-onepage");j.before(e);k&&(z=!0,clearInterval(k));$(this).find(".view-page").hide();$(this).find(".view-slide").show();j.hide();$.each(N,function(b){obj=J(b);obj.css("position","relative");e.append(obj);r(obj);s(obj);a.dynamic_height?obj.css("height",obj.find(".showcase-content").children().height()):obj.css("height",a.content_height)});var f=b(document.createElement("div"));f.addClass("clear");e.append(f)}else $(".showcase-onepage").remove(),$(this).find(".view-page").show(),$(this).find(".view-slide").hide(),j.show();return!1});var L=[];j.removeClass("showcase-load")}})(jQuery);
