var	linkName = 'link';
var fonImage;
var layer1;
var layer2;
var animate = true;
var button = true;

var content = content;
var contentText;

function animationInit() {
	var	t0 = $('#text0');
	var	t1 = $('#text1');
	var	t2 = $('#text2');
	var	t3 = $('#text3');
	var	t4 = $('#text4');
	
	var fonImage = $('#fonImage');
	var layer1 = $('#layer1');
	var layer2 = $('#layer2');
	var content = $('#content');
	var contentText = $('#contentText');
	
	var startImage = $('#startImage');
	var noneFlash = $('#noneFlash');
	
	var current = null;
	
	$(layer1).css('opacity', 0.8);
	$(layer2).css('opacity', 0.75);
	
	$(fonImage).attr('src', '/_data/objects/0000/0750/fon0.jpg');
	$(content).css({'opacity': 0});	
	
	$('#central').find('a.' + linkName + ' img').each(function(index, elem) {
															   
		$(this).mouseover(function() {
			startImage.css('display', 'none');
			noneFlash.css('display', 'none');
			
			layer2.stop(true, true);
			layer1.stop(true, true);
			content.stop(true, true);
			
			$(this).attr('src', '/_data/objects/0000/0750/item' + index + 'h.jpg');
			
			if (current != null) {
				$('a.link img').each(function(n, elem) {
					if (n == current) {
						if (current == index) {
							return false;
						}
						
						$(this).attr('src', '/_data/objects/0000/0750/item' + current + '.jpg');
					}
				});
			}
			
						
			
			if (animate) {
				if (current == index) {
					return;
				}
				animate =! animate;
				t0.css({'display': 'none', 'margin-top': '2px'});
				t1.css({'display': 'none', 'margin-top': '2px'});
				t2.css({'display': 'none', 'margin-top': '2px'});
				t3.css({'display': 'none', 'margin-top': '2px'});
				t4.css({'display': 'none', 'margin-top': '2px'});				
			
				fonImage.attr({'src': '/_data/objects/0000/0750/fon' + index + '.jpg'});
				setTimeout(function() {				
					layer1.css('opacity', 0.8).animate({'opacity': 0}, 500);
					layer2.css({'opacity': 0.75, 'height': 0, 'margin-top': '360px'})
				 	      .animate({'height': '360px', 'margin-top': '0px'}, 'slow', function() {
						$('#text' + index).css('display', 'block');						
						content.css('opacity', 0).animate({'opacity': 1}, 'fast', function() {
							animate =! animate;
							current = index;
						});
					});
				}, 100);
			}
		});
		
		$("#item4botton").hover(
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item4bottonH.gif';
				},
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item4botton.gif';
				}
			);
			
			$("#item3botton").hover(
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item3bottonH.gif';
				},
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item3botton.gif';
				}
			);
			
			$("#item2botton").hover(
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item2bottonH.gif';
				},
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item2botton.gif';
				}
			);		
			
			$("#item1botton").hover(
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item1bottonH.gif';
				},
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item1botton.gif';
				}
			);
			
			$("#item0botton").hover(
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item0bottonH.gif';
				},
				function() {
					this.src = this.src = '/_data/objects/0000/0750/item0botton.gif';
				}
			);				
	});
}
