/*
// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news"> 
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *  
 *  $('#news').innerfade({ 
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 
 *	  timeout: Time between the fades in milliseconds (Default: '2000'), 
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 
 *    containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container get’s applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  }); 
 *
 */
(function(a){a.fn.innerfade=function(b){return this.each(function(){a.innerfade(this,b);
});
};
a.innerfade=function(b,c){var e={animationtype:"fade",speed:"normal",type:"sequence",timeout:2000,containerheight:"auto",runningclass:"innerfade",children:null,skipNextExecution:false};
if(c){a.extend(e,c);
}b=a(b);
var f;
if(e.children===null){f=e.elements=b.children();
}else{f=e.elements=b.children(e.children);
}if(f.length>1){b.css("position","relative").css("height",e.containerheight).addClass(e.runningclass);
for(var d=0;
d<f.length;
d++){a(f[d]).css("z-index",String(f.length-d)).css("position","absolute").hide();
}if(e.type=="sequence"){setTimeout(function(){e.current=1;
e.previous=0;
a.innerfade.next(b);
},e.timeout);
a(f[0]).show();
}else{if(e.type=="random"){e.previous=Math.floor(Math.random()*(f.length));
setTimeout(function(){do{e.current=Math.floor(Math.random()*(f.length));
}while(e.previous==e.current);
a.innerfade.next(b);
},e.timeout);
a(f[e.previous]).show();
}else{if(e.type=="random_start"){e.type="sequence";
e.current=Math.floor(Math.random()*(f.length));
setTimeout(function(){e.current=(e.current+1)%f.length;
e.previous=e.current;
a.innerfade.next(b);
},e.timeout);
a(f[e.current]).show();
}else{alert("Innerfade-Type must either be 'sequence', 'random' or 'random_start'");
}}}}b.data("innerfade-settings",e);
};
a.innerfade.next=function(b){b=a(b);
var c=b.data("innerfade-settings");
if(c.skipNextExecution){c.skipNextExecution=false;
b.data("innerfade-settings",c);
}else{a.innerfade.moveto(b,c.current);
}setTimeout((function(){a.innerfade.next(b);
}),c.timeout);
};
a.innerfade.moveto=function(b,c){b=a(b);
var d=b.data("innerfade-settings");
if(c!==null&&!isNaN(c)){d.current=c;
}d.skipNextExecution=true;
b.data("innerfade-settings",d);
var e=d.elements;
if(d.animationtype=="slide"){a(e[d.previous]).slideUp(d.speed);
a(e[d.current]).slideDown(d.speed);
}else{if(d.animationtype=="fade"){a(e[d.previous]).fadeOut(d.speed);
a(e[d.current]).fadeIn(d.speed,function(){removeFilter(a(this)[0]);
});
}else{alert("Innerfade-animationtype must either be 'slide' or 'fade'");
}}if(d.type=="sequence"){if((d.current+1)<e.length){d.current=d.current+1;
d.previous=d.current-1;
}else{d.current=0;
d.previous=e.length-1;
}}else{if(d.type=="random"){d.previous=d.current;
while(d.current==d.previous){d.current=Math.floor(Math.random()*e.length);
}}else{alert("Innerfade-Type must either be 'sequence', 'random' or 'random_start'");
}}d.skipNextExecution=true;
b.data("innerfade-settings",d);
};
})(jQuery);
function removeFilter(a){if(a.style.removeAttribute){a.style.removeAttribute("filter");
}}