// BROWSERCHECK
var version = parseInt(navigator.appVersion);
if (navigator.appName == "Microsoft Internet Explorer" && version == 4) {
	if (/4\.\d+\D+(\d+)\D/.test(navigator.appVersion)) {
		version = RegExp.$1;
	}
}

if(navigator.appName == "Netscape" && version < 5) {
	alert ('please get a newer browser!');
}
else if(navigator.appName == "Microsoft Internet Explorer" && version < 5) {
	alert ('please get a newer browser!');
}

randomColor();
function randomColor() {
//	colorSpace = Math.round((Math.random() * 6));
	if (colorSpace == 'tokyo' || colorSpace == 'newyork') {
		document.write('<style type="text/css"><!-- ');
		document.write('.link {color:#EEBB00;}');
		document.write('#tickerContent {color:#EEBB00;}');
		document.write(' --><\/style>');		
	}
	if (colorSpace == 'berlin') {
		document.write('<style type="text/css"><!-- ');
		document.write('.link {color:#FE1133;}');
		document.write('#tickerContent {color:#FE1133;}');
		document.write(' --><\/style>');		
	}
}

// DEFINE STYLES FOR BLOCK (.PNG)
	if (navigator.appName == "Microsoft Internet Explorer" && navigator.platform == "Win32") {
		document.write('<style type="text/css"><!-- ');
		document.write('#block {z-index:4;position:absolute;top:222px;width:100%;height:183px;background-repeat: no-repeat;background-position:center;');
		document.write('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'grfx/banner_' + colorSpace + '.png\',sizingMethod=\'scale\');');
		document.write('}');
		document.write('.link {cursor: hand;');
		document.write('}');
		document.write(' --><\/style>');
	}
	else {
		document.write('<style type="text/css"><!-- ');
		document.write('#block {z-index:4;position:absolute;top:222px;width:100%;height:183px;background-repeat: no-repeat;background-position:center;');
		document.write('background-image:url(grfx/banner_' + colorSpace + '.png);');
		document.write('}');
		document.write(' --><\/style>');
	}
// ONLOAD/ONRESIZE: GET ACTUAL WINDOW HEIGHT FOR ADJUSTED HEIGHT OF CONTENT-WRAPPER
// INITIALIZE N FOR ADJUSTMENTS
if (window.innerWidth) {
	window.onresize = adjustHeight;
}

function getWindowHeight(){
	if(window.innerHeight != null) {
		return window.innerHeight;
	}
	if (document.body.offsetHeight != null) {
		return document.body.offsetHeight;
	}
	return (null);
}

function getWindowWidth(){
	if(window.innerWidth != null) {
		return window.innerWidth;
	}
	if (document.body.offsetWidth != null) {
		return document.body.offsetWidth;
	}
	return (null);
}

var wrapperHeight = 0;

function adjustHeight() {
	var visibleHeight = getWindowHeight();
	if (document.getElementById('box_content')) {
//	wrapperHeight = visibleHeight-243;
	wrapperHeight = visibleHeight-356;
	}
	if (document.getElementById('box_fullheight')) {
	wrapperHeight = visibleHeight-60;
	}
	document.getElementById('wrap').style.height = wrapperHeight + 'px';
	linkUnder();
}

// ENABLE AND MOVE LINKS OVER BLOCK [NEW TEASER-ELEMENTS HAVE TO BE ADDED MANUALLY SO FAR]
var toCoverList = new Array('berlin', 'tokyo', 'newyork');
var toCover = toCoverList[0];
var i;
function linkUnder() {
	if (document.getElementById('top_link') && navigator.appName == "Microsoft Internet Explorer") {
		document.getElementById('top_link').style.display = 'none';
		for (i = 0; i < toCoverList.length; i++) {
			var toCoverPosTop = 0;
			var toCoverPosLeft = 0;
			var toCoverElement = document.getElementById(toCoverList[i]);
			if (toCoverElement.offsetParent) {
				while (toCoverElement.offsetParent) {
					toCoverPosTop += toCoverElement.offsetTop;
					toCoverPosLeft += toCoverElement.offsetLeft;
					toCoverElement = toCoverElement.offsetParent;
				}
			}
			else if (toCoverElement.y) toCoverPosTop += toCoverElement.y;
			if (toCoverPosTop-292 >= 40 && toCoverPosTop-292 <= 110) {
				toCover = toCoverList[i];
				toCoverPosTop = toCoverPosTop-292-64;
				linkUnderPosition(toCoverPosTop,toCoverPosLeft);
			}
		}
	}
	else if (document.getElementById('top_link')) {
		document.getElementById('top_link').style.display = 'none';
		for (i = 0; i < toCoverList.length; i++) {
			if (document.getElementById(toCoverList[i]).offsetTop >= 40 && document.getElementById(toCoverList[i]).offsetTop <= 110) {
				toCover = toCoverList[i];
				toCoverPosTop = document.getElementById(toCover).offsetTop-64;
				toCoverPosLeft = document.getElementById(toCover).offsetLeft;
				linkUnderPosition(toCoverPosTop,toCoverPosLeft);
			}
		}
	}
}

function linkUnderPosition(top,left) {
		document.getElementById('top_link').style.marginTop = top + 'px';
		document.getElementById('top_link').style.marginLeft = left + 'px';
		document.getElementById('top_link1').width = document.getElementById(toCover).width;
		if (!document.getElementById(toCover + '_video')) {
			document.getElementById('top_link2').style.visibility = 'hidden';
		}
		else if (document.getElementById(toCover + '_video')) {
			document.getElementById('top_link2').style.visibility = 'visible';
		}
		document.getElementById('top_link').style.display = 'block';
		document.getElementById('top_link').style.visibility = 'visible';
}

// LOAD CONTENTS
function loadContent(what) {
	if (what.slice(0,what.length-2) == 'underlinks' && what.slice(what.length-1,what.length) != '3') {
		what = toCover + what.slice(what.length-1,what.length);
		window.location.href = what + '.html';
	}
	else if (what.slice(what.length-1,what.length) == '3') {
		if (what.slice(0,what.length-2) == 'underlinks') what = toCover + what.slice(what.length-1,what.length);
		window.location.href = what + '.html';
		colorSpace = what.slice(0,what.length-1);
		video = window.open(colorSpace + '_video.html', 'VIDEO' ,'width=360,height=307,top=150,left=150,resizable=no,scrollbars=no');
		video.focus();
	}
	else window.location.href = what + '.html';
}

// DRAGABLE CONTENT
// Based on script source: CodeLifter.com, Copyright 2003

var isIE = document.all;
var isHot = false;
var ddEnabled = false;
var topDoc;
var whichDoc;
var hotDoc;
var offsetX;
var offsetY;
var nowX;
var nowY;
var actualPositionY = '0px';

function ddInit(e){
	topDoc = isIE ? "BODY" : "HTML";
	whichDoc = isIE ? document.all.content : document.getElementById("content");
	hotDoc = isIE ? event.srcElement : e.target;
	while (hotDoc.id != "wrap" && hotDoc.id != "block" && hotDoc.id != "box_content" && hotDoc.id != "box_fullheight" && hotDoc.tagName != topDoc){
		hotDoc = isIE ? hotDoc.parentElement : hotDoc.parentNode;
		ddEnabled = false;
	}
//	if (hotDoc.id == "wrap" && isHot == true){
	if (isHot == true){
		offsetX = isIE ? event.clientX : e.clientX;
		offsetY = isIE ? event.clientY : e.clientY;
		nowX = parseInt(whichDoc.style.left);
		nowY = parseInt(whichDoc.style.top);
		ddEnabled = true;
		document.onmousemove = dd;
	}
/*	else if (hotDoc.id == "block" && isHot == true){
		offsetX = isIE ? event.clientX : e.clientX;
		offsetY = isIE ? event.clientY : e.clientY;
		nowX = parseInt(whichDoc.style.left);
		nowY = parseInt(whichDoc.style.top);
		ddEnabled = true;
		document.onmousemove = dd;
	}
*/
}

function dd(e){
	if (!ddEnabled) return;
	document.getElementById('content').style.marginTop = isIE ? event.clientY+eval(actualPositionY.slice(0,actualPositionY.length-2))-offsetY + 'px' : e.clientY+eval(actualPositionY.slice(0,actualPositionY.length-2))-offsetY + 'px';
}

function safeExit(e) {
	if (ddEnabled) {
		actualPositionY = isIE ? event.clientY+eval(actualPositionY.slice(0,actualPositionY.length-2))-offsetY + 'px' : e.clientY+eval(actualPositionY.slice(0,actualPositionY.length-2))-offsetY + 'px';
		ddEnabled = false;
		linkUnder();
	}
}

document.onmousedown = ddInit;
document.onmouseup = safeExit;

// TICKER
var tickerPos = 1;
var maxTickerLength = 3000;

// START OF EDITABLE (CHANGE OF TEXT-MESSAGE)
//var tickerText = '05/06/14 THE JOKER LICENSED HIS PERFORMANCE TO AKTION \'05 OF GERMAN UNION VER.DI YOUTH ORGANISATION';
var tickerText = 'IEPE LICENSED HIS PERFORMANCE TO THE GERMAN UNION VERDI YOUTH ORGANISATION +++ JOKER ADVISED PLATOON.ORG ON THEIR CAMPAGNE AKTION05';
//IEPE LICENSED HIS PERFORMANCE TO THE GERMAN UNION VERDI YOUTH ORGANISATION (link auf aktion05.de) +++ JOKER ADVISED PLATOON.ORG ON THEIR CAMPAGNE AKTION05  +++ (link auf platoon.org)
// END OF EDITABLE

function ticker() {
	document.getElementById('tickerContent').innerHTML = '<nobr>+++&nbsp;' + tickerText + '&nbsp;+++&nbsp;' + tickerText + '&nbsp;';
	tickerScroll();
}

function tickerScroll() {
	if (tickerPos <= (document.getElementById('tickerContent').innerHTML.length*5)-700) {
		document.getElementById('tickerContent').style.marginLeft = -tickerPos + 'px';
	}
	if (tickerPos > (document.getElementById('tickerContent').innerHTML.length*5)-700 && tickerPos <= maxTickerLength) {
		document.getElementById('tickerContent').style.marginLeft = -tickerPos + 'px';
		document.getElementById('tickerContent').innerHTML = document.getElementById('tickerContent').innerHTML + '<nobr>+++&nbsp;' + tickerText + '&nbsp;';
	}
	else if (tickerPos >= maxTickerLength) {
		tickerPos = 1;
		document.getElementById('tickerContent').innerHTML = '<nobr>+++&nbsp;' + tickerText + '&nbsp;+++&nbsp;' + tickerText + '&nbsp;';
		document.getElementById('tickerContent').style.marginLeft = -tickerPos + 'px';
	}
	tickerPos = tickerPos + 1;
	setTimeout('tickerScroll()',83);
	return;
}