//
//  (ñ) SiteLeader, 2005-2008 || http://www.siteleader.ru
//

var isMSIE = (navigator.userAgent && (navigator.userAgent.indexOf("MSIE") >= 0) && (navigator.appVersion.indexOf("Win") != -1)) ? 1 : 0;
var getEl = function(id) { return document.getElementById(id) }
function js_startup() { return paint_tables() }
function js_obj_adjust(tag_name, class_name, max_width, max_height) {
  var imgs = document.getElementsByTagName(tag_name);
  for (i = 0; i < imgs.length; i++) {
    if (imgs[i].className.indexOf(class_name) != -1) {
      var rate = imgs[i].width / imgs[i].height;
      if (imgs[i].width > max_width) {
        imgs[i].width = max_width;
        imgs[i].height = max_width / rate;
      } else if (imgs[i].height > max_height) {
        imgs[i].height = max_height;
        imgs[i].width = max_height * rate;
      }
    }
  }
}
function js_adjust_me(obj, max_width, max_height) {
  if (!obj) return;
  var rate = obj.width / obj.height;
  if (obj.width > max_width) {
    obj.width = max_width;
    obj.height = max_width / rate;
  } else if (obj.height > max_height) {
    obj.height = max_height;
    obj.width = max_height * rate;
  }
}
function post_form(form_id, mode_id, mode) {
  var form = document.getElementById(form_id);
  if (!form_id) return;
  var form_mode = document.getElementById(mode_id);
  if (form_mode) form_mode.value = mode;
  form.submit();
}
function paint_tables() {
  var tbl=document.getElementsByTagName('table');
  for (var i = 0; i < tbl.length; i++) {
    var lc = tbl[i].className.toLowerCase();
    if (lc.match('default'))
      for(var j = 0; j < tbl[i].rows.length; j++) tbl[i].rows[j].style.backgroundColor = j & 1 ? '#ffffff' : '#f1f1f1';
  }
  return false;
}
function paint_tables_old() {
  var tbl=document.getElementsByTagName('table');
  for (i = 0; i < tbl.length; i++) {
    if (tbl[i].id == 'zebra-0') {
      for(j = 0; j < tbl[i].rows.length; j++) tbl[i].rows[j].style.backgroundColor = j & 1 ? '#ffffff' : '#f1f1f1';
    } else if (tbl[i].id == 'zebra-1') {
      for(j = 0; j < tbl[i].rows.length; j++) tbl[i].rows[j].style.backgroundColor = j & 1 ? '#f1f1f1' : '#ffffff';
    }
  }
  return false;
}
