//**************************************************
//* Öffnet das externe Fenster des Dataranges
//**************************************************
function OpenRangeInNewWindow(p_strId) {
  l_strPath = "../../../_upinclude/script/UpRangeWindow.asp?rq_lDRId=" + p_strId;
  if (! self.RangeWindow)
      RangeWindow = window.open(l_strPath,"UpPopup","dependent=yes,status=no,menubar=no,resizable=yes,scrollbars=yes,width=450,height=350,screenX=0,screenY=0");
  else {
    if (self.RangeWindow.closed)
      RangeWindow = window.open(l_strPath,"UpPopup","dependent=yes,status=no,menubar=no,resizable=yes,scrollbars=yes,width=450,height=350,screenX=0,screenY=0");
    else {
      self.RangeWindow.document.location.href = l_strPath;
      self.RangeWindow.focus();
    }
  }
  return ;
}

//**************************************************
//* Schliesst das offene Fenster des Dataranges
//**************************************************
function CloseWindow() {
  if (self.RangeWindow) {
    if(!self.RangeWindow.closed) {
      self.RangeWindow.close();
    }
  }

  if (self.wndPrint && !self.wndPrint.closed) {
    self.wndPrint.close();
  }
  if (self.wndHelp && !self.wndHelp.closed) {
    self.wndHelp.close();
  }
  if (self.wndShowPic && !self.wndShowPic.closed) {
    self.wndShowPic.close();
  }
  if (self.wndGetTQPic && !self.wndGetTQPic.closed) {
    self.wndGetTQPic.close();
  }
}

//**************************************************
//* Setzt den Referer für den Back Button
//**************************************************
function setReferer() {
  if (parent.UpAppMain) {
    function oldErrorHandler() {
      return false;
    }

    function errorHandler() {
      window.onerror=oldErrorHandler;
      return true;
    }
    window.onerror=errorHandler;
    var l_strReferer = parent.UpAppMain.location.href;
    l_strReferer = l_strReferer.substr(l_strReferer.lastIndexOf("/")+1,l_strReferer.length);
    document.__UpFormReferer.fr_strReferer.value = l_strReferer;
  }
}

//----------------------------------------------------
function ResizeScndLvl(p_bReset) {
//----------------------------------------------------
  if ( !top.document.getElementById('UpNavigate') ) {
    return false;
  } else {
    if ( top.document.getElementById('UpNavigate') ) {
      var oBtn = top.UpApplication.UpAppNav.document.getElementById('ResizeSecndLvLButton');
      var l_lTopScndLevWidth = g_lTopScndLevWidth;
      if ( top.document.getElementById('UpNavigate').style.width == '1px' || p_bReset) {
        top.document.getElementById('UpNavigate').style.width = l_lTopScndLevWidth;
        oBtn.src = l_strPathImg + '../images/assets/minus.gif';
        oBtn.title = lc_strHideSecondLevel;
      } else {
        top.document.getElementById('UpNavigate').style.width = '1px';
        oBtn.src = l_strPathImg + '../images/assets/plus.gif';
        oBtn.title = lc_strShowSecondLevel;
      }
    }
  }
  return;
}

//----------------------------------------------------
function PrintFrame() {
//----------------------------------------------------
  parent.UpAppMain.focus();
  parent.UpAppMain.print();
}

//----------------------------------------------------
function setWindowStartSize() {
//----------------------------------------------------
  var wW=0,wH=0,cW=1024,cH=768;
  var sW=screen.width;
  if (IE4) {
      wH=top.document.body.offsetHeight;
      wW=top.document.body.offsetWidth;
  } else if(NS4) {
      wH=top.document.body.outerHeight;
      wW=top.document.body.outerWidth;
  }
  if (parseInt(sW,10) < cW)
    cW=800,cH=600;
  top.resizeTo(cW,cH)
}

//----------------------------------------------------
function window_OnLoad(p_lFormId) {
//----------------------------------------------------
  window.setTimeout("clicked('g_lFormId" + p_lFormId + "')", 150);
}

//----------------------------------------------------
function GetScreenPosition(oEvent) {
//----------------------------------------------------
  oX=oEvent.screenX;
  oY=oEvent.screenY;
}

//----------------------------------------------------
function LogOut(bIsAnoUser, bCanConnectTrusted, event) {
//----------------------------------------------------
  if (bCanConnectTrusted) {
    window.top.location.href='../_UpMisc/_Abandon.asp';
    return
  }
  if (!event.ctrlKey && bIsAnoUser != true) {
      if (window.top.UpNavigate) {
        if (window.top.UpNavigate.wndShowUser && !window.top.UpNavigate.wndShowUser.closed) {
          window.top.UpNavigate.wndShowUser.close();
        }
        if (window.top.UpNavigate.SearchWin && !window.top.UpNavigate.SearchWin.closed) {
          window.top.UpNavigate.SearchWin.close();
        }
        if (window.top.UpNavigate.wndWait && !window.top.UpNavigate.wndWait.closed) {
          window.top.UpNavigate.wndWait.close();
        }
        if (window.top.wndPicker && !window.top.wndPicker.closed) {
          window.top.wndPicker.close();
        }
        if (self.wndLogin && !self.wndLogin.closed) {
          self.wndLogin.close();
        }
      }
      window.top.location.href='../_UpMisc/_Abandon.asp';
  } else {
    var wW,sMode;
    if (IE4 || NS5) {
      // PopUp relativ zum Hauptfenster setzen
      // unter Berücksichtigung des sichtbaren Bereichs
      wW = (self.document.body.offsetWidth/2)+180;
      if (IE4) {
        oX = window.event.screenX-wW;
        oY = window.event.screenY+100;
      } else {
        oX = oX-wW;
        oY = oY+100;
      }
      if ((oY+240) > screen.availHeight)
        oY=(screen.availHeight/2)-120;
      if (oX < 0)
        oX=(screen.availWidth/2)-210;
      sMode = "dependent=yes,resizable=yes,width=410,height=230,left=" + oX + ",top="+ oY
    } else {
      sMode = "dependent=yes,resizable=yes,width=420,height=260,sreenX=" + oX + ",screenY="+ oY
    }
    wndLogin = open("../_Upmisc/Login/login.asp","Login",sMode);
  }
  return;
}

//----------------------------------------------------
function clicked(strID) {
//----------------------------------------------------
  if (! document.getElementById(strID)) return;
  if ( strClicked != strID ) {
    temp    = strClicked;
    strClicked    = strID;
    MouseOut(temp);
  }
  MouseIn(strID);
  return;
}

//----------------------------------------------------
function MouseIn(strID) {
//----------------------------------------------------
  if(! document.getElementById(strID)) return;
  doc = document.getElementById(strID)
  docDiv = document.getElementById(strID + "Div")

  if ( l_bTreeNav == "True" && strID.substr(0,5) == "l_App" ) {
    doc.style.color = l_strSubMouseOverFont;
  } else {
    doc.style.color = l_strMouseOverFont;
  }

  if (g_lButtonStyle == 1) {
    if ( l_bBgEffect ) docDiv.style.backgroundImage = 'url(' + l_strPathImg + l_strMouseOverImg + ')';
    if (g_lShowBorder == 1) {

      if (document.all) {
        docDiv.style.padding = "2px 3px 2px 3px;";
      } else {
        docDiv.style.padding = "3px 4px 3px 4px;";
      }

      docDiv.style.borderLeftColor   = l_strMouseOverBorder;
      docDiv.style.borderRightColor  = l_strMouseOverBorder;
      docDiv.style.borderTopColor    = l_strMouseOverBorder;
      docDiv.style.borderBottomColor = l_strMouseOverBorder;
      docDiv.style.borderStyle       = l_strBorderStyle;
    }
    docDiv.style.backgroundColor = l_strMouseOverColor;
  } else {
    doc.style.textDecoration = 'underline';
  }
    doc.blur();
}

//----------------------------------------------------
function MouseOut(strID) {
//----------------------------------------------------
  if(! document.getElementById(strID)) return;
  doc = document.getElementById(strID)
  docDiv = document.getElementById(strID + "Div")

  if (strClicked != strID) {
    if ( l_bTreeNav == "True" && strID.substr(0,5) == "l_App" ) {
      doc.style.color = l_strSubMouseOutFont;
    } else {
      doc.style.color = l_strMouseOutFont;
    }
    doc.style.textDecoration = 'none';

    if (g_lButtonStyle == 1) {
      if ( l_bBgEffect ) docDiv.style.backgroundImage = 'url(' + l_strPathImg + l_strMouseOutImg + ')';
      if (g_lShowBorder == 1) {

        docDiv.style.padding = "3px 4px 3px 4px;";
        docDiv.style.borderLeftColor   = "";
        docDiv.style.borderRightColor  = "";
        docDiv.style.borderTopColor    = "";
        docDiv.style.borderBottomColor = "";
        docDiv.style.borderStyle       = "none";
      }
      docDiv.style.backgroundColor = "";
    }
  } else {

    if ( l_bTreeNav == "True" && strID.substr(0,5) == "l_App" ) {
      doc.style.color = l_strSubMouseClickedFont;
    } else {
      doc.style.color = l_strMouseClickedFont;
    }

    if ( g_lButtonStyle == 1 && l_bBgEffect ) {
      docDiv.style.backgroundColor = l_strMouseClickedColor;
      docDiv.style.backgroundImage = 'url(' + l_strPathImg + l_strMouseClickedImg + ')';
    }
  }
}



//----------------------------------------------------
function toggleSubMenu(strIDSub,p_bOpen,p_bToggleImg) {
//----------------------------------------------------
  if(! p_bOpen) return;
  submenu=document.getElementById(strIDSub)
  if (eval(submenu) == null) return;
  if ( submenu.style.display == "none" ) {
    submenu.style.display = "block";
    if ( p_bToggleImg ) document.getElementById('img'+strIDSub).src = l_strImageMinus;
  } else {
    submenu.style.display = "none";
    if ( p_bToggleImg ) document.getElementById('img'+strIDSub).src = l_strImagePlus;
  }
  return;
}

//----------------------------------------------------
function CloseTree() {
//----------------------------------------------------
  var l_aDivs = document.getElementsByTagName("div");
  for ( i=0; i < l_aDivs.length; i++ ) {
    if ( l_aDivs[i].getAttribute("name") == "TopNavMenu" || l_aDivs[i].getAttribute("name") == "UpSubMenu" ) l_aDivs[i].style.display = 'none';
  }
  var l_aImgs = document.getElementsByTagName("img");
  for ( i=0; i < l_aImgs.length; i++ ) {
    if ( l_aImgs[i].getAttribute("name") == "imgPlusMinus" ) l_aImgs[i].src = l_strImagePlus;
  }
  return;
}