
function setBgColor(lid, sColor) {
	$(lid).setStyle({backgroundColor: sColor});
}
function showLayer(lid) {
	$(lid).style.visibility = "visible";
}
function hideLayer(lid) {
	$(lid).style.visibility = "hidden";
}
function loadImg(lid, sUrl, iw, ih) {
	var sHtml = "<div id='divInd' style='position:absolute;left:0px;top:0px;width:"+iw+"px;height:"+ih+"px;z-index:3;background-color:#FFFFFF;text-align:center;border:none;'>";
	sHtml = sHtml + "<span style='position:absolute;left:"+((iw-100)/2+15)+"px;top:"+((ih-20)/2)+"px;vertical-align:middle;z-index:4;'>";
	if (lid=='img_nav_gb') {
		sHtml = sHtml + "<img src='../../../img/indicator.gif' width='16' height='16' alt='' />";
	} else {
		sHtml = sHtml + "<img src='../../img/indicator.gif' width='16' height='16' alt='' />";
	}
	sHtml = sHtml + "</span>";
	sHtml = sHtml + "<span style='position:absolute;left:"+(((iw-100)/2)+35)+"px;top:"+((ih-20)/2)+"px;vertical-align:middle;z-index:4;'>";
	sHtml = sHtml + "<b class='fIndText'>Loading...</b>";
	sHtml = sHtml + "</span>";
	sHtml = sHtml + "</div>";
	$(lid).innerHTML = sHtml;	
	setOpacity('divInd', 4);
	var url = sUrl;
	var pars = '';
	new Ajax.Updater(lid, url, {method: 'get', parameters: pars});
}
function loadContent(lid, sUrl, iw, ih) {
	var sHtml = "<div id='divIndnav' style='position:absolute;left:0px;top:0px;width:"+iw+"px;height:"+ih+"px;z-index:3;background-color:#FFFFFF;text-align:center;border:none;'>";
	sHtml = sHtml + "<span style='position:absolute;left:"+((iw-100)/2+15)+"px;top:"+((ih-20)/2)+"px;vertical-align:middle;z-index:4;'>";
	if (sUrl.include('geschaeftsbereich')) {
		sHtml = sHtml + "<img src='../../../img/indicator.gif' width='16' height='16' alt='' />";
	} else {
		sHtml = sHtml + "<img src='../../img/indicator.gif' width='16' height='16' alt='' />";
	}
	sHtml = sHtml + "</span>";
	sHtml = sHtml + "<span style='position:absolute;left:"+(((iw-100)/2)+35)+"px;top:"+((ih-20)/2)+"px;vertical-align:middle;z-index:4;'>";
	sHtml = sHtml + "<b class='fIndText'>Loading...</b>";
	sHtml = sHtml + "</span>";
	sHtml = sHtml + "</div>";
	$(lid).innerHTML = sHtml;	
	setOpacity('divIndnav', 4);
	var url = sUrl;
	var pars = '';
	new Ajax.Updater(lid, url, {method: 'get', parameters: pars});
}
function setOpacity(oid, value) {
	if (window.XMLHttpRequest) {
		$(oid).style.opacity = value/10;
	} else {
		$(oid).style.filter = 'alpha(opacity=' + value*10 + ')';
	}
}
function verScroll(lid, dir, spd) {
	loop = true;
	layer = "";
	direction = "up";
	speed = 10;
	scrolltimer = null;
	if (lid.indexOf('#')!=-1) {
		p = lid.indexOf('#');
		iParent = lid.substring(0, p);
		iChild = lid.substring(p+1);
	} else {
		iParent = "";
		iChild = lid;
	}
	var page;
	if (iParent=="") {
		page= $(iChild);	
	} else {
		if (document.all) {
			var temp = frames[iParent].document;
		} else {
			var temp = $(iParent).contentDocument;
		}
		page = temp.getElementById(iChild);
	}
	//layer = iChild;
	layer = lid;
	direction = dir;
	speed = spd;
	var y_pos = parseInt(page.style.top);
	var y_h = parseInt(page.style.height);
	if (loop == true) {
		if (document.all) {
			if (direction == "dn" && ((y_pos + y_h) > 460) && (y_h > 4000)) {
				page.style.top = (y_pos - (speed)) + "px";
			} else if (direction == "dn" && ((y_pos + y_h) > 210) && (y_h > 2500) && (y_h <= 4000)) {
				page.style.top = (y_pos - (speed)) + "px";
			} else if (direction == "dn" && ((y_pos + y_h) > 210) && (y_h > 1000) && (y_h <= 2500)) {
				page.style.top = (y_pos - (speed)) + "px";
			} else if (direction == "dn" && ((y_pos + y_h) > 20) && (y_h <= 1000)) {
				page.style.top = (y_pos - (speed)) + "px";
			} else {
				if (direction == "up" && y_pos < 0) {
					page.style.top = (y_pos + (speed)) + "px";
				} else {
					if (direction == "top") {
						page.style.top = 10 + "px";
      				}
   				}
			}
		} else {
			if (direction == "dn" && ((y_pos + y_h) > 210) && (y_h > 1000)) {
				page.style.top = (y_pos - (speed)) + "px";
			} else if (direction == "dn" && ((y_pos + y_h) > 20) && (y_h <= 1000)) {
				page.style.top = (y_pos - (speed)) + "px";
			} else {
				if (direction == "up" && y_pos < 0 && (y_h <= 1000)) {
					page.style.top = (y_pos + (speed)) + "px";
				} else if (direction == "up" && (y_pos < (y_h - 940)) && (y_h > 1000) && (y_pos < 0)) {
					page.style.top = (y_pos + (speed)) + "px";
				} else {
					if (direction == "top") {
						page.style.top = 10 + "px";
      				}
   				}
			}
		}
		scrolltimer = setTimeout("verScroll(layer,direction,speed)", 1);
   	}
}
function stopScroll() {
	loop = false;
	clearTimeout(scrolltimer);
}
/** This is high-level function.
 * It must react to delta being more/less than zero.
 */
function handle(delta) {
	if ($('cInline')) {
		page = $('cInline');
	} else {
		if (document.all) {
			var temp = frames['ifContent'].document;
		} else {
			var temp = $('ifContent').contentDocument;
		}
		page = temp.getElementById('cInline');
	}
	var y_pos = parseInt(page.style.top);
	var y_h = parseInt(page.style.height);
	if (delta < 0) {
		//window.alert(delta);
		if (((y_pos + y_h) > 205) && (y_h > 1000)) {
			page.style.top = (y_pos + (delta * 10)) + "px";
		} else if (((y_pos + y_h) > 15) && (y_h <= 1000)) {
			page.style.top = (y_pos + (delta * 10)) + "px";
		} else {	
		}
	} else {
		//window.alert('up');
		if (y_pos < -5 && (y_h <= 1000)) {
			page.style.top = (y_pos + (delta * 10)) + "px";
		} else if ((y_pos < (y_h - 940)) && (y_h > 1000) && (y_pos < 0)) {
			page.style.top = (y_pos + (delta * 10)) + "px";
		} else {
		}
	}
}

/** Event handler for mouse wheel event.
 */
function wheel(event){
		//window.alert('mousewheel');
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
                handle(delta);
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}


function getMail(mid) {
	mailh.each(function(pair) {
		if (pair.key == mid) {
			location.href = 'mailto:'+pair.value+'@f-und-b.de';
		}
  		//alert(pair.key + ' = "' + pair.value + '"');
	});	
}

function gotoAnchor(aid) {
	if (document.all) {
		//IE
		if (aid.substring(0, 3)=='#nl') {
			//Newsletter
			if (aid=='#nl_0') {
				$('cInline').style.top = '3px';
			} else if (aid=='#nl_1') {
				$('cInline').style.top = '-180px';
			} else if (aid=='#nl_2') {
				$('cInline').style.top = '-350px';
			} else if (aid=='#nl_3') {
				$('cInline').style.top = '-510px';
			} else if (aid=='#nl_4') {
				$('cInline').style.top = '-830px';
			} else if (aid=='#nl_5') {
				$('cInline').style.top = '-1050px';
			} else if (aid=='#nl_6') {
				$('cInline').style.top = '-1200px';
			} else if (aid=='#nl_7') {
				$('cInline').style.top = '-1370px';
			}
		} else if (aid.substring(0, 4)=='#top') {
			//newsletter top nav
			if ($('cInline')) {
				page = $('cInline');
			} else {
				if (document.all) {
					var temp = frames['ifContent'].document;
				} else {
					var temp = $('ifContent').contentDocument;
				}
				page = temp.getElementById('cInline');
			}
			page.style.top = '0px';
		} else if (aid.substring(0, 5)=='#team') {
			var d = frames['ifContent'].document;
			//Team
			if (aid=='#teamGF') {
				d.getElementById('cInline').style.top = '-1px';
			} else if (aid=='#teamGB1') {
				d.getElementById('cInline').style.top = '-86px';
			} else if (aid=='#teamGB2') {
				d.getElementById('cInline').style.top = '-327px';
			} else if (aid=='#teamGB3') {
				d.getElementById('cInline').style.top = '-540px';
			} else if (aid=='#teamGB4') {
				d.getElementById('cInline').style.top = '-753px';
			} else if (aid=='#teamOV') {
				d.getElementById('cInline').style.top = '-902px';
			}
		} else if (aid.substring(0, 5)=='#prod') {
		//Produkte	
			if (aid=='#prodAD') {
				$('cInline').style.top = '3px';
			} else if (aid=='#prodFK') {
				$('cInline').style.top = '-210px';
			} else if (aid=='#prodLQ') {
				$('cInline').style.top = '-585px';
			} else if (aid=='#prodSZ') {
				$('cInline').style.top = '-990px';
			}
		} else if (aid.substring(0, 6)=='#links') {
			//Links
			if (aid=='#links_013') {
				$('cInline').style.top = '3px';
			} else if (aid=='#links_012') {
				$('cInline').style.top = '-430px';	
			} else if (aid=='#links_011') {
				$('cInline').style.top = '-500px';
			} else if (aid=='#links_010') {
				$('cInline').style.top = '-570px';	
			} else if (aid=='#links_009') {
				$('cInline').style.top = '-630px';
			} else if (aid=='#links_008') {
				$('cInline').style.top = '-730px';
			} else if (aid=='#links_001') {
				$('cInline').style.top = '-810px';
			} else if (aid=='#links_002') {
				$('cInline').style.top = '-870px';
			} else if (aid=='#links_003') {
				$('cInline').style.top = '-940px';
			} else if (aid=='#links_004') {
				$('cInline').style.top = '-1000px';
			} else if (aid=='#links_005') {
				$('cInline').style.top = '-1080px';
			} else if (aid=='#links_006') {
				$('cInline').style.top = '-1150px';
			} else if (aid=='#links_007') {
				$('cInline').style.top = '-1210px';	
			}
		}
	} else {
		//Mozila etc.
		//Mozila: one mouse wheel move is 10px
		if (aid.substring(0, 3)=='#nl') {
			//Newsletter
			if (aid=='#nl_0') {
				$('cInline').style.top = '3px';
			} else if (aid=='#nl_1') {
				$('cInline').style.top = '-150px';
			} else if (aid=='#nl_2') {
				$('cInline').style.top = '-310px';
			} else if (aid=='#nl_3') {
				$('cInline').style.top = '-450px';
			} else if (aid=='#nl_4') {
				$('cInline').style.top = '-780px';
			} else if (aid=='#nl_5') {
				$('cInline').style.top = '-990px';
			} else if (aid=='#nl_6') {
				$('cInline').style.top = '-1150px';	
			} else if (aid=='#nl_7') {
				$('cInline').style.top = '-1300px';
			}
		} else if (aid.substring(0, 4)=='#top') {
			//newsletter top nav
			if ($('cInline')) {
				page = $('cInline');
			} else {
				if (document.all) {
					var temp = frames['ifContent'].document;
				} else {
					var temp = $('ifContent').contentDocument;
				}
				page = temp.getElementById('cInline');
			}
			page.style.top = '0px';
		} else if (aid.substring(0, 5)=='#team') {
			var d = $('ifContent').contentDocument;
			//Team
			if (aid=='#teamGF') {
				d.getElementById('cInline').style.top = '-1px';
			} else if (aid=='#teamGB1') {
				d.getElementById('cInline').style.top = '-88px';
			} else if (aid=='#teamGB2') {
				d.getElementById('cInline').style.top = '-300px';
			} else if (aid=='#teamGB3') {
				d.getElementById('cInline').style.top = '-500px';
			} else if (aid=='#teamGB4') {
				d.getElementById('cInline').style.top = '-777px';
			} else if (aid=='#teamOV') {
				d.getElementById('cInline').style.top = '-930px';
			}
		} else if (aid.substring(0, 5)=='#prod') {
			//Produkte	
			if (aid=='#prodAD') {
				$('cInline').style.top = '0px';
			} else if (aid=='#prodFK') {
				$('cInline').style.top = '-210px';
			} else if (aid=='#prodLQ') {
				$('cInline').style.top = '-585px';
			} else if (aid=='#prodSZ') {
				$('cInline').style.top = '-990px';
			}
		} else if (aid.substring(0, 6)=='#links') {
			//Links
			if (aid=='#links_013') {
				$('cInline').style.top = '0px';
			} else if (aid=='#links_012') {
				$('cInline').style.top = '-380px';	
			} else if (aid=='#links_011') {
				$('cInline').style.top = '-440px';	
			} else if (aid=='#links_010') {
				$('cInline').style.top = '-500px';
			} else if (aid=='#links_009') {
				$('cInline').style.top = '-570px';
			} else if (aid=='#links_008') {
				$('cInline').style.top = '-650px';
			} else if (aid=='#links_001') {
				$('cInline').style.top = '-740px';
			} else if (aid=='#links_002') {
				$('cInline').style.top = '-810px';
			} else if (aid=='#links_003') {
				$('cInline').style.top = '-850px';
			} else if (aid=='#links_004') {
				$('cInline').style.top = '-920px';
			} else if (aid=='#links_005') {
				$('cInline').style.top = '-1000px';
			} else if (aid=='#links_006') {
				$('cInline').style.top = '-1060px';
			} else if (aid=='#links_007') {
				$('cInline').style.top = '-1140px';	
			}
		}
	}
	
	/*
	var x = $('ifContent').src;
	var p = x.indexOf('#');
	if (p==-1) {
		$('ifContent').src = x + aid;
	} else {
		$('ifContent').src = x.substring(0, p) + aid;
	}
	*/
	//window.alert(d.getElementById('cInline').style.top);
}
function gotoTop() {
	var ip = parseInt($('cInline').style.top);
	if (document.all) {
		$('cInline').style.top = '0px';
	} else {
		$('cInline').style.top = '0px';
	}
}
function showTop() {
	var d = $('ifContent').contentDocument;
	window.alert(d.getElementById('cInline').style.top);
}
function gotoUrl(url, depth) {
	if (depth==1) {
		parent.location.href = url;
	} else {
		location.href = url;
	}
}
