function l_show(id)
{
  if(document.getElementById(id).style.display == "none") { document.getElementById(id).style.display = "block"; return; }
  if(document.getElementById(id).style.display == "block") { document.getElementById(id).style.display = "none"; return; }
}

function sml_arrow(id_sl, id_arrow)
{
  if(document.getElementById(id_sl).style.display == "none") { document.getElementById(id_arrow).style.backgroundPosition = "0px 0px"; return; }
  if(document.getElementById(id_sl).style.display == "block") { document.getElementById(id_arrow).style.backgroundPosition = "-7px 0px"; return; }	 
}

function user_clad_add_button(id_button, id_clud)
{
  if(document.getElementById(id_clud).style.display == "none") 
  { 
      document.getElementById(id_button).style.backgroundPosition = "0px -18px"; 
	  document.getElementById(id_clud).style.display = "block"; return;
	  return; 
  }
  if(document.getElementById(id_clud).style.display == "block") 
  { 
      document.getElementById(id_button).style.backgroundPosition = "0px 0px"; 
	  document.getElementById(id_clud).style.display = "none"; return;
  }	 
}

function nl2br (str, is_xhtml) {
 
    var breakTag = '';
 
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
 
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}

// targetClass - класс таблиц подлежащих разукрашиванию
// hlClass     - класс подсвеченой строки
// normalClass - класс нормальной строки
function decoreTables(targetClass,hlClass,normalClass) {
  var flag = true;
  var tables = document.getElementsByTagName("TABLE");
  for (var i=0; i<tables.length; i++)
    if (tables[i].className==targetClass) {
      var trs = tables[i].getElementsByTagName("TR");
      for (var j=0; j<trs.length; j++) trs[j].className = (flag=!flag)?hlClass:normalClass;
    }  
}


