/* This notice must be untouched at all times.

FrPop 1.0

 CopyRight (C) 2003 Frode Rustoey (private project). All rights reserved.
 (Frode@Rustoy.no) http://www.rustoy.no/

 We have made some effort to keep the script simple and with understandable naming
 in hope that as many as possible will be able to use it. This effort may
 slow the script down a bit. Any suggestion to make it more efficient are welcome!!!!!!

 Use it as you want!
 Use the adress Frode@Rustoy.no to tell me about changes you have done

 We think it is a good idea to offer the user a possibility to use web browser context menu,
 and to use the script only when needed for important functonality in yor design
 You may, of course, do as you like!

 PLEASE keep your changes "crossbrowser" and SIMPLE!

 We also want you to SHARE any changes with the community!!
 We don't want anybody left out - do we?

 This program is free software for none comercial use.

 You can redistribute it and/or modify it under the terms of the
 GNU General Public License as published by the Free Software Foundation;
 either version 2 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 See the GNU General Public License at http://www.gnu.org/copyleft/gpl.html for more details.

*/


/*------------------- You do not need to do any changes beneath this line--------------
 This part of the script should be saved to file and called as an external script
 Using external scripts will result in use of the browsers cache and save time.
*/

var newLevelImg = '<img src="/WebGrafikk/ikoner/newlevel.gif" style="width:5px; height:15px; border:none;">';
var menuLink    = '<img src="/WebGrafikk/ikoner/globe.gif" style="width:16px; height:16px; border:none;">';
var blackHr = '<img src="/WebGrafikk/1pixel/dot_blac.gif" style="width:99%; height:1px; border:none;">';

// Following values may be changed by some script on the server according to the users setup
// or they might be set by a cookie

var bodyBackground         = '#FFFFFF';
var bodyColor              = invertColor(bodyBackground);//'#FFFFFF';
var highlightBackGround    = '#FFFF00';       //'#FFFF00';
var highlightColor         = bodyColor;//bodyBackground; // '#FF3333';
var highlightBorder        = invertColor(highlightBackGround);//bodyBackground; //'#CCCCCC';
var hotspotColor           = '#008000';
var UseBrowsersContextMenu = false;


function initEdOnWebPop(){
  changeClassRule(0,'background',bodyBackground)
  changeClassRule(0,'color',bodyColor)
  changeClassRule('hotspot','color',hotspotColor)
}

initEdOnWebPop();

function DecToHex(number) {
  var hexbase='0123456789ABCDEF';
  return hexbase.charAt((number>> 4)& 0xf)+ hexbase.charAt(number& 0xf);
}
function giveHex(s){
  return parseInt(s,16);
}

function invertColor(theString) {
    theString=theString.slice(1,7);
    if(theString.length < 6||theString.length>6){
      alert('Wrong value ('+theString+') sent to invertColor! Should have been a hexadecimal number');
      return theString;
    }
    a=theString.slice(0,2);
    b=theString.slice(2,4);
    c=theString.slice(4,6);

    a1=16*giveHex(a.slice(0,1));
    a2=giveHex(a.slice(1,2));
    a=a1+a2;

    b1=16*giveHex(b.slice(0,1));
    b2=giveHex(b.slice(1,2));
    b=b1+b2;

    c1=16*giveHex(c.slice(0,1));
    c2=giveHex(c.slice(1,2));
    c=c1+c2;

    newColor=DecToHex(255-a)+""+DecToHex(255-b)+""+DecToHex(255-c)
    newColor = '#'+newColor;
    return newColor;
}

var UseLocalBrowserContextMenu = UseBrowsersContextMenu;

var HighLightHotspots = false;

var IE_test = document.all && document.getElementById
var NS_test = document.getElementById && !document.all
var NS_event ='';

var BubbleStopped = UseBrowsersContextMenu; // We need to stop the bubbling at the object in question.
var justOpenedPop = false;

// To make it easier for you to read makePopMenu and makeMainMenu we have provided these variables
var pText   = 0; // could be any textstring - use \' if you need ' in the menu
var pUrl    = 1; // any valid adress, relative or absolute
var pTarget = 2; // may be _blank, _top, _parent, _self or whatever you want to use
var pTitle  = 3; // a tooltip-tekst which will pop up on mouseOver
var pIcon   = 4; // the relative or absolute adress (URL) to the image - shouldn't be to large e.g 15*15 pixels
var pEvent  = 5; // could be onClick,onMouseDown, onMouseOver etc

function makePopMenu(popNumber,popLevel,lastLevel,menuArray) {
  var popDiv;
  if (menuArray)
    {
      popDiv = 1;
      var popArray = menuArray;
      var itemCount = 1;
    }
  else
    {
      if (lastLevel)
        {
          var popArray = eowPop[popNumber][lastLevel][popLevel]
          popDiv = 3;
          var itemCount = 2;
        }
      else if (popLevel)
        {
          popDiv = 2;
          var popArray = eowPop[popNumber][popLevel]
          var itemCount = 2;
        }
      else
        {
          popDiv = 1;
          var popArray = eowPop[popNumber];
          var itemCount = 1;
        }
    }
  var closeSub = 'closeSubMenu_IfAny('+popDiv+');';
  //var closeSub ='';
  if (!NS_test)
  	var cancelBubble = 'window.event.cancelBubble = true;'
 // else
    var cancelBubble = '';
  var popMenuTable = '<table cellspacing="0" cellpadding="3" style="background:#EEEEEE;" onmousedown="IsRightClick(false);" onClick="closePop_IfAny();">';
  do {
    var popTarget= "_blank";
    var popTitle = "";
    if (popArray[itemCount][pText] == "" && popArray[itemCount][pUrl] == "")
      popMenuTable += '<tr><td colspan="4" align="center" style="height:0px;padding:2px;margin:0px;">'+blackHr+'</td></tr>';
//      popMenuTable += '<tr style="height:0px;padding:0px;margin:0px;background:#999999;border:1px outset #FFFFFF;"><td colspan="4"></td></tr>';
//     popMenuTable += '<tr style="height:1px;padding:0px;margin:0px;"><td colspan="4"><hr style="height:1px;padding:0px;margin:0px;" /></td></tr>';
    else if (popArray[itemCount][pUrl] == ">")
	  {
	    var subID = 'subMenu'+popNumber+'_'+popDiv+'_'+itemCount;
	    var showSub = ' if (document.getElementById(\''+subID+'\').style.display == \'none\'){showSubMenu(makePopMenu('+popNumber+','+itemCount+','+popLevel+'),\'subMenu'+popNumber+'_'+popDiv+'_'+itemCount+'\',true,'+popDiv+');}';

	    popMenuTable += '<tr class="popMenu" onClick="justOpenedPop=true" onMouseOver="this.className=\'popHover\'; " onMouseOut="this.className=\'popMenu\';'+cancelBubble+'"><td>&nbsp;</td><td onClick="'+showSub+'justOpenedPop=true" onMouseOver="'+closeSub+''+showSub+'" nowrap>'+popArray[itemCount][pText]+'</td><th valign="top" align="right" style="width:10px;" nowrap>'+newLevelImg;
	    popMenuTable += '</th><th valign="top" style="width:2px;"><div id="'+subID+'" style="position:absolute;display:none;border:1px solid #000000;" class="popMenuContainer"></div></th></tr>';
      }
    else
      {
        if (popArray[itemCount][pUrl])
          {
            popMenuTable += '<tr class="popMenu" onClick="window.open(\'';
            popMenuTable += popArray[itemCount][pUrl]
            if (popArray[itemCount][pTarget])
              popTarget=popArray[itemCount][pTarget];
            popMenuTable += '\',\''+popTarget+'\');"'
          }
        else
          popMenuTable += '<tr width="100%" class="popMenu" ';
        if (popArray[itemCount][pTitle])
          popTitle = ' title="'+popArray[itemCount][pTitle]+'"';
        popMenuTable += popTitle+' '+popArray[itemCount][pEvent]
        popMenuTable += ' onMouseOver="this.className=\'popHover\'; '+closeSub+'" onMouseOut="this.className=\'popMenu\'">';
        if (popArray[itemCount][pIcon])
          popMenuTable += '<td valign="top" style="width:20px;"><img src="'+popArray[itemCount][pIcon]+'" border="0" /></td>'
        else if (popArray[itemCount][pUrl])
          popMenuTable += '<th valign="top" style="width:20px;">'+menuLink+'</th>'
        else
          popMenuTable += '<th valign="top" style="width:20px;">&nbsp;&nbsp;&nbsp;&nbsp;</th>';
        popMenuTable += '<td nowrap>'+popArray[itemCount][pText];
        popMenuTable += '</td><td colspan="2">&nbsp;</td></tr>';
      }
    itemCount+=1;
  } while (itemCount < popArray.length);
  popMenuTable += '</table>'
  return popMenuTable; // returning the table to the function that has required it
}

var subMenus = new Array();

function closeSubMenu_IfAny(Level) {
  if (subMenus[Level])
    {
       var object           = document.getElementById(subMenus[Level]);
       object.style.display = 'none';
       subMenus[Level] = '';
    }
}

function showSubMenu(text,objectName,isLeftKey,Level) {
  var object           = document.getElementById(objectName);
  object.style.display = "";
  object.innerHTML     = text;
  subMenus[Level] = objectName;
  makeSureOnScreen(object,object.offsetLeft,object.offsetTop,true);
}

function makeMainMenu(direction,dropUpperRightCheckboxes) {
  document.write('<div style="padding:0px;margin:0px;border:none;border-bottom:1px inset #FFFFFF;"><table id="mainMenu" name="mainMenu" style="position:absolute;z-index:999;" onmousedown="eowPopMenu(\'<h5>The menubar</h5>Perhaps you want to give context sensitive help for the main menu? Click with the right mouse button on the menuitem [ClassWare] for a sample.\');" cellspacing="0" cellpadding="0" border="0" style="border:none;padding;0px;margin:0px;');
  if (direction == 'vertical')
    document.write('">')
  else
//    document.write('width:99%" ><tr><td>&nbsp;&nbsp;</td>');
    document.write('width:99%" ><tr>');
  var mainCount = 0;
  do {
    // No reason to make an entry if no visible element are available
    if (eowPop[mainCount][0][pText] || eowPop[mainCount][0][pIcon])
      {
        aKey=eowPop[mainCount][0][pText].slice(0,1);
        eowPop[mainCount][0][pText] =eowPop[mainCount][0][pText].slice(1,eowPop[mainCount][0][pText].length);
        aLabel = '<label for="mainContainer'+mainCount+'" accesskey="'+aKey+'">';
        eowPop[mainCount][0][pText] = aLabel+'<u>'+aKey+'</u>'+eowPop[mainCount][0][pText];
        if (eowPop[mainCount][0][pIcon])
          var mIcon = '<img src="'+eowPop[mainCount][0][pIcon]+'" align="absbottom" border="0" />'
        else
          var mIcon = '';
        if (direction == 'vertical')
          document.write('<tr>');
        if (eowPop[mainCount].length > 1)
          {
            document.write('<td nowrap id="mainContainer'+mainCount+'" name="mainContainer'+mainCount+'" '+eowPop[mainCount][0][pEvent]+' onfocus="this.onclick();" onblur="this.onmouseout()" onClick="if (LastObject != \'mainMenu'+mainCount+'\') {eowShowPop(makePopMenu('+mainCount+'),\'mainMenu'+mainCount+'\',true);this.className=\'topHover\';} else {closePop_IfAny();justOpenedPop=true;this.className=\'topMenu\';}" onMouseOver="if (LastObject && (LastObject != \'mainMenu'+mainCount+'\')) {eowShowPop(makePopMenu('+mainCount+'),\'mainMenu'+mainCount+'\');this.className=\'topHover\';} else {this.className=\'topHoverOutset\';}"  onMouseOut="this.className=\'topMenu\';" class="topMenu">&nbsp;'+mIcon+'&nbsp;'+eowPop[mainCount][0][pText]+'&nbsp;&nbsp;');
//            document.write('<td nowrap id="mainContainer'+mainCount+'" name="mainContainer'+mainCount+'" '+eowPop[mainCount][0][pEvent]+' onfocus="this.onclick();" onblur="this.onmouseout()" onClick="if (LastObject != \'mainMenu'+mainCount+'\') {eowShowPop(makePopMenu('+mainCount+'),\'mainMenu'+mainCount+'\',true);document.getElementById(\'mainMenu'+mainCount+'\').focus();this.className=\'topHover\';} else {closePop_IfAny();justOpenedPop=true;this.className=\'topMenu\';}" onMouseOver="if (LastObject && (LastObject != \'mainMenu'+mainCount+'\')) {eowShowPop(makePopMenu('+mainCount+'),\'mainMenu'+mainCount+'\');this.className=\'topHover\';} else {this.className=\'topHoverOutset\';}"  onMouseOut="this.className=\'topMenu\';"  class="topMenu">&nbsp;'+mIcon+'&nbsp;'+eowPop[mainCount][0][pText]+'&nbsp;');
            if (direction != 'vertical')
              document.write('<br />');
            document.write('<div id="mainMenu'+mainCount+'" name="mainMenu'+mainCount+'" style="position:absolute;top:22px;display:none;border:1px solid #000000;" class="popMenuContainer"></div></td>');
           }
        else
          document.write('<td nowrap><a href="'+eowPop[mainCount][0][pUrl]+'" target="'+eowPop[mainCount][0][pTarget]+'">'+eowPop[mainCount][0][pText]+'</a></td>');
        if (direction == 'vertical')
          document.write('</tr>');
      }
    mainCount += 1;
  }while (mainCount < eowPop.length);
//      document.write('<tr><td style="height:100%" class="topMenu"></td></tr></table>');
  if (direction != 'vertical')
    {
      document.write('<td style="width:100%" class="topMenu"></td>');
      if (!dropUpperRightCheckboxes)
        {
          if (!UseBrowsersContextMenu)
            isChecked = 'checked'
          else
            isChecked = '';
          document.write('<td nowrap onmousedown="eowPopMenu(\'<h5>Should we use GUI?</h5>Graphical user interfaces (GUIs) are designed based on some recommendations which also includes how to use keyboard and mouse.<br /><br />According to these recommandations the right mouse button should give context sensitive help as we demonstrate on this page! \');" onClick="togglePreferences()" title="You may use the authors context menu or the browsers menu on clicking with the right mouse button."  class="topMenu"><form style="display:inline"><input type="checkbox" id="cMenuPref" name="cMenuPref" '+isChecked+'>Enable context popups</td>');
          document.write('<td nowrap id="aHighlight" name="aHighlight" onmousedown="eowPopMenu(\'<h5>Highlighting hotspots?</h5><p>The browser may highlight areas that are tagged with the class <i>.hotspot</i>.</p><p>This means that the rule for the class <i>.hotspot</i> will be temporary changed to use another backgroundcolor.</p>\');" onClick="if (!document.getElementById(\'cHighlight\').disabled){ toggleHotspotBackground()}" title="The browser may highlight areas considered to be hotspots."  class="topMenu"><input type="checkbox" id="cHighlight" name="cHighlight">Highlight hotspots</form>&nbsp;</td>');
        }
      document.write('</tr>');
    }
  document.write('</table></div>');
}


function getOffsetLeft (object) {
// Should give the offsetLeft according to the screen, not the container......
  var oLeft = object.offsetLeft;
  while ((object = object.offsetParent) != null)
    oLeft += object.offsetLeft;
  return oLeft;
}

function getOffsetTop (object) {
// Should give the offsetTop according to the screen, not the container......
  var oTop = object.offsetTop;
  while((object = object.offsetParent) != null)
    oTop += object.offsetTop;
  return oTop;
}


function makeSureOnScreen(object,X,Y,adjustmentDiv){
  if (IE_test)
    {
      var screenH = document.body.clientHeight
      var screenW = document.body.clientWidth
    }
  else
    {
      var screenH = window.innerHeight
      var screenW = window.innerWidth
    }
  if (Y < screenH - object.offsetHeight)
    {
        object.style.top = Y
    }
  else
    object.style.top = Y - object.offsetHeight+55; //+1 is to make sure that Netscape don't trigger a new event
  if (X < screenW - object.offsetWidth)
    object.style.left = X //-1 is to make sure that Netscape don't trigger a new event
  else
    object.style.left = X - object.offsetWidth+5;
//  if (adjustmentDiv=='')
//    object.style.left = object.style.left -1;
/*
 If the object is to heigh to fit the screen we better add a scrollbar
 Will cause problems if not on the LAST level!!!!!!
 got a problem with Netscape and Opera's way of handling div-tags, which are not
 automatic expanded, but this cute trix expands it using the width of
 the table (lastChild) inside the div. Adding 4 pixels to get room for the border
 Might as well do it for MSIE too even if MSIE expand itself.
*/

//  if (LastObject != 'popContainer' && (NS_test || CheckString(navigator.userAgent,"Opera") != -1))
     object.style.width = object.lastChild.offsetWidth+2;

object.style.overflow='';
//object.style.-moz-box-sizing='';
if (object.offsetHeight > screenH)
  {
    object.style.height = screenH-15;
    object.style.overflow='auto';
//    object.style.-moz-box-sizing='border-box';
  }


/*
What to do if the submenu are placed beneath the screen's bottom
probably no need for getOffsetTop(object), may use object.clientY
and object.clientX instead
*/
if (getOffsetTop(object)+object.offsetHeight > screenH)
  {
    object.style.top = object.offsetTop - (object.offsetHeight-40)
  }
if (getOffsetTop(object) < 1)
  {
    do {
	     object.style.top = object.offsetTop + 15 //((getOffsetTop(object)+object.offsetHeight) - screenH)
       } while (getOffsetTop(object) < 1)
  }

if (getOffsetLeft(object) < 1)
  object.style.top = 1
if (navigator.appName =="Microsoft Internet Explorer" && CheckString(navigator.userAgent,"Opera") == -1)
  {
    coverObject = document.getElementById('IE_selectbugfix');
    coverObject.style.top=object.offsetTop
    coverObject.style.left=object.offsetLeft
    coverObject.style.width=object.offsetWidth
    coverObject.style.height=object.offsetHeight
    coverObject.style.display=''
  }
}

function eowShowPop (text,objectName,isLeftKey,width,height) {
      closePop_IfAny();
      if (objectName)
        LastObject = objectName
      else
        LastObject           = 'popContainer';
      UseLocalBrowserContextMenu = UseBrowsersContextMenu;
      var object           = document.getElementById(LastObject);
      object.style.display = "";

      object.innerHTML     = text;
      if (width && height)
        {
          object.style.width=width+"px";
          object.style.height=height+"px";
          object.style.top="30px";
          if (IE_test)
            {
              var screenW = document.body.clientWidth
            }
          else
            {
              var screenW = window.innerWidth
            }
          object.style.left=screenW-(width +25);
        }
      if (!objectName)
        {
          if (IE_test)
            makeSureOnScreen(object,event.clientX,event.clientY)
          else
            makeSureOnScreen(object,NS_event.clientX-1,NS_event.clientY)
        }
      else
        makeSureOnScreen(object,object.offsetLeft,object.offsetTop);
      justOpenedPop = isLeftKey; // To prevent onClick frome closing it imidiatly
}

function eowPopMenu(text) {
  if (IsRightClick())
    {
      // We want the browsers menu if text are selected.
      if (navigator.appName =="Microsoft Internet Explorer" && CheckString(navigator.userAgent,"Opera") == -1)
        {
          if (document.selection.createRange().text)
            text = "";
        }
      else
        if (document.getSelection) // Opera and Netscape/Mozilla
          {
            var txt = document.getSelection();
             if (txt)
              text = "";
          }
      if (text)
        {
          eowShowPop(text);
          BubbleStopped = !UseBrowsersContextMenu;
        }
     else
       {
        UseLocalBrowserContextMenu = true;
        closePop_IfAny();
       }
    }
}

var LastObject = "";

function closePop_IfAny() {
if (navigator.appName =="Microsoft Internet Explorer" && CheckString(navigator.userAgent,"Opera") == -1)
  document.getElementById('IE_selectbugfix').style.display='none';
  closeSubMenu_IfAny(1)
  if (LastObject )
    {
      var object = document.getElementById(LastObject);
      object.style.display = "none";
      LastObject = "";
    }
}

function closePop_IfNotToSoon(event) {
  if (navigator.appName =="Microsoft Internet Explorer" && CheckString(navigator.userAgent,"Opera") == -1)
    {
       if (document.selection.createRange().text)
         justOpenedPop = false;
    }
   if (!justOpenedPop)
      closePop_IfAny(true)
   justOpenedPop = false;
}


function getClassNumber(myClass) {
// Need to find the number of a class which I know the name of
  if (!document.styleSheets)
    return;
  var myNumber = 'Not found class "'+myClass+'"';
  var CSSRules
  if (document.styleSheets[0].cssRules) {
    CSSRules = 'cssRules'
  }
  else if (document.getElementById) {
    CSSRules = 'rules'
  }
  for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
    if (document.styleSheets[0][CSSRules][i].selectorText == myClass
        || document.styleSheets[0][CSSRules][i].selectorText == "."+myClass) {
      myNumber = i;
	}
  }
  return myNumber;
}

function changeClassRule(myClassName,myProperty,myStyle) {
  if (myClassName > -1 && myClassName < 10)
    var myClassNumber = myClassName
  else
    var myClassNumber= getClassNumber(myClassName)
  if (!document.styleSheets)
    return;
  var myStylesheet = new Array();
  if (document.styleSheets[0].cssRules)  // Mozilla
    {
      myStylesheet = document.styleSheets[0].cssRules;
    }
  else
    {
      myStylesheet = document.styleSheets[0].rules;  // IE
    }
  myStylesheet[myClassNumber].style[myProperty] = myStyle;
}


function toggleHotspotBackground() {
  HighLightHotspots = !HighLightHotspots;
  if (HighLightHotspots)
    {
      changeClassRule('hotspot','background',highlightBackGround)
      changeClassRule('hotspot','color',highlightColor)
      changeClassRule('hotspot','border','solid 1px '+highlightBorder)
    }
  else
    {
/*
For some reason MSIE won't accept the value 'inherit' and Netscape
won't do what we want with empty color
*/
      if (NS_test)
        changeClassRule('hotspot','background','inherit')
      else
        changeClassRule('hotspot','background','')
      changeClassRule('hotspot','color',hotspotColor)
      changeClassRule('hotspot','border','none')
    }
  document.getElementById('cHighlight').checked = HighLightHotspots;
}

function togglePreferences() {
  UseBrowsersContextMenu=!UseBrowsersContextMenu;
  if (UseBrowsersContextMenu)
    {
      closePop_IfAny();
    }
  BubbleStopped=UseBrowsersContextMenu;
  if (UseBrowsersContextMenu)
    {
      changeClassRule('hotspot','cursor','')
      changeClassRule('hotspot','color','')
      changeClassRule('hotspot','background','#FFFFFF')
      changeClassRule('hotspot','border','none')
    }
  else
    {
      changeClassRule('hotspot','cursor','help')
      changeClassRule('hotspot','color',hotspotColor)
      if (HighLightHotspots)
        {
          changeClassRule('hotspot','background',highlightBackGround)
          changeClassRule('hotspot','border','solid 1px')
        }
    }
  document.getElementById('cMenuPref').checked=!UseBrowsersContextMenu;
  document.getElementById('aHighlight').disabled=UseBrowsersContextMenu;
  document.getElementById('cHighlight').disabled=UseBrowsersContextMenu;
}


function IsRightClick(dropClose) {
  var RightClick = false;
  if (navigator.appName == 'Microsoft Internet Explorer' &&
      (   event.button == 2
       || event.button == 3
       || event.keyCode==13
       || (event.button == 1 && event.ctrlKey)))
    RightClick = true;
  else if (navigator.appName == 'Netscape' &&
      (NS_event.which == 3
      || NS_event.which == 2
      || NS_event.keyCode==13
      || (NS_event.which == 1 && NS_event.ctrlKey)))
    RightClick = true;
  if (!BubbleStopped && RightClick)
    {
      BubbleStopped = true;
      if (dropClose)
        closePop_IfAny();
      return true;
    }
  return false;
}

function CheckClick(event){
  NS_event=event;
  if (!BubbleStopped){
    eowPopMenu(mainPop);
  }
  BubbleStopped = UseBrowsersContextMenu; // prepare for next event
  return true;
}

function CheckIfStandard(event) {
  if (UseLocalBrowserContextMenu)
    {
      return true
    }
  else
    return UseBrowsersContextMenu;
}

function CheckString(str,sub){
  var position = str.indexOf(sub);
  return position;
}

function checkOpenPop(object){
if (LastObject != '')
  {
    closePop_IfAny();
    event.keyCode=13;
    object.onmousedown();
    BubbleStopped = false;
  }
}


document.write('<div id="popContainer" onmousedown="IsRightClick(false);" onClick="justOpenedPop=true;" style="border:1px solid #000000;padding:0px;position:absolute;display:none;z-index:50" class="popUp"></div>');
if (navigator.appName =="Microsoft Internet Explorer" && CheckString(navigator.userAgent,"Opera") == -1)
  document.write('<iframe id="IE_selectbugfix" style="width:120px;height:150px;position:absolute;top:20px;left:100px;display:none;" frameborder="0" scrolling="no" marginwidth="0" src="" marginheight="0"></iframe>');

// this iframe is used to cover the background of a popup in case there are
// a selectbox behind it i MSIE. The reason is that MSIE alway places SELECT
// on top unless the object is an iframe

document.onclick=closePop_IfNotToSoon;

document.oncontextmenu= CheckIfStandard;

if(document.layers) { // Necessary for older versions of Netscape
    window.captureEvents(Event.MOUSEDOWN);
    window.onmousedown = CheckClick
}
else {
  document.onmousedown=CheckClick;
}

window.document.onkeypress = CheckClick


