 var browser   = navigator.appName;
 var titel     = document.title;
 var ummgebung = navigator.userAgent;
 var url       = "http:\/\/www.robin-trauer.de";
 var version   = navigator.appVersion;
 var was       = "";



/* ------------ Standardfunktionen ------------ */



function getElementsByClassName(klasse)
{
 /* Vielen Dank an www.styleassistant.de für diese Funktion */

 var alle, objekte = new Array();
 var j=0;

 if ( document.all )  alle = document.all;
 else if (document.getElementsByTagName && !document.all )
 { alle = document.getElementsByTagName("*"); }

 for ( i=0; i<alle.length; i++)
 {
  if ( alle[i].className.indexOf(klasse) != -1 )
  {
   objekte[j] = alle[i];
   j++;
  }
 }
 return objekte;
}


function hg_entfernen(objekt_id)
{
 var objekt = document.getElementById(objekt_id).style;
 objekt.backgroundPosition = "-10000em -10000em";
}

 function hg_herstellen(objekt_id)
{
 var objekt = document.getElementById(objekt_id).style;
 objekt.backgroundPosition = "right 0.2em";
}


function ereignis_zuweisen(objekt_id,ereignis,wert)
{
 objekt = document.getElementById(objekt_id);
 wert   = new Function(wert);

 if ( browser == "Microsoft Internet Explorer" )
      { objekt.attachEvent("on"+ereignis, wert); }
 else { objekt.addEventListener(ereignis, wert, false); }
}


function id_zuweisen(bezeichner,wie)
{
// var id_nr = document.createAttribute("id");
 
 if (arguments.length == 1) { wie = "tn"; }
 switch(wie)
 {
   case "klasse" : elemente  = getElementsByClassName(bezeichner); break;
   case "name"   : elemente  = document.getElementsByName(bezeichner); break;
   case "tn"     : elemente  = document.getElementsByTagName(bezeichner); break;
 }

 for (i=0; i<=elemente.length-1; i++)
 {
//  id_nr.nodeValue = bezeichner+i;
  elemente[i].id = bezeichner+i;
//  elemente[i].setAttributeNode(id_nr);
 }
}


function textknoten_entf(knotensammlung)
{
 // Auch Zeilenumbrüche im Quelltext sind Textknoten. Diese werden hier entfernt.
 var temp_array = new Array();

 for (var j=0; j<knotensammlung.length; j++)
 {
  for (i=0; i<knotensammlung[j].childNodes.length; i++)
  {
   if (knotensammlung[j].childNodes[i].nodeType != 3)
   {
    temp_array.push(knotensammlung[j].childNodes[i].firstChild);
   }
  }
 }
 knotensammlung = new Array();
 knotensammlung = temp_array;

 return knotensammlung;
}





/* ------------ spezielle Funktionen ------------ */



function dl_ausklappen(div_id)
{
 var dl_div  = document.getElementById(div_id);
 var ende    = parseInt(div_id);
 var aktuell = dl_div.offsetHeight;
 var schritt = 10;
 var tmp     = div_id.search("_");
 var lfd_nr  = parseInt(div_id.substring(eval(tmp+1)));

 /* Druckansicht */
 dl_div.childNodes[2].style.display = "block";
 dl_div.childNodes[3].style.display = "block";
 dl_div.childNodes[4].style.display = "block";
 /* Ende Druckansicht */

 if (aktuell < ende)
 {
  dl_div.style.height = eval(aktuell+schritt)+"px";
  window.setTimeout("dl_ausklappen('"+div_id+"')",10);
 }
 else
 {
  /* Direktlink ausblenden */
  if (dl_div.childNodes[0].firstChild.tagName == "A")
  dl_div.childNodes[0].firstChild.style.display = "none";

  dl_div.style.height   = "auto";
  dl_div.style.overflow = "auto";
  dl_div.childNodes[1].firstChild.firstChild.href = "javascript:dl_einklappen('"+div_id+"')";
  getElementsByClassName("einklappen")[lfd_nr].style.display = "block";
  getElementsByClassName("einklappen")[lfd_nr].firstChild.href = "javascript:dl_einklappen('"+div_id+"')";
 }
}

function dl_einklappen(div_id)
{
 var dl_div  = document.getElementById(div_id);
 var ende    = eval(dl_div.childNodes[1].firstChild.offsetHeight+33);
 var aktuell = dl_div.offsetHeight;
 var schritt = 20;


 if (browser == "Microsoft Internet Explorer") schritt = 10;

 dl_div.style.overflow = "hidden";

 if (eval(aktuell-schritt) < ende)
 {
    dl_div.style.height = eval(ende)+"px";
    aktuell = ende;
 }
 if (aktuell > ende)
 {
  dl_div.style.height = eval(aktuell-schritt)+"px";
  window.setTimeout("dl_einklappen('"+div_id+"')",10);
 }
 else
 {
  /* Direktlink einblenden */
  if (dl_div.childNodes[0].firstChild.tagName == "A")
  dl_div.childNodes[0].firstChild.style.display = "inline";

  dl_div.childNodes[1].firstChild.firstChild.href = "javascript:dl_ausklappen('"+div_id+"')";

  /* Druckansicht */
  dl_div.childNodes[2].style.display = "none";
  dl_div.childNodes[3].style.display = "none";
  dl_div.childNodes[4].style.display = "none";
  /* Ende Druckansicht */
 }
}


function druck_link()
{
 document.getElementById("druck_form").setAttribute("action","javascript:druckkontingent()");
}

function druckkontingent()
{
 var konto = document.getElementsByName("account")[0].value;
 var druck = document.getElementById("druckkontingent");

 for (var i=0; i<druck.childNodes.length; i++)
 { if (druck.firstChild.tagName == undefined) druck.removeChild(druck.firstChild); }

 if (browser == "Opera")
 {
  druck.firstChild.style.bottom = "20.4em";
 }

 if (browser == "Microsoft Internet Explorer")
 {
  druck.removeChild(druck.firstChild);
  var neu = document.createElement("iframe");
  neu.setAttribute("scrolling","no");
  neu.setAttribute("src","http://urzs3.urz.uni-magdeburg.de/nudb/kontingent/kontingent.php?account="+konto);
  druck.appendChild(neu);
 }
 else
 {
  druck.firstChild.style.visibility = "visible";
  druck.firstChild.data = "http://urzs3.urz.uni-magdeburg.de/nudb/kontingent/kontingent.php?account="+konto;
 }
}


function pemos_link()
{
 document.getElementById("pemos_form").setAttribute("action","javascript:pemos()");
}


function pemos()
{
 var formu = document.forms[0];
 var fenster = window.open("about:blank","tmp_fenster");

 formu.setAttribute("target","tmp_fenster");
 formu.setAttribute("action","http://student.pemos.de/portal/loginf.php");

 formu.submit.click();
 formu.removeAttribute("target",false);

 fenster.close();
 
 self.location.href = "http://student.pemos.de/portal/index.php?page=news";
}





/* ------------ Funktionsalgorithmus ------------ */



function infos(was)
{
 document.getElementById("info").firstChild.data = was;
}


function download_div()
{
 var dl_div = getElementsByClassName("download");

 for (var i=0; i<dl_div.length; i++)
 {
  var ori_hoehe = dl_div[i].offsetHeight;
  dl_div[i].id = ori_hoehe+"_"+i;
  
  var kinder = dl_div[i].childNodes.length;
  for (var k=0; k<kinder; k++)
  {
   if (dl_div[i].childNodes[k].tagName == undefined)
   {
    dl_div[i].removeChild(dl_div[i].childNodes[k]);
    kinder--;
    k--;
   }
  }

  var kinder = dl_div[i].childNodes[1].childNodes.length;
  for (var k=0; k<kinder; k++)
  {
   if (dl_div[i].childNodes[1].childNodes[k].tagName == undefined)
   {
    dl_div[i].childNodes[1].removeChild(dl_div[i].childNodes[1].childNodes[k]);
    kinder--;
    k--;
   }
  }

  /* Direktlink einblenden */
  if (dl_div[i].childNodes[0].firstChild.tagName == "A")
  dl_div[i].childNodes[0].firstChild.style.display = "inline";

  /* Überschrift durch Aufklapplink ersetzen */
  var tmp = dl_div[i].childNodes[1].firstChild.innerHTML;
  dl_div[i].childNodes[1].firstChild.innerHTML = "";

  var h4_link = document.createElement("a");
  h4_link.setAttribute("href","javascript:dl_ausklappen('"+dl_div[i].id+"')");
  h4_link.innerHTML = tmp;

  dl_div[i].childNodes[1].firstChild.appendChild(h4_link);
  /* Druckansicht */
  dl_div[i].childNodes[2].style.display = "none";
  dl_div[i].childNodes[3].style.display = "none";
  dl_div[i].childNodes[4].style.display = "none";
  /* Ende Druckansicht */


  dl_div[i].style.height = eval(dl_div[i].childNodes[1].firstChild.offsetHeight+33)+"px";
  dl_div[i].style.overflow = "hidden";

  if (browser == "Microsoft Internet Explorer")
  {
   /* Seltsamer IE-Bug: Hintergrundbild(Hier: Datei-Symbol) wird nur angezeigt, wenn man den
      Hintergrund für das erste Kindelement definiert. */
   dl_div[i].childNodes[1].firstChild.firstChild.style.background = "url(\"..\/\")";
  }
 }

}


function inputs()
{
 var tmp = version.search("MSIE");
 var ver = 6;
 if (tmp != -1){ ver = parseFloat(version.substring(tmp+5)); }


 if (ver >= 6)
 {
  id_zuweisen("input");
  for (var i=0; i<=document.getElementsByTagName("input").length-1; i++)
  {
   if ( document.getElementById("input"+i).value == "" )
    { hg_herstellen("input"+i); }
   ereignis_zuweisen("input"+i,"focus","hg_entfernen('input"+i+"')");
   ereignis_zuweisen("input"+i,"blur","if (document.getElementById('input"+i+"').value == '' ) { hg_herstellen('input"+i+"') }");
  }
 }
 return ver;
}


function bookmarks()
{
 var bm_pfad      = "bilder/seite/bookmark/";
 var bm_alt       = new Array();
 var bm_id        = new Array();
 var bm_link      = new Array();

 for ( var i=1; i<=22; i++ ) { bm_id[i] = "bm"+i; }

 bm_link[1]       = "http://www.mister-wong.de/index.php?action=addurl&bm_url="+location.href+"&bm_description="+document.title+"";
 bm_link[2]       = "http://www.icio.de/add.php?url="+location.href+"&title="+document.title+"";
 bm_link[3]       = "http://www.folkd.com/page/submit/"+location.href+"";
 bm_link[4]       = "http://www.yigg.de/neu?exturl="+location.href+"";
 bm_link[5]       = "http://linkarena.com/bookmarks/addlink/?url="+location.href+"";
 bm_link[6]       = "http://www.simpy.com/simpy/LinkAdd.do?href="+location.href+"&title="+document.title+"";
 bm_link[7]       = "http://del.icio.us/post?url="+location.href+"&title="+document.title+"";
 bm_link[8]       = "http://reddit.com/submit?url="+location.href+"&title="+document.title+"";
 bm_link[9]       = "http://digg.com/submit?url="+location.href+"&title="+document.title+"";
 bm_link[10]      = "http://www.furl.net/storeIt.jsp?u="+location.href+"&t="+document.title+"";
 bm_link[11]      = "http://de.bookmarks.yahoo.com?t="+document.title+"u="+location.href+"";
 bm_link[12]      = "http://www.spurl.net/spurl.php?v=3&title="+document.title+"&url="+location.href+"";
 bm_link[13]      = "http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk="+location.href+"&title="+document.title+"";
 bm_link[14]      = "http://de.blinklist.com/?Action=Blink/addblink.php&Name="+document.title+"&Url="+location.href+"";
 bm_link[15]      = "http://www.blogmarks.net/my/marks,new?url="+location.href+"&title="+document.title+"";
 bm_link[16]      = "http://www.diigo.com/post?url="+location.href+"&title="+document.title+"";
 bm_link[17]      = "http://technorati.com/faves/seoportal?add="+location.href+"";
 bm_link[18]      = "http://www.newsvine.com/_wine/save?u="+location.href+"";
 bm_link[19]      = "http://www.blinkbits.com/bookmarklets/save.php?title="+document.title+"&source_url="+location.href+"";
 bm_link[20]      = "http://ma.gnolia.com/bookmarklet/add?url="+location.href+"&title="+document.title+"";
 bm_link[21]      = "http://smarking.com/editbookmark/?url="+location.href+"";
 bm_link[22]      = "http://www.netvouz.com/action/submitBookmark?url="+location.href+"&title="+document.title+"";

 bm_alt[1]        = "MISTER WONG";
 bm_alt[2]        = "Icio";
 bm_alt[3]        = "folkd.com";
 bm_alt[4]        = "Yigg.de";
 bm_alt[5]        = "LinkArena.com";
 bm_alt[6]        = "Simpy.com";
 bm_alt[7]        = "del.icio.us";
 bm_alt[8]        = "Reddit.com";
 bm_alt[9]        = "Digg.com";
 bm_alt[10]       = "furl.net";
 bm_alt[11]       = "yahoo Bookmarks";
 bm_alt[12]       = "Englisch-große Community";
 bm_alt[13]       = "G00gle";
 bm_alt[14]       = "BlinkList.com";
 bm_alt[15]       = "Blogmarks.net";
 bm_alt[16]       = "diigo.com";
 bm_alt[17]       = "technorati.com";
 bm_alt[18]       = "Newsvine.com";
 bm_alt[19]       = "blinkbits.com";
 bm_alt[20]       = "gnolia.com";
 bm_alt[21]       = "Smarking.com";
 bm_alt[22]       = "netvouz.com";



 var h_inhalt = getElementsByClassName("hauptinhalt");

 if (h_inhalt.length != 0)
 {
  var bm_div = document.createElement("div");
  if (browser == "Microsoft Internet Explorer") bm_div.setAttribute("className","bookmarks");
  else  bm_div.setAttribute("class","bookmarks");

  var bm_div2 = document.createElement("div");

  var bm_p = document.createElement("p");
  bm_p.innerHTML = "Seite empfehlen bei";

  bm_div2.appendChild(bm_p);
  bm_div.appendChild(bm_div2);

  var bm_div3 = document.createElement("div");
  var bm_ul = document.createElement("ul");

  for (var i=1; i<=22; i++)
  {
   var bm_li = document.createElement("li");
   var bm_a    = document.createElement("a");
   bm_a.href = bm_link[i];

   var bm_img  = document.createElement("img");
   bm_img.setAttribute("src",bm_pfad + "bm" + i +".gif");
   bm_img.setAttribute("alt",bm_alt[i]);
   bm_img.setAttribute("title",bm_alt[i]);
   bm_img.setAttribute("height","20px");
   bm_img.setAttribute("width","20px");

   bm_a.appendChild(bm_img);
   bm_li.appendChild(bm_a);
   bm_ul.appendChild(bm_li);
  }
  bm_div3.appendChild(bm_ul);
  bm_div.appendChild(bm_div3);

  for (var i=0; i<h_inhalt.length; i++)
  {
   h_inhalt[i].appendChild(bm_div);
   var bm_div = h_inhalt[i].lastChild.cloneNode(true); /* true: Inhalt mitklonen */
  }
 }
}


function gleichlange_div(div_id1,div_id2)
{
 if (typeof(div_id1) != "string")
 {
  div_id1 = String(div_id1.id);
  div_id2 = String(div_id2.id);
 }

 var welcher   = div_id1;
 var div1      = document.getElementById(div_id1);
 var div2      = document.getElementById(div_id2);

 div1.style.paddingBottom = "0";
 div2.style.paddingBottom = "0";

 var h_div1    = parseInt(div1.offsetHeight);
 var h_div2    = parseInt(div2.offsetHeight);
 var differenz = h_div2 - h_div1;
 

 if (differenz < 0) { welcher = div_id2; differenz = -differenz; }
 differenz = differenz + "px";

 document.getElementById(welcher).style.paddingBottom = differenz;


 setTimeout("gleichlange_div('"+div_id1+"','"+div_id2+"')",1000);
}



function initialisierung()
{
 gleichlange_div("inhalt","navigation");
 lichtkasten_init();
 inputs();
 download_div();
 bookmarks();
// infos(was);
 if (window.location.href.search("pemos") != -1)     pemos_link();
 if (window.location.href.search("sonstiges") != -1) druck_link();
}

 window.onload = initialisierung;