function __isIE() {
        var OP = (navigator.userAgent.indexOf('Opera') != -1) ? true : false;
        return (navigator.userAgent.indexOf('MSIE') != -1 && !OP) ? 1 : 0;
}


var prev_comment = 0;

// Ответ на комментарий
function cr(comment_id)
{
	if (prev_comment && prev_comment != comment_id)
	{
		document.getElementById(prev_comment).style.display = 'none';
	}

	var div = document.getElementById(comment_id);

	if (div.style.display != 'block')
	{
		div.style.display = 'block';
	}
	else
	{
		div.style.display = 'none';
	}

	prev_comment = comment_id;
}

var temp_ChildId = '';
var temp_CurrenElementId = '';
var menu_timeout_id = 0;
var filter_timeout_id = 0;
var temp_CurrentSubId	= '';


// обработчик наведения мыши на меню
function TopMenuOver(CurrenElementId, ChildId)
{
	clearTimeout(menu_timeout_id);

	if (temp_CurrenElementId != ''
	&& temp_CurrenElementId != CurrenElementId)
	{
		var oTemp_ChildId = document.getElementById(temp_ChildId);

		if (oTemp_ChildId)
		{
			oTemp_ChildId.style.display = "none";
		}
	}

	temp_ChildId = ChildId;
	temp_CurrenElementId = CurrenElementId;

	if (CurrenElementId == undefined)
	{
		return false;
	}

	if (ChildId != '')
	{		temp_CurrentSubId = ChildId;

		var oChildId = document.getElementById(ChildId);

		if (oChildId)
		{			oChildId.style.left		= document.getElementById(CurrenElementId).offsetLeft + (__isIE() ? 22 : 5) + 'px';

			oChildId.style.display	= "block";
		}
	}
}

// обработчик уведения мыши с меню
function TopMenuOut(CurrenElementId, ChildId)
{	if (CurrenElementId == undefined)
	{
		return false;
	}

	if ((ChildId != '') && (ChildId != temp_CurrentSubId))
	{
		var oChildId = document.getElementById(ChildId);
		if (oChildId)
		{
			menu_timeout_id = setTimeout(function (){oChildId.style.display = "none"}, 300);
		}
	}
}


function hideMenu(ChildId)
{	var oChildId = document.getElementById(ChildId);

	if (oChildId)
	{
			menu_timeout_id = setTimeout(function (){oChildId.style.display = "none"}, 300);
			temp_CurrentSubId = '';	}
}


// Функция обратного вызова для AddIntoCart
function callbackfunction_AddIntoCart(responseJS)
{
	// Результат принят
	sended_request = false;

	if (typeof responseJS != 'undefined')
	{
		// Данные.
		if (typeof responseJS.cart != 'undefined')
		{
			html = responseJS.cart;

			var little_cart = document.getElementById('little_cart');

			if (little_cart)
			{
				little_cart.innerHTML = html;
			}
			else
			{
				alert('Ошибка! Краткая корзина не найдена');
			}
		}
	}
}

function AddIntoCart(shop_path, item_id, item_count)
{
	//location.href = shop_path + 'cart/?ajax_add_item_id=' + item_id + '&count=' + item_count;
	cmsrequest = shop_path + 'cart/?ajax_add_item_id=' + item_id + '&count=' + item_count;

	// Отправляем запрос backend-у
	sendRequest(cmsrequest, 'get', callbackfunction_AddIntoCart);

	return false;
}

// Установка или снятие всех флажков для checkbox'ов элементов.
function SelectAllItems(ASelect, prefix)
{
	element_array = document.getElementsByTagName("input");
	if (element_array.length > 0)
	{
		for (var i = 0; i < element_array.length; i++)
		{
			if (element_array[i].name.search(prefix) != -1)
			{
				// Устанавливаем checked
				element_array[i].checked = ASelect;
			}
		}

	}
}





function commChk()
{	f = document.getElementById('comment_autor');
	if (f && !f.value)
	{		alert('Введите, пожалуйста, Ваше имя.');
		f.focus(); return false;	}


	f = document.getElementById('comment_email');
	if (f && !f.value)
	{
		alert('Введите, пожалуйста, Ваш адрес e-mail.');
		f.focus(); return false;
	}


	f = document.getElementById('comment_text');
	if (f && !f.value)
	{
		alert('Введите, пожалуйста, текст комментария.');
		f.focus(); return false;
	}

	f = document.getElementById('comment_captcha');
	if (f && !f.value)
	{
		alert('Введите, пожалуйста, зашитный код.');
		f.focus(); return false;
	}



	return true;}



