var site = {ShowedSubmenu : null};
$(document).ready(function() {

  /* hacks =) */
  $('.l-wrap').css('margin', 0);

  /* Верхнее меню. Хак для LI:hover (lte IE6) */
  $('#top-menu li').hover(
    function(){ $(this).addClass('hover'); },
    function(){ $(this).removeClass('hover'); }
  )

  // LeftMenu
  $('#left-menu ul.level').hide();

  var tempLevel = $("#left-menu .active").parents("ul.level").eq(0);
  site.ShowedSubmenu = tempLevel;
  tempLevel.prev('.link').addClass("open");
  tempLevel.show();
  $('#left-menu .link').click(
    function()
    {
        $('#left-menu .link').each(function(){$(this).removeClass("open");});
        //$('#left-menu a').each(function(){$(this).removeClass("open");});
        if(site.ShowedSubmenu != null)
        {
            site.ShowedSubmenu.next("ul.level").hide("fast");
            $(this).removeClass("open");
            site.ShowedSubmenu = null;
        }
        var temp = $(this).next("ul.level");
        if(site.ShowedSubmenu != temp)
        {
            $(this).next("ul.level").slideToggle("fast");
            $(this).toggleClass("open");
            site.ShowedSubmenu = $(this);
        }
    }
  );

  //Marquee
  $('marquee').marquee('pointer').mouseover(function () {
      $(this).trigger('stop');
  }).mouseout(function () {
      $(this).trigger('start');
  }).mousemove(function (event) {
      if ($(this).data('drag') == true) { this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX); }
  }).mousedown(function (event) {
      $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
  }).mouseup(function () {
      $(this).data('drag', false);
  });

  $(window).resize(function(){
    $("#marquee .pointer").width(300); // set min width for return correct width of document
    var mL = $("#marquee").css("margin-left");
    var mR = $("#marquee").css("margin-right");
    var wd = parseInt($(document).width()) - (parseInt(mL.substr(0, mL.length-2)) + parseInt(mR.substr(0, mR.length-2)));
    $("#marquee .pointer").width(wd);
  });


});

function photos_carousel_initCallback(carousel){

carousel.buttonNext.bind('click',function(){carousel.startAuto(0);});
carousel.buttonPrev.bind('click',function(){carousel.startAuto(0);});

$('.b-partners .gallery LI A').bind('click',function(){carousel.startAuto(0);})

carousel.clip.hover(function(){carousel.stopAuto() ;},function(){carousel.startAuto();});
};

$(document).ready(function(){
    $('.gallery UL').jcarousel({ scroll: 3,auto: 2,wrap: 'both', initCallback: photos_carousel_initCallback });
});

$('.b-partners .gallery LI A').live('click',function(){
		$('.b-partners .buttons A').removeClass('cur');
		$('.b-partners .ramka').html('<img width="313" height="127"  src="' + $(this).attr('href') + '" alt="">');
		$('.b-partners .content').html($(this).parent().text());
		return false;
	});
	
function Map_text(cat_map){
$.post('ajax/map.php',{cat:cat_map},function(data){document.getElementById('b-content').innerHTML = data;});
}


