/*

Title:		jShowOff: a jQuery Content Rotator Plugin
Author:		Erik Kallevig
Version:	0.1.2
Website:	http://ekallevig.com/jshowoff
License: 	Dual licensed under the MIT and GPL licenses.

*/
(function(a){a.fn.jshowoff=function(b){var c={animatePause:true,autoPlay:true,changeSpeed:600,controls:true,controlText:{play:"Play",pause:"Pause",next:"Next",previous:"Previous"},effect:"fade",hoverPause:true,links:true,speed:3e3};if(b)a.extend(true,c,b);if(c.speed<c.changeSpeed+20){alert("jShowOff: Make speed at least 20ms longer than changeSpeed; the fades aren't always right on time.");return this}this.each(function(b){function w(){l.append('<p class="jshowoff-slidelinks '+j+'-slidelinks"></p>');a.each(e,function(b,c){var d=a(this).attr("title")!=""?a(this).attr("title"):b+1;a('<a class="jshowoff-slidelink-'+b+" "+j+"-slidelink-"+b+'" href="#null">'+d+"</a>").bind("click",{index:b},function(a){t(a.data.index);return false}).appendTo("."+j+"-slidelinks")})}function v(){l.append('<p class="jshowoff-controls '+j+'-controls"><a class="jshowoff-play '+j+'-play" href="#null">'+c.controlText.pause+'</a> <a class="jshowoff-prev '+j+'-prev" href="#null">'+c.controlText.previous+'</a> <a class="jshowoff-next '+j+'-next" href="#null">'+c.controlText.next+"</a></p>");a("."+j+"-controls a").each(function(){if(a(this).hasClass("jshowoff-play"))a(this).click(function(){n()?p("playBtn"):o();return false});if(a(this).hasClass("jshowoff-prev"))a(this).click(function(){r();return false});if(a(this).hasClass("jshowoff-next"))a(this).click(function(){q();return false})})}function u(){a(e).each(function(b){a(this).find("img").each(function(b){h[b]=a("<img>").attr("src",a(this).attr("src"))})})}function t(a){d.children().stop(true,true);if(g!=a||g==a&&s()){if(s())d.children().eq(0).remove();m(e,a);p()}}function s(){return d.children().length>1?true:false}function r(){t(g-1)}function q(){t(g+1)}function p(b){clearInterval(f);if(!b||b=="playBtn")a("."+j+"-play").text(c.controlText.play).addClass("jshowoff-paused "+j+"-paused");if(c.animatePause&&b=="playBtn"){a('<p class="'+j+'-pausetext jshowoff-pausetext">'+c.controlText.pause+"</p>").css({fontSize:"62%",textAlign:"center",position:"absolute",top:"40%",lineHeight:"100%",width:"100%"}).appendTo(l).addClass(j+"pauseText").animate({fontSize:"600%",top:"30%",opacity:0},{duration:500,complete:function(){a(this).remove()}})}}function o(b){if(!s()){g++;m(e,g);if(b=="hover"||!n()){f=setInterval(function(){o()},c.speed)}if(!n()){a("."+j+"-play").text(c.controlText.pause).removeClass("jshowoff-paused "+j+"-paused")}}}function n(){return a("."+j+"-play").hasClass("jshowoff-paused")?false:true}function m(b,e){var f=g;if(g>=b.length||e>=b.length){g=0;var h=true}else if(g<0||e<0){g=b.length-1;var i=true}else{g=e}if(c.effect=="slideLeft"){var k,l;function m(a){k=a=="right"?"left":"right";l=a=="left"?"left":"right"}g>=f?m("left"):m("right");a(b[g]).clone().appendTo(d).slideIt({direction:k,changeSpeed:c.changeSpeed});if(d.children().length>1){d.children().eq(0).css("position","absolute").slideIt({direction:l,showHide:"hide",changeSpeed:c.changeSpeed},function(){a(this).remove()})}}else if(c.effect=="fade"){a(b[g]).clone().appendTo(d).hide().fadeIn(c.changeSpeed,function(){if(a.browser.msie)this.style.removeAttribute("filter")});if(d.children().length>1){d.children().eq(0).css("position","absolute").fadeOut(c.changeSpeed,function(){a(this).remove()})}}else if(c.effect=="none"){a(b[g]).clone().appendTo(d);if(d.children().length>1){d.children().eq(0).css("position","absolute").remove()}}if(c.links){a("."+j+"-active").removeClass(j+"-active jshowoff-active");a("."+j+"-slidelinks a").eq(g).addClass(j+"-active jshowoff-active")}}var d=a(this);var e=a(this).children().remove();var f="";var g=0;var h=[];var i=a(".jshowoff").length+1;var j="jshowoff-"+i;var k=c.cssClass!=undefined?c.cssClass:"";d.css("position","relative").wrap('<div class="jshowoff '+j+'" />');var l=a("."+j);l.css("position","relative").addClass(k);a(e[0]).clone().appendTo(d);u();if(c.controls){v();if(c.autoPlay==false){a("."+j+"-play").addClass(j+"-paused jshowoff-paused").text(c.controlText.play)}}if(c.links){w();a("."+j+"-slidelinks a").eq(0).addClass(j+"-active jshowoff-active")}if(c.hoverPause){d.hover(function(){if(n())p("hover")},function(){if(n())o("hover")})}if(c.autoPlay&&e.length>1){f=setInterval(function(){o()},c.speed)}if(e.length<1){a("."+j).append("<p>For jShowOff to work, the container element must have child elements.</p>")}});return this}})(jQuery);(function(a){a.fn.slideIt=function(b,c){var d={direction:"left",showHide:"show",changeSpeed:600};if(b)a.extend(d,b);this.each(function(b){a(this).css({left:"auto",right:"auto",top:"auto",bottom:"auto"});var e=d.direction=="left"||d.direction=="right"?a(this).outerWidth():a(this).outerHeight();var f={};f["position"]=a(this).css("position")=="static"?"relative":a(this).css("position");f[d.direction]=d.showHide=="show"?"-"+e+"px":0;var g={};g[d.direction]=d.showHide=="show"?0:"-"+e+"px";a(this).css(f).animate(g,d.changeSpeed,c)});return this}})(jQuery)
