﻿if(typeof jQuery!="undefined")jQuery(function(a){a.fn.extend({faded:function(c){var b=a.extend({},a.fn.faded.defaults,c);return this.each(function(){if(a.fn.jquery<"1.3.1")return;var f=a(this),d=f.children(":nth-child(1)"),c=a.metadata?a.extend({},b,f.metadata()):b,s=d.children().size(),e=0,j=0,p=0,k=0,q=0,t=0,o,l,r,m,n;if(c.random){a.fn.reorder=function(b){function c(){return Math.round(Math.random())-.5}return a(this).each(function(){var g=a(this),e=g.children(),f=e.length;if(f>1){e.hide();var d=[];for(i=0;i<f;i++)d[d.length]=i;d=d.sort(c);a.each(d,function(f,d){var a=e.eq(d),c=a.clone(true);c.show().appendTo(g);if(b!==undefined)b(a,c);a.remove()})}})};d.reorder()}function h(){clearInterval(autoplay);clearTimeout(q);q=setTimeout(function(){autoplay=setInterval(function(){g("next")},c.autoplay)},c.autorestart)}d.css({position:"relative"});d.children().css({position:"absolute",top:0,left:0,zIndex:0,display:"none"});if(c.autoheight)d.animate({height:d.children(":eq(0)").outerHeight()},c.autoheight);if(c.pagination){if(c.autopagination){f.append("<ul class="+c.pagination+"></ul>");d.children().each(function(){a("."+c.pagination+"",f).append("<li><a rel="+p+' href="#" >'+(p+1)+"</a></li>");p++})}a("."+c.pagination+" li a:eq(0)",f).parent().addClass("current");a("."+c.pagination+" li a",f).click(function(){n=a("."+c.pagination+" li.current a",f).attr("rel");m=a(this).attr("rel");if(n!=m)g("pagination",m,n);if(c.autoplay)h();return false})}if(c.sequentialloading&&d.children()[0].tagName=="IMG"){d.css({background:"url("+c.loadingimg+") no-repeat 50% 50%"});r=a("img:eq(0)",d).attr("src");a("img:eq(0)",d).attr("src",r).load(function(){a(this).fadeIn(c.speed,function(){o=true})})}else d.find(":eq(0)").fadeIn(c.speed,function(){o=true});if(c.bigtarget){d.css({cursor:"pointer"});d.click(function(){g("next");if(c.autoplay)if(c.autorestart)h();else clearInterval(autoplay);return false})}if(c.autoplay){autoplay=setInterval(function(){g("next")},c.autoplay);h()}a("."+c.nextbtn,f).click(function(){g("next");if(c.autoplay)if(c.autorestart)h();else clearInterval(autoplay);return false});a("."+c.prevbtn,f).click(function(){g("prev");if(c.autoplay)if(c.autorestart)h();else clearInterval(autoplay);return false});function g(h,b,g){if(!l&&o){l=true;switch(h){case "next":j=e;e=k*1+1;if(s===e)e=0;break;case "prev":j=e;e=k*1-1;if(e===-1)e=s-1;break;case "pagination":e=b;j=g}if(c.pagination){a(".pagination li.current",f).removeClass("current");a(".pagination li a:eq("+e+")",f).parent().addClass("current")}if(c.crossfade)d.children(":eq("+e+")").css({zIndex:10}).fadeIn(c.speed,function(){d.children(":eq("+j+")").css({display:"none",zIndex:0});a(this).css({zIndex:0});k=e;l=false});else d.children(":eq("+j+")").fadeOut(c.speed,function(){if(c.autoheight)d.animate({height:d.children(":eq("+e+")").outerHeight()},c.autoheight,function(){d.children(":eq("+e+")").fadeIn(c.speed)});else d.children(":eq("+e+")").fadeIn(c.speed);k=e;l=false})}}})}});a.fn.faded.defaults={speed:300,crossfade:false,bigtarget:false,sequentialloading:false,autoheight:false,pagination:"pagination",autopagination:true,nextbtn:"next",prevbtn:"prev",loadingimg:false,autoplay:false,autorestart:false,random:false}})
