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