var requestURL = "http://" + top.hostName + "/"+ top.VirtualDir +"/jsp/getObjects.jsp";
var requestAdminURL = "http://" + top.hostName + "/"+ top.VirtualDir +"/admin/getAdminObjects.jsp";
var ScrollTo = '';
var searchCondition = '';
var onSelectFunction ='';
var bShowSingleObject = false;
var bbox = top.DefaultBBox;

function InitTreeView()
{
   bgColour = '#FFFFFF';
   bgImage = '';
   TreeViewFont = 'Arial,Helvetica'
   TreeViewFontSize = '12px';
   lineWidth = 19;
   lineHeight = 16;
   imageRoot = "http://" + top.hostName + "/"+ top.VirtualDir +"/img/";
   defaultRoot = 'tv-root.gif';
   defaultFolderOpen = 'tv-folder-open.gif';
   defaultFolderClosed = 'tv-folder-closed.gif';
   defaultLink = 'tv-link.gif';
   linkMarked = 'tv-link-marked.gif';
   linkCont = 'tv-link-cont.gif';
   linkEnd = 'tv-link-end.gif';
   closedCont = 'tv-closed-cont.gif';
   closedEnd = 'tv-closed-end.gif';
   openCont = 'tv-open-cont.gif';
   openEnd = 'tv-open-end.gif';
   vline = 'tv-line.gif';
   blank = 'tv-blank.gif';
	webimportTree = 'webimport.gif';
   newfolderTree = 'newfolder.gif';
   newobjectTree = 'newobject.gif';
   preferencesTree = 'preferences.gif';
   basePreferencesTree = 'base_preferences.gif';
   layoutPreferencesTree = 'layout_preferences.gif';
   tooltipPreferencesTree = 'tooltip_preferences.gif';
   textsPreferencesTree = 'miscellaneous_texts_preferences.gif';
   meetingPointPreferencesTree = 'meeting_point_preferences.gif';
   feedbackPreferencesTree = 'feedback_preferences.gif';
   layerPreferencesTree = 'layer_preferences.gif';
   zoomlevelPreferencesTree = 'zoomlevel_preferences.gif';
   helpTree = 'help.gif';
   logoutTree = 'logout.gif';
   openText = 'öffnen';
   closeText = 'schließen';
   oneBranch = false;
   borderWidth = 2;
   topHeight = 10;
   bottomHeight = 100;
   defaultTarget = '';
   iExplorer = (navigator.appName.indexOf("Internet Explorer") != -1)
   TreeViewData = new Collection();
   return;
}

function drawTreeView()
{
	if (navigator.appName.indexOf("Netscape") != -1){
		borderWidth = 0;
	}

   TreeViewOutput = self.SearchFrame.window.document;
   TreeViewOutput.open("text/html");
   TreeViewOutput.writeln("<html><head><title>navframe</title>");
   TreeViewOutput.writeln("<style type=\"text/css\">");
   TreeViewOutput.writeln("<!--");
   TreeViewOutput.writeln("body{ border:" + borderWidth + "px; border-style:inset;background-color:' + bgColour + ';background-image:url(' + bgImage + ');margin:0px;padding:3px;white-space:nowrap;}");
   TreeViewOutput.writeln("span { font-family: " + TreeViewFont + ";white-space:nowrap;");
   TreeViewOutput.writeln("font-size: " + TreeViewFontSize + ";");
   TreeViewOutput.writeln("color: #000000;");
   TreeViewOutput.writeln("background-color: " + bgColour + " }");
   TreeViewOutput.writeln("a { color:#000000 }");
   TreeViewOutput.writeln("a:active { color:#000000 }");
   TreeViewOutput.writeln("a:visited { color:#000000 }")
   TreeViewOutput.writeln("-->");
   TreeViewOutput.writeln("</style></head>");
   TreeViewOutput.writeln("<BODY onload=\"self.focus\">");
   TreeViewOutput.writeln("<DIV style=\"height:100%;width:100%\">");
   TreeViewOutput.writeln('<FORM name=\"theTree\" style=\"white-space:nowrap;margin:0px;padding:0px;\">');

   TreeViewOutput.write("<SPAN>");
   if (TreeViewData.length > 0) {
      if ( TreeViewData[1].iconWidth != -1 && TreeViewData[1].iconHeight != -1) {
          TreeViewOutput.write('<IMG src="' + imageRoot + TreeViewData[1].iconClosed + '" width="' + TreeViewData[1].iconWidth + '" height="' + TreeViewData[1].iconHeight + '" align="texttop" border="0">');
      }


      if (TreeViewData[1].name.length!= ''){
          if (TreeViewData[1].url != '') {
            theTarhet = '';
            if (TreeViewData[1].target != '') { theTarget = "TARGET=\"" + TreeViewData[1].target + "\""; }
            	TreeViewOutput.write("&nbsp;<A href=\"" + TreeViewData[1].url + "\" "+ theTarget +" onMouseOver=\"window.status='" + TreeViewData[1].tooltip + "';return true;\" onMouseOut=\"window.status=''; return true\"><B>" + TreeViewData[1].name + "</B></A><BR>\n");
          }
          else {
             TreeViewOutput.write(TreeViewData[1].name + '\n');
          }
      }
      else { TreeViewOutput.write('\n'); }
      drawBranchNodes("root","");
   }
   TreeViewOutput.write("</SPAN>");
   TreeViewOutput.write("</FORM>");
   TreeViewOutput.write("</DIV>");
   TreeViewOutput.write("</BODY>\n");
   TreeViewOutput.write("</HTML>");
   TreeViewOutput.close();

   // move to the node
   if (ScrollTo.length > 0) {
        var i=0;
        var yOld, yNew;
        yNew = getPosition (ScrollTo).y;
        self.SearchFrame.window.scrollTo(0,yNew);
        do {
            yOld = yNew
            yNew = getPosition (ScrollTo).y;
            self.SearchFrame.window.scrollBy(0, parseInt(yNew-yOld));

            // security break
            i++;
            if (i == 100) break;
        }
        while ( yNew != yOld )
        ScrollTo = '';
   }

   return;
}

function drawBranchNodes(parentNode, imageString)
{
   var childnodes = extractChildNodes(parentNode);
   var currentNode = 0;
   while (currentNode < childnodes.length)
   {
      var newImageString = imageString;
      currentNode++;
      TreeViewOutput.write(imageString);

      if (currentNode != childnodes.length) {
         switch (childnodes[currentNode].state) {
          case -1:
            TreeViewOutput.write("<IMG src=\"" + imageRoot + linkCont + "\" width=\"" + lineWidth + "\" height=\"" + lineHeight + "\" align=\"texttop\">");
            break;
          case 0:
            TreeViewOutput.write("<A name=\"" + childnodes[currentNode].id + "\" href=\"\" onClick=\"self.parent.toggle('" + childnodes[currentNode].id + "');return false\"><IMG id=\"" + childnodes[currentNode].id + "\" src=\"" + imageRoot + closedCont + "\" width=\"" + lineWidth + "\" height=\"" + lineHeight + "\" alt=\"["+ openText +"]\" align=\"texttop\" border=\"0\" onMouseOver=\"window.status='["+ openText +"]';return true\" onMouseOut=\"window.status='';return true\"></A>");
            break;
          default:
             TreeViewOutput.write("<A name=\"" + childnodes[currentNode].id + "\" href=\"\" onClick=\"self.parent.toggle('" + childnodes[currentNode].id + "'); return false\"><IMG id=\"" + childnodes[currentNode].id + "\" src=\"" + imageRoot + openCont + "\" width=\"" + lineWidth + "\" height=\"" + lineHeight + "\" alt=\"["+ closeText +"]\" align=\"texttop\" border=\"0\" onMouseOver=\"window.status='["+ closeText +"]'; return true\" onMouseOut=\"window.status=''; return true\"></A>");
             newImageString = newImageString + "<IMG src=\"" + imageRoot + vline + "\" width=\"" + lineWidth + "\" height=\"" + lineHeight + "\" align=\"texttop\">";
         }
      }
      else {
         switch (childnodes[currentNode].state) {
          case -1:
            TreeViewOutput.write("<IMG src=\"" + imageRoot + linkEnd + "\" width=\"" + lineWidth + "\" height=\"" + lineHeight + "\" align=\"texttop\">");
            break;
          case 0:
            TreeViewOutput.write("<A name=\"" + childnodes[currentNode].id + "\" href=\"\" onClick=\"self.parent.toggle('" + childnodes[currentNode].id + "'); return false\"><IMG id=\"" + childnodes[currentNode].id + "\" src=\"" + imageRoot + closedEnd + "\" width=" + lineWidth + " height=" + lineHeight + " ALT='["+ openText +"]' align=\"texttop\" border=\"0\" onMouseOver=\"window.status='["+ openText +"]'; return true\" onMouseOut=\"window.status=''; return true\"></A>");
            break;
          default:
            TreeViewOutput.write("<A name=\"" + childnodes[currentNode].id + "\"  href=\"\" onClick=\"self.parent.toggle('" + childnodes[currentNode].id + "'); return false\"><IMG id=\"" + childnodes[currentNode].id + "\" src=\"" + imageRoot + openEnd + "\" width=" + lineWidth + " height=" + lineHeight + " ALT='["+ closeText +"]' align=\"texttop\" border=\"0\" onMouseOver=\"window.status='["+ closeText +"]'; return true\" onMouseOut=\"window.status=''; return true\"></A>");
            newImageString = newImageString + "<IMG src=\"" + imageRoot + blank + "\" width=\"" + lineWidth + "\" height=\"" + lineHeight + "\" align=\"texttop\">";
         }
      }

     // icon dependent on state
     switch (childnodes[currentNode].state) {
        case -1:    // normal item -> Node.iconOpen is used for the executed javascript-function

            var linkIcon;
            // check if the object is currently displayed in map
            if (checkObjectForDisplay(childnodes[currentNode].id) ) {
                linkIcon = childnodes[currentNode].iconOpen;
            }
            else {
                linkIcon = childnodes[currentNode].iconClosed;
            }

            TreeViewOutput.write("<a href=\"javascript:parent.toggleShowObjectGroup('"+ childnodes[currentNode].id + "');\" onMouseOver=\"window.status='"+ childnodes[currentNode].tooltip +"'; return true\" onClick=\"window.status='"+ childnodes[currentNode].tooltip +"'; return true\" onMouseOut=\"window.status=''; return true\">");
            TreeViewOutput.write("<IMG id=\""+ childnodes[currentNode].id +"\" src=\"" + imageRoot + linkIcon + "\" width=\"" + childnodes[currentNode].iconWidth + "\" height=\"" + childnodes[currentNode].iconHeight + "\" align=\"texttop\" border=\"0\">");
            TreeViewOutput.write("</a>&nbsp;");

            break;
        case 1:     // opened folder
            TreeViewOutput.write("<IMG src=\"" + imageRoot + childnodes[currentNode].iconOpen + "\" width=\"" + childnodes[currentNode].iconWidth + "\" height=\"" + childnodes[currentNode].iconHeight + "\" align=\"texttop\" border=\"0\">&nbsp;");
            break;
        case 0:     // closed folder
            TreeViewOutput.write("<IMG src=\"" + imageRoot + childnodes[currentNode].iconClosed + "\" width=\"" + childnodes[currentNode].iconWidth + "\" height=\"" + childnodes[currentNode].iconHeight + "\" align=\"texttop\" border=\"0\">&nbsp;");
      }

      if (childnodes[currentNode].url == "") {
         TreeViewOutput.write(childnodes[currentNode].name + "<BR>\n");
      }
      else {
         TreeViewOutput.write("<A href=\"" + childnodes[currentNode].url + "\" target=\"" + childnodes[currentNode].target + "\" onMouseOver=\"window.status='" + childnodes[currentNode].tooltip + "'; return true\" onMouseOut=\"window.status=''; return true\">" + childnodes[currentNode].name + "</A><BR>\n");
      }
      if (childnodes[currentNode].state == 1) {
         drawBranchNodes(childnodes[currentNode].id, newImageString);
      }
   }
   return;
}

function toggle(id)
{
   var nodeIndex = findNodeIndex(id);
   var currentState = TreeViewData[nodeIndex].state;
   if (oneBranch)
      closeAllBranchNodes();
   if (currentState == 1)
      TreeViewData[nodeIndex].state = 0;
   else
      TreeViewData[nodeIndex].state = 1;
   if (oneBranch)
      openAllUnderNode(TreeViewData[nodeIndex].parent);
   timeOut = setTimeout("drawTreeView()",100);

   ScrollTo=id;
   return false;
}

function closeAllBranchNodes()
{
   var currentNode = 0;
   while (currentNode < TreeViewData.length)
   {
      currentNode++;
      if (TreeViewData[currentNode].state == 1)
         TreeViewData[currentNode].state = 0;
   }
   return;
}

function openAllUnderNode(id)
{
   var nodeIndex = findNodeIndex(id);
   if (id != 'root')
   {
      TreeViewData[nodeIndex].state = 1;
      openAllUnderNode(TreeViewData[nodeIndex].parent);
   }
   return;
}

function findNodeIndex(id)
{
   var currentNode = 0;
   while (currentNode < TreeViewData.length)
   {
      currentNode++;
      if (TreeViewData[currentNode].state != -1)
         if (TreeViewData[currentNode].id == id)
            return currentNode;
   }
   return -1;
}

function extractChildNodes(parentNode)
{
   var childNodes = new Collection();
   var currentNode = 1;
   while (currentNode < TreeViewData.length)
   {
      currentNode++;
      if (TreeViewData[currentNode].parent == parentNode) {
         childNodes.add(TreeViewData[currentNode]);
      }
   }
   return childNodes;
}

function Collection()
{
   this.length = 0;
   this.add = add;
   return this;
}

function add(object)
{
  this.length++;
  this[this.length] = object;
  return;
}

function Node(id,parent,iconClosed,iconOpen,state,name,tooltip,url,target,width,height)
{
   this.id = id;
   this.parent = parent;
   if (iconClosed != "") {
      this.iconClosed = iconClosed;
   }
   else {
      if (state != -1) {
         this.iconClosed = defaultFolderClosed;
      }
      else {
         if (parent != "") {
            this.iconClosed = defaultLink;
         }
         else {
            this.iconClosed = defaultRoot;
        }
     }
   }
   if (iconOpen != "") {
      this.iconOpen = iconOpen;
   }
   else {
      this.iconOpen = defaultFolderOpen;
   }

   this.state = state;
   this.name = name;
   this.tooltip = tooltip;
   this.url = url;
   if (target != "") {
      this.target = target;
   }
   else {
      this.target = defaultTarget;
   }

   this.iconWidth = width;
   this.iconHeight = height;
   return this;
}


// =============================================================================================
// functions for sending requests to the server
//================================================================================================

// get data of the tree
function loadTreeData() {
    var theRequest = "RequestType=GetTree";
    sendToServer(requestURL,theRequest,'parent.getTree();');
}

// get data of the tree
function loadTreeDataAdmin(objectLevel, functionalityLevel) {
    var theRequest = "RequestType=GetTree;AL=";
    theRequest += objectLevel;
    sendToServer(requestAdminURL,theRequest,'parent.getAdminTree('+functionalityLevel+');');
}

// get objects of a specific group
function loadObjectData (theGroupID, theGroupName) {
    // save search condition for display
    searchCondition = theGroupName;

    // set the function if a result object is selected
    onSelectFunction = "showObjectInMap()";

    // now send the request
    var theRequest = "RequestType=GetObjectsByGroup;GroupID="+theGroupID;
    sendToServer(requestURL,theRequest,'parent.getObjects();');
}

function loadAdminObjectData (theGroupID, theGroupName) {

	theGroupName = encodeURI(theGroupName);
    // save search condition for display
    searchCondition = theGroupName;

    // set the function if a result object is selected
    onSelectFunction = "showObjectInMap()";

    // now send the request
    var theRequest = "RequestType=GetObjects;GroupID="+theGroupID;
    sendToServer(requestAdminURL,theRequest,'parent.getObjectMenu();');
}

function loadAdminFolderData (theGroupID, theGroupName) {

	theGroupName = encodeURI(theGroupName);
    // save search condition for display
    searchCondition = theGroupName;

    // set the function if a result object is selected
    onSelectFunction = "showObjectInMap()";

    // now send the request
    var theRequest = "RequestType=GetFolder;GroupID="+theGroupID;
    sendToServer(requestAdminURL,theRequest,'parent.getFolderMenu();');
}

function loadFolderData (theGroupID, theGroupName) {
    // save search condition for display
    searchCondition = theGroupName;

    // set the function if a result object is selected
    onSelectFunction = "showObjectInMap()";

    // now send the request
    var theRequest = "RequestType=GetFolder;GroupID="+theGroupID;
    sendToServer(requestAdminURL,theRequest,'parent.getFolderMenu2();');
}


// get objects by a-z search
function loadObjectsBySearch () {

    theSearchString = SearchFrame.document.theTree.azsearch.value;

    // save search condition for display
    searchCondition = top.SearchCriterionTitle + '&nbsp;&nbsp;<I>' + theSearchString + '</I>&nbsp;';

    // set the function if a result object is selected
    onSelectFunction = "showObjectInMap()";

    // now send the request
    var theRequest = "RequestType=GetObjectsBySearch;searchString="+theSearchString;
    sendToServer(requestURL,theRequest,'parent.getObjects();');
}

// get all streets beginning with a specific character
function loadStreetsByCharacter(theChar){

    // set the function if a result object is selected
    onSelectFunction = "loadBoundingBox()";

    // write request
    var theRequest = 'RequestType=GetStreetsByCharacter;searchCharacter='+theChar;
    sendToServer(requestURL,theRequest,'parent.getStreetsByCharacter();');
}

// get all addresses
function loadAddress () {
    var streetName = SearchFrame.document.theTree.streetName.value;
    var houseNumber = SearchFrame.document.theTree.houseNumber.value;

    // set the function if a result object is selected
    onSelectFunction = "loadBoundingBox()";

    // write request
    var theRequest = 'RequestType=GetAddress;streetName='+streetName+';houseNumber='+houseNumber+';';
    sendToServer(requestURL,theRequest,'parent.getAddress();');
}


// load the bounding box fpr the selected item
function loadBoundingBox () {

    // get the bounding box of the selected item
    var selItem = ResultFrame.document.theForm.ObjectList.selectedIndex;
    if (selItem != -1) {
        var Value = ResultFrame.document.theForm.ObjectList.options[selItem].value;

        var theRequest = 'RequestType=GetBoundingBox;selectedItem='+Value;
        sendToServer(requestURL, theRequest,'parent.getBoundingBox();');
    }
}

function sendToServer(theURL,theRequest, theJsFunction) {

	var thePostForm = OSPostFrame.document.forms[0];
	thePostForm.action = theURL;
	thePostForm.Request.value = theRequest;
	if (typeof (theJsFunction) != 'string') { theJsFunction= 'parent.processResponse();'; }
	thePostForm.JavaScriptFunction.value = theJsFunction;

	thePostForm.submit();
}


//================================================================================================
// functions for processing the responses of the server
//================================================================================================

// process response of "getTree"-request
function getTree () {

    var theItem;
    var thePostForm = OSPostFrame.document.forms[0];

    // create the root
    TreeViewData.add(new Node('root', '', '', '', -1, '', '', '', '', -1, -1));
    // create the street search

	TreeViewData.add(new Node('gStreetSearch', 'root', '', '', 0, top.TreeStreetDescription, top.TreeStreetDetailDescription, '', '', 16, 16));
    theItem  = top.StreetNameText + ":&nbsp;<INPUT type=\"text\" name=\"streetName\" style=\"width:120px;font-size:10px;font-family:Arial;\" onkeydown=\"parent.executeByEnter(event,'loadAddress()');\">&nbsp;&nbsp;";
    theItem += top.HouseNumberText + ".:&nbsp;<INPUT type=\"text\" name=\"houseNumber\"  style=\"width:30px;font-size:10px;font-family:Arial;\" onkeydown=\"parent.executeByEnter(event,'loadAddress()');\">&nbsp;&nbsp;";

    theItem += "<INPUT type=\"button\" name=\"senden\" value=\"?\" onclick=\"parent.loadAddress()\" style=\"width:20px;height:20px;font-family:Arial;font-size:11px;font-weight:bold\">";
    TreeViewData.add(new Node('oStreetSearch1', 'gStreetSearch', 'tv-street.gif', '', -1, theItem, '', '', '', -1, -1));

    theItem  =  "<A href=\"javascript:parent.loadStreetsByCharacter('a');\" id=\"a\" onMouseOver=\"parent.markCharacter('a');return true;\" onMouseOut=\"parent.unmarkCharacter('a');\">A</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('b');\" id=\"b\" onMouseOver=\"parent.markCharacter('b');return true;\" onMouseOut=\"parent.unmarkCharacter('b');\">B</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('c');\" id=\"c\" onMouseOver=\"parent.markCharacter('c');return true;\" onMouseOut=\"parent.unmarkCharacter('c');\">C</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('d');\" id=\"d\" onMouseOver=\"parent.markCharacter('d');return true;\" onMouseOut=\"parent.unmarkCharacter('d');\">D</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('e');\" id=\"e\" onMouseOver=\"parent.markCharacter('e');return true;\" onMouseOut=\"parent.unmarkCharacter('e');\">E</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('f');\" id=\"f\" onMouseOver=\"parent.markCharacter('f');return true;\" onMouseOut=\"parent.unmarkCharacter('f');\">F</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('g');\" id=\"g\" onMouseOver=\"parent.markCharacter('g');return true;\" onMouseOut=\"parent.unmarkCharacter('g');\">G</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('h');\" id=\"h\" onMouseOver=\"parent.markCharacter('h');return true;\" onMouseOut=\"parent.unmarkCharacter('h');\">H</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('i');\" id=\"i\" onMouseOver=\"parent.markCharacter('i');return true;\" onMouseOut=\"parent.unmarkCharacter('i');\">I</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('j');\" id=\"j\" onMouseOver=\"parent.markCharacter('j');return true;\" onMouseOut=\"parent.unmarkCharacter('j');\">J</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('k');\" id=\"k\" onMouseOver=\"parent.markCharacter('k');return true;\" onMouseOut=\"parent.unmarkCharacter('k');\">K</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('l');\" id=\"l\" onMouseOver=\"parent.markCharacter('l');return true;\" onMouseOut=\"parent.unmarkCharacter('l');\">L</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('m');\" id=\"m\" onMouseOver=\"parent.markCharacter('m');return true;\" onMouseOut=\"parent.unmarkCharacter('m');\">M</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('n');\" id=\"n\" onMouseOver=\"parent.markCharacter('n');return true;\" onMouseOut=\"parent.unmarkCharacter('n');\">N</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('o');\" id=\"o\" onMouseOver=\"parent.markCharacter('o');return true;\" onMouseOut=\"parent.unmarkCharacter('o');\">O</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('p');\" id=\"p\" onMouseOver=\"parent.markCharacter('p');return true;\" onMouseOut=\"parent.unmarkCharacter('p');\">P</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('q');\" id=\"q\" onMouseOver=\"parent.markCharacter('q');return true;\" onMouseOut=\"parent.unmarkCharacter('q');\">Q</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('r');\" id=\"r\" onMouseOver=\"parent.markCharacter('r');return true;\" onMouseOut=\"parent.unmarkCharacter('r');\">R</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('s');\" id=\"s\" onMouseOver=\"parent.markCharacter('s');return true;\" onMouseOut=\"parent.unmarkCharacter('s');\">S</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('t');\" id=\"t\" onMouseOver=\"parent.markCharacter('t');return true;\" onMouseOut=\"parent.unmarkCharacter('t');\">T</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('u');\" id=\"u\" onMouseOver=\"parent.markCharacter('u');return true;\" onMouseOut=\"parent.unmarkCharacter('u');\">U</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('v');\" id=\"v\" onMouseOver=\"parent.markCharacter('v');return true;\" onMouseOut=\"parent.unmarkCharacter('v');\">V</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('w');\" id=\"w\" onMouseOver=\"parent.markCharacter('w');return true;\" onMouseOut=\"parent.unmarkCharacter('w');\">W</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('x');\" id=\"x\" onMouseOver=\"parent.markCharacter('x');return true;\" onMouseOut=\"parent.unmarkCharacter('x');\">X</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('y');\" id=\"y\" onMouseOver=\"parent.markCharacter('y');return true;\" onMouseOut=\"parent.unmarkCharacter('y');\">Y</A>&nbsp;\n";
    theItem +=  "<A href=\"javascript:parent.loadStreetsByCharacter('z');\" id=\"z\" onMouseOver=\"parent.markCharacter('z');return true;\" onMouseOut=\"parent.unmarkCharacter('z');\">Z</A>";
    TreeViewData.add(new Node('oStreetSearch2', 'gStreetSearch', 'tv-empty.gif', '', -1, theItem, '', '', '', -1,-1));

    // a-z search
    TreeViewData.add(new Node('gFullSearch', 'root', '', '', 0, top.TreeSearchAZ, '', '', '', 16, 16));

    theItem  = "<INPUT type=\"text\" name=\"azsearch\" style=\"width:220px;font-size:10px;font-family:Arial;\" onkeydown=\"parent.executeByEnter(event,'loadObjectsBySearch()');\">&nbsp;&nbsp;";
    theItem += "<INPUT type=\"button\" name=\"senden\" value=\"?\" onclick=\"parent.loadObjectsBySearch()\" style=\"width:20px;height:20px;font-family:Arial;font-size:11px;font-weight:bold\">";
    TreeViewData.add(new Node('oFullSearch1', 'gFullSearch', 'tv-empty.gif', '', -1, theItem, '', '', '', -1,-1));



    // object_groups level 1
    objectGroups = new Array();
    objectGroups = thePostForm.objectGroupsLevel1.value.split(';;;');
    var numberOfObjectGroups = objectGroups.length;
    var objID;
    var objName;
    var objToolTip;
    var objHasSubObj;

    for (i=0; i<numberOfObjectGroups; i++){
        objID = objectGroups[i].split('|||')[0];
        objName = objectGroups[i].split('|||')[1];
        objToolTip = objectGroups[i].split('|||')[2];
        objHasSubObj = parseInt(objectGroups[i].split('|||')[3]);

		//if (numberOfObjectGroups > 1){
        	if ( objHasSubObj == 1) {
            	TreeViewData.add(new Node(objID, 'root', '', '', 0, objName, objToolTip , '', '', 16, 16));
        	}
        	else {
            	//Objectstructure:  (id,parent,iconClosed,iconOpen,state,name,tooltip,url,target,width,height)
            	TreeViewData.add(new Node(objID, 'root', defaultLink, linkMarked, -1, objName, objToolTip, "javascript:parent.loadObjectData("+ objID +",'"+ objName +"');", '', 16, 16));
        	}
		//}
    }

    // object_groups level 2
    objectGroups = new Array();
    objectGroups = thePostForm.objectGroupsLevel2.value.split(';;;');
    var numberOfObjectGroups = objectGroups.length;
    var objID;
    var objName;
    var objToolTip;
    var objIDLevel1;

    for (i=0; i<numberOfObjectGroups; i++){
        objID = objectGroups[i].split('|||')[0];
        objName = objectGroups[i].split('|||')[1];
        objToolTip = objectGroups[i].split('|||')[2];
        objIDLevel1 = objectGroups[i].split('|||')[3];

        TreeViewData.add(new Node(objID, objIDLevel1 ,  defaultLink, linkMarked, -1, objName, objToolTip, "javascript:parent.loadObjectData("+ objID +",'"+ objName +"');", '', 16, 16));
    }

    // now write the tree
    drawTreeView();
}


function getAdminTree(functionalityLevel){

    var theItem;
    var thePostForm = OSPostFrame.document.forms[0];

    // create the root
    TreeViewData.add(new Node('root', '', '', '', -1, '', '', '', '', -1, -1));

    if (functionalityLevel == 2){
		TreeViewData.add(new Node('WEB-Import', 'root', webimportTree, '', -1, 'WEB-Import', 'Datei einlesen', "javascript:parent.getWebImport();", '', 16, 16));
		TreeViewData.add(new Node('Neuen Ordner erstellen', 'root', newfolderTree, '', -1, 'Neuen Ordner erstellen', 'Neuen Ordner erstellen', "javascript:parent.newFolder();", '', 16, 16));
	}

    // -----------------------------------------------------
    //            object_groups level 1
    // -----------------------------------------------------
    objectGroups = new Array();
    objectGroups = thePostForm.objectGroupsLevel1.value.split(';;;');
    var numberOfObjectGroups = objectGroups.length;
    var objID;
    var objName;
    var objToolTip;
    var objHasSubObj;

    for (i=0; i<numberOfObjectGroups; i++){
        objID = objectGroups[i].split('|||')[0];
        objName = objectGroups[i].split('|||')[1];
        objToolTip = objectGroups[i].split('|||')[2];
        objHasSubObj = parseInt(objectGroups[i].split('|||')[3]);

		if (functionalityLevel == 2){
			TreeViewData.add(new Node('Neuen Ordner erstellen', objID, newfolderTree, '', -1, 'Neuen Ordner erstellen', 'Neuen Ordner erstellen', "javascript:parent.newSubFolder(" + objID + ");", '', 16, 16));
		}

		TreeViewData.add(new Node('Neues Objekt erstellen', objID, newobjectTree, '', -1, 'Neues Objekt erstellen', 'Neues Objekt erstellen', "javascript:parent.newObject(" + objID + ");", '', 16, 16));

		if (numberOfObjectGroups > 1){				// else "undefined"
			if (functionalityLevel == 2){
            	TreeViewData.add(new Node(objID, 'root', '', '',0, objName, objToolTip, "javascript:parent.loadAdminFolderData("+ objID +",'"+ objName +"');", '', 16, 16));
            }
            else{
            	TreeViewData.add(new Node(objID, 'root', '', '',0, objName, objToolTip, "javascript:parent.loadFolderData("+ objID +",'"+ objName +"');", '', 16, 16));
        		//Objectstructure:  (id,parent,iconClosed,iconOpen,state,name,tooltip,url,target,width,height)
        	}
		}
    }

    // -----------------------------------------------------
    //            object_groups level 2
    // -----------------------------------------------------
    objectGroups = new Array();
    objectGroups = thePostForm.objectGroupsLevel2.value.split(';;;');
    var numberOfObjectGroups = objectGroups.length;
    var objID;
    var objName;
    var objToolTip;
    var objIDLevel1;

    for (i=0; i<numberOfObjectGroups; i++){
        objID = objectGroups[i].split('|||')[0];
        objName = objectGroups[i].split('|||')[1];
        objToolTip = objectGroups[i].split('|||')[2];
        objIDLevel1 = objectGroups[i].split('|||')[3];

		TreeViewData.add(new Node('Neues Objekt anlegen', objID, newobjectTree, '', -1, 'Neues Objekt anlegen', 'Neues Objekt anlegen', "javascript:parent.newObject(" + objID + ");", '', 16, 16));

        if (functionalityLevel == 2){
			TreeViewData.add(new Node(objID,  objIDLevel1, '', '', 0, objName, objToolTip , "javascript:parent.loadAdminFolderData("+ objID +",'"+ objName +"');", '', 16, 16));
		}
		else{
			TreeViewData.add(new Node(objID,  objIDLevel1, '', '', 0, objName, objToolTip , "javascript:parent.loadFolderData("+ objID +",'"+ objName +"');", '', 16, 16));
		}
     }

	// -----------------------------------------------------
	//            objects level 3
	// -----------------------------------------------------
    objects = new Array();
    objects = thePostForm.objectGroupsLevel3.value.split(';;;');
    var numberOfObjects = objects.length;
    var objsID;
    var objsName;
    var objsToolTip;
    var objsIDLevel1;


    for (i=0; i<numberOfObjects; i++){
    	objsID = objects[i].split('|||')[0];
    	objsName = objects[i].split('|||')[1];
    	objsToolTip = objects[i].split('|||')[2];
    	objsIDLevel1 = objects[i].split('|||')[3];
    	TreeViewData.add(new Node(objsID, objsIDLevel1 ,  defaultLink, linkMarked, -1, objsName, objsToolTip, "javascript:parent.loadAdminObjectData("+ objsID +",'"+ objsName +"');", '', 16, 16));
	}

	if (functionalityLevel == 2){
		TreeViewData.add(new Node('Einstellungen', 'root', preferencesTree, preferencesTree, 0, 'Einstellungen', 'Allgemeine Projekteinstellungen', "javascript:parent.choose_preferences();", '', 16, 16));
    	TreeViewData.add(new Node('Grundeinstellungen', 'Einstellungen', basePreferencesTree, basePreferencesTree, -1, 'Grundeinstellungen', 'Grundeinstellungen', "javascript:parent.base_preferences();", '', 16, 16));
    	TreeViewData.add(new Node('Grafische Einstellungen', 'Einstellungen', layoutPreferencesTree, layoutPreferencesTree, -1, 'Layout', 'Layout', "javascript:parent.layout_preferences();", '', 16, 16));
    	TreeViewData.add(new Node('Tooltips', 'Einstellungen', tooltipPreferencesTree, tooltipPreferencesTree, -1, 'Tooltips', 'Tooltips', "javascript:parent.tooltip_preferences();", '', 16, 16));
		TreeViewData.add(new Node('Sonstige Texte', 'Einstellungen', textsPreferencesTree, textsPreferencesTree, -1, 'Sonstige Texte', 'Sonstige Texte bearbeiten', "javascript:parent.text_preferences();", '', 16, 16));
		TreeViewData.add(new Node('Zoomstufen-Einstellungen', 'Einstellungen', layerPreferencesTree, layerPreferencesTree, -1, 'Zoomstufen', 'Zoomstufen-Einstellungen', "javascript:parent.zoomlevel_preferences();", '', 16, 16));
		TreeViewData.add(new Node('Layer-Einstellungen', 'Einstellungen', zoomlevelPreferencesTree, zoomlevelPreferencesTree, -1, 'Layer', 'Layer-Einstellungen', "javascript:parent.layer_preferences();", '', 16, 16));
	}

	if (functionalityLevel == 2){
    	TreeViewData.add(new Node('Hilfe zur Administration', 'root', helpTree, '', -1, 'Hilfe zur Administration', 'Administration Online-Hilfe', "javascript:parent.help();", '', 16, 16));
	}

    TreeViewData.add(new Node('Log-Out', 'root', logoutTree, '', -1, 'Log-Out', 'Ausloggen', "javascript:parent.logOut();", '', 16, 16));

    // now write the tree
    drawTreeView();
}


// process response of "getObjects"-request
function getObjects () {

    // empty the result list
    ResultFrame.deleteAllObjects();

    // objects
    var thePostForm = OSPostFrame.document.forms[0];
    theObjects = new Array();
    if (thePostForm.theObjects.value.length > 0) {
        theObjects = thePostForm.theObjects.value.split(';;;');
    }
    var numberOfObjects = theObjects.length;
    var realRecordCount = thePostForm.RecordCount.value;

    // add headline
    var theHeadLine = "<B>"+ searchCondition +"</B>: ["+ numberOfObjects + "] " + top.ObjectsFound + ".";
    if (realRecordCount > numberOfObjects){
        theHeadLine += ' ' + top.SearchDelimiter1 + ' <span style="font-weight:bold;">'+ numberOfObjects +'</span> ' + top.SearchDelimiter2 + '.';
    }

    // add headline
    	ResultFrame.document.getElementById("HeadLine").innerHTML = theHeadLine;

    // now add the objects to the listbox
    if (numberOfObjects > 0 ){
        for (i=0; i<numberOfObjects; i++){
            objID  = theObjects[i].split('|||')[0];
            objName = theObjects[i].split('|||')[1];
            objToolTip = theObjects[i].split('|||')[2];
            objX = theObjects[i].split('|||')[3];
            objY = theObjects[i].split('|||')[4];
            objLayer = theObjects[i].split('|||')[5];
            objGroup = theObjects[i].split('|||')[6];

           	theValue = objID+'|||'+objX+'|||'+objY+'|||'+objLayer+'|||'+objGroup;
            // add object to list box
            ResultFrame.addObject(theValue, objName);
            }
        }

        // only 1 item -> do selection
        if (numberOfObjects == 1) {
            ResultFrame.document.theForm.ObjectList.selectedIndex=0;
            executeOnSelectFunction();
        }
}


// process response of "getObjects"-request
function getObjectMenu() {

    // objects
    var thePostForm = OSPostFrame.document.forms[0];

    // now add the objects to the listbox
    if (thePostForm.theObjects.value.length > 0) {
		theObjects = new Array();
        theObjects = thePostForm.theObjects.value.split(';;;');

        objID  = theObjects[0].split('|||')[0];
		objName = theObjects[0].split('|||')[1];
		objToolTip = theObjects[0].split('|||')[2];
		objX = theObjects[0].split('|||')[3];
		objY = theObjects[0].split('|||')[4];
		objLayer = theObjects[0].split('|||')[5];
		objGroup = theObjects[0].split('|||')[6];

		objName = objName.replace(/ä/g,"ae");
		objName = objName.replace(/ö/g,"oe");
		objName = objName.replace(/ü/g,"ue");

		objName = objName.replace(/Ä/g,"Ae");
		objName = objName.replace(/Ö/g,"Oe");
		objName = objName.replace(/Ü/g,"Ue");

        ResultFrame.document.location.href="admin_object.jsp?id=" + objID + "&name=" + objName;

        // center item in map
        parent.showInMap (objX-bbox,objY-bbox, parseFloat(objX)+bbox ,parseFloat(objY)+bbox ,0 , objLayer, objID, objGroup);
    }
}


function getWebImport() {
        ResultFrame.document.location.href="webimport.jsp";
}


function choose_preferences() {
        ResultFrame.document.location.href="choose_preferences.jsp";
}


function base_preferences() {
        ResultFrame.document.location.href="base_preferences.jsp";
}


function tooltip_preferences() {
        ResultFrame.document.location.href="tooltip_preferences.jsp";
}


function layout_preferences() {
        ResultFrame.document.location.href="layout_preferences.jsp";
}


function text_preferences() {
        ResultFrame.document.location.href="text_preferences.jsp";
}


function meeting_point_preferences() {
        ResultFrame.document.location.href="meeting_point_preferences.jsp";
}


function feedback_preferences() {
        ResultFrame.document.location.href="feedback_preferences.jsp";
}


function layer_preferences() {
        ResultFrame.document.location.href="layer_preferences.jsp";
}


function zoomlevel_preferences() {
        ResultFrame.document.location.href="zoomlevel_preferences.jsp";
}


function newFolder() {
        ResultFrame.document.location.href="new_folder.jsp";
}


function newSubFolder(objID) {
        ResultFrame.document.location.href="new_sub_folder.jsp?id=" + objID;
}


function newObject(objID) {
        ResultFrame.document.location.href="new_object.jsp?id=" + objID;
}


function logOut() {
		  top.window.location.reload();
}


function help() {
		  top.openWindow ('help', top.adminHelpURL);
}


function getFolderMenu() {
    // objects
    var thePostForm = OSPostFrame.document.forms[0];

    // now add the objects to the listbox
    if (thePostForm.theFolder.value.length > 0) {
    	theObjects = new Array();
        theObjects = thePostForm.theFolder.value.split(';;;');

		objLanguage  = theObjects[0].split('|||')[0];
		objId = theObjects[0].split('|||')[1];
		objName = theObjects[0].split('|||')[2];
		objTooltip = theObjects[0].split('|||')[3];

		objName = objName.replace(/&/g,"und");
		objTooltip = objTooltip.replace(/&/g,"und");

		objName = objName.replace(/ä/g,"ae");
		objTooltip = objTooltip.replace(/ä/g,"ae");

		objName = objName.replace(/ö/g,"oe");
		objTooltip = objTooltip.replace(/ö/g,"oe");

		objName = objName.replace(/ü/g,"ue");
		objTooltip = objTooltip.replace(/ü/g,"ue");

		objName = objName.replace(/Ä/g,"Ae");
		objTooltip = objTooltip.replace(/Ä/g,"Ae");

		objName = objName.replace(/Ö/g,"Oe");
		objTooltip = objTooltip.replace(/Ö/g,"Oe");

		objName = objName.replace(/Ü/g,"Ue");
		objTooltip = objTooltip.replace(/Ü/g,"Ue");

        ResultFrame.document.location.href="admin_folder.jsp?objLanguage=" + objLanguage + "&objId=" + objId + "&objName=" + objName + "&objTooltip=" + objTooltip;
    }
}

function getFolderMenu2() {
    // objects
    var thePostForm = OSPostFrame.document.forms[0];

    // now add the objects to the listbox
    if (thePostForm.theFolder.value.length > 0) {
		theObjects = new Array();
        theObjects = thePostForm.theFolder.value.split(';;;');

        objLanguage  = theObjects[0].split('|||')[0];
		objId = theObjects[0].split('|||')[1];
		objName = theObjects[0].split('|||')[2];
		objTooltip = theObjects[0].split('|||')[3];

		objName = objName.replace(/&/g,"und");
		objTooltip = objTooltip.replace(/&/g,"und");

		objName = objName.replace(/ä/g,"ae");
		objTooltip = objTooltip.replace(/ä/g,"ae");

		objName = objName.replace(/ö/g,"oe");
		objTooltip = objTooltip.replace(/ö/g,"oe");

		objName = objName.replace(/ü/g,"ue");
		objTooltip = objTooltip.replace(/ü/g,"ue");

		objName = objName.replace(/Ä/g,"Ae");
		objTooltip = objTooltip.replace(/Ä/g,"Ae");

		objName = objName.replace(/Ö/g,"Oe");
		objTooltip = objTooltip.replace(/Ö/g,"Oe");

		objName = objName.replace(/Ü/g,"Ue");
		objTooltip = objTooltip.replace(/Ü/g,"Ue");

        ResultFrame.document.location.href="admin_folder2.jsp?objLanguage=" + objLanguage + "&objId=" + objId + "&objName=" + objName + "&objTooltip=" + objTooltip;
    }
}

// process response of "getStreetsByCharacter"-request
function getStreetsByCharacter () {

    // empty the result list
    ResultFrame.deleteAllObjects();

    // objects
    var thePostForm = OSPostFrame.document.forms[0];
    theStreets = new Array();
    if (thePostForm.Data.value.length > 0) {
        theStreets = thePostForm.Data.value.split(';;;');
    }
    var numberOfStreets = theStreets.length;

    // add headline
    var theHeadLine = "<B>" + top.StreetNameText + "</B>: ["+ numberOfStreets + "] " + top.FoundStreets + ".";

    ResultFrame.document.getElementById("HeadLine").innerHTML = theHeadLine;

    // now add the objects to the listbox
    if (numberOfStreets > 0 ){
        for (i=0; i<numberOfStreets; i++){

            theValue = theStreets[i].split('|||')[0];
            objName = theStreets[i].split('|||')[1];

            // add object to list box
            ResultFrame.addObject(theValue, objName);
        }

        // only 1 item -> do selection
        if (numberOfStreets == 1) {
            ResultFrame.document.theForm.ObjectList.selectedIndex=0;
            executeOnSelectFunction();
        }
    }
}

// process response of "getAddress"-request
function getAddress () {

    // empty the result list
    ResultFrame.deleteAllObjects();

    // objects
    var thePostForm = OSPostFrame.document.forms[0];
    theAddresses = new Array();
    if (thePostForm.Data.value.length > 0) {
        theAddresses = thePostForm.Data.value.split(';;;');
    }
    var numberOfAddresses = theAddresses.length;
    var realRecordCount = thePostForm.RecordCount.value;

    // add headline
    var theHeadLine = '<B>' + top.AddressDescription + '</B>: ['+ realRecordCount + '] ' + top.FoundAddresses + '.';
    if (realRecordCount > numberOfAddresses){
        theHeadLine += ' ' + top.SearchDelimiter1 + ' <span style="font-weight:bold;">'+ numberOfAddresses +'</span> ' + top.SearchDelimiter2 + '.';
    }

    ResultFrame.document.getElementById("HeadLine").innerHTML = theHeadLine;

    // now add the objects to the listbox
    if (numberOfAddresses > 0 ){
        for (i=0; i<numberOfAddresses; i++){

            theValue = theAddresses[i].split('|||')[0];
            objName = theAddresses[i].split('|||')[1];

            // add object to list box
            ResultFrame.addObject(theValue, objName);
        }

        // only 1 item -> do selection
        if (numberOfAddresses == 1) {
            ResultFrame.document.theForm.ObjectList.selectedIndex=0;
            executeOnSelectFunction();
        }
    }
}


function getBoundingBox () {

        var theBoundingBox = new Array();
        theBoundingBox = OSPostFrame.document.forms[0].BoundingBox.value.split(';;;');
        var minBoundingBox = OSPostFrame.document.forms[0].MinBoundingBox.value;

        // show it in the map
        if (theBoundingBox[0]!=-1 && theBoundingBox[1]!=-1 && theBoundingBox[2]!=-1 && theBoundingBox[3]!=-1){

            // check bbox size
            if ( (theBoundingBox[2]-theBoundingBox[0]) < minBoundingBox ) {
                var dx = minBoundingBox - (theBoundingBox[2]-theBoundingBox[0]);
                theBoundingBox[0] = theBoundingBox[0] - parseFloat(dx/2);
                theBoundingBox[2] = parseFloat(theBoundingBox[2]) + parseFloat(dx/2);
            }
            if ( (theBoundingBox[1]-theBoundingBox[3]) < minBoundingBox ) {
                var dy = minBoundingBox - (theBoundingBox[3]-theBoundingBox[1]);
                theBoundingBox[1] = theBoundingBox[1] - parseFloat(dy/2);
                theBoundingBox[3] = parseFloat(theBoundingBox[3]) + parseFloat(dy/2);
            }

            // show in map
            parent.showInMap (theBoundingBox[0],theBoundingBox[1],theBoundingBox[2],theBoundingBox[3], 1);
        }
        else {
        		alert(top.NoCoordinatesForStreet + '!');
        }

        // reset the selected Item -> item could be selected second time
        ResultFrame.document.theForm.ObjectList.selectedIndex = -1;
}


//================================================================================================
// communicate with the graphic
//================================================================================================
// center the object in the map
function showObjectInMap () {

    var theGroupID = "";

    // get the coords from the selected value
    var theIndex = ResultFrame.document.theForm.ObjectList.selectedIndex;
    var theObject = ResultFrame.document.theForm.ObjectList.options[theIndex];
    var theID = theObject.value.split('|||')[0];
    var theX = theObject.value.split('|||')[1];
    var theY = theObject.value.split('|||')[2];
    var theLayer = theObject.value.split('|||')[3];

    // show whole group or just the single object ?
    if (bShowSingleObject == false){
        theGroupID = theObject.value.split('|||')[4];

        // set the group_id for marking the treeview
        addObjectToShow  (theGroupID);
    }
    else {
        theGroupID = theID;
    }

    parent.showInMap (theX-bbox,theY-bbox, parseFloat(theX)+bbox ,parseFloat(theY)+bbox ,0 , theLayer, theID, theGroupID);

    // reset selection
    ResultFrame.document.theForm.ObjectList.selectedIndex = -1;
}

function toggleShowObjectGroup (objID) {
    if (checkObjectForDisplay(objID) ) {
        parent.turnOffSymbols(objID);
        deleteObjectToShow(objID);
        // change treeview icon
        SearchFrame.document.getElementById(objID).src = imageRoot + defaultLink;
    }
    else {
        parent.turnOnSymbols(objID);
        addObjectToShow(objID);
        // change treeview icon
        SearchFrame.document.getElementById(objID).src = imageRoot + linkMarked;
    }
}

//================================================================================================
// miscellaneous functions
//================================================================================================


function getPosition(elementId){

    // Element-Objekt zur ID ermitteln
    var element= SearchFrame.document.getElementById(elementId);

    // der Aufruf dieser Funktion ermittelt die absoluten Koordinaten  des Objekts element
    var elem=element,tagname="",x=0,y=0;

    while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined")) {
        y+=elem.offsetTop;     /* Offset des jeweiligen Elements addieren */
        x+=elem.offsetLeft;    /* Offset des jeweiligen Elements addieren */
        tagname=elem.tagName.toUpperCase(); /* tag-Name ermitteln, Grossbuchstaben */

        // wenn beim Body-tag angekommen elem fuer Abbruch auf 0 setzen
        if (tagname=="BODY")
        elem=0;

        // wenn elem ein Objekt ist und offsetParent enthaelt  Offset-Elternelement ermitteln
        if (typeof(elem)=="object")
        if (typeof(elem.offsetParent)=="object")
            elem=elem.offsetParent;
    }

    // Objekt mit x und y zurueckgeben
    position=new Object();
    position.x=x;
    position.y=y;
    return position;
}


function markCharacter (elName) {
    SearchFrame.document.getElementById(elName).style.backgroundColor="#0000FF";
    SearchFrame.document.getElementById(elName).style.color="#FFFFFF";

    window.status = elName.toUpperCase();

    elName = '';
}

function unmarkCharacter (elName) {
    // Hintergrundfarbe des
    SearchFrame.document.getElementById(elName).style.backgroundColor = "#FFFFFF";
    SearchFrame.document.getElementById(elName).style.color = "#000000";

    window.status = '';
}


function executeOnSelectFunction() {
    var theFunction = new Function(onSelectFunction);
	theFunction ();
}

// if "enter"-key is pressed -> execute passed funcion
function executeByEnter (theEvent,Fcn) {

    if (theEvent.keyCode == 13) {
        //theEvent.r
        var theFunction = new Function(Fcn);
	    theFunction ();
	    theEvent.returnValue = false;
	}
	return true;
}


function checkObjectForDisplay(objID) {

    // check if symbol already exits
    var sTemp = "," + top.aObjectIDsToShow.join (",")+ ",";
    // if value not found -> add id
    if (sTemp.indexOf(","+objID+",") != -1) {
        return true;
    }
    else {
        return false;
    }

}


// add a symbol to the diplayed symbols
function addObjectToShow (theID) {

    // check if symbol already exits
    var sTemp = "," + top.aObjectIDsToShow.join (",")+ ",";

    // if value not found -> add id
    if (sTemp.indexOf(","+theID+",") == -1) {
        top.aObjectIDsToShow.push(theID);
    }

    // set treeview-icon to display-state
    if (SearchFrame.document.getElementById(theID)) { SearchFrame.document.getElementById(theID).src = imageRoot + linkMarked; }
}

// delete a symbol from the diplayed symbols
function deleteObjectToShow (theID) {

    var aTemp = new Array();
    for (var i=0, j=0; i<top.aObjectIDsToShow.length; i++) {

        if (top.aObjectIDsToShow[j] == theID){ j++; }

        aTemp[i] = top.aObjectIDsToShow[j];
        j++;
    }
	//alert(aTemp.join("|||"));
    top.aObjectIDsToShow = aTemp;
}


function resetObjectSearch () {
    top.aObjectIDsToShow = new Array();
   drawTreeView();
}

