
/// FUNKTIONEN FÜR DIE MENÜS (_menu.html)

function initSubMenuPage() {
	// Erst prüfen, ob umgebendes Frameset geladen ist, anschließend Menüselektion vornehmen
	if(checkFramesetSubMenu()) { 
		setSubMenuSelection();
	}
}

function checkFramesetSubMenu() {
	// Prüfen, ob umgebendes Frameset geladen ist
	if (!parent.inhalt) {
		strURL = location.pathname;
		// Letztes Verzeichnis ermitteln
		strURL = strURL.substr(0,strURL.lastIndexOf("/"));
		strURL = strURL.substring(strURL.lastIndexOf("/")+1);
		// Location Wechseln	
		location.href = "../index.html?"+strURL;
	} else {
		return true;
	}
}

function setSubMenuSelection() {
	// Menüselektion setzen
	if (location.search) {
		strParameter = location.search;
		strParameter = strParameter.substring(1,strParameter.indexOf("."));
	} else if (parent.inhalt) {
		strParameter = parent.inhalt.location.pathname;
		strParameter = strParameter.substring(strParameter.lastIndexOf("/")+1,strParameter.indexOf("."));
	}
	if ((FP_swapImg) && (strParameter != "")) {
		FP_swapImg(0,0,/*id*/strParameter,/*url*/'../../_img/punkt_ro_gr.gif')
	}
}

/// FUNKTIONEN FÜR DIE EIGENTLICHEN INHALTSSEITEN

function initContentPage() {
	// Erst prüfen, ob umgebendes Frameset geladen ist, anschließend Themenbild laden
	if(checkFramesetContent()) { 
		loadThemenbild();
	}
}

function checkFramesetContent() {
	// Prüfen, ob umgebendes Frameset geladen ist
	if (!parent.inhalt) {
		strURL = location.pathname.substring(location.pathname.lastIndexOf("/")+1);
		location.href = "index.html?"+strURL;
	} else {
		return true;
	}
}

function loadThemenbild() {
	// Zeigt die Themenabbildung unten an
	if (parent.parent.themenbild) {
		strURL = location.pathname;
		strThemenbild = "../_img" + strURL.substring(strURL.substring(0,strURL.lastIndexOf("/")).lastIndexOf("/"),strURL.lastIndexOf(".")) + ".jpg";
		parent.parent.themenbild.location.href = "../../_res/_themenbild.shtml?" + strThemenbild;
	}
}

/// FUNKTIONEN FÜR DAS SUBFRAME (inhalt + menu)

function initSubFramePage() {
	// Erst prüfen, ob umgebendes Frameset geladen ist, anschließend ggf. Subpage laden laden
	if(checkFramesetSubFrame()) { 
		loadContentPage();
	}
}

function checkFramesetSubFrame() {
	if (!parent.kopf) {
	// Prüfen, ob umgebendes Frameset geladen ist
		strURL = location.pathname;
		// Letztes Verzeichnis ermitteln
		strURL = strURL.substr(0,strURL.lastIndexOf("/"));
		strURL = strURL.substring(strURL.lastIndexOf("/")+1);
		// Location Wechseln	
		location.href = "../index.html?"+strURL+location.search;
	} else {
		return true;
	}
}

function loadContentPage() {
	// Unterseite laden
	if (location.search) {
		strURL = location.search.substring(1,location.search.length);
		frames.inhalt.location.href = strURL;
		frames.menu.location.href = "_menu.html" + location.search;
	}
}

/// FUNKTIONEN FÜR DAS HAUPTFRAME

function initFramePage() {
	loadSubFrame();
}

function loadSubFrame() {
	if (location.search) {
		strURL = location.search.substring(1,location.search.length);
		frames.subframe.location.href = strURL;
	}
}

/// FUNKTIONEN FÜR sonstige Framebestandteile

function checkFramesetOther() {
	// Prüfen, ob umgebendes Frameset geladen ist, sonst Startseite anspringen	
	if (!parent.kopf) {
		strURL = location.pathname;
		location.href = "../";
	}
}

/// FUNKTIONEN FP

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function FP_swapImgRestore() {//v1.0
 var doc=document,i; if(doc.$imgSwaps) { for(i=0;i<doc.$imgSwaps.length;i++) {
  var elm=doc.$imgSwaps[i]; if(elm) { elm.src=elm.$src; elm.$src=null; } } 
  doc.$imgSwaps=null; }
}

