$(document).ready (function() {

/* Hide central elements */

//$('')

/* Wrapers */
if ($('.wraper-box').length != 0)
{
	$('.wraper-box').hide();
}

$('.wraper-link').click (function (event){
	$(this).next('.wraper-box').slideToggle('fast');
	event.preventDefault ? event.preventDefault() : event.returnValue = false; 
});

/* Search clean up */

$('#search-input').focus ( function (event) {
	var val = $(this).val ();
	if (val == 'Поиск...')
		{
			$(this).val ('');
		}
});
$('#search-input').blur ( function (event) {
	var val = $(this).val ();
	if (val == '')
		{
			$(this).val ('Поиск...');
		}
});
// END Search clean up

/* Main menu animation */


var main_m = $('#main-menu');
var main_m_lt = $('.main-menu-lt');
var main_m_rt = $('#main-menu');

if ($('#main-menu li.active-item').length != 0)
{
	var active_m = $('#main-menu li.active-item');
}
else
{
	var active_m = false;
}

$('#main-menu li.mm-item').hover ( function (event) {

	if (active_m !== false)
	{
		active_m.css('background-position','top');
		if (active_m.is(':first-child'))
		{
			main_m_lt.css('background-position','top');
		}
		if (active_m.is(':last-child'))
		{
			main_m_rt.css('background-position','right top');
		}		
	}


	if ($(this).is(':first-child'))
	{
		main_m_lt.css('background-position','bottom');
	}
	if ($(this).is(':last-child'))
	{
		main_m_rt.css('background-position','right bottom');
	}


	
	$(this).css('background-position','bottom');


}, function (event) {

	if (active_m !== false)
	{
		active_m.css('background-position','bottom');

		if (active_m.is(':first-child'))
		{
			main_m_lt.css('background-position','bottom');
		}
		if (active_m.is(':last-child'))
		{
			main_m_rt.css('background-position','right bottom');
		}		
	}


	if ($(this).is(':first-child'))
	{
		main_m_lt.css('background-position','top');
	}
	if ($(this).is(':last-child'))
	{
		main_m_rt.css('background-position','right top');
	}	
	

	
	$(this).css('background-position','top');


});
	
});
