var glossaryDefinitionUrl;var glossaryXmlHttp;var glossaryContainer;var glossaryPopup;var glossaryPopupWindow;var glossaryPopupTitle;var glossaryPopupText;var glossaryPopupClose;var glossaryTerm;var glossaryKeywords;var glossaryRegexps;var glossaryDefinitions;function addGlossaryTerms(url,definitionUrl,parent,popup,popupWindow,popupTitle,popupText,popupClose){glossaryDefinitionUrl=definitionUrl;glossaryXmlHttp=null;glossaryContainer=parent;glossaryPopup=popup;glossaryPopupWindow=popupWindow;glossaryPopupTitle=popupTitle;glossaryPopupText=popupText;glossaryPopupClose=popupClose;glossaryPopup.style.opacity=0;glossaryPopup.style.filter="alpha(opacity=0)";glossaryPopup.style.position="absolute";glossaryPopupWindow.style.display="none";glossaryPopupWindow.style.position="absolute";addPopupEvents(glossaryPopup);addPopupWindowEvents(glossaryPopupClose);document.onclick=clickOutsideGlossaryPopupWindow;if(window.XMLHttpRequest){glossaryXmlHttp=new XMLHttpRequest()}else{if(window.ActiveXObject){glossaryXmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}}if(glossaryXmlHttp!=null){glossaryXmlHttp.onreadystatechange=addGlossaryTermsStateChange;glossaryXmlHttp.open("GET",url,true);glossaryXmlHttp.send(null)}}function addPopupEvents(node){if(node==glossaryPopup){node.onmouseover=fadePopupIn2}node.onmouseout=hideGlossaryPopup;node.onclick=showGlossaryPopupWindow;for(var i=0;i<node.childNodes.length;i++){if(node.childNodes[i].nodeType!=3){addPopupEvents(node.childNodes[i])}}}function addPopupWindowEvents(node){node.onclick=hideGlossaryPopupWindow;for(var i=0;i<node.childNodes.length;i++){if(node.childNodes[i].nodeType!=3){addPopupEvents(node.childNodes[i])}}}function addGlossaryTermsStateChange(){if(glossaryXmlHttp.readyState==4){if(glossaryXmlHttp.status==200||glossaryXmlHttp.status==0){var keywords=glossaryXmlHttp.responseText;glossaryDefinitions=new Object();if(keywords.length>0){glossaryKeywords=keywords.split("\r\n");glossaryRegexps=new Array();for(var i=0;i<glossaryKeywords.length;i++){glossaryRegexps[i]=new RegExp();glossaryRegexps[i].compile("\\b"+glossaryKeywords[i]+"\\b","i")}applyGlossaryTerms(glossaryContainer)}}}}function applyGlossaryTerms(node){if(node==null){return}if(node.nodeType==3){var text=new String(node.data);for(var i=0;i<glossaryRegexps.length;i++){var result=glossaryRegexps[i].exec(text);if(result){var s1=text.slice(0,result.index);var s2=text.slice(result.index+glossaryKeywords[i].length);if(s1.length>0&&s1.charAt(s1.length-1)=="-"){continue}if(s2.length>0&&s2.charAt(0)=="-"){continue}var t1=document.createTextNode(s1);var t2=document.createTextNode(s2);var p1=document.createElement("span");var p2=document.createElement("span");p1.appendChild(t1);p2.appendChild(t2);var popup=document.createElement("span");popup.className="glossaryTerm";popup.onmouseover=showGlossaryPopup;popup.onmouseout=hideGlossaryPopup;popup.appendChild(document.createTextNode(result[0]));var container=document.createElement("span");container.appendChild(p1);container.appendChild(popup);container.appendChild(p2);node.parentNode.replaceChild(container,node);applyGlossaryTerms(t1);applyGlossaryTerms(t2);break}}}else{if(node.nodeType==1&&node.nodeName.toLowerCase()!="a"&&node.nodeName.toLowerCase()!="input"&&node.nodeName.toLowerCase()!="textarea"&&node.nodeName.toLowerCase()!="select"&&node.nodeName.toLowerCase()!="pre"&&node.nodeName.toLowerCase()!="code"&&node.nodeName.charAt(0).toLowerCase()!="h"&&node.id.indexOf("header")==-1){for(var i=0;i<node.childNodes.length;i++){applyGlossaryTerms(node.childNodes[i])}}}}function getX(node){if(node==null){return 0}var x=node.offsetLeft;if(node.offsetParent){x+=getX(node.offsetParent)}if(node.offsetParent&&node.offsetParent!=document.body&&node!=document.body&&(!document.documentElement||node.offsetParent!=document.documentElement)&&node.offsetParent.scrollLeft){x-=node.offsetParent.scrollLeft}return x}function getY(node){if(node==null){return 0}var y=node.offsetTop;if(node.offsetParent){y+=getY(node.offsetParent)}if(node.offsetParent&&node.offsetParent!=document.body&&node!=document.body&&(!document.documentElement||node.offsetParent!=document.documentElement)&&node.offsetParent.scrollTop){y-=node.offsetParent.scrollTop}return y}function showGlossaryPopup(e){if(!e){e=window.event}var term;if(e.target){term=e.target}else{if(e.srcElement){term=e.srcElement}}if(term==null){return}if(term==glossaryTerm){fadePopupOut2();return}hideGlossaryPopup();glossaryPopup.style.display="block";glossaryPopup.style.left=(getX(term)-getX(glossaryPopup.offsetParent))+"px";glossaryPopup.style.top=(getY(term)-getY(glossaryPopup.offsetParent)-glossaryPopup.offsetHeight+3)+"px";glossaryTerm=term;fadePopupIn1()}function showGlossaryPopupWindow(e){if(!e){e=window.event}if(glossaryTerm){var text;if(glossaryTerm.innerText){text=glossaryTerm.innerText}else{if(glossaryTerm.textContent){text=glossaryTerm.textContent}else{if(typeof(glossaryTerm.childNodes[0])=="string"){text=glossaryTerm.childNodes[0]}else{return}}}if(!glossaryDefinitions[text.toLowerCase()]||glossaryDefinitions[text.toLowerCase()]==null){if(window.XMLHttpRequest){glossaryXmlHttp=new XMLHttpRequest()}else{if(window.ActiveXObject){glossaryXmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}}glossaryXmlHttp.onreadystatechange=getGlossaryDefinitionStateChange;glossaryXmlHttp.open("GET",glossaryDefinitionUrl+"?text="+escape(text),true);glossaryXmlHttp.send(null)}else{showGlossaryPopupWindowWorker(text)}e.cancelBubble=true;if(e.stopPropagation){e.stopPropagation()}}}function getGlossaryDefinitionStateChange(){if(glossaryXmlHttp.readyState==4&&glossaryTerm){if(glossaryXmlHttp.status==200||glossaryXmlHttp.status==0){var definition=glossaryXmlHttp.responseText;var text;if(glossaryTerm.innerText){text=glossaryTerm.innerText}else{if(glossaryTerm.textContent){text=glossaryTerm.textContent}else{if(typeof(glossaryTerm.childNodes[0])=="string"){text=glossaryTerm.childNodes[0]}else{return}}}glossaryDefinitions[text.toLowerCase()]=definition;showGlossaryPopupWindowWorker(text)}}}function showGlossaryPopupWindowWorker(text){glossaryPopupTitle.innerHTML=text;glossaryPopupText.innerHTML=glossaryDefinitions[text.toLowerCase()];glossaryPopupWindow.style.display="block";glossaryPopupWindow.style.position="absolute";glossaryPopupWindow.style.left=getX(glossaryTerm)+"px";glossaryPopupWindow.style.top=(getY(glossaryTerm)-glossaryPopupWindow.offsetHeight)+"px";if(getY(glossaryPopupWindow)<0){glossaryPopupWindow.style.top=(getY(glossaryTerm)+glossaryTerm.offsetHeight)+"px"}hideGlossaryPopup()}function clickOutsideGlossaryPopupWindow(e){if(glossaryPopupWindow.style.display=="none"){return}if(!e){e=window.event}var inPopupWindow=false;var target;if(e.target){target=e.target}else{if(e.srcElement){target=e.srcElement}}while(target){if(target==glossaryPopupWindow){inPopupWindow=true;break}else{target=target.parentNode}}if(!inPopupWindow){hideGlossaryPopupWindow()}}function hideGlossaryPopupWindow(){glossaryPopupWindow.style.display="none"}function fadePopupIn1(){setTimeout("fadePopupInWorker1()",25)}function fadePopupInWorker1(){var opacity=parseFloat(glossaryPopup.style.opacity);if(opacity<0.5){opacity+=0.05;glossaryPopup.style.opacity=opacity;glossaryPopup.style.filter="alpha(opacity="+(opacity*100)+")";if(opacity<0.5){fadePopupIn1()}}}function fadePopupIn2(){setTimeout("fadePopupInWorker2()",25)}function fadePopupInWorker2(){var opacity=parseFloat(glossaryPopup.style.opacity);if(opacity<1){opacity+=0.05;glossaryPopup.style.opacity=opacity;glossaryPopup.style.filter="alpha(opacity="+(opacity*100)+")";if(opacity<1){fadePopupIn2()}}}function fadePopupOut2(){setTimeout("fadePopupOutWorker2()",25)}function fadePopupOutWorker2(){var opacity=parseFloat(glossaryPopup.style.opacity);if(opacity>0.5){opacity-=0.05;glossaryPopup.style.opacity=opacity;glossaryPopup.style.filter="alpha(opacity="+(opacity*100)+")";if(opacity>0.5){fadePopupOut2()}}}function hideGlossaryPopup(e){if(!e){e=window.event}if(hitTest(e,glossaryPopup)||hitTest(e,glossaryTerm)){return}glossaryPopup.style.opacity=0;glossaryPopup.style.filter="alpha(opacity=0)";glossaryPopup.style.display="none";glossaryTerm=null}function hitTest(e,target){if(!e||!target){return false}if(e&&e.clientX&&e.clientY){var x,y;if(e.pageX&&e.pageY){x=e.pageX;y=e.pageY}else{x=e.clientX;y=e.clientY;if(document.documentElement.scrollLeft){x+=document.documentElement.scrollLeft}else{if(document.body.scrollLeft){x+=document.body.scrollLeft}}if(document.documentElement.scrollTop){y+=document.documentElement.scrollTop}else{if(document.body.scrollTop){y+=document.body.scrollTop}}}var minX=getX(target);var maxX=minX+target.offsetWidth;var minY=getY(target);var maxY=minY+target.offsetHeight;if(x>=minX&&x<=maxX&&y>=minY&&y<=maxY){return true}}return false};