dom = (document.getElementById)? true : false;
nn4 = (document.layers)? true : false;
ie4 = (document.all && !dom)? true : false;

function show(elemId){ 
 if (dom) document.getElementById(elemId).style.display = "block";
 else if (ie4) document.all[elemId].style.display = "block";

}

function show2(elemId){ 
 if (dom) document.getElementById(elemId).style.display = "inline";
 else if (ie4) document.all[elemId].style.display = "inline";

}

function hide(elemId){ 
 if (dom) document.getElementById(elemId).style.display = "none";
 else if (ie4) document.all[elemId].style.display = "none";
}

function changeVisible(elemId) { 
 if (document.getElementById(elemId)) {
   if (dom) current=document.getElementById(elemId).style.display;
   else if (ie4) current=document.all[elemId].style.display;
  
   if (current=="none") {current="block";} else {current="none";}

   if (dom) document.getElementById(elemId).style.display=current;
   else if (ie4) document.all[elemId].style.display=current;
 }

}




function swapOptions(the_elem,the_array_name,value)
{

  var the_array = eval(the_array_name);
  the_elem2=document.forms['editDoc'].elements[the_elem];
  if (the_array!=undefined) setOptionText(the_elem2, the_array,value);
    else  setOptionText(the_elem2, Array(), value);
}



function setOptionText(the_select, the_array, value)
{

Object.prototype.in_array = function(datum, strict) {

    if (strict) function equals(a,b) { return a === b }
    else function equals(a,b) { return a == b }

    for (var i in this) {
        if (equals(this[i], datum)) return true;
    }
    return false;
}


  the_select.options.length=the_array.length;
  the_select.options[0] = new Option("[Выбрать]","0");
  for (loop=1; loop < the_array.length; loop++)
  {
    if (value.in_array(the_array[loop][0])==true)  the_select.options[loop] = new Option(the_array[loop][1],the_array[loop][0],true,true);
      else the_select.options[loop] = new Option(the_array[loop][1],the_array[loop][0]);
  }

  the_select.onchange && the_select.onchange();
}


function styleTab (simpleTab) {
  var Tab=simpleTab;
  for(a="";a<10;a++) {
	if (document.getElementById(simpleTab)) {
	  if (dom) {
     document.getElementById(simpleTab).className = "item";
    }
    else if (ie4) {
      document.all[simpleTab].className = "item";
    }
	} 
	simpleTab=Tab+a;
  }
}

