
function activate_dealers_brand(brand_id){
  active_tabs = $$('#dealer-info .active');
  for(var j = 0; j<active_tabs.length; j++){
      active_tabs[j].removeClassName('active');
  }
  $('brand-'+brand_id).addClassName('active');
}

function compare_select_max_3(event) {
  var checkbox = event.target || event.srcElement;
  label1 = $('count-for-compare-top');
  label2 = $('count-for-compare-bottom');
  checks = $$('.compare');
  count = 0;
  for (check in checks){
    if(checks[check].checked){
      count += 1;
    }
  }
  if ((count==3 && !checkbox.checked)||(count>3)){
    alert('salīdzināšanai atļauts izvēlēties līdz 3 mašīnām!')
    checkbox.checked = false;
    count -= 1;
  }
  label1.innerHTML = label2.innerHTML = '('+count+'/3)';
}

function prepare_compare_checkboxes(){
  checks = $$('.compare');
  for (check = 0; check < checks.length; check += 1){
    Event.observe(checks[check],'click',compare_select_max_3);
  }  
}

function has_errors(fname){
  var item = $(fname);
  item.addClassName('haserror');
  //Effect.Shake(item);
}

function getWinWidth(){
    var w = window.innerWidth;
    if(!w) return document.body.offsetWidth;
    return w
}