/*
============================================================
	Menu
============================================================
*/
var _path;
var _startLoad = 0;
var _menuItem = new Array();
var _btnItem = new Array();

function menuPreload(path) {
	_path = path;

	_menuItem[0] = new Image(); _menuItem[0].src = _path + 'img/menu_home_off.gif';
	_menuItem[1] = new Image(); _menuItem[1].src = _path + 'img/menu_home_on.gif';
	_menuItem[2] = new Image(); _menuItem[2].src = _path + 'img/menu_contents1_off.gif';
	_menuItem[3] = new Image(); _menuItem[3].src = _path + 'img/menu_contents1_on.gif';
	_menuItem[4] = new Image(); _menuItem[4].src = _path + 'img/menu_contents2_off.gif';
	_menuItem[5] = new Image(); _menuItem[5].src = _path + 'img/menu_contents2_on.gif';
	_menuItem[6] = new Image(); _menuItem[6].src = _path + 'img/menu_contents3_off.gif';
	_menuItem[7] = new Image(); _menuItem[7].src = _path + 'img/menu_contents3_on.gif';
	_menuItem[8] = new Image(); _menuItem[8].src = _path + 'img/menu_contents4_off.gif';
	_menuItem[9] = new Image(); _menuItem[9].src = _path + 'img/menu_contents4_on.gif';
	_menuItem[10] = new Image(); _menuItem[10].src = _path + 'img/menu_contents5_off.gif';
	_menuItem[11] = new Image(); _menuItem[11].src = _path + 'img/menu_contents5_on.gif';
	_menuItem[12] = new Image(); _menuItem[12].src = _path + 'img/menu_contents6_off.gif';
	_menuItem[13] = new Image(); _menuItem[13].src = _path + 'img/menu_contents6_on.gif';
	_menuItem[14] = new Image(); _menuItem[14].src = _path + 'img/menu_contents7_off.gif';
	_menuItem[15] = new Image(); _menuItem[15].src = _path + 'img/menu_contents7_on.gif';

	if (_path == './') {
		_btnItem[0] = new Image(); _btnItem[0].src = _path + 'img/b_go_off.gif';
		_btnItem[1] = new Image(); _btnItem[1].src = _path + 'img/b_go_on.gif';
		_btnItem[2] = new Image(); _btnItem[2].src = _path + 'img/b_study_off.gif';
		_btnItem[3] = new Image(); _btnItem[3].src = _path + 'img/b_study_on.gif';
		_btnItem[4] = new Image(); _btnItem[4].src = _path + 'img/b_walk_off.gif';
		_btnItem[5] = new Image(); _btnItem[5].src = _path + 'img/b_walk_on.gif';
		_btnItem[6] = new Image(); _btnItem[6].src = _path + 'img/b_experience_off.gif';
		_btnItem[7] = new Image(); _btnItem[7].src = _path + 'img/b_experience_on.gif';
		_btnItem[8] = new Image(); _btnItem[8].src = _path + 'img/b_play_off.gif';
		_btnItem[9] = new Image(); _btnItem[9].src = _path + 'img/b_play_on.gif';
		_btnItem[10] = new Image(); _btnItem[10].src = _path + 'img/b_buy_off.gif';
		_btnItem[11] = new Image(); _btnItem[11].src = _path + 'img/b_buy_on.gif';
		_btnItem[12] = new Image(); _btnItem[12].src = _path + 'img/b_eat_off.gif';
		_btnItem[13] = new Image(); _btnItem[13].src = _path + 'img/b_eat_on.gif';
	}

	_startLoad = 1;
}

function menuRoll(imgName, num) {
	if (_startLoad == 1) {
		if (document.images) document.images[imgName].src=_menuItem[num].src;
	}
}

function btnRoll(imgName, num) {
	if (_path == './' && _startLoad == 1) {
		if (document.images) document.images[imgName].src=_btnItem[num].src;
	}
}


/*
============================================================
	Random Top Image
============================================================
*/
function randTopImage() {
	var topImages = new Array();
	for (var _i = 0; _i < 3; _i ++) {
		if (_i > 0) {
			topImages[_i] = './topMessage/files/topImage_' + (_i + 1) + '.jpg';
		} else {
			topImages[_i] = './topMessage/files/topImage.jpg';
		}
	}
	var topImageSrc = topImages[Math.floor(Math.random() * 3)];
	var topImageHtml = '<img src="' + topImageSrc + '" width="780" height="282" alt="Moat-encircled Village" border="0" />';

	document.write(topImageHtml);
}


/*
============================================================
	Page Top
============================================================
*/
function WinDisIE(){
	var Ypix = document.body.scrollTop || document.documentElement.scrollTop;

	return Ypix;
}

function WinDisNN(){
	Ypix = window.pageYOffset;
	return Ypix;
}

function pageTop() {
	if (navigator.appName.charAt(0) == 'N') {
		Ypix = WinDisNN();
	} else {
		Ypix = WinDisIE();
	}

	var disY = (Ypix - (Ypix / 10));
	disY = Math.floor(disY);
	if (disY > 0) {
		window.scrollTo(0, disY);
		setTimeout('pageTop()', 10);
		clearTimeout();
	} else {
		clearTimeout();
	}
}


/*
============================================================
	Pop Up
============================================================
*/
function openPop(fi, na, w, h) {
	window.open(fi,na,'width=' + w + ',height=' + h + ',left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,favorites=no,resizable=yes').focus();
}


/*
============================================================
	Window Close
============================================================
*/
function window_close() {
	window.opener = window;
	var win = window.open(location.href, '_self');
	win.close();
}


/*
============================================================
	Window Print
============================================================
*/
function window_print() {
	window.print()
}
