x=0; 
y=0; 
prevMenu='0';

function checkBrowser() {
    var ua = navigator.userAgent
    if(ua.indexOf('Safari') !=-1 || ua.indexOf('KHTML') !=-1) {
		return 'safari';
    } else if(document.all) {                   //win-e4,win-e5,win-e6
		return 'ie';
    } else if(ua.indexOf('Gecko') !=-1)         //n6,n7,m1
		return 'nav';
}

function getX(obj) { 
	if(obj.offsetParent.tagName != 'BODY') { 
		x += obj.offsetParent.offsetLeft; 
		getX(obj.offsetParent); // BODY °´Ã¼¿¡ ÀÌ¸£±â±îÁö Àç±ÍÈ£ÃâÇÏ¿© offsetLeft°ªÀ» ´©Àû 
	} 
	return x; 
} 

function getY(obj) { 
	if(obj.offsetParent.tagName != 'BODY') { 
		y += obj.offsetParent.offsetTop; 
		getY(obj.offsetParent); // BODY °´Ã¼¿¡ ÀÌ¸£±â±îÁö Àç±ÍÈ£ÃâÇÏ¿© offsetTop°ªÀ» ´©Àû 
	} 
	return y; 
} 

function get_x(obj){ 
	result=getX(obj)+obj.offsetLeft; // »óÀ§°´Ã¼ÀÇ offsetLeftÀÇ ÃÑÇÕ + ÀÚ½ÅÀÇ offsetLeft 
	x=0; // ÃÊ±âÈ­ 
	return result; 
} 

function get_y(obj){ 
	result=getY(obj)+obj.offsetTop; // »óÀ§°´Ã¼ÀÇ offsetTopÀÇ ÃÑÇÕ + ÀÚ½ÅÀÇ offsetTop 
	y=0; // ÃÊ±âÈ­ 
	return result; 
}

function menuover(num) {
	var obj = document.getElementById("topmenu_"+num);

	if(document.getElementById("submenu_"+num)) {
		var subobj = document.getElementById("submenu_"+num);
		var sub_x = get_x(obj);
		subobj.style.display = "block";
		subobj.style.left = sub_x + "px";
	}

	if(document.getElementById("submenu_"+prevMenu)) {
		var prevsubobj = document.getElementById("submenu_"+prevMenu);
		prevsubobj.style.display = "none";
	}

	obj.className = "over";
	prevMenu = num;
}

function menuout(num) {
	var obj = document.getElementById("topmenu_"+num);
	obj.className = "";
}
