// 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" && navigator.userAgent.indexOf("Netscape") != -1 && version < 5) {
	window.location.href = 'browser.html';
}
// UPDATE BROWSERCHECK FOR IE8
//else if(navigator.userAgent.indexOf("MSIE 6.0") != -1 || navigator.userAgent.indexOf("MSIE 6.0") != -1 || navigator.userAgent.indexOf("MSIE 7.0") != -1 || navigator.userAgent.indexOf("MSIE 8.0") != -1) {
//	alert(navigator.userAgent+' '+version);
//}
else if(navigator.platform == "Win32" && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Opera") == -1) {
//	if (Microsoft.AlphaImageLoader.enabled != true || version < 5) {
	if (version < 5) {
		window.location.href = 'browser.html';
	}
}
else if(navigator.platform == "MacPPC" && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Opera") == -1) {
	window.location.href = 'browser.html';
}

var pngElements = new Array('c2Sub0','c2Sub1','c2Sub2','c2Sub3','c3Sub0','c3Sub1','c3Sub2','c3Sub3','c6Sub0','c6Sub1','c6Sub2','c6Sub3','c6Sub4','videoLayer');
// LAYOUT ADJUSTED FOR IE-PC
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1) {
	document.write('<style type="text/css"><!-- ');
	document.write('#contentContainer {width:930px;height:593px;}.clearFloat {margin:-2px;}');
	for (var i = 0; i < pngElements.length; ++i) {
		if(pngElements[i].slice(2,6) == 'Sub0') {
			document.write('#' + pngElements[i] + ' {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'./fileadmin/templates/grfx/subnav_bg0.png\',sizingMethod=\'image\');width:13px;height:16px;margin-left:2px;background-repeat:no-repeat;background-position:5px 0px;}');
		}
		else if(pngElements[i] == 'videoLayer') {
			document.write('#' + pngElements[i] + ' {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'./fileadmin/templates/grfx/videobg.png\',sizingMethod=\'scale\');}');
		}
		else {
			document.write('#' + pngElements[i] + ' {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'./fileadmin/templates/grfx/subnav_bg1.png\',sizingMethod=\'scale\');height:16px;padding:3px 4px 3px 0px;background-repeat:repeat-x;background-position:0px 0px;}');
			document.write('.pipe {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'./fileadmin/templates/grfx/subnav_bg1.png\',sizingMethod=\'scale\');height:16px;width:6px;padding:2px 2px 2px 2px;background-repeat:repeat-x;background-position:0px 0px;}');
		}
	}
	document.write(' --><\/style>');
}
else {
	for (var j = 0; j < pngElements.length; ++j) {
		document.write('<style type="text/css"><!-- ');
		if(pngElements[j].slice(2,6) == 'Sub0') {
			document.write('#' + pngElements[j] + ' {background-image:url(./fileadmin/templates/grfx/subnav_bg0.png);width:18px;height:30px;background-repeat:no-repeat;background-position:5px 0px;}');
		}
		else if(pngElements[j] == 'videoLayer') {
			document.write('#' + pngElements[j] + ' {background-image:url(./fileadmin/templates/grfx/videobg.png);width:100%;height:100%;}');
		}
		else {
			document.write('#' + pngElements[j] + ' {background-image:url(./fileadmin/templates/grfx/subnav_bg1.png);height:14px;padding:4px 4px 3px 0px;background-repeat:repeat-x;background-position:0px 0px;}');
			document.write('.pipe {background-image:url(./fileadmin/templates/grfx/subnav_bg1.png);height:14px;width:6px;padding:3px 2px 2px 2px;background-repeat:repeat-x;background-position:0px 0px;}');
		}
		document.write(' --><\/style>');
	}
}

// ONLOAD/ONRESIZE: GET ACTUAL WINDOW HEIGHT FOR ADJUSTED POSITION OF CONTENT & INITIALIZE N FOR ADJUSTMENTS
function getWindowHeight(){
	if (window.innerHeight) return window.innerHeight;
	else if(document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	}
	else if (document.body && document.body.offsetHeight) {
		return document.body.offsetHeight-4; // IE QUIRKS-MODE?
	}
	return (null);
}

function getWindowWidth(){
	if(window.innerWidth) { // STILL NEEDED FOR WHICH BROWSER/VERSION?
		return window.innerWidth;
	}
	else if(document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	}
	else if(document.body && document.body.offsetWidth) {
		return document.body.offsetWidth-4; // IE QUIRKS-MODE?
	}
	return (null);
}

function adjustPos() {
	var topBottom = getWindowHeight();
	var leftRight = getWindowWidth();
	var safetyDist = 1;
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1) {
		safetyDist = safetyDist + 4;
	}
	var topDist = (topBottom-596)/2;
	if(topDist < 10) topDist = 10;
	var leftDist = (leftRight-parseInt(document.getElementById('wrapper').style.width))/2;
	if(leftDist < 10) leftDist = 10;

	document.getElementById('wrapper').style.top = topDist + 'px';
	document.getElementById('wrapper').style.left = leftDist + 'px';
	if(document.getElementById('overLay')) {
		document.getElementById('overLay').style.top = (topDist+1) + 'px';
		document.getElementById('overLay').style.left = (leftDist+406) + 'px';
	}
	if (activeContent == 'c2b' && document.getElementById('contentScrollH504Motion')) {
		document.getElementById('wrapper').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('navContainer').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('contentContainer').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('contentScrollH504Motion').style.height = (topBottom-topDist-80-7-safetyDist)+'px';
		document.getElementById('thumbContainer').style.height = document.getElementById('contentScrollH504Motion').style.height;
//		if(document.getElementById('insertVideo')) {
		if(movieWidth) { // IF MOVIE IS DEFINED
			document.getElementById('insertVideo').style.marginLeft = (getWindowWidth()-movieWidth)/2+'px';
			document.getElementById('insertVideo').style.marginTop = (getWindowHeight()-movieHeight)/2+'px';
		}
	}
	else if (activeContent == 'c2b' && document.getElementById('contentScrollH302Motion')) {
		document.getElementById('wrapper').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('navContainer').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('contentContainer').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('contentScrollH302Motion').style.height = (topBottom-topDist-80-111-22-safetyDist-50)+'px';
		document.getElementById('thumbContainer').style.height = document.getElementById('contentScrollH302Motion').style.height;
//		if(document.getElementById('insertVideo')) {
		if(movieWidth) { // IF MOVIE IS DEFINED
			document.getElementById('insertVideo').style.marginLeft = (getWindowWidth()-movieWidth)/2+'px';
			document.getElementById('insertVideo').style.marginTop = (getWindowHeight()-movieHeight)/2+'px';
		}
	}
	else if (activeContent != 'c1w' && document.getElementById('contentScrollH504')) {
		document.getElementById('wrapper').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('navContainer').style.height = (topBottom-topDist-safetyDist)+'px';
//		if(document.getElementById('topOfButtonRightBuy')) document.getElementById('topOfButtonRightBuy').style.height = (topBottom-topDist-80-7-safetyDist-50)+'px';
//		if(document.getElementById('topOfButtonRightCart')) document.getElementById('topOfButtonRightCart').style.height = (topBottom-topDist-80-7-safetyDist-50)+'px';
		document.getElementById('contentContainer').style.height = (topBottom-topDist-safetyDist)+'px';
		document.getElementById('contentScrollH504').style.height = (topBottom-topDist-80-7-safetyDist)+'px';
		if(document.getElementById('thumbContainer')) document.getElementById('thumbContainer').style.height = document.getElementById('contentScrollH504').style.height;
	}
	else if(activeContent == 'c1w' && document.getElementById('contentScrollW442')) {
		document.getElementById('thumbContainer').style.height = document.getElementById('contentScrollW442').style.height;
	}
	// C2SUB > MOTION
	document.getElementById('c2Sub').style.top = (topDist+183) + 'px';
	document.getElementById('c2Sub').style.left = (leftDist+22) + 'px';
	// C3SUB > SHOP
	document.getElementById('c3Sub').style.top = (topDist+287) + 'px';
	document.getElementById('c3Sub').style.left = (leftDist+22) + 'px';
	// C6SUB > ABOUT
	document.getElementById('c6Sub').style.top = (topDist+354) + 'px';
	document.getElementById('c6Sub').style.left = (leftDist+22) + 'px';
	if(document.getElementById('issueBanner')) {
		document.getElementById('issueBanner').style.top = (topDist+30) + 'px';
		document.getElementById('issueBanner').style.left = (leftDist+777) + 'px';
	}

	// ANPASSUNG SCROLLING AN VERÄNDERTE CONTENTCONTAINERHÖHE
	if(viewPort) {
		document.getElementById('contentToScroll').style.top = '0px';
		document.getElementById('thumb').style.top = '0px';
		contentTopCache = 0; // reset cache for contenTop
		contentHeightCache = 0; // reset cache for contenHeight
		thumbTopCache = 0; // reset cache for thumbTop
		thumbHeightCache = 0; // reset cache for thumbHeight
		resetScroll(viewPort);
	}
}
// LOAD CONTENTS
function loadContent(what) {
	window.location.href = what;
}

var activeContent;
function goTo(what,state,sub,content) {
	if (content) activeContent = content;
	if (activeContent == 'c2b') {
		if(state == 'over') {
		if(sub) {
			if(what.slice(2,5) == 'Sub') what = what.slice(0,2)+'b';
			document.getElementById(what.slice(0,2) + 'Sub').style.display = 'block';
			document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
		}
		else {
			document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
		}
	}
		else if(state=='out') {
		if(sub) {
			if(what.slice(2,5) == 'Sub') what = what.slice(0,2)+'b';
//			document.getElementById('outPut').innerHTML = what + ' =? ' + activeContent;
			document.getElementById(what.slice(0,2) + 'Sub').style.display = 'none';
			if(activeContent == what) {
				document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
			}
			else document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '.png';
		}
		else if(activeContent == what) {
			document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
		}
		else document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '.png';
	}
	}
	else {
		if(state == 'over') {
			if(sub) {
				if(what.slice(2,5) == 'Sub') what = what.slice(0,2)+'w';
				document.getElementById(what.slice(0,2) + 'Sub').style.display = 'block';
				document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
			}
			else {
				document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
			}
		}
		else if(state=='out') {
			if(sub) {
				if(what.slice(2,5) == 'Sub') what = what.slice(0,2)+'w';
	//			document.getElementById('outPut').innerHTML = what + ' =? ' + activeContent;
				document.getElementById(what.slice(0,2) + 'Sub').style.display = 'none';
				if(activeContent == what) {
					document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
				}
				else document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '.png';
			}
			else if(activeContent == what) {
				document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '_1.png';
			}
			else document.getElementById(what).src = './fileadmin/templates/grfx/' + what + '.png';
		}
	}
}

function checkUserLevel() {
/*	if(document.getElementById('tx-srfeuserregister-pi1-name') && document.getElementById('tx-srfeuserregister-pi1-address') && document.getElementById('tx-srfeuserregister-pi1-city') && document.getElementById('tx-srfeuserregister-pi1-zip') && document.getElementById('tx-srfeuserregister-pi1-static_info_country')) {
		if(document.getElementById('tx-srfeuserregister-pi1-name').value != '' && document.getElementById('tx-srfeuserregister-pi1-address').value != '' && document.getElementById('tx-srfeuserregister-pi1-city').value != '' && document.getElementById('tx-srfeuserregister-pi1-zip').value != '' && document.getElementById('tx-srfeuserregister-pi1-static_info_country').value != '') {
			document.getElementById('tx-srfeuserregister-pi1-usergroup').value = 4;
		}
	}
	else {
		document.getElementById('tx-srfeuserregister-pi1-usergroup').value = 3;
	}
	alert(document.getElementById('tx-srfeuserregister-pi1-usergroup').value);
*/
}

/*function hand(theId) {
	if (document.all) {
		document.all(theId).style.cursor ='hand';
	}
	else {
		document.getElementById(theId).style.cursor ='pointer';
	}
}*/