// JavaScript Document

var timeout_change = null;
var op_timeout_change = null;

// needed by other functions: returns URL information
function filterURL(){
	// here you have to update your foldernames:
	var navi_elements = new Array('main.htm','aktuelles','programm','gruppen','huetten','service','kontakt','topnavi');
	var ret = new Array();
	var mainurl = document.location.href;
	var split_url = mainurl.split("/");
	split_url_leng = split_url.length; 

	for(w=0;w<navi_elements.length;w++){
		for (q=0;q<split_url_leng;q++){
			if(split_url[q] == navi_elements[w]){
				ret[0] = w;
				ret[1] = split_url[q];
				ret[2] = split_url_leng - q;
				return ret;
			}
		}
	}
	return null;
}

function footer(){
	if(!top.getFrameinfo()){
		var ft_timeout_change = window.setTimeout("footer()",1000);
	}else{
		// adds the 'nach oben' anchor link, if necessary
		number = filterURL();
		if(number != null){
			hierarchie = "";
			for( r = 0 ; r < number[2]-1 ; r++ ){
				hierarchie = hierarchie+"../";
			}
			document.write("<div id='body_height' style='visibility: hidden' valign='top' align='right'><br><a href='#'onClick='window.scrollTo(0,0)'>nach oben</a> &nbsp;<img src='"+hierarchie+"/images/nach_oben.jpg' width='15' height='15' border='0'><img src='"+hierarchie+"/images/blank10x10.gif' width='30' height='10'> </div>");
			var entire_leng = (document.all)? document.all.body_height.offsetTop : document.getElementById("body_height").offsetTop;
			var avail_leng = screen.availHeight;
			if(entire_leng - avail_leng >= -130){
			
				if (document.getElementById) {
				document.getElementById("body_height").style.visibility='visible';
				}
				if (document.layers){
				window.document.body_height.visibility='visible';
				}	
				if (document.all) {
				document.all.body_height.style.visibility='visible';
				}
			}
			
			//adds the 'lastmodified' information, if page is in 'aktuelles' or 'programm'
			if(number[1] == 'aktuelles' || number[1] == 'programm'){
				var datum = document.lastModified.split(" ");
				if(document.all && datum.length == 2){
					datum = datum[0].split("/");
					document.write("<i>Letzte &Auml;nderung:  " + datum[1] + "." + datum[0] + "." + datum[2] + "</i>");
				}else{
					document.write("<i>Last Update: "+document.lastModified+"</i>");
				}
			}
		}
	}
}

// builds topFrame and leftFrame around the mainFrame by click on 'open in new browser window'
function getFrameset(){
	if(top == self){
	number = filterURL();
		if(number != null){
			hierarchie = "";
			
			for( r = 0 ; r < number[2]-1 ; r++ ){
				hierarchie = hierarchie+"../";
			}
			new_location = hierarchie+"index.htm";
			top.name = "URL="+document.location.href;
			window.location.replace(new_location);
			
		}else{
			if(window.location.hostname != ""){
				new_location = window.location.hostname.split("/");
				window.location.replace();
			}
		}
	}
}

// moves the red navigation arrow to its proper place
function actuallyChange(){
	if(!top.getFrameinfo()){
		var fc_timeout_change = window.setTimeout("actuallyChange()",1000);
	}else{
		operate();
	}
}

function operate(){
		op_timeout_change = window.setTimeout("operate()",1000);
		number = filterURL();
		if(number != null && number[1] != "topnavi"){
			parent.leftFrame.MM_swapImgRestore();
			eval(parent.leftFrame.MM_swapImage('pfeil_aus_'+(number[0]+1)+'','','images/pfeil.jpg',1));
			eval('parent.leftFrame.showLayer("'+number[0]+'")');
			parent.leftFrame.clickSwitch(number[0]);
		}
		if(number != null && number[1] == "topnavi"){
				parent.leftFrame.MM_swapImgRestore();
				parent.leftFrame.clickSwitch('-1');
		}
		clearTimeout(op_timeout_change);
		op_timeout_change = null;
}

function write_email(name, domain){
	document.write("<a href=\"mailto:" + name + "@" + domain + "\">" + name + "@" + domain + "</a>");
//	document.write('hallo');
}