(function($){var a={},c="doTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(l){var m=this,h,k={},g=l?$.fn:$,n=arguments,i=4,f=n[1],j=n[2],p=n[3];if(typeof f!=="string"){i--;f=l=0;j=n[1];p=n[2]}if(l){h=m.eq(0);h.data(l,k=h.data(l)||{})}else{if(f){k=a[f]||(a[f]={})}}k.id&&clearTimeout(k.id);delete k.id;function e(){if(l){h.removeData(l)}else{if(f){delete a[f]}}}function o(){k.id=setTimeout(function(){k.fn()},j)}if(p){k.fn=function(q){if(typeof p==="string"){p=g[p]}p.apply(m,d.call(n,i))===true&&!q?o():e()};o()}else{if(k.fn){j===undefined?e():k.fn(j===false);return true}else{e()}}}})(jQuery);

$(document).ready(function()
{
	var interval;
	var $i = 0;
	var $n_e = $("#slideshow .scroller .slide").length;
	var $bullets = $("#bullets .bullet");
	
	function sliderScroll($i)
	{
		var target = $("#slideshow .scroller .slide").eq($i);
		if(target.length < 1) return false;
		$("#slideshow .current").removeClass("current");
		target.addClass("current");
		$("#slideshow").scrollTo(target,500,{axis:'x'});
		$("#bullets .selected").removeClass("selected");
		$("#bullets .bullet").eq($i).addClass("selected");
		return true;
	}
	
	
	function prev($i, $n_e)
	{
		$previ = $i - 1;
		if($previ < 0)
		{
			$previ = $n_e - 1;	
		}
		if(sliderScroll($previ))
		{
			return $previ;	
		}
	}
	function next($i, $n_e)
	{
		
		$nexti = $i + 1;
		if($nexti > ($n_e - 1))
		{
			$nexti = 0;	
		}
		if(sliderScroll($nexti))
		{
			return $nexti;	
		}
		
	
	}
	function timeOutClick()
	{
		$.doTimeout("slidenext");
		$.doTimeout("slideclick",15000,function () {$i = next($i, $n_e);initInterval();});
		
	}
	function initInterval()
	{
		$.doTimeout("slideclick");
		$.doTimeout("slidenext",10000,function () {$i = next($i, $n_e); return true;});
	}
	if($("#slideshow").length > 0)
	{
		$("#bullets .bullet:first").addClass("selected");
		$('a.left').click(function()
		{
			$i = prev($i, $n_e);
			timeOutClick();
		})
		$('a.right').click(function()
		{
			$i = next($i, $n_e);
			timeOutClick();
		})
		initInterval();
		$bullets.each(function() {
			$(this).click(function(){
				$i = $(this).index();
				sliderScroll($i);
				timeOutClick();
			})
		});
	}
	
})
// JavaScript Document
