ci.promo = {
	slideshow:null,
	indicator:null,
	//&interval:null,  to enable interval remove "//&"
	size:0,
	index:0,
	slideWidth:0,
	slideDelay:500,
	effectDuration:300,
	
	init:function(){
		var x = ci.promo;
		
		//set vars
		x.slideshow = $('#promo_mask ul');
		x.size = x.slideshow.children('li').length;
		x.slideWidth = x.slideshow.children('li').width();
		x.slideshow.css({width:(x.size*x.slideWidth)+'px'});
		x.indicator = $('#promo_nav').length > 0 ? $('#promo_nav') : $('#promo_nav_pattern');
		
		//next and prev arrows
		$('#promo_button').find('a').click(function(e){
			e.preventDefault();
			
			//&clearInterval(x.interval);
				if($(this).attr('class')=='prev') x.prev();
				else if($(this).attr('class')=='next') x.next();
			//&x.startInterval();
		});
		x.loaded();
	},
	loaded:function(){
		var x = ci.promo;
		$(window).load(function(){
			//&x.startInterval();
			x.bindClick();
		});
	},
	startInterval:function(){
		var x = ci.promo;
		//&x.interval = setInterval(x.next, x.slideDelay+x.effectDuration);
	},
	prev:function(){
		var x = ci.promo;
		if(--x.index < 0) x.index = x.size-1;
		x.run();
	},
	next:function(){
		var x = ci.promo;
		if(++x.index == x.size) x.index = 0;
		x.run();
	},
	run:function(){
		var x = ci.promo;
		x.slideshow.stop().animate({left:'-'+(x.index*x.slideWidth)+'px'}, x.effectDuration, x.runIndicator);
	},
	runIndicator:function(){
		var x = ci.promo;
		x.indicator.children('li').removeClass('active');
		x.indicator.children('li:eq('+x.index+')').addClass('active');
	},
	unbindClick:function(){
		var x = ci.promo;
		x.indicator.children('li').unbind('click.promo');
	},
	bindClick:function(){
		var x = ci.promo;
		x.indicator.find('a').bind('click.promo', x.clickIndicator);
	},
	clickIndicator:function(e){
		e.preventDefault();
		var x = ci.promo;
			//&clearInterval(x.interval);
			x.index = $(this).parent('li').index();
			x.run();
			//&x.startInterval();
	}
}
