makeDashedLine = function(){
    var dLine = $("#dashed-thing");
    if(dLine){
      var item_to_dash = $("#left .menu li.active").get(0);
      if(!item_to_dash){
        item_to_dash = $("#left .menu li:first-child").get(0);
      }
      dLine.css("display","block");
      var height = ($(item_to_dash).height()/2) + $(item_to_dash).position().top + $(item_to_dash).parent().position().top - dLine.position().top;
      dLine.height(parseInt(height,10));

    }
}


prepareGallery = function(){
    $('#center ul.gallery-c').each(function() {
        $('a', this).lightBox({
                overlayOpacity: .6,
                fixedNavigation: true,
                txtImage: "Фотография",
                txtOf: "из",
                txtClose: "Закрыть",
                imageBtnPrev: '/i/lightbox/btn-prev.gif',
                imageBtnNext: '/i/lightbox/btn-next.gif',
                imageBtnClose: '/i/lightbox/btn-close.gif',
                imageLoading: '/i/lightbox/ico-loading.gif'
            });
    });
}

setMenuAnimation = function(){
    $('#left .menu li:not(.active) img').each(
        function() {
            var img = $(this);
            this.parentNode.imgLink = this;
            img.hide();
        }
    );
    $('#left .menu li:not(.active) a').mouseover(function() {
                            $(this.parentNode.imgLink).fadeIn(200);
                       }).mouseout(function() {
                            $(this.parentNode.imgLink).fadeOut(200);
                       });
}

function _setSubscribeForm() {
    var form = document.getElementById('subscribe-form');
    if (form) {
        var actDOM = form['_action'];
        var act;
        for (var i=0; i<actDOM.length; i++) {
            if (actDOM[i].checked) {
                act = actDOM[i].value;
                break;
            }
        }
        if (act == 'subscribe') {
            $('#sf-name-input-container').show();
        } else {
            $('#sf-name-input-container').hide();
        }
    }
}
    window.setSubscribeForm = _setSubscribeForm;

$(document).ready(function(){
    makeDashedLine();
    prepareGallery();
    setMenuAnimation(); // NEW
});

