/*
* slides, a slideshow plugin for jquery
* intructions: http://slidesjs.com
* by: nathan searles, http://nathansearles.com
* version: 1.0.7
* updated: december 29th, 2010
*
* licensed under the apache license, version 2.0 (the "license");
* you may not use this file except in compliance with the license.
* you may obtain a copy of the license at
*
* http://www.apache.org/licenses/license-2.0
*
* unless required by applicable law or agreed to in writing, software
* distributed under the license is distributed on an "as is" basis,
* without warranties or conditions of any kind, either express or implied.
* see the license for the specific language governing permissions and
* limitations under the license.
*/
(function($){$.fn.slides=function(option){option=$.extend({},$.fn.slides.option,option);return this.each(function(){$('.'+option.container,$(this)).children().wrapall('
');var elem=$(this),control=$('.slides_control',elem),total=control.children().size(),width=control.children().outerwidth(),height=control.children().outerheight(),start=option.start-1,effect=option.effect.indexof(',')<0?option.effect:option.effect.replace(' ','').split(',')[0],paginationeffect=option.effect.indexof(',')<0?effect:option.effect.replace(' ','').split(',')[1],next=0,prev=0,number=0,current=0,loaded,active,clicked,position,direction;if(total<2){return;}
if(start<0){start=0;};if(start>total){start=total-1;};if(option.start){current=start;};if(option.randomize){control.randomize();}
$('.'+option.container,elem).css({overflow:'hidden',position:'relative'});control.css({position:'relative',width:(width*3),height:height,left:-width});control.children().css({position:'absolute',top:0,left:width,zindex:0,display:'none'});if(option.autoheight){control.animate({height:control.children(':eq('+start+')').outerheight()},option.autoheightspeed);}
if(option.preload&&control.children()[0].tagname=='img'){elem.css({background:'url('+option.preloadimage+') no-repeat 50% 50%'});var img=$('img:eq('+start+')',elem).attr('src')+'?'+(new date()).gettime();$('img:eq('+start+')',elem).attr('src',img).load(function(){$(this).fadein(option.fadespeed,function(){$(this).css({zindex:5});elem.css({background:''});loaded=true;});});}else{control.children(':eq('+start+')').fadein(option.fadespeed,function(){loaded=true;});}
if(option.bigtarget){control.children().css({cursor:'pointer'});control.children().click(function(){animate('next',effect);return false;});}
if(option.hoverpause&&option.play){control.children().bind('mouseover',function(){stop();});control.children().bind('mouseleave',function(){pause();});}
if(option.generatenextprev){$('.'+option.container,elem).after('prev');$('.'+option.prev,elem).after('next');}
$('.'+option.next,elem).click(function(e){e.preventdefault();if(option.play){pause();};animate('next',effect);});$('.'+option.prev,elem).click(function(e){e.preventdefault();if(option.play){pause();};animate('prev',effect);});if(option.generatepagination){elem.append('');control.children().each(function(){$('.'+option.paginationclass,elem).append(''+(number+1)+'');number++;});}else{$('.'+option.paginationclass+' li a',elem).each(function(){$(this).attr('href','#'+number);number++;});}
$('.'+option.paginationclass+' li a[href=#'+start+']',elem).parent().addclass('current');$('.'+option.paginationclass+' li a',elem).click(function(){if(option.play){pause();};clicked=$(this).attr('href').replace('#','');if(current!=clicked){animate('pagination',paginationeffect,clicked);}
return false;});$('a.link',elem).click(function(){if(option.play){pause();};clicked=$(this).attr('href').replace('#','')-1;if(current!=clicked){animate('pagination',paginationeffect,clicked);}
return false;});if(option.play){playinterval=setinterval(function(){animate('next',effect);},option.play);elem.data('interval',playinterval);};function stop(){clearinterval(elem.data('interval'));};function pause(){if(option.pause){cleartimeout(elem.data('pause'));clearinterval(elem.data('interval'));pausetimeout=settimeout(function(){cleartimeout(elem.data('pause'));playinterval=setinterval(function(){animate("next",effect);},option.play);elem.data('interval',playinterval);},option.pause);elem.data('pause',pausetimeout);}else{stop();}};function animate(direction,effect,clicked){if(!active&&loaded){active=true;switch(direction){case'next':prev=current;next=current+1;next=total===next?0:next;position=width*2;direction=-width*2;current=next;break;case'prev':prev=current;next=current-1;next=next===-1?total-1:next;position=0;direction=0;current=next;break;case'pagination':next=parseint(clicked,10);prev=$('.'+option.paginationclass+' li.current a',elem).attr('href').replace('#','');if(next>prev){position=width*2;direction=-width*2;}else{position=0;direction=0;}
current=next;break;}
if(effect==='fade'){option.animationstart();if(option.crossfade){control.children(':eq('+next+')',elem).css({zindex:10}).fadein(option.fadespeed,function(){control.children(':eq('+prev+')',elem).css({display:'none',zindex:0});$(this).css({zindex:0});option.animationcomplete(next+1);active=false;});}else{option.animationstart();control.children(':eq('+prev+')',elem).fadeout(option.fadespeed,function(){if(option.autoheight){control.animate({height:control.children(':eq('+next+')',elem).outerheight()},option.autoheightspeed,function(){control.children(':eq('+next+')',elem).fadein(option.fadespeed);});}else{control.children(':eq('+next+')',elem).fadein(option.fadespeed,function(){if($.browser.msie){$(this).get(0).style.removeattribute('filter');}});}
option.animationcomplete(next+1);active=false;});}}else{control.children(':eq('+next+')').css({left:position,display:'block'});if(option.autoheight){option.animationstart();control.animate({left:direction,height:control.children(':eq('+next+')').outerheight()},option.slidespeed,function(){control.css({left:-width});control.children(':eq('+next+')').css({left:width,zindex:5});control.children(':eq('+prev+')').css({left:width,display:'none',zindex:0});option.animationcomplete(next+1);active=false;});}else{option.animationstart();control.animate({left:direction},option.slidespeed,function(){control.css({left:-width});control.children(':eq('+next+')').css({left:width,zindex:5});control.children(':eq('+prev+')').css({left:width,display:'none',zindex:0});option.animationcomplete(next+1);active=false;});}}
if(option.pagination){$('.'+option.paginationclass+' li.current',elem).removeclass('current');$('.'+option.paginationclass+' li a[href=#'+next+']',elem).parent().addclass('current');}}};});};$.fn.slides.option={preload:false,preloadimage:'/img/loading.gif',container:'slides_container',generatenextprev:false,next:'next',prev:'prev',pagination:true,generatepagination:true,paginationclass:'pagination',fadespeed:350,slidespeed:350,start:1,effect:'slide',crossfade:false,randomize:false,play:0,pause:0,hoverpause:false,autoheight:false,autoheightspeed:350,bigtarget:false,animationstart:function(){},animationcomplete:function(){}};$.fn.randomize=function(callback){function randomizeorder(){return(math.round(math.random())-0.5);}
return($(this).each(function(){var $this=$(this);var $children=$this.children();var childcount=$children.length;if(childcount>1){$children.hide();var indices=[];for(i=0;i