/*globals clearTimeout,jQuery,setTimeout */
/* ***********************************************************************************
 
	 CJ Simpler Slideshow JavaScript framework
	 
	 Copyright (c) 2010, Doug Jones. All rights reserved.
	 
	 Redistribution and use in source and binary forms, with or without
	 modification, are permitted provided that the following conditions
	 are met:
	 
	 a) Redistributions of source code must retain the above copyright
	 notice, this list of conditions and the following disclaimer.
	 
	 b) Redistributions in binary form must reproduce the above copyright
	 notice, this list of conditions and the following disclaimer in the
	 documentation and/or other materials provided with the distribution. 
	 
	 c) Neither the name of the Creative Juices, Bo. Co. nor the names of its
	 contributors may be used to endorse or promote products derived from
	 this software without specific prior written permission.
	 
	 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
	 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
	 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
	 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
	 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
	 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
	 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
	 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
	 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	 
	 For further information, visit the Creative Juices website: www.cjboco.com.
	 
	 Version History
	 
	 1.0 (04-05-2010) - Initial release.
	 					(A simpler version based off of CJ Simple Slideshow 2.1.1)
 
 *********************************************************************************** */
(function($){$.fn.cjSimplerSlideShow=function(d){var e={autoRun:true,delay:3000,dissolve:70,showCaptions:false};var f={version:'1.0',elem:null,slides:[],captions:[],links:[],current:0,timer:null};function setOpacity(o){if(parseFloat(o.t)>1){o.t=1.0;return}$(o).css({opacity:parseFloat(o.t),MozOpacity:parseFloat(o.t),filter:"alpha(opacity="+(parseFloat(o.t)*100)+")"})}function setSlide(){var o=parseFloat(f.slides[f.current].t);var x=f.slides[f.current+1]?f.current+1:0;var a=parseFloat(f.slides[x].t);o-=0.05;a+=0.05;$(f.slides[x]).css({display:"block"});f.slides[f.current].t=parseFloat(o);f.slides[x].t=parseFloat(a);setOpacity(f.slides[f.current]);setOpacity(f.slides[x]);if(f.captions[f.current]&&f.captions[x]){$(f.captions[x]).css({display:"block"});f.captions[f.current].t=parseFloat(o);f.captions[x].t=parseFloat(a);setOpacity(f.captions[f.current]);setOpacity(f.captions[x])}if(f.links[f.current]!==null){}if(o<=0){$(f.slides[f.current]).css({display:"none"});if(f.captions[x]){$(f.captions[x]).css({display:"block"});$(f.captions[f.current]).css({display:"none"})}f.current=x;f.timer=setTimeout(setSlide,e.delay)}else{f.timer=setTimeout(setSlide,e.dissolve)}}function init(){if($(f.elem).css("position")===""||$(f.elem).css("position")==="static"){$(f.elem).css("position","relative")}var c=$("<div>").css({display:"block",width:"0px",height:"0px",position:"absolute",overflow:"hidden"}).addClass("cj_slideshow_wrapper");$(f.elem).find("img").each(function(){var a=$(this)[0].parentNode.nodeName==="A"?$(this).parent()[0]:$(this)[0],slideImg=$(this)[0];$(a).css({display:"none",position:"absolute",top:"0px",left:"0px","z-index":"1"});f.slides.push(a);f.slides[f.slides.length-1].t=0.0;$(a).appendTo($(c));if(e.showCaptions){if($(slideImg).attr("alt")!==""){var b=$("<span>").css({position:"absolute",display:"none",width:"100%",height:"auto"}).addClass("cj_slideshow_caption_wrapper").html($(slideImg).attr("alt"));$(c).append(b);f.captions.push(b);f.captions[f.captions.length-1].t=0.0}else{f.captions.push(null);f.captions[f.captions.length-1].t=0.0}}});$(f.elem).append($(c));$(f.elem).find("br").remove();$(f.elem).css({display:"block"});if(f.slides.length>0){$(f.slides[0]).css({display:"block"});f.slides[0].t=1.0;if(f.captions[0]){$(f.captions[0]).css({display:"block"});f.captions[0].t=1.0}$(f.elem).find(".cj_slideshow_wrapper").css({width:$(f.elem).width(),height:$(f.elem).height()})}}function start(){f.timer=setTimeout(setSlide,e.delay)}if(d){$.extend(e,d)}return this.each(function(){f.elem=this;init();if(e.autoRun){start()}})}})(jQuery);
