$('input.searchButton').live('click', function ()
{
	if ($('input.search').val() == 'Поиск'
		|| $('input.search').val().length < 3)
		return false;
		
	document.location.href = cbSystemRoot + 'search/find/id/1/word/' + $('input.search').val() + '/';
});

$('input.search').live('keyup', function (event)
{
	if (event.which == 13)
	{
		$('input.searchButton').click();
		$('input.search').blur();
	}
});

$('.l2table tr').live('mouseover', function ()
{
	if ($(this).hasClass('noAnim'))
		return;
		
	$('.l2table tr').each(function ()
	{
		$(this).removeClass('l2animationClass');
	});
	
	$(this).addClass('l2animationClass');
	$('.l2animationClass td').each(function ()
	{
		if (!$(this).hasClass('noAnim') && !$(this).hasClass('title'))
			$(this).css('background-color', '#EEE');
	});
});

$('.l2table tr').live('mouseout', function ()
{
	if ($(this).hasClass('noAnim'))
		return;
		
	$('.l2animationClass td').each(function ()
	{
		if (!$(this).hasClass('noAnim') && !$(this).hasClass('title'))
			$(this).css('background-color', 'transparent');
	});
	$(this).removeClass('l2animationClass');
});

function loadEnchantSkill(skillId, skillLevelSelector)
{
	if (!skillId)
		return;
		
	cbAjax(cbSystemRoot + 'l2/get_enchant_skill/id/' + skillId + '/level/' + $(skillLevelSelector).val() + '/', '#skill' + skillId, '');
}

function ipbCreateTopic(id, cat, fid, action)
{
	if (!id || !cat || !fid)
		return;
		
	var url = cbSystemRoot + 'ipb_migrate/spec_topic_create/id/' + id + '/cat/' + cat;
	
	$.ajax({
	url: url,
	beforeSend: function(request)
	{
		$('#postsLoader').css('display', '');
		request.setRequestHeader('AJAX', 1);
	},
	success: function(data)
	{
		if (data > 0)
		{
			if (action == 'add')
				document.location.href = cbSystemRoot + 'forum/?act=post&do=reply_post&f=' + fid + '&t=' + data;
			else if (action == 'view')
				document.location.href = cbSystemRoot + 'forum/?showtopic=' + data;
		}
		else
			alert('Произошла ошибка. Обратитесь к администратору. Приносим извинения за неудобства.');
		$('#postsLoader').css('display', 'none');
	}});
}
