var siteversion = null;
var cookiename = 'siteversion';
var flashPlayer = null;

function initNeteye() {
	//
	// Check flash availability (version 9 is required)
	//
	flashPlayer = deconcept.SWFObjectUtil.getPlayerVersion();
	siteversion = readCookie(cookiename);

	if (flashPlayer['major'] < 9) {
		if (flashPlayer['major'] > 0) {
			if (siteversion == "text") {
				displayTextVersion();
			} else {
				displayFlashDownloadVersion();
			}
		} else {
			displayTextVersion();
		}
	} else {
		createCookie('siteversion', 'upgrade');
		// full flash version
	}
}

function displayFlashDownloadVersion() {

	createCookie('siteversion', 'upgrade');

	$('#container').remove();
	$('body').addClass('noRequiredFlashVersion').css('background','#000D16');
	$('body').prepend('<div id="flashDownloadTeaser"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" id="flashDownloadLink"></a></div>');
	$('#flashDownloadTeaser').css( {
		background: '#000D16 url(media/images/noflash-fallback.jpg) top left no-repeat',
		width:'975px',
		height:'826px',
		display:'block'
	});
	$('#flashDownloadLink').css( {
		position:'absolute',
		top:'246px',
		left:'384px',
		width:'208px',
		height:'139px',
		display:'block'
	});
	$('#flashDownloadTeaser').append('<a href="#" id="textLink">Zur Textversion</a>');

	$('#textLink').click( function() {
		createCookie('siteversion', 'text');
		// Seite neu laden
		document.location.reload();
		return false;
	});
}
function displayTextVersion() {
	createCookie('siteversion', 'text');

	$('#container').show();
	$('#flashcontent').remove();
	$('html').css('overflow','auto');

	var flashLink = $('#flash-hint a').html();
	var flashHint = 'Für die Vollversion dieser Website'
		+ ' benötigen Sie das Adobe Flash 9 Plugin.'
		+ ' Dieses können Sie '
		+ '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">hier herunterladen</a>.';
		
	if (flashPlayer['major'] > 0) {
		flashHint = flashHint + '<br /><br />Aktuell installierte Version: <code>' + flashPlayer['major'] + '.' + flashPlayer['minor'] + '</code> ';
	}

	$('#flash-hint').html(flashHint);
}

// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions