//JavaScript

jQuery.noConflict();

var aMonths = ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'];

jQuery(document).ready(function(){
	var b = new Breathe();
	b.init();
});

function Breathe(){
	
}

Breathe.prototype = {
	init:function(){
		this.findBlock();
	},
	findBlock:function(){
		var _my = this;
		this.timeBlock = jQuery('.footer .time p');
		this.getTime();
		setInterval(function(){
			_my.getTime();
		}, 5000);
		this.initMenu();
		this.mainMenu();
		this.timeBlock.attr('title', this.timeNow.getDate() + ' ' + aMonths[this.timeNow.getMonth()] + ' ' + (!jQuery.browser.msie ? this.timeNow.getYear()+1900 : this.timeNow.getYear()) + ' г.');
	},
	getTime:function(){
		this.timeNow = new Date();
		var t = this.timeNow.toTimeString();
		var n = t.slice(0, 5);
		this.timeBlock.html(n);
	},
	initMenu:function(){
		var _my = this;
		this.menu = jQuery('.footer .menu');
		this.menu.mouseover(function(){
			clearTimeout(_my.tim);
			_my.showMenu();
		}).mouseout(function(){
			_my.tim = setTimeout(function(){
				_my.hideMenu();
			}, 50);
		});
		this.li = jQuery('.footer .menu li');
		this.li.mouseover(function(){
			for(var i=0; i<_my.li.length; i++){
				_my.li.eq(i).find('div').css({display:'none'});
			}
			clearTimeout(_my.ti);
			jQuery(this).find('div').eq(0).css({display:'block'});
		}).mouseout(function(){
			var _m = this;
			_my.ti = setTimeout(function(){
				jQuery(_m).find('div').eq(0).css({display:'none'});
			}, 50);
		});
	},
	showMenu:function(){
		var _my = this;
		this.menu.css({background:'url(/images/2wind/menu2-bg-act.gif) no-repeat'});
		jQuery('.footer .menu .inner').css({display:'block'});
	},
	hideMenu:function(){
		this.menu.css({background:'url(/images/2wind/menu2-bg.gif) no-repeat'});
		jQuery('.footer .menu .inner').css({display:'none'});
	},
	mainMenu:function(){
		var _my = this;
		this.wrapper = jQuery('.top-part .menu');
		this.wrapper.find('a').mouseover(function(){
			clearTimeout(_my.ti);
			jQuery(this).parents('.m').find('.first').animate({opacity:0}, 300);
		}).mouseout(function(){
			var _my = this;
			_my.ti = setTimeout(function(){
				jQuery(_my).parents('.m').find('.first').animate({opacity:1}, 300);
			}, 50);
		});
	}
}
