id_old = 0;

if(document.images){
 imgArr = new Array();
 for(i=1;i<=9;i++){
  imgArr[i] = new Image(); 
  imgArr[i].src = "/i/m0" + i + "a.gif"; 
 }
}

function afisha(id){
 for(i=1;i<=3;i++){
  o = document.getElementById('afisha' + i);
  a = document.getElementById('aa' + i);
  if(o && a){
   o.className = 'afisha_hide';
   a.className = 'n';
  }
 }
 o = document.getElementById('afisha' + id);
 a = document.getElementById('aa' + id);
 if(o && a){
  o.className = 'afisha_show';
  a.className = 'a';
 }
}

function sel(what){
 o = document.getElementById('sel');
 a = document.getElementById('sela');
 if(o && a){
  if(what){
   o.className = 'afisha_show';
   a.innerHTML = 'кратко...';
   a.href = 'javascript:sel(0);'
   //a.innerHTML = '';
   //a.href = '';
  }else{
   o.className = 'afisha_hide';
   a.innerHTML = 'подробнее...';
   a.href = 'javascript:sel(1);'
  }
 }
}

function getParent(it){
 it_parent = null;
 if(it != null){
  if(document.all){
   it_parent = it.parentElement;
  }else{
   it_parent = it.parentNode;
  }
 }
 return it_parent;
}
function getParent_ro(it){
 if(it != null){
  if(it.tagName == 'TD'){
   itp = getParent(it);
  }else{
   if(it.tagName == 'H4' || it.tagName == 'P'){
    itp = getParent(it);
    itp = getParent(itp);
   }else{
    if(it.tagName == 'A'){
     itp = getParent(it);
     itp = getParent(itp);
     itp = getParent(itp);
    }
   }
  }
  return itp;
 }
 return null;
}
function ro(e,className){
 if(document.all){
  e = window.event;
  it = e.srcElement;
 }else{
  it = e.target;
 }
 itp = getParent_ro(it);
 if(itp != null){
  itp.className = className;
 }
}
function handler_ro(e){
 ro(e,'ro_over');
}
function clear_ro(e){
 ro(e,'ro_out');
}
function click_ro(e){
 if(document.all){
  e = window.event;
  it = e.srcElement;
 }else{
  it = e.target;
 }
 if(it.tagName == 'TD' || it.tagName == 'P' || it.tagName == 'H4'){
  it_row = getParent_ro(it);
  c = 0;
  if(it_row != null){
   n = it_row.childNodes.length;
   for(i=0;i<n;i++){
    if(it_row.childNodes[i].tagName == 'TD'){
     if(c >= 1){
      break;
     }else{
      c++;
     }
    }
   }
   if(it_row.childNodes[i] != null){
    n = it_row.childNodes[i].length;
    for(j=0;j<n;j++){
     if(it_row.childNodes[i].childNodes[j].tagName == 'H4'){
      break;
     }
    }
    if(it_row.childNodes[i].childNodes[j] != null){
     n = it_row.childNodes[i].childNodes[j].length;
     for(k=0;k<n;k++){
      if(it_row.childNodes[i].childNodes[j].childNodes[k].tagName == 'A'){
       break;
      }
     }
     url = it_row.childNodes[i].childNodes[j].childNodes[k].getAttribute('href');
     if(url){
      window.location = url;
     }
    }
   }
  }
 }
}


function err_send(e){
 if(document.all){
  e = window.event;
 }
 if((e.ctrlKey) && ((e.keyCode == 0xA)||(e.keyCode == 0xD))){
  var txt = "" + get_selection();
  if(txt.length >= 200){
   alert("Выделен слишком большой текст");
   return;
  }
  if(txt.length < 4){
   alert("Выделен слишком маленький текст");
   return;
  }
  var url = window.location.href;
  if(window.confirm("Ошибка в строке:\n«" + txt + "»\n\nОтправить?")){
   $.post("/err.php", {str:""+txt, url:""+url}, alert("Спасибо, информация отправлена"));
  }
 }
}

function get_selection(){
 if(document.all){
  var sel = document.selection;
  var rng = sel.createRange();
  rng.select();
  return rng.text;
 }else{
  return window.getSelection();
 }
}

function removeHTMLTags(str){
 str = str.replace(/&(lt|gt);/g, function (strMatch, p1){
  return (p1 == 'lt') ? '<' : '>';
 });
 return str.replace(/<\/?[^>]+(>|$)/g, ' ');
}

