function rollOver(obj,image) {
	if (document.images) {
		var reg = new RegExp("newsletter.therme-geinberg.at", "i")
		if (document.location.href.match(reg)) {
			document[obj].src = "http://www.therme-geinberg.at"+image;
		} else {
			document[obj].src = image;
		}
	}
}

function resetImages() {
	var reg = new RegExp("newsletter.therme-geinberg.at", "i");
	if (document.location.href.match(reg)) {
		document['Aktuell'].src = 'http://www.therme-geinberg.at/imperia/_img/nav_top_aktuell.gif';
		document['Shop'].src = 'http://www.therme-geinberg.at/imperia/_img/nav_top_shop.gif';
		document['Info'].src = 'http://www.therme-geinberg.at/imperia/_img/nav_top_info.gif';
		document['Kontakt'].src = 'http://www.therme-geinberg.at/imperia/_img/nav_top_kontakt.gif';
	} else {
		document['Aktuell'].src = '/imperia/_img/nav_top_aktuell.gif';
		document['Shop'].src = '/imperia/_img/nav_top_shop.gif';
		document['Info'].src = '/imperia/_img/nav_top_info.gif';
		document['Kontakt'].src = '/imperia/_img/nav_top_kontakt.gif';
	}
}

// subnav slide menu
var state = new Object;
state.Aktuell = 0;
state.Shop = 0;
state.Info = 0;
state.Kontakt = 0;

function toggleMenu(obj) {
	if (!obj) {
		resetAllSliders();
	} else {
		var objState = obj.substring(7,obj.length);
		if (state[objState] == 1) {
			//state[objState] = 0;
			//slideup(obj, -55);
			//resetAllSliders();
		} else {
			var status = checkAllSliders();
			if (status) {
				instantSwitchSliders(obj);
			} else {
				slidedown(obj, 65);
			}
			state[objState] = 1;
			rollOver(objState,'/imperia/_img/nav_top_'+objState+'_on.gif');
		}
	}
}

function checkAllSliders() {
	var on;
	if (state.Aktuell == 1) {
		on = true;
	}
	if (state.Shop == 1) {
		on = true;
	}
	if (state.Info == 1) {
		on = true;
	}
	if (state.Kontakt == 1) {
		on = true;
	}
	if (on) {
		return true;
	} else {
		return false;
	}
}

function instantSwitchSliders(obj) {
	state.Aktuell = 0;
	state.Shop = 0;
	state.Info = 0;
	state.Kontakt = 0;
	document.getElementById('slider-Aktuell').style.top = "-55px";
	document.getElementById('slider-Shop').style.top = "-55px";
	document.getElementById('slider-Info').style.top = "-55px";
	document.getElementById('slider-Kontakt').style.top = "-55px";
	document.getElementById(obj).style.top = "65px";
	resetSubnavLinks();
	resetSubnavLayers();
	resetImages();
}

function resetSliders() {
	if (state.Aktuell == 1) {
		document.getElementById('slider-Aktuell').style.top = "-55px";
		state.Aktuell = 0;
	}
	if (state.Shop == 1) {
		document.getElementById('slider-Shop').style.top = "-55px";
		state.Shop = 0;
	}
	if (state.Info == 1) {
		document.getElementById('slider-Info').style.top = "-55px";
		state.Info = 0;
	}
	if (state.Kontakt == 1) {
		document.getElementById('slider-Kontakt').style.top = "-55px";
		state.Kontakt = 0;
	}
}

function resetAllSliders() {
	//alert('we start teh dance');
	slideup('slider-Shop',-55);
	state.Shop = 0;
	slideup('slider-Aktuell',-55);
	state.Aktuell = 0;
	slideup('slider-Info',-55);
	state.Info = 0;
	slideup('slider-Kontakt',-55);
	state.Kontakt = 0;
	if ((document.getElementById('slider-top')) && (document.getElementById('slider-top').style.display == 'block')) {
		document.getElementById('slider-top').style.display =  'none';
	}
	if ((document.getElementById('slider-bottom')) && (document.getElementById('slider-bottom').style.display == 'block')) {
		document.getElementById('slider-bottom').style.display =  'none';
	}
	resetSubnavLinks();
	resetSubnavLayers();
	resetImages();
}

function slideup(obj, endpos) {
	if (window.down) {
		clearTimeout(down);
	}
	var decrease = 10;
	if (document.getElementById(obj)) {
		var el = document.getElementById(obj).style;
		var top = parseInt(el.top);
		if (top > endpos) {
			top -= decrease;
			el.top = top + "px";
			var up = setTimeout("slideup('" + obj + "'," + endpos + ")",3);
		}
	}
}

function slidedown(obj, endpos) {
	if (window.up) {
		clearTimeout(up);
	}
	var increase = 5;
	if (document.getElementById(obj)) {
		var el = document.getElementById(obj).style;
		var top = parseInt(el.top);
		if (top < endpos) {
			top += increase;
			el.top = top + "px";
			var down = setTimeout("slidedown('" + obj + "'," + endpos + ")",3);
		} else {
			if (document.getElementById('slider-top')) {
				document.getElementById('slider-top').style.display =  'block';
			}
			if (document.getElementById('slider-bottom')) {
				document.getElementById('slider-bottom').style.display =  'block';
			}
			//alert("you are a good chap");
		}
	}
}

function toggleSubnav(obj,status,parent) {
	var test = obj.split("_");;
	var str = '';
	if (document.all) {
		for (var i=0;i<document.all.length;i++) {
			if ((document.all[i].id) && (document.all[i].id.match(test[0]))) {
				document.getElementById(document.all[i].id).style.display = 'none';
			}
		}
	} else {
		for (var j=0;j<document.getElementsByTagName('div').length;j++) {
			if ((document.getElementsByTagName('div')[j].id) && (document.getElementsByTagName('div')[j].id.match(test[0]))) {
				document.getElementById(document.getElementsByTagName('div')[j].id).style.display = 'none';
			}
		}
	}
	if ((status == 'on') && (document.getElementById(obj))) {
		document.getElementById(obj).style.display = 'block';
	}
	resetSubnavLinks();
	document.getElementById(parent).className = 'subnav-link-on';
}

function resetSubnavLinks() {
	for (var i=0;i<document.getElementsByTagName('div').length;i++) {
		if ((document.getElementsByTagName('div')[i].className) && (document.getElementsByTagName('div')[i].className.match('subnav-link-on'))) {
			document.getElementById(document.getElementsByTagName('div')[i].id).className = 'subnav-link';
		}
	}
}

function resetSubnavLayers() {
	for (var i=0;i<document.getElementsByTagName('div').length;i++) {
		if ((document.getElementsByTagName('div')[i].id) && (document.getElementsByTagName('div')[i].className.match('sub-subnav-box'))) {
			document.getElementsByTagName('div')[i].style.display = 'none';
		}
	}
}

function hideHelp() {
	document.getElementById('bg-switcher-help').style.display = 'none';
}

function showHelp() {
	document.getElementById('bg-switcher-help').style.display = 'block';
}

function getWindowSize() {
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		//alert(myWidth);
	} else {
		if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		} else {
			if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
			}
		}
	}
	return (myWidth);
}

function change() {
	var maxResolution = 950; 
	var myWidth = getWindowSize();
	if (myWidth <= maxResolution) {
		if (document.getElementById('start-slogan-image')) {
			document.getElementById('start-slogan-image').src = '/imperia/_img/start_text_small.gif';
		}
		checkTeaserWidth(500);
		document.styleSheets[1].disabled = true;
		document.styleSheets[0].disabled = false;
	} else {
		if (document.getElementById('start-slogan-image')) {
			document.getElementById('start-slogan-image').src = '/imperia/_img/start_text.gif';
		}
		checkTeaserWidth(680);
		document.styleSheets[1].disabled = false;
		document.styleSheets[0].disabled = true;
	}
}

function checkTeaserWidth(width) {
	if (!document.getElementById('stuff')) {
		for (var i=0;i<document.getElementsByTagName('div').length;i++) {
			if ((document.getElementsByTagName('div')[i].className == 'teaser-3-container') || (document.getElementsByTagName('div')[i].className == 'content-transparent-container')) {
				document.getElementsByTagName('div')[i].style.width = width+'px';
			}
		}
	}
}

function cooking(origImg) {
	var status;
	if (document.cookie.match('tg_internet_bg')) {
		status = document.cookie.substring(15,(document.cookie.length));
		if (status == 'off') {
			origImg = origImg.replace(/url\(/g, "");
			origImg = origImg.replace(/\)/g, "");
			removeImage(origImg);
			setCookie('off');
		} else {
			initImage();
		}
	} else {
		initImage();
		setCookie('on');
	}
}

function initImage() {
	var imageId = 'backgroundImg';
	var image = document.getElementById(imageId);
	if (image) {
		setOpacity(image, 0);
		image.style.display = 'block';
		fadeIn(imageId,0);
	}
}

function removeImage(origImg) {
	document.getElementById('backgroundImg').style.display = 'none';
	document.getElementById('backgroundPic').style.background = 'none';
}

function toggleBGImage(origImage) {
	if (document.getElementById('content').style.backgroundImage.match(origImage)) {
		document.getElementById('bg-switcher-help').innerHTML = 'Hintergrund einblenden';
		document.getElementById('content').style.background = 'none';
		document.getElementById('img-switch').src = '/imperia/_img/bg_off.gif';
		setCookie('off');
	} else {
		document.getElementById('content').style.background = 'transparent url('+origImage+') repeat 0 0';
		document.getElementById('img-switch').src = '/imperia/_img/bg_on.gif';
		document.getElementById('bg-switcher-help').innerHTML = 'Hintergrund ausblenden';
		setCookie('on');
	}
}

function setCookie(status) {
	var index;
	if(document.cookie != document.cookie) {
		index = document.cookie.indexOf('tg_internet_bg');
	} else {
		index = -1;
	}
	if (index == -1) {
		document.cookie = "tg_internet_bg="+status+"; Path=/; expires=Monday, 19-Feb-2021 05:59:00 GMT";
	}
}

function checkFred() {
	if ((navigator.platform == 'MacPPC') && (navigator.appVersion.substr(17,6) == 'MSIE 5')) {
		return true;
	} else {
		return false;
	}
}

window.onload = function(e) {
	var fred = checkFred();
	if (fred) {
		document.getElementById('bg-switcher').style.display = 'none';
	}
	var origImg = document.getElementById('content').style.backgroundImage;
	change();
	cooking(origImg);	
	for (var i=0;i<20;i++) {
		if (document.getElementById(i+'-l-0')) {
			document.getElementById(i+'-l-0').style.display = "block";
			document.getElementById(i+'-n-0').className = "tab-nav-on";
		}
	}
}

function setOpacity(obj, opacity) {
	//alert("chap");
	opacity = (opacity == 100) ? 99.999 : opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.KHTMLOpacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		var obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
	}
}

function fadeOut(objId,opacity) {
	if (document.getElementById) {
		var obj = document.getElementById(objId);
		if (opacity >= 0) {
			setOpacity(obj, opacity);
			opacity -= 10;
			window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 100);
		}
	}
}

function toggleBackground(origImage) {
	if (document.getElementById('backgroundImg').style.opacity != 0) {
		document.getElementById('backgroundPic').style.background = 'none';
		document.getElementById('bg-switcher-help').innerHTML = 'Hintergrund einblenden';
		document.getElementById('img-switch').src = 'http://tg2004.netural.com/imperia/_img/bg_off.gif';
		fadeOut('backgroundImg',100);
		setCookie('off');
	} else {
		document.getElementById('backgroundImg').src = origImage;
		document.getElementById('backgroundPic').style.background = 'url(http://tg2004.netural.com/imperia/_img/loading.gif) no-repeat';
		document.getElementById('img-switch').src = 'http://tg2004.netural.com/imperia/_img/bg_on.gif';
		document.getElementById('bg-switcher-help').innerHTML = 'Hintergrund ausblenden';
		document.getElementById('backgroundImg').style.display = 'block';
		fadeIn('backgroundImg',0);
		setCookie('on');
	}
}

window.onresize = function(e) {
	change();
}

function impressionen(obj) {
	var maxResolution = 950; 
	var myWidth = getWindowSize();
	if (myWidth <= maxResolution) {
		return ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="477" HEIGHT="356" id="'+obj+'" ALIGN=""><PARAM NAME=movie VALUE="_flash/impressionen_'+obj+'_small.swf"><PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#1E6FC1><PARAM NAME=wmode VALUE=transparent><EMBED src="_flash/impressionen_'+obj+'_small.swf" quality=high bgcolor=#1E6FC1 wmode=transparent WIDTH="477" HEIGHT="356" NAME="'+obj+'" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');
	} else {
		return ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="703" HEIGHT="356" id="'+obj+'" ALIGN=""><PARAM NAME=movie VALUE="_flash/impressionen_'+obj+'_big.swf"><PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#1E6FC1><PARAM NAME=wmode VALUE=transparent><EMBED src="_flash/impressionen_'+obj+'_big.swf" quality=high bgcolor=#1E6FC1 wmode=transparent WIDTH="703" HEIGHT="356" NAME="'+obj+'" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');
	}
}

function switchLayer(tab,obj) {
	obj = parseInt(obj);
	if (isNaN(obj)) {
		obj = 0;
	}
	var temp = tab+'l-'+obj;
	if (!document.getElementById(temp)) {
		obj = 0;
	}
	if (!obj) {
		obj = 0;
	}
	var navObj = 'n-' + obj;
	obj = 'l-' + obj;
	for (var i=0;i<99;i++) {
		if (document.getElementById(tab+'l-'+i)) {
			document.getElementById(tab+'l-'+i).style.display = "none";
		}
		if (document.getElementById(tab+'n-'+i)) {
			document.getElementById(tab+'n-'+i).className = "tab-nav";
		}
	}
	document.getElementById(tab+obj).style.display = "block";
	document.getElementById(tab+navObj).className = "tab-nav-on";
}

function loadLayer() {
	var urlquery = location.href.split("?");
	var test = urlquery[1];
	if (test) {
		if (test.length >= 1) {
			test = test.substring(0,1);
			switchLayer(test);
		}
	} else {
		switchLayer();
	}
}

function showBigImage(imageurl,imgDesc,xres,yres) {
  	var window_x 			= parseInt(xres)+30;
	var window_y 			= parseInt(yres)+78;
	var image_desc 			= imgDesc;
	var image_url			= imageurl;
	var window_properties 	= "width=" + window_x + ",height=" + window_y + ",menubar=yes,resizable=yes,scrollbars=yes";
    var win 				= window.open("","Image",window_properties);
	win.document.write("<html><head><title>"+image_desc +"</title><link rel=\u0022STYLESHEET\u0022 type=\u0022text/css\u0022 href=\u0022/tg/internet/_css/style.css\u0022></head><body>");
	win.document.write("<center><p align=\u0022center\u0022><a href=\u0022javascript:window.close();\u0022><img src=\u0022");
	win.document.write(imageurl);
	win.document.write("\u0022 width=\u0022"+xres +"\u0022 height=\u0022"+yres +"\u0022 border=\u00220\u0022></a></p></center>")
	win.document.write ("<div class=\u0022content-transparent-button\u0022 style=\u0022text-align: right; margin-right: 5px;\u0022><a href=\u0022javascript:window.close();\u0022>schlie&szlig;en</a></div>");
	win.document.write("</body></html>");
}

function submitForm(form) {
	var win = window.open("", "SHOP","width=794,height=453,resizable=yes,scrollbars=1");
	form.submit();
	win.focus();
}

function presetDate() {
	var d = new Date();
	var day = d.getDate();
	var month = d.getMonth();
	//var year = d.getYear()+1900;
	var year = d.getYear();
	document.getElementById("day").value = day;
	document.getElementById("month").value = month;
	document.getElementById("year").value = year;
}

function openCallme(url, width, height, winname) {
	var callMeURL = url +"?referer=" + document.location.href;
	var old = self;
	var trails="width=505,height=738,toolbar=no,directories=no,status=yes,scrollbars=yes,resize=yes,menubar=no";
	newWindow=window.open(callMeURL,winname,trails);              
}

function openPopup(url, width, height, winname) {
	var old = self;
	var trails="width=" + width + ",height=" + height + ",toolbar=no,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no";
	newWindow=window.open(url,winname,trails);
}


