
//***************************************************************************
// allow only frame-free-environment "in the wild"!
//***************************************************************************
if(self!=top) {
  if ((window.location.hostname != 'cms.uni-karlsruhe.de') && (window.location.hostname != 'cms2.uni-karlsruhe.de')) {
    top.location.href = self.location.href;
  }
}

//***************************************************************************
//check if browser knows DOM, is MOZILLA etc...
//***************************************************************************
var dom = false;    //true if browser knows document.getElementByID
var msie = false;   // true if browser knows document.all
var net = false;    //true if browser knows document.layers
var moz = false;    //true if browser knows document.getElementByID but not document.all, browser may also be OPERA!
document.all&&window.offscreenBuffering?msie=true:msie=false;
document.layers&&!document.getElementById?net=true:net=false;
document.getElementById?dom=true:dom=false;
document.getElementById&&document.all?moz=false:moz=true;
document.getElementById&&!document.all?moz=true:moz=false;
// IE + win32
// curtain down
// its exciting. girls are screaming. whats behind the curtain?
// curtain will be lifted up by the minmax_scanning-function
// lookout for >> hide('vorhang') <<
/*@cc_on
@if (@_win32 && @_jscript_version>4) {
document.write('<div class="vorhang" id="vorhang" style="position:absolute;top:0px;left:0px;background:#ffffff;color:#ffffff;width:100%;height:100%;visibility:visible;z-index:999;">&nbsp;</div>')
document.getElementById('vorhang').style.height = getWindowHeight();
}
@end @*/

var array_links = new Array();
function show_links() {
    var server = document.URL.substring(0, document.URL.lastIndexOf('/')+1);
    var script = document.URL.substring(document.URL.lastIndexOf('/')+1);
    script = script.substring(0, script.lastIndexOf('#'));
    var div = document.createElement('div');
    div.setAttribute((document.all ? 'className' : 'class'), 'show_print_only');
    div.className = 'show_print_only';
    var foo = div.appendChild(document.createElement('ul'));
    foo.setAttribute((document.all ? 'className' : 'class'), 'show_print_only');
    foo.className = 'show_print_only';
    foo.appendChild(document.createElement('br'));
    var foo_h2 = foo.appendChild(document.createElement('h2'));
    foo_h2.appendChild(document.createTextNode('Links'));
    
    var count = 1;
    var array_elements = document.getElementById('content').getElementsByTagName('*');
    for (var i = 0; i < array_elements.length; i++) {
        if ((array_elements[i].getAttribute('href')) && (array_elements[i].getAttribute('src') != array_elements[i].getAttribute('href')) ){
            var found = -1;
            for (var j = 0; j < array_links.length; j++) {
                if (array_links[j] == array_elements[i].getAttribute('href')) {
                    found = j;
                }
            }
            var note = document.createElement('sup');
            note.setAttribute((document.all ? 'className' : 'class'), 'show_print_only');
            note.className = 'show_print_only';
            if (found >= 0) {
                note.appendChild(document.createTextNode(found));
            } else {
                note.appendChild(document.createTextNode(count));
                var foo_li = foo.appendChild(document.createElement('li'));
                addon = (array_elements[i].getAttribute('href').indexOf('://') < 0) ? server : '';
                addon += (array_elements[i].getAttribute('href').charAt(0) == '#') ? script : '';
                if (array_elements[i].getAttribute('href').charAt(0) == '/') addon = addon.substring(0, addon.length - 1);
                foo_li.appendChild(document.createTextNode(count + '. ' + addon + array_elements[i].getAttribute('href')));
                array_links[count] = array_elements[i].getAttribute('href');
                count++;
            }
            array_elements[i].parentNode.insertBefore(note, array_elements[i].nextSibling);
        }
    }
    document.getElementById('content').appendChild(div);
}

//***************************************************************************
//init the headcell, the document size
//***************************************************************************
function init(headcell) {
//    show_links();
    //headcell
   if(dom && headcell!='' && headcell>0 && headcell<13) {
      headcell = 'headcell'+headcell;
      //set the actual headercell highlighted
      document.getElementById(headcell).className = "headercellactive";
      
      //preload all the necessary images
      var preload = new Array();
      for(i=0;i<document.getElementsByTagName("img").length;i++){
        mySrc = document.getElementsByTagName("img")[i].src;
         if(mySrc.indexOf("_0.gif")>0) {
          newSrc=mySrc.replace(/_0.gif/,"_1.gif");
          preload[i]= new Image();
          preload[i].src;
        }
      }
    }
    //set the document height at least to the window height
  
    //get window-size
    d=document
       if (typeof window.innerWidth!='undefined') {
        var winWidth = window.innerWidth;
        var winHeight = window.innerHeight;
       } else {
        if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
         var winWidth = d.documentElement.clientWidth
         var winHeight = d.documentElement.clientHeight
        } else {
         if (d.body && typeof d.body.clientWidth!='undefined') {
          var winWidth = d.body.clientWidth
          var winHeight = d.body.clientHeight
         }
        }
       }
    //get document sizes
    moz?offsetHeight=50:offsetHeight=20;
    document.getElementById("header")?headerHeight = document.getElementById("header").offsetHeight:headerHeight=0;
    document.getElementById("middleline")?middlelineHeight = document.getElementById("middleline").offsetHeight:middlelineHeight=0;
    document.getElementById("footer")?footerHeight = document.getElementById("footer").offsetHeight:footerHeight = 0;
    document.getElementById("changedate")?changedateHeight = document.getElementById("changedate").offsetHeight:changedateHeight = 0;
    document.getElementById("feedback")?feedbackHeight = document.getElementById("feedback").offsetHeight:feedbackHeight = 0;
    document.getElementById("main")?mainHeight = document.getElementById("main").offsetHeight:mainHeight = 0;
    //set footer to the bottom only if documents height is less than windows height 
    if(winHeight > (headerHeight + middlelineHeight + mainHeight + footerHeight + changedateHeight)) {
        document.getElementById("main").style.height = winHeight - headerHeight - middlelineHeight - footerHeight - changedateHeight - offsetHeight + "px";
    }
    //set height of navigation-div to height of main-div!
    // "dann klappts auch mit den abständen nach links..."
/** 03.05.05 ek -- wird nicht benötigt, anpassungen im css haben denselben effekt**/
   // setHeight('navigation',getHeight('main'));
}
//***************************************************************************
//do the highlighting for the left menus
//***************************************************************************
//
//Use: onmouseover="hilight('whichmenu','ID')"
//
//****************************************************************************
function hilight(which, id) {
   if(which=='mainmenu') {
      tdelm=document.getElementById('entry'+id);
      arrowelm=document.getElementById('arrow'+id);
      tdelm.className=="menuentry"?tdelm.className="menuentryactive":tdelm.className="menuentry";
      arrowelm.className=="menuarrow"?arrowelm.className="menuarrowactive":arrowelm.className="menuarrow";
    }
    if(which=='submenu') {
      tdelm=document.getElementById('subentry'+id);
      tdelm.className=="submenuentry"?tdelm.className="submenuentryactive":tdelm.className="submenuentry";
    }
}

//***************************************************************************
//change images
//***************************************************************************
//
//changing: <name>_0.gif <--> <name>_1.gif
//Use: <img src="" onmouseover=changeImage(this) onmouseout=changeImage(this)
//
// img_0 and img_1 have to be stored in the same directory!
//****************************************************************************
function changeImage(el) {
  if(dom) {
    oldSrc = el.src;
    oldSrc.indexOf("_0.gif")>0?newSrc=oldSrc.replace(/_0.gif/,"_1.gif"):newSrc=oldSrc.replace(/_1.gif/,"_0.gif");
    el.src = newSrc;
  }
}
//*****************************************
// do the google search
// 
// sitesearch.value is allways set to the server
// in the browsers URL
//
//****************************************
function initGoogleSearch() {
    //get actual server
    //google results only for this server!
     
    myServer = window.location.host;
    if(myServer.indexOf("www.uni-karlsruhe.de")>-1) {
        myServer = "uni-karlsruhe.de"; 
    }
    //myServer = "http://www.uni-karlsruhe.de";
    document.forms["searchForm"].domains.value="uni-karlsruhe.de";
    document.forms["searchForm"].hl.value="de";
    document.forms["searchForm"].ie.value="ISO-8859-1";
    document.forms["searchForm"].oe.value="ISO-8859-1";
    document.forms["searchForm"].sitesearch.value=myServer;
    document.forms["searchForm"].action = "http://www.google.com/u/karlsruhe"
    document.forms["searchForm"].submit();
    return false;
}
  // **********************************//
  // this one belongs to klaus...
  // 
  // TBD: CHECK IF THIS IS USED ANYMORE!
  // ISSUE: SEEMS TO BE USED IN THE LEFT-NAVIGATIONS
  //        BUT THIS IS NOT FOR SURE... :-))
   // 
 /*********** OLD ONE ... ************/
  function target_click( url, target )
  {
    if ( target == "blank" )
      w = window.open( url, "Fenster1", "location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes" );
    else if ( target == "top" )
      top.location.href = url;
    else
      self.location.href = url;
  }
//****************************************//
// open Window for Glossary
// 
//
//
/****************************************/
 function openGlossar(url) {
   myurl = url+"?edit=no"
   properties = 'toolbar=no,location=no,directories=no,status=no,titlebar=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=450,top=10,left=10';
   glossarWin=window.open(myurl,'glossar',properties);
   glossarWin.focus();    
   return false;
 }
/*************************************************
    ´BASIC DHTML FUNCTIONS
**************************************************/
//
// this are some basic dhtml functions to return and set some
// essential element-properties
// like their position on the page or the visibility
// functions names should be self-explaining...
// have fun...
function getWindowWidth() {
    d=document
       if (typeof window.innerWidth!='undefined') {
        return winWidth = window.innerWidth;
       } else {
        if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
         return winWidth = d.documentElement.clientWidth
        } else {
         if (d.body && typeof d.body.clientWidth!='undefined') {
          return winWidth = d.body.clientWidth
         }
        }
       }
}
function getWindowHeight() {
    d=document
       if (typeof window.innerWidth!='undefined') {
        return winHeight = window.innerHeight;
       } else {
        if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
         return winHeight = d.documentElement.clientHeight
        } else {
         if (d.body && typeof d.body.clientWidth!='undefined') {
          return winHeight = d.body.clientHeight
         }
        }
       }
}
function getElemLeft(elem) {
   if(msie) {
       var layer = document.getElementById(elem), x=0;
        if(layer){
          while (layer.offsetParent != null && layer.offsetParent.tagName != "HTML") {
            x += layer.offsetLeft; layer = layer.offsetParent; 
            }
          x += layer.offsetLeft;
        }
         return x;
    }
 if(net)return eval('document.layers["'+elem+'"]').left;
 //if(moz)return parseInt(eval('document.getElementById("'+elem+'")').style.left);
 if(dom) {
    element = document.getElementById(elem);
       var left = 0;
       do {
         left += element.offsetLeft;
         element = element.offsetParent;
       }
       while (element)
       return left;
  }
}
function getElemTop(elem) {
   if(msie) {
       var layer = document.getElementById(elem), y=0;
        if(layer){
          while (layer.offsetParent != null && layer.offsetParent.tagName != "HTML") {
            y += layer.offsetTop; layer = layer.offsetParent; 
            }
          y += layer.offsetTop;
        }
         return y;
    }
 if(net) return eval('document.layers["'+elem+'"]').top;
 if(dom) {
    element = document.getElementById(elem);
       var top = 0;
       do {
         top += element.offsetTop;
         element = element.offsetParent;
       }
       while (element)
       return top;
    }
}
function setElemLeft(elem,i) {
    if(net)eval('document.layers["'+elem+'"]').left=i+"px";
    if(dom) {
        document.getElementById(elem).style.left=i+"px";
    }
}
function setElemTop(elem,i) {
    if(net)eval('document.layers["'+elem+'"]').top=i;
    if(dom) {
        document.getElementById(elem).style.top=i+"px";
    }
}
function getWidth(elem){
 if(net)return eval('document.layers["'+elem+'"]').clip.width;
 if(dom)return eval('document.getElementById("'+elem+'")').offsetWidth;
}
function setWidth(elem,w){
 if(net)eval('document.layers["'+elem+'"]').clip.width=w;
 if(dom)eval('document.getElementById("'+elem+'")').style.width=w;
}
function getHeight(elem){
 if (elem){
     
     if(net){
        if (eval('document.layers["'+elem+'"]'))
            return eval('document.layers["'+elem+'"]').clip.height;
        else
            return 0;
     }
     if(dom){
        if (eval('document.getElementById("'+elem+'")'))
            return eval('document.getElementById("'+elem+'")').offsetHeight;
        else
            return 0;
     }
 }
}
function setHeight(elem,h){
 if(net)eval('document.layers["'+elem+'"]').clip.height=h;
 if(dom)eval('document.getElementById("'+elem+'")').style.height=h;
}
function getVisibility(elem){
 if(net) return eval('document.layers["'+elem+'"]').visibility;
 if(dom) return eval('document.getElementById("'+elem+'")').style.visibility;
}
function show(elem){
 if(net)eval('document.layers["'+elem+'"]').visibility="show";
 if(dom)eval('document.getElementById("'+elem+'")').style.visibility="visible";
}
function hide(elem){
 if(net)eval('document.layers["'+elem+'"]').visibility="hide";
 if(dom)eval('document.getElementById("'+elem+'")').style.visibility="hidden";
}
function clipRect(elem,t,r,b,l){
 
 if(net){
  var lyrRef=eval('document.layers["'+elem+'"]');
  lyrRef.clip.top=t;
  lyrRef.clip.right=r;
  lyrRef.clip.bottom=b;
  lyrRef.clip.left=l;
 }
 if(dom)eval('document.getElementById("'+elem+'")').style.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
}
function pushTo(elem,px,py){
 if(net) eval('document.layers["'+elem+'"]').moveTo(px,py);
 if(dom){
  eval('document.getElementById("'+elem+'")').style.left=px;
  eval('document.getElementById("'+elem+'")').style.top=py;
 }
}
function setClassNameByElemName(elem, i, myclass) {
 if(dom){
  eval('document.getElementsByName("'+elem+'")')[i].className=myclass;
 }
}
function setClassNameByElemId(elem, myclass) {
 if(dom){
  eval('document.getElementById("'+elem+'")').className=myclass;
 }
}

/****************************************************/

//************************************
//skip all errors on live servers
//************************************
//
// this is to supress all errors on the live-Server
// if server name starts with www or test-www
// no javascript errors will be shown
// remember this, if the pages are doing funny things, and you are not willing to laugh about them!!!
// maybe some javascript-code is "running amok"...
function resumeNext() {
  return true;
}
if(document.URL.indexOf("://www")>0 || document.URL.indexOf("://test-www")>0){
  document.all?window.onerror=resumeNext:window.onError=resumeNext;
}

//*****************************************//
//*****************************************//
// MINIMAX FUNCTION                        //
//
//*****************************************//
// needed cause of ie's fuckin min-max-implementation
// minmax.js: make IE5+/Win support CSS min/max-width/height
// version 1.0, 08-Aug-2003
// written by Andrew Clover <and@doxdesk.com>, use freely
/*@cc_on
@if (@_win32 && @_jscript_version>4)
var minmax_elements;
minmax_props= new Array(
  new Array('min-width', 'minWidth'),
  new Array('max-width', 'maxWidth'),
  new Array('min-height','minHeight'),
  new Array('max-height','maxHeight')
);

// Binding. Called on all new elements. If ..body.., initialise; check all
// elements for minmax properties


function minmax_bind(el) {
  var i, em, ms;
  var st= el.style, cs= el.currentStyle;
  if (minmax_elements==window.undefined) {
    // initialise when body element has turned up, but only on IE
    if (!document.body || !document.body.currentStyle) return;
    minmax_elements= new Array();
    window.attachEvent('onresize', minmax_delayout);
    // make font size listener
    em= document.createElement('div');
    em.setAttribute('id', 'minmax_em');
    em.style.position= 'absolute'; em.style.visibility= 'hidden';
    em.style.fontSize= 'xx-large'; em.style.height= '5em';
    em.style.top='-5em'; em.style.left= '0';
    if (em.style.setExpression) {
      em.style.setExpression('width', 'minmax_checkFont()');
      document.body.insertBefore(em, document.body.firstChild);
    }
  }
  // transform hyphenated properties the browser has not caught to camelCase
  for (i= minmax_props.length; i-->0;)
    if (cs[minmax_props[i][0]])
      st[minmax_props[i][1]]= cs[minmax_props[i][0]];
  // add element with properties to list, store optimal size values
  for (i= minmax_props.length; i-->0;) {
    ms= cs[minmax_props[i][1]];
    if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
      st.minmaxWidth= cs.width; st.minmaxHeight= cs.height;
      minmax_elements[minmax_elements.length]= el;
      // will need a layout later
      minmax_delayout();
      break;
  } }
}

// check for font size changes
var minmax_fontsize= 0;
function minmax_checkFont() {
  var fs= document.getElementById('minmax_em').offsetHeight;
  if (minmax_fontsize!=fs && minmax_fontsize!=0)
    minmax_delayout();
  minmax_fontsize= fs;
  return '5em';
}

// Layout. Called after window and font size-change. Go through elements we
// picked out earlier and set their size to the minimum, maximum and optimum,
// choosing whichever is appropriate
// Request re-layout at next available moment


var minmax_delaying= false;
function minmax_delayout() {
  if (minmax_delaying) return;
  minmax_delaying= true;
  window.setTimeout(minmax_layout, 0);
}
function minmax_stopdelaying() {
  minmax_delaying= false;
}

function minmax_layout() {
  window.setTimeout(minmax_stopdelaying, 100);
  var i, el, st, cs, optimal, inrange;
  for (i= minmax_elements.length; i-->0;) {
    el= minmax_elements[i]; st= el.style; cs= el.currentStyle;
    // horizontal size bounding
    st.width= st.minmaxWidth; optimal= el.offsetWidth;
    inrange= true;
    if (inrange && cs.minWidth && cs.minWidth!='0' && cs.minWidth!='auto' && cs.minWidth!='') {
      st.width= cs.minWidth;
      inrange= (el.offsetWidth<optimal);
    }
    if (inrange && cs.maxWidth && cs.maxWidth!='none' && cs.maxWidth!='auto' && cs.maxWidth!='') {
      st.width= cs.maxWidth;
      inrange= (el.offsetWidth>optimal);
    }
    if (inrange) st.width= st.minmaxWidth;
    // vertical size bounding
    st.height= st.minmaxHeight; optimal= el.offsetHeight;
    inrange= true;
    if (inrange && cs.minHeight && cs.minHeight!='0' && cs.minHeight!='auto' && cs.minHeight!='') {
      st.height= cs.minHeight;
      inrange= (el.offsetHeight<optimal);
    }
    if (inrange && cs.maxHeight && cs.maxHeight!='none' && cs.maxHeight!='auto' && cs.maxHeight!='') {
      st.height= cs.maxHeight;
      inrange= (el.offsetHeight>optimal);
    }
    if (inrange) st.height= st.minmaxHeight;
  }
  hide('vorhang');

  if(typeof posDivs == "function") {
     posDivs();
    }

}

// Scanning. Check document every so often until it has finished loading. Do
// nothing until ..body.. arrives, then call main init. Pass any new elements
// found on each scan to be bound 


var minmax_SCANDELAY= 500;
function minmax_scan() {
    var el = document.getElementById("content");
    var grenze = document.all.length
    if (el){
        if (grenze > el.sourceIndex+50)
            grenze = el.sourceIndex + 50;
   
        for (var i= 0; i<grenze; i++) {
            el= document.all[i];
            if (!el.minmax_bound) {
                el.minmax_bound= true;
                minmax_bind(el);
            }
        }
    
        el = document.getElementById("footer");
        if (el && !el.minmax_bound) {
            el.minmax_bound= true;
            minmax_bind(el);
        }
    
        el = document.getElementById("changedate");
        if (el && !el.minmax_bound) {
            el.minmax_bound= true;
            minmax_bind(el);
        }  

    }else{
        //Falls es keinen content gibt Funktion trotzdem starten um Vorhang wieder zu entfernen
        
        for (var i= 0; i<grenze; i++) {
            el= document.all[i];
            if (!el.minmax_bound) {
                el.minmax_bound= true;
                minmax_bind(el);
            }
        }

    }
       
}
var minmax_scanner;
function minmax_stop() {
  window.clearInterval(minmax_scanner);
  minmax_scan();
}
function hide_vorhang(){
 hide('vorhang');
}

minmax_scan();
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
window.attachEvent('onload', minmax_stop);

@end @*/
