easecrypt - various dev files
[anomen-overlay.git] / www-apps / pmwiki / cookbook / AesCrypt / submodal / common.js
blobb1f8178994601ff0a4300911fceae7de8cdf3069
1 /**
2  * COMMON DHTML FUNCTIONS
3  * These are handy functions I use all the time.
4  *
5  * By Seth Banks (webmaster at subimage dot com)
6  * http://www.subimage.com/
7  *
8  * Up to date code can be found at http://www.subimage.com/dhtml/
9  *
10  * This code is free for you to use anywhere, just keep this comment block.
11  */
13 /**
14  * X-browser event handler attachment and detachment
15  * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
16  *
17  * @argument obj - the object to attach event to
18  * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
19  * @argument fn - function to call
20  */
21 function addEvent(obj, evType, fn){
22  if (obj.addEventListener){
23     obj.addEventListener(evType, fn, false);
24     return true;
25  } else if (obj.attachEvent){
26     var r = obj.attachEvent("on"+evType, fn);
27     return r;
28  } else {
29     return false;
30  }
32 function removeEvent(obj, evType, fn, useCapture){
33   if (obj.removeEventListener){
34     obj.removeEventListener(evType, fn, useCapture);
35     return true;
36   } else if (obj.detachEvent){
37     var r = obj.detachEvent("on"+evType, fn);
38     return r;
39   } else {
40     alert("Handler could not be removed");
41   }
44 /**
45  * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
46  *
47  * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
48  *
49  * Gets the full width/height because it's different for most browsers.
50  */
51 function getViewportHeight() {
52         if (window.innerHeight!=window.undefined) return window.innerHeight;
53         if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
54         if (document.body) return document.body.clientHeight; 
56         return window.undefined; 
58 function getViewportWidth() {
59         var offset = 17;
60         var width = null;
61         if (window.innerWidth!=window.undefined) return window.innerWidth; 
62         if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
63         if (document.body) return document.body.clientWidth; 
66 /**
67  * Gets the real scroll top
68  */
69 function getScrollTop() {
70         if (self.pageYOffset) // all except Explorer
71         {
72                 return self.pageYOffset;
73         }
74         else if (document.documentElement && document.documentElement.scrollTop)
75                 // Explorer 6 Strict
76         {
77                 return document.documentElement.scrollTop;
78         }
79         else if (document.body) // all other Explorers
80         {
81                 return document.body.scrollTop;
82         }
84 function getScrollLeft() {
85         if (self.pageXOffset) // all except Explorer
86         {
87                 return self.pageXOffset;
88         }
89         else if (document.documentElement && document.documentElement.scrollLeft)
90                 // Explorer 6 Strict
91         {
92                 return document.documentElement.scrollLeft;
93         }
94         else if (document.body) // all other Explorers
95         {
96                 return document.body.scrollLeft;
97         }