/*
 * jQuery image-slider
 * http://www.jalsoedesign.net/jquery/image-slider
 * 
 * Copyright (c) 2011 - Andreas Jalsøe
 * JalsoeDesign.net
 *
 * Licences: MIT, GPL
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
*/
(function($){$.fn.imageslider=function(objOptions){var objDefaults={intImageSplits:10,arrImages:new Array(),intSwitchSeconds:10,intFadeSpeed:1000}
objOptions=$.extend(objDefaults,objOptions);return this.each(function(){if(objOptions.arrImages.length>1){var intContainerWidth=$(this).width();var intImageSpacing=Math.min(Math.round(intContainerWidth/objOptions.intImageSplits),intContainerWidth);var strImageHTML="<img alt=\"\" />";objOptions.intImageSplitPlus=(1000/objOptions.intImageSplits);objOptions.intSwitchSeconds=Math.max(0,(objOptions.intSwitchSeconds*1000)-1000);for(var i=0;i<objOptions.intImageSplits;i++)strImageHTML+="<div style=\"width: "+intImageSpacing+"px; background-position: "+(-i*intImageSpacing)+"px 0px;\" imagesliderid=\""+(i+1)+"\"></div>";if(!$(this).hasClass("imageslider"))$(this).addClass("imageslider");$(this).width(intImageSpacing*objOptions.intImageSplits).html(strImageHTML).attr("currentimage",0);$(this).find("div").css("opacity",0);load_new_picture($(this));}else{$(this).html("<img src=\""+objOptions.arrImages[0]+"\" alt=\"\" />");}});function load_new_picture(elmContainerDiv){var intFadedCounter=0;var intCurrentImage=parseInt($(elmContainerDiv).attr("currentimage"));var intNextImage=intCurrentImage+1;if(intNextImage>objOptions.arrImages.length-1)intNextImage=0;$(elmContainerDiv).find("img").attr("src",objOptions.arrImages[intCurrentImage]).ready(function(){$(elmContainerDiv).find("div").css("backgroundImage","url("+objOptions.arrImages[intCurrentImage]+")").css("opacity",1);setTimeout(function(){$(elmContainerDiv).css("backgroundImage","url("+objOptions.arrImages[intNextImage]+")").find("div").each(function(){var elmImageDiv=$(this);setTimeout(function(){$(elmImageDiv).fadeTo(objOptions.intFadeSpeed,0,function(){$(elmImageDiv).css("opacity",0);intFadedCounter++;if(intFadedCounter==objOptions.intImageSplits){$(elmContainerDiv).attr("currentimage",intNextImage);load_new_picture(elmContainerDiv);}});},objOptions.intSwitchSeconds+(parseInt($(elmImageDiv).attr("imagesliderid"))*objOptions.intImageSplitPlus));});},1000);});}};})(jQuery);
