// -----------------------------------------------------------------------------------
// This file contains common JavaScripts
// -----------------------------------------------------------------------------------
// 
// :: BrowserDetection   -> returns some variables, which browser is used
// :: MM_openBrWindow    -> opens new browserwindow
// :: deblur             -> nach anklicken eines Links deblur(this);
// -----------------------------------------------------------------------------------

var MAC_NS, PC_NS, IE, PC_MOZ, MOZ;
// Browserdetection
MAC_NS = false; MAC_IE  = false; 
PC_NS  = false; PC_IE   = false;
IE     = false; NS      = false;
PC_MOZ = false; MAC_MOZ = false; 
MOZ    = false;

BROWSERVERSION = 0;
p = parent;
        
BROWSERVERSION = navigator.appVersion.substring(0,1);

// just use css of ie - it's the same. ulf 05-16-02
if((navigator.userAgent.indexOf("Opera")!=-1))
  PC_IE = true;

if((navigator.userAgent.indexOf("Gecko")!= -1))
  { 
  if((navigator.appVersion.indexOf("Mac")!= -1))
    {
    MAC_MOZ = true;
    MOZ     = true;
    } 
  else
    {
    PC_MOZ   = true;
    MOZ    = true;
    }
  }
        
if((navigator.appVersion.indexOf("Mac")!= -1))
  {
  if(navigator.appName=="Netscape")
    {
    MAC_NS = true;
    NS     = true;
    }
  else
    {
    MAC_IE = true;
    IE     = true;
    }
  }
else
  {
  if(navigator.appName=="Netscape")
    {
    PC_NS = true;
    NS    = true;
    }
  else
    {
    PC_IE = true;
    IE    = true;
    }
  }

// Gets Layer Reference
function MM_findObj(n, d)
  { //v3.0
  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); return x;
  }

// Gets Layer Reference
function tmt_findObj(n)
  {
  var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
  x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
  }else{x=document.getElementById(n)}return x;
  }

// Show/Hode Layer
function MM_showHideLayers()
  { 
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
  for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
  v=(v=='show')?'visible':(v='hide')?'hidden':v;
  if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
  obj.visibility=v; }}
  }

// Opens New BrowserWindow
function MM_openBrWindow(theURL,winName,features)
  { 
  // SessionID ermitteln und bei Bedarf an URL anhängen
  get_param = document.location.search;
  //alert(get_param);
  
  if( get_param.length > 1 && theURL.indexOf("sessionid") == -1 )
    {
    get_param = get_param.substr(1,get_param.length);
    
    if( get_param.charAt(0) == "&" )
      get_param = get_param.substr(1,get_param.length);
    
    params    = get_param.split( "&" );
    sessionid = "";
    
    for( i=0; i<params.length; i++)
      {
      vars = params[i].split( "=" );
      key  = vars[0];
      if( vars.length > 1 )
        val  = vars[1];
      else
        val  = "";
      
      if( key == "sessionid" )
        sessionid = val;
      }
    
    if( sessionid != "" )
      {
    
      if( theURL.indexOf("?") == -1 ) 
        theURL += "?sessionid=" + sessionid;
      else
        theURL += "&sessionid=" + sessionid;
      }
    }
    
  // neues Fenster oeffnen
  OpenWin = window.open(theURL,winName,features);
  
  // eigene Instanz an neues Fenster uebergeben
  OpenWin.opener = self; 
  
  // neues Fenster fokussieren
  OpenWin.focus();    
  }
    
function popupShowMain( url )
  {
  top.opener.top.document.location= url;
  //window.close();
  }    

// HideScrollbar
function HideScrollBar()
  {
  if( IE )
    document.body.scroll = "no"; 
  }

// Deblur nach Anklicken eines Links
function deblur(x)
  {
  if ( IE || MOZ )
    x.blur();
  }
    
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);
