// You can reuse this code if you 
// do not modify any part thereof.
// Please send bug reports / improvement requests
// to the author: Alexei.Kourbatov@intel.com

if(!self.jxPopUpFontFace)   jxPopUpFontFace="Helvetica, Arial, sans-serif"
if(!self.jxPopUpFontSize)   jxPopUpFontSize=9
if(!self.jxPopUpFontColor)  jxPopUpFontColor="000000"
if(!self.jxPopUpBgColor)    jxPopUpBgColor="FFFFEE"
if(!self.jxPopUpBorderColor)jxPopUpBorderColor="000000"
if(!self.jxPopUpBorderWidth)jxPopUpBorderWidth=1
if(!self.jxPopUpMargin)     jxPopUpMargin=5
if(!self.jxPopUpOval)       jxPopUpOval=0
if(!self.jxPopUpShadow)     jxPopUpShadow=8
if(!self.jxPopUpShadowColor)jxPopUpShadowColor="BBBBBB"
if(!self.jxPopUpDeleteOnMove)jxPopUpDeleteOnMove=0

ver4=(parseInt(navigator.appVersion)>3)
ns4 =(navigator.appName=="Netscape" && ver4)?true:false
ie4 =(navigator.appName!="Netscape" && ver4)?true:false

jxPopMouseX=0
jxPopMouseY=0

function GlossWindow(txt,winTitle) {
 if (!winTitle) winTitle='Glossary'
 if (txt.charAt(0)=='#') {
//  alert ('Trying to open: '+top.trueRootURL+top.glossDir+top.glossFile+txt)
  jxPopUpWin=window.open(top.trueRootURL+top.glossDir+top.glossFile+txt,'myPopUp','width=350,height=200,left=20,top=20,scrollbars=1,menubar=0,resizable=1,dependent=1')
 }
 else {
  jxPopUpWin=window.open('about:blank','myPopUp','width=390,height=240,left=20,top=20,scrollbars=1,menubar=0,resizable=1,dependent=1')
  var pSize=jxPopUpFontSize; if (pSize<10) pSize++;
  jxPopUpWin.document.write('<head><title>'+winTitle+'</title></head><body bgcolor="'+jxPopUpBgColor+'"><font color="'+jxPopUpFontColor+'" size=2 point-size="'+pSize+'" face="'+jxPopUpFontFace+'" style="font:'+jxPopUpFontSize+'pt">'
   +txt+'</font></body>')
  jxPopUpWin.document.close()
 }
 jxPopUpWin.focus()
}

function PopUp(txt,left,topY,width) {
 if (!width) width=0; 
 if (!left) left=null; 
 if (!topY) topY=null;
 if (!ver4) {GlossWindow(txt,'Glossary'); return}
 if (txt.charAt(0)=='#') {
  if (!top.glossCacher || !top.glossCacher.doJava) {GlossWindow(txt,'Glossary'); return}
  if (!top.glossCacher.document || !navigator.javaEnabled()) {GlossWindow(txt,'Glossary'); return}
  var anch=txt.substring(1,txt.length)
  var N=top.glossCacher.glossN[anch]
  if (N==null) txt='Glossary entry not found: '+txt
  else txt='<base href="'+top.trueRootURL+'main/">'+top.glossCacher.document.loadFile.getSegmentN(N)
 }

 jxPopMouseX=jxMouseX
 jxPopMouseY=jxMouseY

 if (!jxPopUpShown || jxPopUpContent!=txt) {
  if (width==0||width==null) {
   if (txt.length<40) width=6*(txt.length)
   else width=parseInt(19*Math.sqrt(txt.length))
   if (width>700) width=700
  }
  if (left==null || topY==null) {
   jxPopX=jxMouseX+8
   jxPopY=jxMouseY+5
  }
  else {
   jxPopX=left
   jxPopY=topY
  }
  jxPopUpContent=txt
  setTimeout('jxShowPopUpDHTML('+width+')',100)
  if (ie4) {for(var i=0;i<document.links.length;i++)document.links[i].blur()}
 }
}

function jxPopLayer(id,content,left,top,width,height,bgColor,visibility,zIndex) {
 if (ns4) {
  var lyr=document.layers[id]=new Layer(width)
  lyr.name=id
  lyr.left=left
  lyr.top=top
  if (height!=null) lyr.clip.height=height
  lyr.bgColor = bgColor
  lyr.visibility = (visibility=='hidden')?'hide':'show'
  lyr.zIndex=zIndex
  lyr.document.write(content)
  lyr.document.close()
 }
 else if (ie4) {
  var str = '\n<DIV id='+id+' style="position:absolute;left:'+left+';top:'+top+';width:'+width
  if (height!=null) {
   str += ';height:'+height+';clip:rect(0,'+width+','+height+',0)'
  }
  str += ';background-color:'+bgColor+';z-index:'+zIndex+';visibility:'+visibility
      +';">'+content+'</DIV>'
  document.body.insertAdjacentHTML("BeforeEnd",str)
 }
}

function jxDeletePopLayer(id) {
 if (ns4 && document.layers[id]) {
  document.layers[id].visibility="hide"
  delete document.layers[id]
 }
 else if (ie4 && document.all[id]) {
  document.all[id].style.visibility="hidden"
  document.all[id].innerHTML=""
  document.all[id].outerHTML=""
 }
}

function jxShowPopLayer(id) {
 if (ns4 && document.layers[id]) document.layers[id].visibility="show"
 if (ie4 && document.all[id]) document.all[id].style.visibility="visible"
}

jxPopUpRetry=0
jxPopUpShown=0
jxPopUpContent=0

function jxShowPopUpDHTML(width) {
 if (jxPopUpDeleteOnMove && (jxIsFar(jxPopMouseX,jxMouseX,150)||jxIsFar(jxPopMouseY,jxMouseY,50))) return
 if (jxPopUpShown) jxRemovePopUp()

 var nsSize=jxPopUpFontSize; if (nsSize==9) nsSize=10 

 txt='<font color="'+jxPopUpFontColor+'" face="'+jxPopUpFontFace+'" point-size='+nsSize+' style="font:'+jxPopUpFontSize+'pt">'
    +jxPopUpContent+'</font>'

 var DY=jxPopUpMargin+jxPopUpBorderWidth
 var DX=DY+2

 if (ns4) {
  jxPopLayer('jxPopUpMeasurer',txt,1,1,width-2*DX,null,'FFFFEE','hidden',3)
  jxPopW=document.layers['jxPopUpMeasurer'].document.width+2*DX
  jxPopH=document.layers['jxPopUpMeasurer'].document.height+2*DY
  var winW=window.innerWidth-16
  var winH=window.innerHeight
 }
 if (ie4) {
  if (!document.all['jxmeasurer']) document.body.insertAdjacentHTML('BeforeEnd','\n<DIV id="jxmeasurer" style="position:absolute;left:1;top:1;width:640;height:200;visibility:hidden;"></DIV>')
  document.all['jxmeasurer'].insertAdjacentHTML('BeforeEnd','\n<DIV id="jxPopUpMeasurer" style="position:absolute;left:1;top:1;width:'+(width-2*DX)+';">'+txt+'</DIV>')
  jxPopW=document.all['jxPopUpMeasurer'].scrollWidth+2*DX
  jxPopH=document.all['jxPopUpMeasurer'].scrollHeight+2*DY
  var winW=document.body.offsetWidth-20
  var winH=document.body.offsetHeight-4
 }
 jxDeletePopLayer('jxPopUpMeasurer')

 if (jxPopW<jxPopH && !jxPopUpRetry) {
  jxPopUpRetry=1
  setTimeout('jxShowPopUpDHTML('+width+')',100)
  return
 }

 if (isNaN(jxPopX)) var cornerX=parseInt(0.5*(winW-jxPopW))
 else var cornerX=jxPopX-(ns4?pageXOffset:document.body.scrollLeft)
 if (isNaN(jxPopY)) var cornerY=parseInt(0.4*(winH-jxPopH))
 else var cornerY=jxPopY-(ns4?pageYOffset:document.body.scrollTop)

 var shadW=jxPopW+jxPopUpShadow
 var shadH=jxPopH+jxPopUpShadow
 if (cornerX+shadW>winW) cornerX=winW-shadW
 if (cornerY+shadH>winH) cornerY=winH-shadH
 jxPopX=cornerX+(ns4?pageXOffset:document.body.scrollLeft); if (jxPopX<0)jxPopX=0
 jxPopY=cornerY+(ns4?pageYOffset:document.body.scrollTop);  if (jxPopY<0)jxPopY=0

 jxPopLayer('jxPopUpText',txt,jxPopX+DX,jxPopY+DY,jxPopW-2*DX,jxPopH-2*DY,jxPopUpBgColor,'hidden',1003)

 if (jxPopUpOval) {
  var Z=(jxPopUpBorderWidth<=4)?4:jxPopUpBorderWidth
  jxPopLayer('jxPopUpPad' ,  '',jxPopX+jxPopUpBorderWidth+1,jxPopY+jxPopUpBorderWidth+1,jxPopW-2*jxPopUpBorderWidth-2,jxPopH-2*jxPopUpBorderWidth-2,jxPopUpBgColor,'hidden',1002)
  jxPopLayer('jxPopUpPad1',  '',jxPopX+jxPopUpBorderWidth,jxPopY+Z,jxPopW-2*jxPopUpBorderWidth,jxPopH-2*Z,jxPopUpBgColor,'hidden',1002)
  jxPopLayer('jxPopUpPad2',  '',jxPopX+Z,jxPopY+jxPopUpBorderWidth,jxPopW-2*Z,jxPopH-2*jxPopUpBorderWidth,jxPopUpBgColor,'hidden',1002)
  jxPopLayer('jxPopUpFrame', '',jxPopX,jxPopY+4,jxPopW,jxPopH-8,jxPopUpBorderColor,'hidden',1001)
  jxPopLayer('jxPopUpFrame1','',jxPopX+4,jxPopY,jxPopW-8,jxPopH,jxPopUpBorderColor,'hidden',1001)
  jxPopLayer('jxPopUpFrame2','',jxPopX+2,jxPopY+1,jxPopW-4,jxPopH-2,jxPopUpBorderColor,'hidden',1001)
  jxPopLayer('jxPopUpFrame3','',jxPopX+1,jxPopY+2,jxPopW-2,jxPopH-4,jxPopUpBorderColor,'hidden',1001)
  jxPopLayer('jxPopUpShad', '',jxPopX+jxPopUpShadow,jxPopY+4+jxPopUpShadow,jxPopW,jxPopH-8,jxPopUpShadowColor,'hidden',1000)
  jxPopLayer('jxPopUpShad1','',jxPopX+4+jxPopUpShadow,jxPopY+jxPopUpShadow,jxPopW-8,jxPopH,jxPopUpShadowColor,'hidden',1000)
  jxPopLayer('jxPopUpShad2','',jxPopX+2+jxPopUpShadow,jxPopY+1+jxPopUpShadow,jxPopW-4,jxPopH-2,jxPopUpShadowColor,'hidden',1000)
  jxPopLayer('jxPopUpShad3','',jxPopX+1+jxPopUpShadow,jxPopY+2+jxPopUpShadow,jxPopW-2,jxPopH-4,jxPopUpShadowColor,'hidden',1000)
 }
 else {
  jxPopLayer('jxPopUpPad','',jxPopX+jxPopUpBorderWidth,jxPopY+jxPopUpBorderWidth,jxPopW-2*jxPopUpBorderWidth,jxPopH-2*jxPopUpBorderWidth,jxPopUpBgColor,'hidden',1002)
  jxPopLayer('jxPopUpFrame','',jxPopX,jxPopY,jxPopW,jxPopH,jxPopUpBorderColor,'hidden',1001)
  jxPopLayer('jxPopUpShad','',jxPopX+jxPopUpShadow,jxPopY+jxPopUpShadow,jxPopW,jxPopH,jxPopUpShadowColor,'hidden',1000)
 }
 jxShowPopLayer('jxPopUpText')
 jxShowPopLayer('jxPopUpPad')
 jxShowPopLayer('jxPopUpPad1')
 jxShowPopLayer('jxPopUpPad2')
 jxShowPopLayer('jxPopUpFrame')
 jxShowPopLayer('jxPopUpFrame1')
 jxShowPopLayer('jxPopUpFrame2')
 jxShowPopLayer('jxPopUpFrame3')
 jxShowPopLayer('jxPopUpShad')
 jxShowPopLayer('jxPopUpShad1')
 jxShowPopLayer('jxPopUpShad2')
 jxShowPopLayer('jxPopUpShad3')

 jxPopUpShown=1
 clearTimeout(jxPopUpTimer)
}

function jxRemovePopUp() {
 jxDeletePopLayer('jxPopUpShad')
 jxDeletePopLayer('jxPopUpShad1')
 jxDeletePopLayer('jxPopUpShad2')
 jxDeletePopLayer('jxPopUpShad3')
 jxDeletePopLayer('jxPopUpFrame')
 jxDeletePopLayer('jxPopUpPad')
 jxDeletePopLayer('jxPopUpFrame1')
 jxDeletePopLayer('jxPopUpFrame2')
 jxDeletePopLayer('jxPopUpFrame3')
 jxDeletePopLayer('jxPopUpPad1')
 jxDeletePopLayer('jxPopUpPad2')
 jxDeletePopLayer('jxPopUpText')
 jxPopUpShown=0
 jxMouseTooFar=0
}

jxPopUpTimer=0
jxMouseTooFar=0

function jxPopUpRetest() { 
 setTimeout("jxPopUpRetest()",1000)
 if (jxPopUpShown && jxPopUpDeleteOnMove) {
  if ( (jxIsFar(jxPopMouseX,jxMouseX,60) || jxIsFar(jxPopMouseY,jxMouseY,50))
      && !jxIsWithin(jxMouseX+(ie4?document.body.scrollLeft:0),jxMouseY+(ie4?document.body.scrollTop:0),jxPopX,jxPopY,jxPopW,jxPopH) 
     )
  {
   if (jxMouseTooFar==0) jxPopUpTimer=setTimeout("jxRemovePopUp()",1500)
   jxMouseTooFar=1
  }
  else { jxMouseTooFar=0; clearTimeout(jxPopUpTimer); }
 }
} if (ver4) jxPopUpRetest()

function jxIsFar(a,b,c) {return(a-b>c||b-a>c)}
function jxIsWithin(a,b,x,y,dx,dy) {return (a>=x && x+dx>=a && b>=y && y+dy>=b)}

function jxPopUpVersion() {return 'Version 1.0; coded 03 Jun 1999 by Alexei Kourbatov'}
top.jxPopUpVersion=self.jxPopUpVersion


//  E V E N T  H A N D L I N G

jxMouseX=0
jxMouseY=0

function jxPopUpMouseUp(e) { setTimeout("jxRemovePopUp()",50) }
function jxPopUpMouseMove(e) {
 if (ns4) {jxMouseX=e.pageX; jxMouseY=e.pageY} 
 if (ie4) {jxMouseX=event.x; jxMouseY=event.y} 
}
document.onmouseup  =jxPopUpMouseUp
document.onmousemove=jxPopUpMouseMove
if (ns4) document.captureEvents(Event.KEYUP | Event.MOUSEDOWN | Event.MOUSEUP)

jxPopUpLoaded=1
