	var acttab;
	acttab = 1;
	function refreshInsets(e,leftn,leftc,rightn,rightc,load_xajax,filter)
	{
			for (i = 0; i < 4; i++)
			{
			  if (i == (rightn-1))
			  {
          document.getElementById('b' + i).className = 'act_menu';
			  }
			  else
			  {
  			  if (i == rightn)
  			  {
            document.getElementById('b' + i).className = 'user_menu_la';
  			  }
  			  else
  			  {
  			    if (i == 0)
  			    {
              document.getElementById('b' + i).className = 'user_menu_l';
  			    }
  			    else
  			    {
              document.getElementById('b' + i).className = 'user_menu';
  			    }
  			  }
			  }
			}
			if (rightn == 4)
			{
        document.getElementById('rc').src = '/images/menu_activ_r.gif';
			}
			else
			{
        document.getElementById('rc').src = '/images/menu_passiv_r.gif';
			}
	  
		acttab = rightn;
		if (!acttab) acttab = 0;
		if (acttab == 1) acttab = 0;
		
		if (load_xajax){
			document.getElementById('processing').style.visibility = 'visible';
			xajax_TabChange(acttab, 1, filter);
		}
	}
	
	function init(gr_id){
		
		var togglers = $('div.display'); 
		var stretchers2 = $('div.menu_content div#menu_active2'); 
		
		preLoad = new Image(); preLoad.src = 'img/str1.gif';
		//todo get gr_id		
		var gr_id2=100;
		
		$('div.menu_content').each(function(index, value) {
			//console.log("index", index, "value", value);
		
			$(value).children().each(function(index2, value2) {
				//console.log("index", index2, "value", value2);
				if (value2.id == "menu_active2"){
					gr_id2=index;
				}
			});
			//if (gr_id2 != 100) {gr_id2=index;}

		});	
		//console.log( "value", gr_id2);
		//alert(gr_id);

		
		/*
		$('#sidemenu .display').click(function(){
			
				var liItems = $("#sidemenu .display .menu_content").get();

				//iterate through this array in reverse order    
				for(var i = liItems.length - 1; i >= 0; --i)
				{
					if($(liItems[i]).css('display') == 'block')
					{
						
						if($(liItems[i]).html() != $(this).children('.menu_content').html())
							$(liItems[i]).hide("blind", null, 0);
					}	
				}

				if($(this).children('.menu_content').css('display') == 'none')
				$(this).children('.menu_content').show("blind", null, 500);
				
		});*/
		
/*
		var myAccordion = new Fx.Accordion(togglers, stretchers, { opacity: false, alwaysHide: true,
		 transition: Fx.Transitions.quadOut, display: gr_id2, duration: 400,
			
			onActive: function(toggler, stretcher){
				toggler.setStyle('backgroundImage', 'url(\'img/str1.gif\')');
			},
		
			onBackground: function(toggler, stretcher){
				toggler.setStyle('backgroundImage', 'url(\'img/str1.gif\')');
			}
		});
*/		
		//document.getElementById('sidemenu').style.visibility = 'visible';
	}
	
	function ResetErrors(){
		var stretchers = $$('div.errorBox');
		stretchers.each(function(h3, i){
			h3.outerHTML="";
		});
	}

		
	function SwitchArrow(obj){
		if (obj.id != 'ch'){
			obj.style.backgroundImage='url(\'img/str1.gif\')';
			if (lastobj) lastobj.style.backgroundImage='url(\'img/str1.gif\')';
		}
		lastobj = obj;
	} 
	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 exec(cmd) {
	    var sort = $("input[id $= hSort]").val();
	    $.ajax({
	        type: "POST",
	        url: "/jQueryAjaxRequest.aspx/HandleCommand",
	        data: "{command : '" + cmd + "'}",
	        contentType: "application/json; charset=utf-8",
	        dataType: "json",
	        success: function(response) { confirmCommand(response); },
	        error: function(response) { $.notifier("Произошла ошибка. Попробуйте снова.", "error"); }
	    });
	}

	function confirmCommand(response) {
	    var result = eval('(' + response.d + ')');
	    if (result.IsSuccess) {
	        switch (result.Command.split("_")[0]) {
	            case "getModificationsAddBasket":
	                $("#tModsData").html(result.Message);
	                $("#h3Title").html(result.Message2);
	                $("#divPopupModifications").fadeIn();
	                Basket();
	                break;
	            case "getModificationsAddReview":
	                $("#tModsData").html(result.Message);
	                $("#h3Title").html(result.Message2);
	                $("#divPopupModifications").fadeIn();
	                break;
	        }
	    }
	    else {
	        $.notifier("Произошла ошибка. Попробуйте снова.", "error");
	    }
	}

	function CallTrack() {
	    $(document).bind('keydown', function(event) {
	        if (event.ctrlKey && event.keyCode == '13') {
	            $("#divPopupCallTRacker").fadeIn();
	            pageTracker._trackPageview("/call_tracker");
	            $(document).unbind('keydown');
	        }
	    });
	}
	
	function ValidateEmail(email) {
	    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	    return reg.test(email);
	}
	
	function completeNotify() {
	    var inputs = $("input[id*=hCommandStatusMessage]");
	    for (var i = 0; i < inputs.length; i++) {
	        var message = inputs[i].value;
	        if (message) {
	            $.notifier(message);
	            inputs[i].value = '';
	        }
	    }
	}

	function HtmlEncode(value) {
	    return $('<div/>').text(value).html().replace(/\"/g, "&quot;");
	}

	function HtmlDecode(value) {
	    return $('<div/>').html(value).text().replace(/&quot;/g, "\"");
	}
