
//=============================================
//=== siebterkontinent interaktive medien	===
//=== http://www.siebterkontinent.de		===
//=== © 2000 siebterkontinent				===
//=============================================

var IE = navigator.appName.indexOf("Microsoft") != -1;
var NS = navigator.appName.indexOf("Netscape") != -1 && navigator.appVersion.substring(0,1) < 5;
var MAC = navigator.platform.indexOf("Mac") != -1;


// ===========================================================================================================
// Einstellungen fuer das follow-Script
var Vel = 0.7;	// Geschwindigkeit
var Acc	= 25;	// Beschleunigung


// ===========================================================================================================
// Definieren der Variablen
var frameHeight	= 0;
var frameWidth 	= 0;
var Pos		= 0;
var PosY	= 0;
var PosP1	= 0;
var sY		= 0;
var cY		= 0;


// ===========================================================================================================
// Initialisierung
function resizeFix() {
	if (NS) { // wenn Fenstergroesse geaendert wurde; reload
		if  ((frameHeight != this.innerHeight) || (frameWidth != this.innerWidth)) {
			location.reload();
			frameHeight = this.innerHeight;
			frameWidth = this.innerWidth;
		}		
	}
	else if (IE) {
		frameHeight = document.body.clientHeight;
		frameWidth = document.body.clientWidth;
	}
	
}


// ===========================================================================================================
// Abfrage welche Funktion aufgerufen werden soll
function startFollow(extraPOS) {
	
	if (IE && !MAC) { posControl_IE(extraPOS); } 
	else if (IE && MAC) { posControl_IEMac(extraPOS); } 
	else if (NS) {
		document.captureEvents(Event.MOUSEMOVE);
		
		frameHeight = this.innerHeight;
		frameWidth = this.innerWidth;

		posControl_NS(extraPOS);
	} else {
		posControl(extraPOS);
	}
}


// ===========================================================================================================
// Hauproutine für Netscape auf WIN und MAC
function posControl_NS(extraPOS) {

		Pos = this.pageYOffset;
		var dY = Pos - PosY;
		sY = Vel * (sY + dY / (Acc-4));
		if ((sY < 0.3 && dY > 0.1) || (sY > -0.3 && dY < -0.1) ) { sY = 0; PosY = Pos;  }
		if (!MAC) {
			var tmp = Pos -PosP1;
			if ((tmp < 200) && (tmp > 0)) { sY = 0; }
			else if ((tmp > -380) && (tmp < 0)) { sY = 0; }
			PosP1 = Pos;
		}
		PosY = PosY + sY;
		document.layers.navi.top = extraPOS+Math.round(PosY);
		resizeFix();
		setTimeout("posControl_NS("+extraPOS+")", 1);
}


// ===========================================================================================================
// Hauproutine für IExplorer auf WIN
function posControl_IE(extraPOS) {

		Pos = document.body.scrollTop;
		var dY = Pos - PosY;
		sY = Vel * (sY + dY / Acc);
		if ((sY < 0.3 && dY > 0.1) || (sY > -0.3 && dY < -0.1) ) { sY = 0; PosY = Pos; }
		var tmp = Pos - PosP1;
		if ((tmp < 400) && (tmp > 0)) { sY = 0; }
		else if ((tmp > -380) && (tmp < 0)) { sY = 0; }	
		PosP1 = Pos;	
		PosY = PosY + sY;
		document.all.navi.style.top = extraPOS+Math.round(PosY);
		resizeFix();
		setTimeout("posControl_IE("+extraPOS+")", 1);
}


// ===========================================================================================================
// Hauproutine für IExplorer auf MAC
function posControl_IEMac(extraPOS) {

		Pos = document.body.scrollTop;		
		var dY = Pos - PosY;
		sY = Vel * (sY + dY / Acc);
		if ((sY < 0.15 && dY >0.15) || (sY > -0.15 && dY < -0.15)) { 
			sY = 0; 
			PosY = Pos; 
		}
		PosY = PosY + sY;
		document.all.navi.style.top = extraPOS+Math.round(PosY);
		resizeFix();
		setTimeout("posControl_IEMac("+extraPOS+")", 1);
}


// ===========================================================================================================
// Hauproutine für alle anderen Browser
function posControl(extraPOS) {

		Pos = window.pageYOffset;
		var dY = Pos - PosY;
		sY = Vel * (sY + dY / Acc);
		if ((sY < 0.3 && dY > 0.1) || (sY > -0.3 && dY < -0.1) ) { sY = 0; PosY = Pos; }
		var tmp = Pos - PosP1;
		if ((tmp < 400) && (tmp > 0)) { sY = 0; }
		else if ((tmp > -380) && (tmp < 0)) { sY = 0; }	
		PosP1 = Pos;	
		PosY = PosY + sY;
		document.getElementById("navi").style.top = extraPOS+Math.round(PosY);
		resizeFix();
		setTimeout("posControl("+extraPOS+")", 1);
}