1    // Cookie handling
2    var Cookie =
3    {
4        read: function (name)
5        {
6      		  // Work around for Firefox when 'HTTP only' cookies are in use
7            if (typeof(document.cookie) != "string" && navigator.product == "Gecko") delete HTMLDocument.prototype.cookie;
8
9            var arrCookies = document.cookie.split ('; ');
10            for (var i=0; i<arrCookies.length; i++)
11            {
12                var arrCookie = arrCookies[i].split ('=');
13
14                if (arrCookie[0] == name)
15                {
16                    return decodeURIComponent (arrCookie[1]);
17                }
18            }
19            return false;
20        },
21
22        write: function (name, value, expires, path)
23        {
24      		  // Work around for Firefox when 'HTTP only' cookies are in use
25            if (typeof(document.cookie) != "string" && navigator.product == "Gecko") delete HTMLDocument.prototype.cookie;
26
27            if (expires)
28            {
29                var date = new Date ();
30                date.setTime (date.getTime () + (((((expires * 24) * 60) * 60) * 1000)));
31                expires = '; expires=' + date.toGMTString ();
32            }
33            else expires = '';
34
35            if (!path) path = '/';
36
37            document.cookie = name+'='+encodeURIComponent (value)+expires+'; path='+path;
38        },
39
40        remove: function (name)
41        {
42            this.write (name, '', -1);
43        }
44    }
45
46    // Detects if can set a cookie in the browser
47    function browserSupportsCookies()
48    {
49        Cookie.write('cookiesEnabled', 1);
50        var boolCookiesEnabled = Cookie.read('cookiesEnabled');
51        Cookie.remove('cookiesEnabled');
52        if (boolCookiesEnabled != 1)
53        {
54            return false;
55        }
56        return true;
57    }
58
59    // Detects if the browser supports Ajax
60    function browserSupportsAjax()
61    {
62        if (typeof XMLHttpRequest == "undefined" && typeof ActiveXObject == "undefined" && window.createRequest == "undefined")
63        {
64            return false;
65        }
66        return true
67    }
68
69    // Detects if the browser can use ActiveX if necessary
70    function ActiveXEnabledOrUnnecessary ()
71    {
72        if (typeof ActiveXObject != "undefined")
73        {
74            var xhr = null;
75            try{
76                xhr=new ActiveXObject("Msxml2.XMLHTTP");
77            }catch (e){
78                try{
79                    xhr=new ActiveXObject("Microsoft.XMLHTTP");
80                }catch (e2){
81                    try{
82                        xhr=new ActiveXObject("Msxml2.XMLHTTP.4.0");
83                    }catch (e3){
84                        xhr=null;
85                    }
86                }
87            }
88            if (xhr == null)
89            {
90                return false
91            }
92        }
93
94        return true;
95    }