/* scripts by Mark Dibbets (markyd@ilse.nl), jan 2005  please do not remove this line */

var ie = navigator.appName.toLowerCase().indexOf('microsoft') != -1 ? 1 : 0;
var mac =  navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 1 : 0;
var win = !mac ? 1 : 0;
var safari =  navigator.userAgent.toLowerCase().indexOf('safari') != -1 ? 1 : 0;
var mozilla = navigator.appName.toLowerCase().indexOf('netscape') != -1 && !safari ? 1 : 0;
var winIE = ie && !mac ? 1: 0;
var macIE = ie && mac ? 1: 0;

var getE = function (el){return document.getElementById(el);}

function setupMenus(){
	// fuc** the fuc**n mac ie
	if (macIE){
		return false;
	}
	if (ie){
		window.event.cancelBubble = true;
		var listitems = getE('menu').getElementsByTagName('li');
		for (var i = 0; i < listitems.length; i++){
			var li = listitems[i];
			if (li.className.indexOf('kids') != -1){
				li.onmouseover = function(){
					if (this.className.indexOf('kidsover') == -1){
						this.className = this.className.replace('kids','kidsover');
					}
				}		
				li.onmouseout = function(){
					if(window.event)	{
						var el = window.event.toElement;
						while (el){
							el = el.parentNode;
							if (el == this){
								return;
							}
						}
						this.className = this.className.replace('kidsover','kids');
					}
				}
			}
		}
	}
	// selected state menu top
	var tM = getE('menu');
	if (tM){
		var tMAs = tM.getElementsByTagName('a');		
		var loc = String(location.href).split('?id=')[0];
		loc = loc.split('&id=')[0];
		loc = loc.split('&offset=')[0];
		loc = loc.split('&sound=')[0];
		loc = loc.split('&search=')[0];
		var rootLi = false;
		for (var i = 0; i < tMAs.length; i++){
			var a = tMAs[i];
			if (String(a.href) == loc){
				rootLi = a.id ? a.parentNode : a.parentNode.parentNode.parentNode;
				break;
			}
		}
		if (loc.indexOf('php') == -1){
			rootLi = getE('menuhome').parentNode;
		}
		if (rootLi){
			rootLi.className += ' selected';
		}
	}
}

function createMouseOvers(){
	var p = 0, d = document.images;
	prelImgs = new Array();
	for (var i = 0; i < d.length; i++){
		var o = d[i];
		if (o.src.indexOf('_out') != -1){
			var s = o.src, l = s.length, e = s.substring(l-4,l);
			o.outSrc = s;
			o.overSrc = s.substring(0,l-8)+'_over'+e;
			o.onmouseover = function(){this.src = this.overSrc;}
			o.onmouseout = function(){this.src = this.outSrc;}
			prelImgs[p] = new Image();
			prelImgs[p].src = o.overSrc;
			p++;
		}
	}
}

function popupPic(pic,height){
	var w = window.open(pic,'popup','scrollbars=yes,resizable=yes,width=638,height='+height);
}

function openWin(url,width,height){
	var w = window.open(url,'window','scrollbars=yes,resizable=yes,width='+width+',height='+height);
}

onload = function(){setupMenus();createMouseOvers();}