var title_table = new Array();
var automatic_move = 1;  
var actual_where = 0;
var slide_every = 14000;
var mainW = 508;
var mainH = 176;
var actualHighestPictureId = 0;
var numberTotalPicture = 0 ; 
var menuHeight = 27;
var menuTopPosition = mainH - menuHeight;
var timer = setInterval('appearNewPictureAutomaticVersion();',slide_every);


function timer_stop()
{
	clearInterval(timer);
	automatic_move = 0;  
	//$('intro_menu_list_a_plus').setStyle( { background:'transparent url(http://static.virtualvillage.com/www/homepage_promo/b_intro_menu_play.gif) no-repeat', color:'#722D74' } );
}

function timer_buttom()
{
	if(automatic_move == 1 )
	{
		timer_stop();
	}else {
		timer = setInterval('plus_one = actual_where+1 ; slide_to(plus_one);',slide_every); 
		automatic_move = 1;
		//$('intro_menu_list_a_plus').setStyle( { background:'transparent url(http://static.virtualvillage.com/www/homepage_promo/b_intro_menu_pause.png) no-repeat', color:'#722D74' } );
	}	
}

	
function showList() 
{ 
	if($('intro_menu').getStyle('top') == mainH+'px')
	{
		new Effect.Move(
			'intro_menu', 
			{
				x:0,
				y:menuTopPosition,
				mode: 'absolute',
				duration: 0.3,
				transition: Effect.Transitions.sinoidal 
			}
		);
	}
}
function hideList() 
{ 		
	if($('intro_menu').getStyle('top') == menuTopPosition+'px' ){
		var dsdf = "3";
		new Effect.Move(
			'intro_menu', 
			{
				x:0,
				y:mainH,
				mode: 'absolute',
				duration: 0.3,
				transition: Effect.Transitions.sinoidal 
			}
		); 
	}
	
}


function appearNewPicture(where) // change slide version 2 
{
	if(actualHighestPictureId != where)
	{
		$('intro_menu_list_a_' + where ).setStyle({'backgroundImage' : 'url(http://static.virtualvillage.com/www/home/16px2.png)'});
		$('intro_menu_list_a_' + actualHighestPictureId ).setStyle({'backgroundImage' : 'url(http://static.virtualvillage.com/www/home/16px1.png)'});
		
		new Effect.Fade('slide_id'+actualHighestPictureId+'_type1', { duration: 0.9 } );
		new Effect.Appear('slide_id'+where+'_type1', { duration: 0.9 } );
		actualHighestPictureId = where;
	}
	
}
function appearNewPictureAutomaticVersion() // change slide and calculating the next frame to show
{
	
	temp = numberTotalPicture - 1;
	if(actualHighestPictureId < temp )
	{
		temp = actualHighestPictureId+1;
		appearNewPicture(temp);
	}else{
		appearNewPicture(0);
	}
}

Event.observe(
	document, 
	'mousemove', 
	function(event){
		try {
			ofset = $('intro_animation_2').cumulativeOffset() ; 
			rightposition = ofset[0] + mainW;
			bottomposition = ofset[1] + mainH;
			
			x = Event.pointerX(event);
			y = Event.pointerY(event);
			
			if(x > ofset[0] && x < rightposition && y > ofset[1] && y <  bottomposition) {	
				showList();
			}else{
				hideList();
			}
		}catch(err){
		}
		
	}
);


Event.observe(		
	window, 		
	'load', 		
	function() 		{ 
		$('long_animation').childElements().each(function(s, index) {
			numberTotalPicture = $('long_animation').childElements().size();
			if (s.identify() != 'slide_id0_type1'){
				s.hide();
			}
		});
		
	}
);
