Fix CRLF
[openemr.git] / contrib / acog / acog.js
blob9b78e396bba7480d5f5acaa3a4416478bf4d9fa9
1 function MM_findObj(n, d) { //v4.01
2   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
3     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
4   if(!(x=d[n])&&d.all) x=d.all[n]; 
5   for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
6   for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
7   x=MM_findObj(n,d.layers[i].document);
8   if(!x && d.getElementById) x=d.getElementById(n); 
9   return x;
12 function MM_changeProp(objName,x,theProp,theValue) { //v6.0
13   var obj = MM_findObj(objName);
14   if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
15     if (theValue == true || theValue == false)
16       eval("obj."+theProp+"="+theValue);
17     else eval("obj."+theProp+"='"+theValue+"'");
18   }
21 function initialize(){
22 if (document.all || document.getElementById){
23   setInterval("statmenu_ie()",10)
24 } else if (document.layers){
25   setInterval("statmenu_ns()",10)
29 function statmenu_ns(){
30   MM_changeProp('jtf','','style.top', (pageYOffset+10)+'px','DIV');
31   MM_changeProp('jtef','','style.top', (pageYOffset+115)+'px','DIV');
32   MM_changeProp('atab','','style.top', (pageYOffset+242)+'px','DIV');
35 function statmenu_ie(){
36   //var pageoffsetx=document.all? document.body.scrollLeft : window.pageXOffset
37   var pageoffsety=document.all? document.body.parentNode.scrollTop : window.pageYOffset;
38   MM_changeProp('jtf','','style.top', (pageoffsety+10)+'px','DIV');
39   MM_changeProp('jtef','','style.top', (pageoffsety+115)+'px','DIV'); 
40   MM_changeProp('atab','','style.top', (pageoffsety+242)+'px','DIV');
44 function TOOLTIP() {
45     this.width = 200;      
46     this.bgColor = '#FEF5D6';        
47     this.textColor = 'black';      
48     this.borderColor = 'black';    
49     this.opacity = 100;           
50     this.cursorDistance = 5;   
52     // don't change
53     this.text = '';
54     this.obj = 0;
55     this.sobj = 0;
56     this.active = false;
58     this.create = function() {
59       if(!this.sobj) this.init();
61       var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + ' bgcolor=' + this.bgColor + '><tr>' +
62               '<td align=left class="tooltip">'+ this.text + '</td></tr></table>';
64       if(document.layers) {
65         t = '<table border=0 cellspacing=0 cellpadding=1><tr><td bgcolor=' + this.borderColor + '>' + t + '</td></tr></table>';
66         this.sobj.document.write(t);
67         this.sobj.document.close();
68       }
69       else {
70         this.sobj.border = '1px solid ' + this.borderColor;
71         this.setOpacity();
72         if(document.getElementById) document.getElementById('ToolTip').innerHTML = t;
73         else document.all.ToolTip.innerHTML = t;
74       }
75       this.show();
76     }
78     this.init = function() {
79       if(document.getElementById) {
80         this.obj = document.getElementById('ToolTip');
81         this.sobj = this.obj.style;
82       }
83       else if(document.all) {
84         this.obj = document.all.ToolTip;
85         this.sobj = this.obj.style;
86       }
87       else if(document.layers) {
88         this.obj = document.ToolTip;
89         this.sobj = this.obj;
90       }
91     }
93     this.show = function() {
94       var ext = (document.layers ? '' : 'px');
95       var left = mouseX;
97       if(left + this.width + this.cursorDistance > winX) left -= this.width + this.cursorDistance;
98       else left += this.cursorDistance;
100       this.sobj.left = left + ext;
101       this.sobj.top = mouseY + this.cursorDistance + ext;
103       if(!this.active) {
104         this.sobj.visibility = 'visible';
105         this.active = true;
106       }
107     }
109     this.hide = function() {
110       if(this.sobj) this.sobj.visibility = 'hidden';
111       this.active = false;
112     }
114     this.setOpacity = function() {
115       this.sobj.filter = 'alpha(opacity=' + this.opacity + ')';
116       this.sobj.mozOpacity = '.1';
117       if(this.obj.filters) this.obj.filters.alpha.opacity = this.opacity;
118       if(!document.all && this.sobj.setProperty) this.sobj.setProperty('-moz-opacity', this.opacity / 100, '');
119     }
120   }
122   var tooltip = mouseX = mouseY = winX = 0;
124   if(document.layers) {
125     document.write('<layer id="ToolTip"  class="tooltip" onClick="toolTip()"></layer>');
126     document.captureEvents(Event.MOUSEMOVE);
127   }
128   else document.write('<div id="ToolTip" style="position:absolute; z-index:99" class="tooltip" onClick="toolTip()"></div>');
129   document.onmouseover = getMouseXY;
131   function getMouseStub(e){
132   }
134   function getMouseXY(e) {
135     if(document.all) {
136         mouseX = event.clientX + document.body.scrollLeft;
137         mouseY = event.clientY + document.body.scrollTop;
138     }
139     else {
140       mouseX = e.pageX;
141       mouseY = e.pageY;
142     }
143     if(mouseX < 0) mouseX = 0;
144     if(mouseY < 0) mouseY = 0;
146     if(document.body && document.body.offsetWidth) winX = document.body.offsetWidth - 25;
147     else if(window.innerWidth) winX = window.innerWidth - 25;
148     else winX = screen.width - 25;
150     if(tooltip && tooltip.active) tooltip.show();
151   }
153   function toolTip(text, width, opacity) {
154     if(text) {
155       tooltip = new TOOLTIP();
156       tooltip.text = text;
157       if(width) tooltip.width = width;
158       if(opacity) tooltip.opacity = opacity;
159       tooltip.create();
160     }
161     else if(tooltip) tooltip.hide();