RestoreFrame('taipeh');

var CLyr, INIT = false;

function Init(lc)
{
 	document.images['gameicon'].src = parent.gameicon.src;
	parent.SetLC(lc);
	if(parent.I4 || parent.N6	&&	parent.SavHash	!=	'#art') top.document.title = document.title;
	if(!parent.N4 && !parent.O5)
	{
		if(parent.I4) CLyr1 = document.all['C1'].style, CLyr2 = document.all['C2'].style;
		else CLyr1 = document.getElementById('C1').style, CLyr2 = document.getElementById('C2').style;
		CButt(parent.game.location.href.lastIndexOf("taipehmain")>0);
	}
	document.forms[0].LVL[parent.GLVL].checked=true;
	INIT = true;
}

function CButt(v)
{
	if(parent.N4 || parent.O5 || !document.getElementById) return;
	
	CLyr1.display = (v) ? 'inline' : 'none';
	CLyr2.display = (v) ? 'inline' : 'none';
}

function CColor(obj,v)
{
	if(obj.style)
	{ 
		obj.style.color = (v) ? '#ffffff' : '#cccccc';
		obj.style.backgroundColor = (v) ? '#00b020' : '#207000';
	}
}

function DoIt(t,work,lc)
{
	if(t.blur) t.blur();
	URLref = (parent.game.location.href.lastIndexOf("taipehmain")>0) ? 'M' : 'H';
	if(URLref=='M') parent.game.Msg();

	switch(work)
	{
		case 'Talk':
		parent.SetLC(lc);
		if(URLref=='H') parent.game.location.replace('taipehhlp'+lc+'.htm?'+parent.game.clyr);
		else parent.game.SL();
		window.location.replace("taipehcnt"+lc+".htm");
		break;

		case 'Help':
		if(URLref!='H') { parent.GPush(); parent.game.location.href = 'taipehhlp'+parent.LCODE+'.htm'; CButt(false); }
		break;

		case 'New':
		parent.GPP = false;
		if(URLref=='M') { parent.game.MList.length = 0; parent.game.Init(false); }
		else parent.game.location.href = 'taipehmain.htm';
		break;

		case 'Restart':
		if(URLref=='M' && parent.game.UList.length) { parent.game.AGAIN = true; parent.game.Init(false); }
		else parent.game.location.href = 'taipehmain.htm';
		break;

		case 'Hint':
		if(URLref=='M' && !parent.game.AUTO && parent.game.MList.length) parent.game.MTip();
		break;

		case 'Auto':
		if(URLref=='M' && !parent.game.AUTO) parent.game.Init(true);
		break;

		case 'Back':
		if(URLref=='M' && !parent.game.AUTO) parent.game.Back();
		break;

		case 'Layout':
		n = (parent.Stil) ? 0 : 2;
		if(URLref=='M') { setTimeout("parent.game.CD("+n+")",600); parent.game.Msg(parent.MSG[5],true); }
		else { parent.SetI(true,n); parent.game.ShowPics(parent.game.clyr); }
		break;
		
		case 'Level':
		parent.GLVL = (document.forms[0].LVL[0].checked==true) ? 0 : 1;
	}
}
