
var __current_shown_nav = 0;
var __nav_timeout = null;



function showNav(id)
{
  var oNAV, oCELL, i, w, j, oTMP;


	if(__current_shown_nav)
	{
		clearTimeout(__nav_timeout);
		_GID('nav_id_' + __current_shown_nav).setAttribute('is_hover', '0');
		if(__current_shown_nav!=id)
		{
			hideNav2(__current_shown_nav);
		}
	}
			
	oNAV = _GID('nav_id_' + id);
	oCELL = _GID('Nav' + id);
	oNAV.style.width = (oCELL.clientWidth ? oCELL.clientWidth : oCELL.offsetWidth) + 2 + 'px';

	w = 0;
	j = 0;

	for (i=1; i<id; i++)
	{
		w += (oCELL.clientWidth ? _GID('Nav' + i).clientWidth : _GID('Nav' + i).offsetWidth) + j;
	}

	oNAV.style.top = '141px';
	oNAV.style.left = w + 'px';

	__current_shown_nav = id;

			
	oNAV.setAttribute('is_hover', '1');


	oNAV.style.display = 'block';

	oTMP = document.getElementsByTagName('SELECT');
	for(i=0; i<oTMP.length; i++)
	{
		if(oTMP[i].id == 'search_where')
		{
			oTMP[i].style.display = 'none';
		}
	}
}


function hideNav(id)
{
	if(!__current_shown_nav) return;
	
	_GID('nav_id_' + id).setAttribute('is_hover', '0');

	__nav_timeout = setTimeout("hideNav2('"+id+"')", 100);
}


function hideNav2(id)
{
  var oNAV;

	oNAV = _GID('nav_id_' + id);


	if(typeof(oNAV) != 'object') return;
			

	if(oNAV.getAttribute('is_hover') == '1') return;


	oNAV.style.display = 'none';
	__current_shown_nav = false;


	oTMP = document.getElementsByTagName('SELECT');
	for(i=0; i<oTMP.length; i++)
	{
		if(oTMP[i].id == 'search_where')
		{
			oTMP[i].style.display = '';
		}
	}
}



function onResizeNav()
{
	if(__current_shown_nav)
	{
		showNav(__current_shown_nav);
	}
}


function hideNavAll()
{
	if(__current_shown_nav)
	{
	        hideNav(__current_shown_nav);
	}
}
		
		

function navInit()
{
  var i, oNAV, oCELL, fn;
	for(i=1; i<10; i++)
	{
		oNAV = _GID('nav_id_' + i);
		oCELL = _GID('Nav' + i);

		if(oNAV)
		{
			oNAV.onmouseover = function (){showNav(this.getAttribute('nav_id'))};
			oNAV.onmouseout = function (){hideNav(this.getAttribute('nav_id'));};
			oNAV.setAttribute('nav_id', i);

			oCELL.onmouseover = function (){showNav(this.getAttribute('nav_id'));};
			oCELL.onmouseout = function (){hideNav(this.getAttribute('nav_id'));};
			oCELL.setAttribute('nav_id', i);
		}
	}
}
        		
addHook('WindowOnResize', 'onResizeNav');
addHook('DocumentOnClick', 'hideNavAll');
addHook('WindowOnLoad', 'navInit');












function vote_popup(c)
{
	var f = document.forms.poll;
	if(f)
	{
		if(f.option_id.value=='')
		{
		}else{
			var option_id = '';
			for (i=0; i<self.document.poll.option_id.length; i++)
			{
			        if(self.document.poll.option_id[i].checked == true)
			        {
			            option_id = self.document.poll.option_id[i].value;
			            break;
			        }
			}
			if(option_id != '')
			{
				option_id = '&option_id='+option_id;
				var s='misc/vote_popup'+(c=='4'?'_games':'')+'.php?action=vote&poll_ident='+f.poll_ident.value+option_id;
			}else{
				var s='misc/vote_popup'+(c=='4'?'_games':'')+'.php?poll_id='+f.poll_ident.value;
			}
			wpopup(s,600,500,1);
			return false;
		}
	}
}


function voteSet(t)
{
	var f = document.forms.poll;
	if(f)
	{
		for (i=0; i<self.document.poll.option_id.length; i++)
		{
		        if(self.document.poll.option_id[i].value == t)
		        {
			        self.document.poll.option_id[i].checked = true;
		        }
		}
	}
}



document.write('<div id="img_map_box" style="position: absolute; width: 150px; height: 113px;display: none; background-color: InfoBackground" onmouseover="map_show(this.id, this.id)" onmousemove="map_show(this.id, this.id)"><img id="img_map" width="150" height="113" alt="" border="0"></div>');


function initMapOvers()
{
if(document.getElementsByTagName)
{
	var i, o, a = document.getElementsByTagName('IMG');

	for(i=0; i<a.length; i++)
	{
		if(a[i].id =='img_map_th')
		{
		        a[i].setAttribute('_path', a[i].src.replace(/(http:\/\/([^\/]*))(\/.*\/)([^\/]*)/i, "$3"));

		        a[i].onmouseover = function(){
				map_show(this.alt, this.getAttribute('_path').replace('60x45/', ''));
		        }
		        a[i].onmousemove = function(e){
				var oImg, oBox, x, y;
	
				oBox = _GID('img_map_box');
				oImg = _GID('img_map');

				x = (window.event ? window.event.clientX : (e ? (e.pageX ? e.pageX : 0) : 0));
				y = (window.event ? window.event.clientY + document.body.scrollTop : (e ? (e.pageY ? e.pageY : 0) : 0));

				if(oBox)
				{
					oBox.style.left = (x + 50) + 'px';
					oBox.style.top = (y - oBox.scrollHeight / 2) + 'px';
				}
		        }
		        a[i].onmouseout = function(e){
				map_hide();
			}
		}
	}

}
}
addHook('WindowOnLoad', 'initMapOvers');



function map_show(id, path)
{
  var oImg, oBox;
	
	oBox = document.getElementById('img_map_box');
	oImg = document.getElementById('img_map');

	if(oBox)
	{
		if(oBox.style.display != 'block')
		{
			oImg.src = path + '150x113/' + id;
		}

		oBox.style.display = 'block';
	}
}



function map_hide()
{
  var oBox;

	oBox = document.getElementById('img_map_box');
	
	if(oBox)
	{
		oBox.style.display = 'none';
	}
}


if (parseInt(navigator.appVersion) >= 4)
{
	if (navigator.appName == "Netscape")
	{
	        try {
			document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
		}catch(e){}
	}
}



function search_submit(p)
{
  var where, what, path;
	path = (p ? p : '');
	try {
		where = _GID('search_where').value;
		what = trim(_GID('search_what').value);

		if(what == '')
		{
			return false;
		}

		switch(where)
		{
			case 'ftp':
				wpopup(path + 'ftp/ftp_search.php?search_text=' + what, 700, 550, 1);
				break;
			case 'mercury':
				wpopup(path + 'misc/mercury.php?search_text=' + what, 450, 550, 1);
				break;
			case 'google':
				window.open('http://www.google.ru/search?hl=ru&ie=windows-1251&q=' + what);
				break;
			case 'rambler':
				window.open('http://search.rambler.ru/cgi-bin/rambler_search?words=' + what);
				break;
			case 'yandex':
				window.open('http://www.yandex.ru/yandsearch?text=' + what);
				break;
			case 'meta-ukraine':
				window.open('http://www.meta-ukraine.com/search.asp?q=' + what);
				break;
			case 'yahoo':
				window.open('http://search.yahoo.com/bin/search?p=' + what);
				break;
			case 'altavista':
				window.open('http://uk.altavista.com/web/results?itag=wrx&kgs=0&kls=0&q=' + what);
				break;
		}
	}catch(e){alert(e);}

	return false;
}
