pc_arrayContainer = new Array();
jQuery(function($){
		$('#content_main .cc_customerSearch').each( function(i){
			if( typeof(pc_arrayContainer[i]) == 'undefined')
			{
				pc_clients = $('.cc_customerContent',this);
				pc_nbClients = pc_clients.length;
				if(pc_nbClients > 1)
				{
					pc_arrayContainer[i] = $(this);
					pc_arrayContainer[i].carousel = new pc_carousel(this , '.cc_customerContent');
					
					pc_arrayContainer[i].mouseover(function()
					{
						index =  $('.cc_customerSearch').index(this);
						if(index != -1)
							pc_arrayContainer[index].carousel.timer.stop();
					}
					)
					pc_arrayContainer[i].mouseout(function()
					{
						index =  $('.cc_customerSearch').index(this);
						if(index != -1)
							pc_arrayContainer[index].carousel.timer.start(index);
					}
					);
					pc_arrayContainer[i].carousel.goTo(1);	
					pc_arrayContainer[i].carousel.timer.start(i);
				}
			}
		}
		);	
}
);


function pc_clock (statement) {
	this.time = null;
	this.state = statement;
	this.position = null;
	
	this.start = function( j )
	{
		if(this.time == null)
		{	
			this.position = j;
			this.time = setInterval("pc_arrayContainer["+this.position+"].carousel.timer.repeat()",5000);
		}
	}
	
	this.repeat = function()
	{
		this.state.next();
	}
	
	this.stop = function()
	{
		if(this.time != null)
		{
			clearInterval(this.time);
			this.time = null;
		}
	}
}

function pc_carousel (container , object) {
	this.container = $(container);
	this.movable = $(object , this.container);
	this.length = this.movable.length;
	this.current = 0;
	
	if( typeof(this.timer) == 'undefined')
	{
		this.timer = new pc_clock( this );
	}
	this.next = function()
	{
		this.current = ++this.current % this.length;
		this.show();
	}
	
	this.prev = function()
	{
		this.current--;
		if( 0 > this.current)
		{
			this.current = 0;
		}
		this.show();
	}
	
	this.goTo = function( i )
	{	
		this.current = i;
		this.show();
	}
	
	this.show = function()
	{
		$(this.movable).removeClass('show');
		$(this.movable[this.current]).addClass('show');
	}
}
