
/*$.fn.fadeIn = function(delay,callbk,out) {
  return this.each(function() {
    var _this = $(this);
    for (i = 1; i <= 100; i++) {
      (function(j) {
            setTimeout(function() {  
                  if (out==true) j=100-j;
                  _this.css('opacity', j/100);
                  _this.css('MozOpacity', j/100);
                  _this.css('KhtmlOpacity', j/100);
                  _this.css('display', "block"); 
                   if (j==100&&callbk!=undefined) {callbk.call(_this);}
                   else if (out==true&&callbk!=undefined&&j==0) {callbk.call(_this);}
                  _this.css('filter', "alpha(opacity=" + j + ");");},j*delay/100);
                 
        })(i);     
    }
  });
};

$.fn.fadeOut = function(delay,callbk) {
  return $(this).fadeIn(delay,callbk,true);
};*/


$(document).ready(function() {

  // В модуле услуг зачем-то ссылки ч0рные, а в клиентах голубые, хз почему...
  var inact_link_extra_classes = $('#inact_link_extra_classes').val();
  var inact_link_classes = inact_link_extra_classes ?
                           'dotted ' + inact_link_extra_classes :
                           'dotted';
  var service_class = $('#service_class').val();
  if (!service_class) service_class = 'service';
  var container = '.' + service_class + ' ';
      
  bindBlurbSwitchLinks = function() {
    var new_id = $(this).parents('dt').attr('_id');
    var old_id = $(container + 'dt.act').attr('_id');
    if (new_id != old_id)
    {
      $(container + 'img[_id=' + old_id + ']').hide(); //fadeOut(200, function() {
        //$(container + 'img[_id=' + new_id + ']').fadeIn(200);
      //});

      $(container + 'dd[_id=' + old_id + ']').hide('blind', {}, 200, function() {
        $(container + 'dd[_id=' + old_id + ']').removeClass('act');
        $(container + 'dd[_id=' + old_id + ']').addClass('inact');
        $(container + 'img[_id=' + new_id + ']').show();
        $(container + 'dt[_id=' + old_id + ']').removeClass('act');
        $(container + 'dt[_id=' + old_id + ']').addClass('inact');
        $(container + 'dt[_id=' + old_id + '] a').addClass(inact_link_classes);
        $(container + 'dt[_id=' + new_id + ']').removeClass('inact');
        $(container + 'dt[_id=' + new_id + ']').addClass('act');
        $(container + 'dt[_id=' + new_id + '] a').removeClass(inact_link_classes);
        $(container + 'dd[_id=' + new_id + ']').removeClass('inact');
        $(container + 'dd[_id=' + new_id + ']').addClass('act');

        $(container + 'dd[_id=' + new_id + ']').show('blind', {}, 200);
        $(container + 'a.dotted').click(bindBlurbSwitchLinks);
      });
    }
    return false;
  };

  $(container + 'a.dotted').click(bindBlurbSwitchLinks);

});
