$(document).ready(function(){


	// РАБОТАЕМ С ПОЗИЦИРОВАНИЕМ ОСНОВНОГО ДИВА В ЗАВИСИМОСТИ ОТ РАЗМЕРОВ РАБОЧЕЙ ОБЛАСТИ ОКНА БРАУЗЕРА

	function screenSize() {
		var w, h;
		w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
		h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
		return {w:w, h:h};
	}

	maindiv = function(){
		if(screenSize().h>888){
			$('#wrapper').css({'padding-top': '218px'});
			$('body').css({'background-position': 'center 0px'});
			$('html').css({'background-position': 'center 0px'});
		}else{
			if(screenSize().h>670){
				$('#wrapper').css({'padding-top':screenSize().h - 670 + 'px'});
				$('body').css({'background-position': 'center ' + -(218 - (screenSize().h - 670)) + 'px'});
				$('html').css({'background-position': 'center ' + -(218 - (screenSize().h - 670)) + 'px'});
			}else{
				$('#wrapper').css({'padding-top':'0px'});
				$('body').css({'background-position': 'center -218px'});
				$('html').css({'background-position': 'center -218px'});
			}
		}
	}

	$(window).bind('resize',maindiv);
	maindiv();

	// РАБОТАЕМ С АРИЯМИ МАПА
	$('map[name="mainmap"] area').each(function(){
		$(this).mouseover(function(){
			$('.' + $(this).attr('rel')).css({'display':'block'});
		});
		$(this).mouseout(function(){
			$('.' + $(this).attr('rel')).css({'display':'none'});
		});
		/*$('.' + $(this).attr('rel')).mouseover(function(){
			$(this).css({'display':'block'});
		});
		$('.' + $(this).attr('rel')).mouseout(function(){
			$(this).css({'display':'none'});
		});*/
	});

	$('a.menu').mouseover(function(){
		$(this).addClass('hover'+$(this).attr('rel'));
	});
	$('a.menu').mouseout(function(){
		$('a.menu').removeClass('hover'+$(this).attr('rel'));
	});

	if($('.mnenia_text').length){
		$('.mnenia_text').mousewheel(function(event, delta) {
			/*if (delta > 0) {
				//$('.mnenia_text').stop();
				//$('.mnenia_text').scrollTo('-=' + (delta*10) + 'px', 100, {axis:'y'}, {easing:'linear'});
				$(this).scrollTop($(this).scrollTop()-(delta*10));
			}else{
				//$('.mnenia_text').stop();
				//alert('+=' + (-(delta*10)) + 'px');
				//$('.mnenia_text').scrollTo('+=' + (-(delta*10)) + 'px', 100, {axis:'y'}, {easing:'linear'});
				$(this).scrollTop($(this).scrollTop()-(delta*10));
			}*/
			//$('.sound').html($(this).scrollTop()-(delta*10).toFixed(0)+'='+Math.random( ));
			$(this).scrollTop($(this).scrollTop()-(delta*10).toFixed(0));
			return false;
		});
		$('a.mnenia_scroll_top').mousedown(function(){
			$('.mnenia_text').stop();
			$('.mnenia_text').scrollTo('-=10000px', 9000, {axis:'y'}, {easing:'linear'});
			return false;
		});
		$('a.mnenia_scroll_bottom').mousedown(function(){
			$('.mnenia_text').stop();
			$('.mnenia_text').scrollTo('+=10000px', 9000, {axis:'y'});
			return false;
		});
		$('a.mnenia_scroll_bottom,a.mnenia_scroll_top').mouseup(function(){
			$('.mnenia_text').stop();
			return false;
		});
		$('a.mnenia_scroll_bottom,a.mnenia_scroll_top').click(function(){
			return false;
		});
	}
	
	if($('.blog_text').length){
		$('.blog_text').mousewheel(function(event, delta) {
			$(this).scrollTop($(this).scrollTop()-(delta*10).toFixed(0));
			return false;
		});
		
		$('a.mnenia_scroll_top').mousedown(function(){
			$('.blog_text').stop();
			$('.blog_text').scrollTo('-=10000px', 9000, {axis:'y'}, {easing:'linear'});
			return false;
		});
		$('a.mnenia_scroll_bottom').mousedown(function(){
			$('.blog_text').stop();
			$('.blog_text').scrollTo('+=10000px', 9000, {axis:'y'});
			return false;
		});
		$('a.mnenia_scroll_bottom,a.mnenia_scroll_top').mouseup(function(){
			$('.blog_text').stop();
			return false;
		});
		$('a.mnenia_scroll_bottom,a.mnenia_scroll_top').click(function(){
			return false;
		});
	}

	if($('a.sound').length){
		$('a.sound').click(function(){
			$(this).toggleClass('offed');
			return false;
		});
	}


if($('.error').length){
  $('.error .close').click(function(){
   $(this).parent().css({'display':'none'});
  });
 }


});
