removed temporary test file
[xynt.git] / commons.js
1   function $(id) { return document.getElementById(id); }
2
3   /* replacement of setInterval on IE */
4 (function(){
5     /*if not IE, do nothing*/
6     if(!document.uniqueID){return;};
7
8     /*Copy the default setInterval behavior*/
9     var nativeSetInterval = window.setInterval;
10     window.setInterval = function(fn,ms) {              
11         var param = [];
12         if(arguments.length <= 2)       {
13             return nativeSetInterval(fn,ms);
14         }
15         else {
16             for(var i=2;i<arguments.length;i+=1) {
17                 param[i-2] =  arguments[i];
18             }   
19         }
20         
21         if(typeof(fn)=='function') {
22             
23             return (function (fn,ms,param) {
24                 var fo = function () {                                                          
25                     fn.apply(window,param);
26                 };                      
27                 return nativeSetInterval(fo,ms); 
28             })(fn,ms,param);
29         }
30         else if(typeof(fn)=='string')
31         {
32             return  nativeSetInterval(fn,ms);
33         }
34         else
35         {
36             throw Error('setInterval Error\nInvalid function type');
37         };
38     };
39
40     /*Copy the default setTimeout behavior*/
41     var nativeSetTimeout = window.setTimeout;
42     window.setTimeout = function(fn,ms) {               
43         var param = [];
44         if(arguments.length <= 2)       {
45             return nativeSetTimeout(fn,ms);
46         }
47         else {
48             for(var i=2;i<arguments.length;i+=1) {
49                 param[i-2] =  arguments[i];
50             }   
51         }
52         
53         if(typeof(fn)=='function') {
54             
55             return (function (fn,ms,param) {
56                 var fo = function () {                                                          
57                     fn.apply(window,param);
58                 };                      
59                 return nativeSetTimeout(fo,ms); 
60             })(fn,ms,param);
61         }
62         else if(typeof(fn)=='string')
63         {
64             return  nativeSetTimeout(fn,ms);
65         }
66         else
67         {
68             throw Error('setTimeout Error\nInvalid function type');
69         };
70     };
71
72 })()
73
74 function getStyle(x,IEstyleProp, MozStyleProp) 
75 {
76     if (x.currentStyle) {
77         var y = x.currentStyle[IEstyleProp];
78     } else if (window.getComputedStyle) {
79         var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
80     }
81     return y;
82 }
83
84 function doSomething(e) {
85         if (!e) var e = window.event
86         // handle event
87         e.cancelBubble = true;
88         if (e.stopPropagation) e.stopPropagation();
89 }