// frameset.js, muß von der jeweiligen index.html eingeschlossen werden
// Index.html muß drei Variablen belegen:
// topFrameSource, contentFrameSource, bottomFrameSource
// frameset.js registriert FensterGroessenänderungen und ruft danach
// index.html mit den aktuellen Fensterinhalten im QueryString auf.
// Dieser kann in index.html ausgelesen werden.
// Die Argumentennamen sind top, content und bottom. Die Variablen
// topFrameSource, contentFrameSource, bottomFrameSource können dann entsprechnd
// neu belegt werden.

// Groesse des oberen Frames gilt nur fuer netscape--//
//-- changed by e-mojo.de: topMin was 103 --//
var topMin = 130;

//-- Groesse des unteren Frames gilt nur fuer netscape und... --//
//-- Abrage, ob NT und setzen der 16 fuer NT und die 22 fuer andere systeme --//
var bottMin = (isNT()) ? 22 : 28;

function isNT() {
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
}

//--Groesse des fensters bestimmen --//
var win_height = window.innerHeight;
var height_percent = (win_height/100);
var curr_width = window.innerWidth;
var curr_height = window.innerHeight;
var tmpTop = 0;
var tmpBottom = 0;
var allDefined = 0;
var checkTopHeight = true;
var checkBottomHeight = true;
var user_agent = window.navigator.userAgent;
var topName="null";
var middleName="null";
var bottomName="null";

//-- Browserabfrage   --//
function IsIE() {
	//	get browser type
	var Check = 1;
	var Browser = navigator.appName;
	Version = parseInt(navigator.appVersion.substring(0,1));
	if (Browser == "Netscape" && Version < 5) {
		Check = 0;
	}
	return Check;
}

//-- resize check   --//
function startTimeout() {
	timer = setTimeout('checkForResize()',1000);
}

//-- Aufruf der index.html mit entsprechendem Query - String nach Resize   --//
function checkForResize() {
	clearTimeout(timer);
	checkSources();
	if ((window.innerWidth != curr_width) || (window.innerHeight != curr_height)) {
		if ((topName)&&(middleName)&&(bottomName)) {
    		tmpURL=frameset_url+"?top="+topName+"&content="+middleName+"&bottom="+bottomName;
		} else {
			tmpURL=frameset_url;
        }
		window.location.href = tmpURL;
	} else {
		startTimeout();
	}
}

//-- Framesetberechnung fuer netscape --//
if (!IsIE()) {
	for (i = 1; i < 100; i++) {
		if (checkTopHeight) {
			if (Math.floor(height_percent*i) >= topMin) {
				tmpTop = i;
				checkTopHeight = false;
				allDefined++;
			}
		}
		if (checkBottomHeight) {
			if (Math.floor(height_percent*i) >= bottMin) {
				tmpBottom = i;
				checkBottomHeight = false;
				allDefined++;
			}
		}
		if (allDefined == 2) {
		//-- wenn es netscape ist, erscheint dieser term --//        
			document.writeln("<frameset onLoad='checkSources();startTimeout(); ' rows='" + tmpTop + "%,*," + tmpBottom + "%' framespacing=0 frameborder='no' border='0'>");
			document.writeln("<frame src='" + topFrameSource + "' frameborder=0 name='navi' marginwidth=0 marginheight=0 scrolling='no'>");
			document.writeln("<frame src='" + contentFrameSource + "' name='bmwclubcontent' frameborder=0 marginwidth=0 marginheight=0 noresize scrolling='auto'>");
			document.writeln("<frame src='" + bottomFrameSource + "' frameborder=0 name='bottom' marginwidth=0 marginheight=0 scrolling='no'>");
			document.writeln("<\/frameset>");
			i = 100;
		}
	}
} else {
	//-- wenn es explorer ist, erscheint dieser term --//
	//-- changed by e-mojo.de: 1st row height was 105 --//
	document.writeln("<frameset rows='130,*,22' name='Hauptframe' framespacing=0 frameborder='no' border='0'>");
	document.writeln("<frame src='" + topFrameSource + "' frameborder=0 name='navi' marginwidth=0 marginheight=0 scrolling='no'>");
	document.writeln("<frame src='" + contentFrameSource + "' name='bmwclubcontent' frameborder=0 marginwidth=0 marginheight=0 noresize scrolling='auto'>");
	document.writeln("<frame src='" + bottomFrameSource + "' frameborder=0 name='bottom' marginwidth=0 marginheight=0 scrolling='no'>");
	document.writeln("<\/frameset>");
}

//-- Abfrage der aktuellen Fensterinhalte um nicht bei einem rezise auf die index-start-seite zu kommen (netscape)  --//
function checkSources() {
	if (window.frames[0]) {
		topName = window.frames[0].location.href;
	}
	if (window.frames[1]) {
		middleName = window.frames[1].location.href;
	}
	if (window.frames[2]) {
		bottomName = window.frames[2].location.href;
	}
}
