// JavaScript Document
function addLoadEvent(func) {
	var oldonLoad = window.onload;
	if (typeof window.onload != 'function') {
			window.onload = func;
	}else {
		window.onload = function(){
			oldonLoad();
			func();
		}
	}
}

addLoadEvent(준비);
function 준비() {
	var force = document.getElementById("force");
	var control = document.getElementById("control");
	var control_button = control.getElementsByTagName("a");
	var title = document.getElementById("header").getElementsByTagName("h1");

	var x=10;
	var y=100;
	var xx = 10; // 가로축 이동량
	var yy = 10; // 세로축 이동량
	control_button[0].onmouseup= function () {
		check(x,y);
		y = y - yy;
		moveout(x,y);
		force.setAttribute("src","imeges/player1-008.png");
		//alert ("위");
	}
		control_button[1].onmouseup = function () {
		check(x,y);
		x = x - xx;
		moveout(x,y)
		force.setAttribute("src","imeges/player1-006.png");
		//alert ("왼쪽");
	}
		control_button[2].onmouseup = function () {
		check(x,y);
		x = x + xx;
		moveout(x,y)
		force.setAttribute("src","imeges/player1-003.png");
		//alert ("오른쪽");
	}
		control_button[3].onmouseup = function () {
		check(x,y);
		y = y + yy;
		moveout(x,y)
		force.setAttribute("src","imeges/player1-001.png");
		//alert ("아래");
	}
	function check(x,y) {		
		}
	function moveout(x,y) {
		for (i=0;i<=3;i++){
			control_button[i].setAttribute("style","display:block;")
		}
		if (x < 0) {x=0;control_button[1].setAttribute("style","display:none;");}
		if (y < 0) {y=0;control_button[0].setAttribute("style","display:none;");}
		if (x > 436) {x=436;control_button[2].setAttribute("style","display:none;");}
		if (y > 268) {y=268;control_button[3].setAttribute("style","display:none;");}
		
		force.setAttribute("style","top:"+y+"px; left:"+x+"px;")
		title[0].innerHTML = "top:"+y+"px; left:"+x+"px;";
	}
}