// JavaScript Document
/*
2010-12-01          Artem Kolombet      - add animate change image
                                        - if user click on one of the menu item  - timer destroy and do not set more
....................................................................................................................       

*/

rotatingIndex = 1;

jQuery(document).ready(function(){
								
	delayTime = delay_Time;
	iElements = i_Elements; 
	
	if(typeof(rotatingItems) != 'undefined')
		rotatingTimer = setTimeout('nextRotatingFrame()', delayTime);
		
	rotatingImg = jQuery('.rightSide li ');
	
	rotatingImg.click(function(){
		var block_id = parseInt(jQuery(this).attr('id').replace('board_',''));
		
		clearTimeout(rotatingTimer);

		nextRotatingFrame(block_id - 1, 1);
	
	});

})

function nextRotatingFrame(index, click)
{
	
    
	if(typeof(index) != 'undefined')
		rotatingIndex = index;
	
	if(typeof(index) == 'undefined')
    {
		if (click != 1)
        {
            rotatingTimer = setTimeout('nextRotatingFrame()', delayTime);
             
        }
    }
	rotatingObj = jQuery('.rotating_billboard').find('.image');

	if(rotatingIndex >= 5)
		rotatingIndex = 0;
        //alert(rotatingIndex);
    rotatingObj.find('div').fadeTo(iAnimateSpeed,0.3, function(){
       rotatingObj.find('div').css('top', (rotatingIndex-1)*(-250)+"px"); 
       rotatingObj.find('div').fadeTo(iAnimateSpeed, 1);
    });
    
    //rotatingObj.find('img').attr('src', rotatingItems[rotatingIndex].webImage);
    

	
	rotatingImg.removeClass('active');
	
	rotatingImg.eq(rotatingIndex).addClass('active');


	rotatingIndex++;

}
