/*
 *  @include "/jTweener/release/jTweener-doc.js"
 */
 
 
$(window).load(function(){
	var process = $('#process');
	var process_items = process.find('li');
	var process_images = $('#process-images li');
	var bottle = $('#bottle');
	
	// сохраняю координаты всех элементов
	var item_coords = [];
	process_items.each(function(){
		item_coords.push({
			top: parseInt($(this).css('top'), 10)
		});
	});
	
	var bottle_pos = {
		top: parseInt(bottle.css('top'), 10)
	};
	
	process.addClass('inited');
	bottle.addClass('inited');
	$('#process-images').addClass('inited');
    
    $('#content').css('zoom', 1);
	
	$t(bottle).tween(bottle_pos, {
		time: 0.5, 
		transition: 'easeinoutcubic',
		delay: 2
	});
	
	process_items.each(function(i){
		$t([this, process_images.get(i)]).tween(item_coords[i], {
			time: 0.6,
			transition: 'easeoutcubic',
			delay: 2.5 + (item_coords.length - i) * 0.1
		});
	});
	
	var marker = $('<div class="marker png"/>');
	
	process_items.eq(0).addClass('selected').append(marker);
	process_items.find('.pseudo-href').click(function(){
		var item = $(this).parent();
		process_items.removeClass('selected');
		item.addClass('selected').append(marker);
		
		var link = item.find('.pseudo-href');
		
		marker.css({
			left: (link.width() - marker.width()) / 2,
			top: (link.height() - marker.height()) / 2
		})
		
		var ix = process_items.index(item[0]);
		$('#description')
			.find('dt, dd').removeClass('selected').end()
			.find('dt').eq(ix).addClass('selected').end().end()
			.find('dd').eq(ix).addClass('selected')
	});
	
	
});
