var flag_state = '';

function start()
{
	if (document.getElementById("link1") != null)
	{
		document.getElementById("link1").href = "#";
	}
	if (document.getElementById("link2") != null)
	{
		document.getElementById("link2").href = "#";
	}
	if (document.getElementById("link3") != null)
	{
		document.getElementById("link3").href = "#";
	}
	t_minus();

	if (top != self)
	{
		top.location = self.location;
	}
}

function Popup(i, j, game_url)
{
	myElement = document.getElementById("ce");
	if (myElement != null)
	{
		var hilfe = "<div class=\"popup3\"><iframe frameborder=\"0\" id=\"Frame\" src=\"" + game_url + "manual.php?typ=" + i + "&s=" + j + "\" width=\"412\" height=\"440\" border=\"0\"></iframe></div><a href=\"#\" onClick=\"Close()\"><img src=\"img/un/x.gif\" border=\"1\" class=\"popup4\" alt=\"Close\"></a>";
		myElement.innerHTML = hilfe;
	}
}

function Close()
{
	myElement = document.getElementById("ce");
	if (myElement != null)
	{
		myElement.innerHTML = '';
	}
}



var dom = document.getElementById ? 1 : 0;
var ie = document.all ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") > -1) ? 1 : 0;
var ieReal = (ie && (!mac) && (typeof (window.offscreenBuffering) != 'undefined')) ? 1 : 0;
var isActiveX = ieReal;
var isSp2 = ieReal && (window.navigator.userAgent.indexOf("SV1") != -1);

function changeOpacity(obj, opacity)
{
	if (ieReal)
	{
		obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (opacity * 100) + ')';
	}
	else if (dom)
	{
		obj.style.MozOpacity = opacity;
		// obj.style.opacity = opacity;
	}
}

// Lagerbestand wird hoch gez&auml;hlt












function t_minus()
{
	// Zeit wird herunter gezaehlt
	for (i = 1;; i++)
	{
		myElement = document.getElementById("timer" + i);
		if (myElement != null)
		{
			sek = t_format1(myElement) - 1;
			if (sek < 0)
			{
				setTimeout("document.location.reload()", 1000);
			}
			else
			{
				sek = t_format2(sek);
				myElement.innerHTML = sek;
			}
		}
		else
		{
			break;
		}
	}
	setTimeout("t_minus()", 1000);
}

function t_format1(myElement)
{
	// 00:01:30 wird zu 90s umformatiert
	p = myElement.innerHTML.split(":");
	sek = p[0] * 3600 + p[1] * 60 + p[2] * 1;
	return sek;
}

function t_format2(s)
{
	// 90s wird zu 00:01:30 umformatiert
	if (s > -1)
	{
		stunden = Math.floor(s / 3600);
		minuten = Math.floor(s / 60) % 60;
		sekunden = s % 60;
		t = stunden + ":";
		if (minuten < 10)
		{
			t += "0";
		}
		t += minuten + ":";
		if (sekunden < 10)
		{
			t += "0";
		}
		t += sekunden;
	}
	else
	{
		t = "0:00:0?";
	}
	return t;
}



// Ajax
var http_request = false;

function macheRequest(url, name)
{

	http_request = false;

	if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
			// zu dieser Zeile siehe weiter unten
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
			}
		}
	}

	if (!http_request)
	{
		alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
		return false;
	}
	http_request.onreadystatechange = function()
	{
		changeInhalt(name);
	};
	http_request.open('GET', url, true);
	http_request.send(null);

}

function changeInhalt(name)
{

	if (http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{
			// alert(http_request.responseText);
			myElement = document.getElementById(name);
			if (myElement != null)
			{
				myElement.innerHTML = http_request.responseText;
			}

		}
		else
		{
			alert('Bei dem Request ist ein Problem aufgetreten.');
		}
	}
}
// End Ajax

