// функция для раскрытия сворачивания левого меню
jQuery(document).ready(function(){
  var url = 'http://martinperevod.ru';
  jQuery('.block-submenu').hide();
  
  // открытие подменю при активном подменю
  jQuery('.block-submenu').each(function(){
    jQuery(this).find('a').each(function(){
      if (location.href.substring(url.length) == jQuery(this).attr('href')){
        //jQuery(this).addClass('selected');
        jQuery(this).parent().parent().parent().show();
          return false;
        }
    });
  });
  
  // открытие подменю при открытии главного
  jQuery('.unpoint').each(function(){
    if (location.href.substring(url.length) == jQuery(this).find('a').eq(1).attr('href')){
	  jQuery(this).find('.block-submenu').show();
      return false;	  
	}  
  });
  
  jQuery('.leftblock').find('a').each(function(){
    if (location.href.substring(url.length) == jQuery(this).attr('href')){
	  jQuery(this).addClass('selected');  
	}  
  });
  

});

 /* открыть - закрыть меню */
  function menuToggle(obj){
    var div = jQuery(obj).parent().find('div');
    jQuery('.block-submenu').not(jQuery(div)).hide();
    jQuery(div).toggle();
  }

/* калькулятор */
function calc(){
  var $ = jQuery;
  $.post('/ajax/calc.php', $('#langform').serialize(),
    function(data){
    	_gaq.push(['_trackEvent', 'Калькулятор цен', 'Кнопка посчитать стоимость']);		
		_gaq.push(['_trackPageview', '/goals/priceCalc']); 

      $('#calc_result').show().find('strong').text(data.summa);
      if (data.discount){
        $('#discountVal').text(data.discount);
        $('#discount').show();
      } else {
        $('#discount').hide();
      }
      $('#vote-block').show(); //alert(data.anal);
      $('#anal').val(data.anal);
    }, 'json'
  );

  return false;
}

