// если ссылка содержит путь схожий с тем где сейчас находится броузер, то она получит класс act
base=$('base').attr('href');if(base){$('a').each(function(){if(base.indexOf(this.href)>-1)$(this).addClass('act');});}

// если у таблицы установлен бордер, то применяем к ней оформление
$('table[border=1]').attr('border',0).attr('cellspacing',1).addClass('ntable');

// стандартный input:button
$('input[type=button]:not([class]),input[type=submit]:not([class])').each(function(){
  $(this).wrap('<span>').parent().attr('class','button')
  $(this).focus(function(){
    $(this).blur()
  })
});

// стандартный input:file
$('input:file').wrap('<span>').before('<span>Обзор...</span>').parent().addClass('butfile')
$('input:file').change(function(){
  $(this).parent().css('width',200)
  $(this).parent().find('span').css('width',180).text(this.value.replace(/^.+(\/|\\)/,''))
  $(this).parent().find('input').css('margin','0 0 0 65px')
})

// маркер
if(!$.browser.msie){
  $('input[type="password"][title]').each(function(){
    if(!this.value){
      this.type = 'text'
      this.alt = 'password'
    }else{
      this.alt = 'password'
    }
  })
  $('input[type="text"][title]').each(function(){
    if(this.value == ''){
      $(this).css('color', '#a0a0a0')
      this.value = this.title
    }
  }).focus(function(){
    if(this.value == this.title){
      $(this).css('color', '#000000')
      this.value = ''
      this.type = this.alt
      $(this).focus()
    }
  }).blur(function(){
    if(this.value == ''){
      $(this).css('color', '#a0a0a0')
      this.value = this.title
      this.type = 'text'
    }
  })
  $('form').submit(function(){
    $('input[type="text"][title]').each(function(){
      if(this.value == this.title){
        this.value = ''
      }
    })
  })
}

// растягивает сайт по высоте если необходимо
function he(){
  var input = 'body';  // id блока у которого проверяем высоту
  var output = 'hof'; // id блока для которого выставляем высоту
  var height = 50;    // это высота статичных элементов шаблона
  var id = function(x){
    return document.getElementById(x)
  }
  if(window.innerHeight){
    x = window.innerHeight - height;
  }else{
    x  = document.documentElement.clientHeight - height;
  }
  if(id(input).offsetHeight>x){
    x = id(input).offsetHeight;
  }
  if(id(output).style.height!=x){
    id(output).style.height = x+'px';
    win_h = x;
  }
}
he(); setInterval(he,1000);


//
window.yandex_metrika_callback = function() {
    window.yaCounter847580 = new Ya.Metrika(847580);
}
jQuery(document).ready(function() {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.src = ((document.location.protocol=='https:')?'https:':'http:') + '//mc.yandex.ru/metrika/watch.js';
    s.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(s);
});
