	function open_window(link,w,h) //opens new window
	{
		var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'newWin',win);
		newWin.focus();
	}

	function open_printable_version(link) //opens new window
	{
		var win = "menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'perintableWin',win);
		newWin.focus();
	}

	function confirmDelete(id, ask, url) //confirm order delete
	{
		temp = window.confirm(ask);
		if (temp) //delete
		{
			window.location=url+id;
		}
	}



	function confirmUnsubscribe() //unsubscription confirmation
	{
		temp = window.confirm('{/literal}{$smarty.const.QUESTION_UNSUBSCRIBE}{literal}');
		if (temp) //delete
		{
			window.location="index.php?killuser=yes";
		}
	}

	function validate() // newsletter subscription form validation
	{
		if (document.subscription_form.email.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		if (document.subscription_form.email.value == 'Email')
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		return true;
	}
	function validate_disc() // review form verification
	{
		if (document.formD.nick.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_NICKNAME}{literal}");
			return false;
		}

		if (document.formD.topic.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_MESSAGE_SUBJECT}{literal}");
			return false;
		}

		return true;
	}
	function validate_search()
	{

		if (document.Sform.price1.value!="" && ((document.Sform.price1.value < 0) || isNaN(document.Sform.price1.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}
		if (document.Sform.price2.value!="" && ((document.Sform.price2.value < 0) || isNaN(document.Sform.price2.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}

		return true;
	}
	function setHomePage() {}

/**
 * Рекурсивно получает координату Y на экране выбранного элемента
 * @param element - выбранный элемент
 * @return координату Y на экране выбранного элемента
 */
function getAbsoluteTop(element) {
    var top = element.offsetTop;
    if(element.offsetParent) {
        top += getAbsoluteTop(element.offsetParent);
    }
    return top;
}

/**
 * Вызывается когда мышь проходит над пунктом меню
 * @param categoryID - id of category
 */
function menuMouseOver(categoryID) {
    var parentLink = document.getElementById("menu" + categoryID);
    var subMenu = document.getElementById("submenu" + categoryID);
    //устанавливаем координаты блока подменю таким образом, чтобы оно располагалось справа от нужного пункта меню
    subMenu.style.top = getAbsoluteTop(parentLink);
    subMenu.style.left = parentLink.offsetWidth;
    subMenu.style.visibility = "visible";
}

/**
 * Вызывается когда мышь уходит с пункта меню
 * @param categoryID - id of category
 */
function menuMouseOut(categoryID) {
    document.getElementById("submenu" + categoryID).style.visibility = "hidden";
}

/**
 * Вызывается когда мышь проходит над пунктом подменю
 * @param categoryID - id of category
 */
function subMenuMouseOver(categoryID) {
    document.getElementById("submenu" + categoryID).style.visibility = "visible";
}

/**
 * Вызывается когда мышь уходит с пункта подменю
 * @param categoryID - id of category
 */
function subMenuMouseOut(categoryID) {
    document.getElementById("submenu" + categoryID).style.visibility = "hidden";
}

