if( typeof sl == 'undefined'){
	var sl = {};
}

sl.MenuAnimator = function(options)
{
	this.count = 0;
	
	return this;
};

sl.MenuAnimator.prototype.init = function()
{
	soundManager.url = BASE_HREF + 'js/swf/';
	soundManager.onready(
		$.proxy(function()
		{
			this.kittSound = soundManager.createSound({
		    	id: 'kitt',
		    	url:  BASE_HREF + 'js/sound/kitt.mp3',
				//onload: $.proxy(this.startAnimation, this),
				volume: 50
			});	  	
			
			this.startAnimation();
		}, this)
	);
};

sl.MenuAnimator.prototype.startAnimation = function()
{
	this.$menuItems = $('.main-city a');
	var length = this.$menuItems.length;
	this.$active = this.$menuItems.find('.active');
	
	var speed = 35;
	var speed2 = 40;
	
	this.kittSound.stop();
	this.kittSound.play();

	this.$menuItems.each($.proxy(function(i, e){
		$(e).delay((length - i) * speed).animate({backgroundColor: '#ffffff', color: '#FE2E30' }, speed2).animate({backgroundColor: '#FE2E30', color: '#fff' }, speed2);
	}, this));
	
	this.$menuItems.each($.proxy(function(i, e){
		$(e).delay(i * speed * 2).animate({backgroundColor: '#ffffff', color: '#FE2E30' }, speed2).animate({backgroundColor: '#FE2E30', color: '#fff' }, speed2);
	}, this));
	
	setTimeout($.proxy(function(){
		this.$menuItems.css({backgroundColor: '', color: ''});
	}, this), 700);

	this.count++;
	
	if(this.count < 2) setTimeout($.proxy(this.startAnimation, this), 1000);
};

