function $(id) {
  return document.getElementById(id);
}

function addp(csurl) {
try {
window.external.AddSearchProvider(csurl);
} catch (e) {
alert("У вас должен быть Internet Explorer (7.0 или выше) или Firefox (2.0 или выше) чтобы установить плагин поиска.");
}}


function addBookmark(url, title)
{
  if (!url) url = location.href;
  if (!title) title = document.title;

  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
  //IE4+
  else if (typeof window.external == "object") window.external.AddFavorite(url, title);
  //Opera7+
  else if (window.opera && document.createElement)
  {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
  }
  else return false;

  return true;
}



function mfover(t){
	t.style.cursor="hand";
	t.style.fontStyle="italic";
}
function mfout(t){
	t.style.fontStyle="";
}
function findPos(obj) {
	var curleft=curtop=0;
	//var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function showa(a){
	if (curopen>=0){
		hidea(curopen);
		curopen=a;
	}
	curs=findPos($('h'+a));
	$('a'+a).style.left=curs[0]+"px";
	vw=document.body.offsetWidth;
	mw=350;
	if ((mw+curs[0]+20)>vw){
		$('a'+a).style.left=(vw-mw-20)+"px";
	}
	$('a'+a).style.top=(curs[1]+15)+"px";
	$('a'+a).style.display="";
	curopen=a;
	mousein=1;
}
function hidea(a){
	$('a'+a).style.display="none";
	mousein=0;
}
function bovera(a){
	mousein=1;
}
function ct(a){
	if (mousein==0){
		if (curopen>=0){
			hidea(a);
			if (curopen!=a){
			}else{
				curopen=-1;
			}						
		}
	}else{
		if (curopen!=a){
			$('a'+a).style.display="none";
		}
	}
}
function bouta(a){
	mousein=0;
	setTimeout(function() {ct(a);},200);
}

var curopen=-1;
var mousein=0;

function makemenu(){
	var divs = $('alfa').getElementsByTagName("div");	
for(i = 0; i < divs.length; i ++){
	t=divs[i];
	n=(t.id).substr(1);
	t.onmouseout=function(){bouta((this.id).substr(1))};
	t.onmouseover=function(){bovera((this.id).substr(1))};
}                  
var as = $('alfa').getElementsByTagName("a");	
for(i = 0; i < as.length; i ++){
	t=as[i];
	if (t.id){
		n=(t.id).substr(1);
		t.onmouseover=function(){showa((this.id).substr(1))};
		t.onmouseout=function(){bouta((this.id).substr(1))};
	}
}
}

function makemenu2(){
for (a=0;a<b.length;a++){
	if (b[a]){
		len=b[a].length;
		if (len>0){
			div='<div id=a'+a+' style="display:none">';
			icount=0;
			for (i=0;i<len;i++){
				div+="<a href=/t"+a+"/"+icount+"/>"+b[a][i]+"</a><BR>";
				icount++;
			}
			div+="</div>";
			document.write(div);
			t=$("a"+a);
			t.onmouseout=function(){bouta((this.id).substr(1))};
			t.onmouseover=function(){bovera((this.id).substr(1))};			
			t=$("h"+a);
			t.onmouseover=function(){showa((this.id).substr(1))};
			t.onmouseout=function(){bouta((this.id).substr(1))};			
		}
	}
}
}
