var loaded=false;
var showmenu=true;
var mx=0;
var my=0;
var rowHeight=14;
var colWidth=111;
var menuX=50;
var menuY=100;
var personal_h=0;
var images_h=0;
var links_h=0;
var games_h=0;

function handlerMM(e){
	if(ie) {
		mx=event.clientX;
		my=event.clientY;
	} else {
		mx=e.clientX;
		my=e.clientY;
	}
	showMenu();
}
function handlerMO(){
	hideMenu();
}
function hideMenu() {
	if(loaded) {
		document.getElementById("personal").style.top=-150;
		document.getElementById("images").style.top=-150;
		document.getElementById("games").style.top=-150;
		document.getElementById("links").style.top=-150;
	}
}
function showMenu() {
	if(loaded) {
		moveIt("personal",menuX,personal_h);
		moveIt("images",menuX+colWidth,images_h);
		moveIt("games",menuX+(colWidth*2),games_h);
		moveIt("links",menuX+(colWidth*3),links_h);
	}
}
function imgOn(layerRef,img) {
	eval("document."+img+".src="+img+"On.src");
} 
function imgOff(layerRef,img) {
	eval("document."+img+".src="+img+".src");
} 
function loadImage() {
	var url=window.location+"";
	var ImgName = url.substring(url.indexOf("?")+1,url.length);
	eval("document.image.src='"+ImgName+"'");
}
function moveIt(ref,rx,rh) {
	if(showmenu) {
		if(mx<rx) {
			newPos=((rx-mx)+menuY)-rh;
		} else if(mx>rx+colWidth) {
			newPos=((mx-rx)-(colWidth-menuY))-rh;
		} else {
			newPos=menuY-rh;
		}
		if(my>(menuY+20)) {
			newPos=newPos+(my-(menuY+20));
		}
		if((newPos+rh)<(games_h+menuY+50)){
			document.getElementById(ref).style.top=newPos;
		}
	} else {
		hideMenu();
	}
}
function setRefs() {
	personal_h=3*rowHeight;
	images_h=4*rowHeight;
	games_h=4*rowHeight;
	links_h=4*rowHeight;

	if (window.innerWidth || window.innerHeight) {
		docWidth=window.innerWidth;
		docHeight=window.innerHeight;
	} else {
		docWidth=document.body.clientWidth;
		docHeight=document.body.clientHeight;
	}
	menuX=(docWidth/2)-300;
//	document.getElementById("x1").innerHTML = document.getElementById("xW").style.width;
	document.getElementById("x").style.top=100;
//	document.getElementById("x0").style.left=menuX;
	document.getElementById("x").style.left=menuX;
	document.getElementById("personal").style.left=menuX;
	document.getElementById("images").style.left=menuX+111;
	document.getElementById("games").style.left=menuX+222;
	document.getElementById("links").style.left=menuX+333;
	loaded=true;
	showMenu();
}
function winOpen(url,name,wx,wy) {
	window.open(url,name,"width="+wx+",height="+wy+",titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=1");
}
