/**************************************************/
/* Global Scripting Functions for A-IMS           */
/**************************************************/

//### Framework nachladen ###
// Überprüft für jede Seite, ob alle Frames (z.B. Menüleiste etc.) vorhanden sind.
if ( top == self ) {							// Wenn es kein Framework gibt ...
	var LH = location.href;
	var datei = LH.substring(LH.lastIndexOf('/')+1, LH.length);	//Host+Pfad abschneiden
	//alert("Kein Framework vorhanden!\nAufgerufene Datei: '"+datei+"'  (ex_global.js).");
	var indatei = datei;
	if (location.search != '') {					//Datei enthält Search-String
		indatei = LH.substring(LH.indexOf('?')+1, LH.length);	//Search extrahieren
		datei = datei.substring(0, datei.indexOf('?'));		//Datei extrahieren
		//alert("Kein Framework vorhanden! Datei enthält Search-String\nDatei ohne Search: '" + datei + "'\nSearch-String: '" + indatei + "'  (ex_global.js).");
	}
	
	if (datei=='' || datei=='index.html') datei = 'index.htm';
	if (datei != 'index.htm') {					// und wenn es nicht die Startseite ist ...
		var iscontentfile = true;				// dann lade das gesamte Framework nach mit der aufgerufenen Seite als Inhaltsframeseite:
		// Wenn die aufgerufene Seite keine Inhalts-, sondern eine Frameworkseite ist, dann lade die gesamte Homepage ganz normal:
		var framepages = ["oben.htm", "rechts.htm", "x-links.htm", "x-oben.htm", "x-rechts.htm", "x-unten.htm"];
		for (i=0;i<framepages.length;i++) { 
			if (datei == framepages[i]) {
			  top.document.location.replace('../index.htm'); 
			  iscontentfile = false;
			}
		}
		if (iscontentfile) {
		  //alert("Framework wird nachgeladen mit "+indatei+"  (ex_global.js)");
		  top.document.location.replace('index.htm?' + indatei);
		}
	}
}

//### Ändert die 2 Collagen-Bilder oben und rechts vom Main-Frame aus. ###
function collage (bild_ob,bild_re) {
  if (top != self) {
	var imgpath = "../img/";  //var imgpath = (document.all) ? "../img/" : "img/";
	top.foben.document.collage_ob.src   = imgpath + bild_ob;
	top.frechts.document.collage_re.src = imgpath + bild_re;
  }
  else {
    setTimeout(eval("collage("+bild_ob+","+bild_re+")"), 2000);
  }
}

//### Öffnet das Mail-Formular als Popup-Fenster. ###
function popup() {
  var popwin = window.open("../share/popup.htm","","top=80,left=80,width=380,height=460,location=0,menubar=0,toolbar=0,directories=0,resizable=yes,scrollbars=yes");
}
function popup2() {  //anderer Dateipfad
  var popwin = window.open("share/popup.htm","","top=80,left=80,width=380,height=480,location=0,menubar=0,toolbar=0,directories=0,resizable=yes,scrollbars=yes");
}
function winopen(adr,breite,hoehe) {
  if (breite==null) breite = 300;
  if (hoehe==null) hoehe = 400;
  var popwin = window.open(adr, "", "top=80,left=80,width="+breite+",height="+hoehe+",location=0,menubar=0,toolbar=0,directories=0,resizable=yes,scrollbars=yes");
}

//### Aktiven Link highlighten (Style wechseln) ###
// Siehe auch die Ruby-Klassen im Stylesheet 'styles.css'. 
function highlightCurrentPageLink() {
  // Alle Links durchlaufen und pruefen: 
  var anzHrefs = document.getElementsByTagName("a").length;
  for (var i = 0; i <= anzHrefs - 1; i++) {
    // Link auf aktuelle Seite gefunden, also CSS umstellen auf aktiv:
    if (document.getElementsByTagName("a")[i].href == document.location.href) {
      var currentClassName = document.getElementsByTagName("a")[i].className;
      var newClassName = currentClassName.replace(/inaktiv/,"aktiv");
      document.getElementsByTagName("a")[i].className = newClassName;
    }
  }
}

//alert('"ex_global.js" wurde geladen in "'+location.href+'"');


//### MM-Funktionen ###
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


/**************************************************/
/* (C) EXYST Internet, www.exyst.de               */
/**************************************************/

