var enabletabpersistence=0;
var tabcontentIDs=new Object()

function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id;
var ullist=document.getElementById(ulid).getElementsByTagName("li");
for(var i=0; i<ullist.length; i++) {
  ullist[i].className="";
  if(typeof tabcontentIDs[ulid][i]!="undefined") { document.getElementById(tabcontentIDs[ulid][i]).style.display="none"; }
}
linkobj.parentNode.className="selected";
document.getElementById(linkobj.getAttribute("rel")).style.display="block";
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"));
}

function savetabcontentids(ulid, relattribute){
if(typeof tabcontentIDs[ulid]=="undefined")
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){
if(enabletabpersistence==1)
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(){
for (var i=0; i<arguments.length; i++){
if (enabletabpersistence==0 && getCookie(arguments[i])!="")
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i])
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li")
for (var x=0; x<ulist.length; x++){
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel"))
ulistlink.onclick=function(){
expandcontent(this)
return false
}
if (ulist[x].className=="selected" && clickedontab=="")
expandcontent(ulistlink)
}
}
if (clickedontab!=""){
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined")
expandcontent(culistlink)
else
expandcontent(ulist[0].getElementsByTagName("a")[0])
}
}
}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value
}

function r(imName,over) {
  if(!over) { imName.style.backgroundColor="#f3f3f3"; } 
  if(over==1) { imName.style.backgroundColor="#ffc0c0"; }
  if(over==2) { imName.style.backgroundColor="#ffffff"; } 
  if(over==3) { imName.style.backgroundColor="#ffc0c0"; }
}



function dopopup(x,y) {
if(isie && thtml!="") { var oPopupBody=oPopup.document.body; oPopupBody.innerHTML=menu_html(); oPopup.show(x, y, 300, 180, document.body); }
}
function click(e) {
if(isie && thtml!="") { if(document.all) { if(event.button==2||event.button==3) { dopopup(event.x-1,event.y-1); } } }
}

function menu_html(ntst) {
var html="";

if(thtml!="") {
html+='<div id=wndtop style="border:2px solid #e0e0e0; width:300px; height:180px; font: normal 11px tahoma; padding: 10px 10px 10px 10px; overflow:auto; background-color: #b2b2b2; background-image: url(/d1/bgr.jpg); background-position: top; background-repeat: repeat-x;">';
html+='<ST'+'YLE>\n';
html+='input { font: normal 10px tahoma; padding-bottom:3px; }\n';
html+='</'+'STYLE>\n';
html+='<SC'+'RIPT LANGUAGE="JavaScript">\n';
html+='\n<'+'!--\n';
html+='window.onerror=null;\n';
html+='/'+' -'+'->\n';
html+='</'+'SCRIPT>\n';
html+='<font color=#909090>Допустимые действия в этом режиме:<br><br></font>';
html+=thtml;
html+='</div>';
}
return(html);
}


