var I4 = false, N4 = false, N6 = false, O5 = false;
if(window.opera) O5 = true, window.defaultStatus = " ";
if(document.all && !O5) I4 = true;
if(document.layers) N4 = true;
if(document.getElementById && !I4) N6 = true;
if(O5 && document.captureEvents && document.contains) O5 = false;

window.onerror = function stopErrors() { return true; }

if((I4 || N6) && top.frames.length>0) top.document.title = document.title;
if(N4) var LHide = "hide", LShow = "show";
else var LHide = "hidden", LShow = "visible";

var SavFlng = parent.frames.length, SavHash = location.hash, SavName = name, SDat = null, Back = 0, Tipps = 0, Id = null, INIT = false;
var gameicon = new Image();
// if(SavHash=='#evamaria' || SavHash=='#frederic') gameicon.src = '../images/icons/'+SavHash.substring(1)+'40x40.gif';
// else 

gameicon.src = 'images/blindekuh.gif';


if(O5) var IWin = '', UWin = '';
else
{
	Iwin = new Image(), Uwin = new Image();
	Iwin.src = 'images/thefinger.gif', Uwin.src = 'images/congratulate.gif';
	var IWin = '<img src="'+Iwin.src+'" width=33 height=15 hspace=2 vspace=2 align=left alt="">';
	var UWin = '<img src="'+Uwin.src+'" width=25 height=27 hspace=2 vspace=2 align=left alt="">';
}

function gotoUrl()
{
	if(SavFlng == 5 && SavHash == "#MAP") URL0 = 'sitemap.htm', POS = 15;
	else if(SavHash=="#REM") URL0 = 'noframes.htm', POS = 0;
		else URL0 = 'mainfram.htm', POS = 0;

	if((SavFlng == 4 || SavFlng == 5) && SavName == "mainframe") parent.index.gotoUrl(URL0,POS,SavHash,'../');
	else if(SavHash=="#REM") top.location.href = '../'+URL0+SavHash;
		else
		{
			if(document.referrer.toLowerCase().indexOf('$index.htm')>0) top.location.href = document.referrer;
			else
			{
				if(SavHash=="#MAP" && SavFlng==0 && SavName=="bysearchrem") top.location.href = '../home.htm';
				else
				{
					if(SavHash=='#games') top.location.href = 'home.htm';
					else if(SavHash=='#evamaria') top.location.href = '../evi/games.htm';
						else if(SavHash=='#frederic') parent.data.location.href = '../frederic/games.htm';
							else
							{
								URLpfx = (document.location.href.toLowerCase().indexOf('file:')<0) ? "http://www.purpurhain.de/" : "../";
								top.location.href = URLpfx + "noframes.htm";
							}
				}
			}
		}
	return false;
}

function SetI(f)
{
	i1 = (SetI.arguments.length==2) ? SetI.arguments[1] : Stil;
	i2 = i1+1;
	IList = Array(i1+'c1',i1+'c2',i1+'c3',i1+'c4',i1+'c5',i1+'c6',i1+'c7',i1+'c8',i1+'c9',
			i1+'b1',i1+'b2',i1+'b3',i1+'b4',i1+'b5',i1+'b6',i1+'b7',i1+'b8',i1+'b9',
			i1+'d1',i1+'d2',i1+'d3',i1+'d4',i1+'d5',i1+'d6',i1+'d7',i1+'d8',i1+'d9',
			i1+'r1',i1+'r2',i1+'r3',
			i1+'w1',i1+'w2',i1+'w3',i1+'w4',
			i1+'fl1',i1+'fl2',i1+'fl3',i1+'fl4',
			i1+'se1',i1+'se2',i1+'se3',i1+'se4',
			i2+'c1',i2+'c2',i2+'c3',i2+'c4',i2+'c5',i2+'c6',i2+'c7',i2+'c8',i2+'c9',
			i2+'b1',i2+'b2',i2+'b3',i2+'b4',i2+'b5',i2+'b6',i2+'b7',i2+'b8',i2+'b9',
			i2+'d1',i2+'d2',i2+'d3',i2+'d4',i2+'d5',i2+'d6',i2+'d7',i2+'d8',i2+'d9',
			i2+'r1',i2+'r2',i2+'r3',
			i2+'w1',i2+'w2',i2+'w3',i2+'w4',
			i2+'fl1',i2+'fl2',i2+'fl3',i2+'fl4',
			i2+'se1',i2+'se2',i2+'se3',i2+'se4');
	Stil = i1;

	if(f)
	{
		imgList = Array();
		for (ix=0;ix<IList.length;ix++)
		{
			imgList[ix] = new Image();
			imgList[ix].src = "images/"+IList[ix]+".gif";
		}
		INIT = true;
	}
}

function SetLC(lc)
{
	LCODE = lc;
	MSG = (lc=='d') ? Array('Bitte warten,<br><br>die Spielsteine werden gesetzt.','Spielstein ist nicht frei!','Ausgewählte Spielsteine passen nicht zusammen!','Spiel-Ende,<br><br>keine freien Steine mehr vorhanden!<br>(Rest:','Gratuliere,<br><br>Du hast gewonnen!','Bitte warten,<br><br>andere Spielsteine werden geladen.','Gewonnen!!!<br><br>Kannst Du das auch?') : Array('Hold on,<br><br>tiles will be placed.','Tile isn\'t free!','Tiles don\'t match!','End of game,<br><br>no more free tiles!<br>(remaining:','Congratulations on winning Taipeh!','Hold on,<br><br>alternate tiles are loaded.','I did it!<br><br>All tiles are removed.');
}

var BList = new Array(), UList = new Array();
var GPP = false;
function GPush()
{
	BList = Array();
	UList = Array();
	BList = game.BList;
	UList = game.UList;
	GPP = true;
}

function GPop()
{
	game.BList = BList;
	game.UList = UList;
	game.AGAIN = true;
}

function SetKeks()
{
	if(navigator.cookieEnabled)
	{
		keks = 'PurpurHain=Taipeh,'+Stil+','+LCODE+','+GLVL;
		expd = new Date();
    	expd.setDate(expd.getDate()+7);
		keks += '; expires='+expd.toGMTString();
		document.cookie = keks;
	}
}

function GetKeks()
{
	if(navigator.cookieEnabled && document.cookie)
	{
		vk = document.cookie.split(',');
		if(vk.length>2 && vk[0]=='PurpurHain=Taipeh')
		{
			if(!isNaN(vk[1])) Stil = 1*vk[1];
			if(vk[2]!='')    LCODE = vk[2].substring(0,1);
			if(!isNaN(vk[3])) GLVL = 1*vk[3];
			if(LCODE!='d') LCODE = 'u';
		}
	}
}

var IList = new Array(), imgList = new Array(), MSG = new Array();
var Stil = 0, LCODE = 'd', GLVL = 0;
GetKeks();
SetI(false,Stil);
SetLC(LCODE);
onunload = SetKeks;

s1 = '<frame name="game" src="taipehinit.htm" scrolling="no" noresize>';
s2 = '<frame name="control" src="taipehcnt'+LCODE+'.htm" scrolling="no" noresize>';
s3 = (SavHash=='#evamaria')? '110,*">'+s2+s1 : '*,110">'+s1+s2;
document.writeln('<frameset frameborder=no border=0 rows="*,0"><frameset frameborder=no border=0 cols="'+s3+'</frameset><frame name="log" src="taipehlog.htm" scrolling="no" noresize></frameset>');
