/* Copyright © 1998, 2012, Oracle and/or its affiliates.  All rights reserved. */
/* Version 11.1.0.0 */

//* <XBuild version="11.1.0-release,trace,browser.all,playback,hint-1"/>
//* <BaseDir path="E:/BUILDROOT_SUN/Builds/Branches/Hacienda/tfs/TargetApps/BrowserAppsBuild/Build/Source/Applications/"/>
//* <FileRef type="source" path="stdhemi/scripts/iasoptions.js" time="2012-01-13T11:50:31"/>
//* <FileRef type="reference" path="../Include/Gateway/GatewayCookie.js" time="2012-01-13T11:50:41"/>
//* <FileRef type="reference" path="../Include/Tools/Cookie.js" time="2012-01-13T11:50:46"/>


//* <FileBegin path="stdhemi/scripts/iasoptions.js"/>
//x /// <reference path="../../../Include/Gateway/GatewayCookie.js"/>

//* <FileBegin path="../Include/Gateway/GatewayCookie.js"/>
//x /// <reference path="../Tools/Cookie.js"/>

//* <FileBegin path="../Include/Tools/Cookie.js"/>

var _Cookie = { // ../Include/Tools/Cookie.js: 2
    Create: function(name, evalue, keepDays, path, domain, secure) { // ../Include/Tools/Cookie.js: 3
        var ename = encodeURIComponent(name); // ../Include/Tools/Cookie.js: 4
        var cookie = ename + '=' + evalue; // ../Include/Tools/Cookie.js: 5
        if (keepDays >= -1) { // ../Include/Tools/Cookie.js: 6
            var time = new Date().getTime(); // ../Include/Tools/Cookie.js: 7
            var millisecondsSinceMidnight = time % 86400000; // ../Include/Tools/Cookie.js: 8
            var expires = new Date(time - millisecondsSinceMidnight + 86400000 * (keepDays + 1)); // ../Include/Tools/Cookie.js: 9
            cookie += "; expires=" + expires.toGMTString(); // ../Include/Tools/Cookie.js: 10
        } // ../Include/Tools/Cookie.js: 11
        if (path) // ../Include/Tools/Cookie.js: 12
            cookie += "; path=" + path; // ../Include/Tools/Cookie.js: 13
        if (domain) // ../Include/Tools/Cookie.js: 14
            cookie += "; domain=" + domain; // ../Include/Tools/Cookie.js: 15
        if (secure) // ../Include/Tools/Cookie.js: 16
            cookie += "; secure"; // ../Include/Tools/Cookie.js: 17
        return cookie; // ../Include/Tools/Cookie.js: 18
    }, // ../Include/Tools/Cookie.js: 19
    TryGet: function(cookie, name) { // ../Include/Tools/Cookie.js: 20
        var ename = encodeURIComponent(name); // ../Include/Tools/Cookie.js: 21
        var nameValueList = cookie.split('; '); // ../Include/Tools/Cookie.js: 22
        for (var i = 0, n = nameValueList.length; i < n; ++i) { // ../Include/Tools/Cookie.js: 23
            var nameValue = nameValueList[i]; // ../Include/Tools/Cookie.js: 24
            if (nameValue == ename) // ../Include/Tools/Cookie.js: 25
                return ''; // ../Include/Tools/Cookie.js: 26
            var eqPos = nameValue.indexOf('='); // ../Include/Tools/Cookie.js: 27
            if ((eqPos > 0) && (eqPos == ename.length) && (nameValue.substr(0, eqPos) == ename)) // ../Include/Tools/Cookie.js: 28
                return nameValue.substr(eqPos + 1); // ../Include/Tools/Cookie.js: 29
        } // ../Include/Tools/Cookie.js: 30
        return null; // ../Include/Tools/Cookie.js: 31
    }, // ../Include/Tools/Cookie.js: 32
    EncodeHash: function(hash) { // ../Include/Tools/Cookie.js: 33
        if (!hash) // ../Include/Tools/Cookie.js: 34
            return ''; // ../Include/Tools/Cookie.js: 35
        var tokens = []; // ../Include/Tools/Cookie.js: 36
        for (var key in hash) // ../Include/Tools/Cookie.js: 37
            tokens.push(encodeURIComponent(key) + ':' + encodeURIComponent(hash[key])); // ../Include/Tools/Cookie.js: 38
        return tokens.join('&'); // ../Include/Tools/Cookie.js: 39
    }, // ../Include/Tools/Cookie.js: 40
    DecodeHash: function(value) { // ../Include/Tools/Cookie.js: 41
        var hash = {}; // ../Include/Tools/Cookie.js: 42
        if (value) { // ../Include/Tools/Cookie.js: 43
            var tokens = value.split('&'); // ../Include/Tools/Cookie.js: 44
            for (var i = 0, n = tokens.length; i < n; ++i) { // ../Include/Tools/Cookie.js: 45
                var keyValue = tokens[i].split(':'); // ../Include/Tools/Cookie.js: 46
                hash[decodeURIComponent(keyValue[0])] = ((keyValue.length == 2) ? decodeURIComponent(keyValue[1]) : ''); // ../Include/Tools/Cookie.js: 47
            } // ../Include/Tools/Cookie.js: 48
        } // ../Include/Tools/Cookie.js: 49
        return hash; // ../Include/Tools/Cookie.js: 50
    } // ../Include/Tools/Cookie.js: 51
}; // ../Include/Tools/Cookie.js: 52

/** @constructor */ // ../Include/Tools/Cookie.js: 54
var Cookie = { // ../Include/Tools/Cookie.js: 55
    CreateFromValue: function(name, value, keepDays, path, domain, secure) { // ../Include/Tools/Cookie.js: 56
        return _Cookie.Create(name, encodeURIComponent(value), keepDays, path, domain, secure); // ../Include/Tools/Cookie.js: 57
    }, // ../Include/Tools/Cookie.js: 58
    CreateFromHash: function(name, hash, keepDays, path, domain, secure) { // ../Include/Tools/Cookie.js: 59
        return _Cookie.Create(name, _Cookie.EncodeHash(hash), keepDays, path, domain, secure); // ../Include/Tools/Cookie.js: 60
    }, // ../Include/Tools/Cookie.js: 61
    CreateExpired: function(name, path, domain) { // ../Include/Tools/Cookie.js: 62
        return _Cookie.Create(name, '', -1, path, domain); // ../Include/Tools/Cookie.js: 63
    }, // ../Include/Tools/Cookie.js: 64
    TryGetValue: function(cookie, name, defaultValue) { // ../Include/Tools/Cookie.js: 65
        var evalue = _Cookie.TryGet(cookie, name); // ../Include/Tools/Cookie.js: 66
        if (evalue == null) // ../Include/Tools/Cookie.js: 67
            return defaultValue; // ../Include/Tools/Cookie.js: 68
        return encodeURIComponent(evalue); // ../Include/Tools/Cookie.js: 69
    }, // ../Include/Tools/Cookie.js: 70
    TryGetHash: function(cookie, name, defaultValue) { // ../Include/Tools/Cookie.js: 71
        var evalue = _Cookie.TryGet(cookie, name); // ../Include/Tools/Cookie.js: 72
        if (evalue == null) // ../Include/Tools/Cookie.js: 73
            return defaultValue; // ../Include/Tools/Cookie.js: 74
        return _Cookie.DecodeHash(evalue); // ../Include/Tools/Cookie.js: 75
    } // ../Include/Tools/Cookie.js: 76
} // ../Include/Tools/Cookie.js: 77

//* <FileEnd path="../Include/Tools/Cookie.js"/>


var GatewayCookie = { // ../Include/Gateway/GatewayCookie.js: 3
    Set: function(_cookie, _property, _value) { // ../Include/Gateway/GatewayCookie.js: 4
        var hash = Cookie.TryGetHash(document.cookie, _cookie, {}); // ../Include/Gateway/GatewayCookie.js: 5
        hash[_property] = _value; // ../Include/Gateway/GatewayCookie.js: 6
        document.cookie = Cookie.CreateFromHash(_cookie, hash, 365, '/'); // ../Include/Gateway/GatewayCookie.js: 7
    }, // ../Include/Gateway/GatewayCookie.js: 8

    Get: function(_cookie, _property) { // ../Include/Gateway/GatewayCookie.js: 10
        var hash = Cookie.TryGetHash(document.cookie, _cookie, {}); // ../Include/Gateway/GatewayCookie.js: 11
        return hash[_property]; // ../Include/Gateway/GatewayCookie.js: 12
    }, // ../Include/Gateway/GatewayCookie.js: 13

    GetAll: function(_cookie) { // ../Include/Gateway/GatewayCookie.js: 15
        return Cookie.TryGetHash(document.cookie, _cookie, {}); // ../Include/Gateway/GatewayCookie.js: 16
    } // ../Include/Gateway/GatewayCookie.js: 17
}; // ../Include/Gateway/GatewayCookie.js: 18

//* <FileEnd path="../Include/Gateway/GatewayCookie.js"/>


    function Update() // stdhemi/scripts/iasoptions.js: 3
    { // stdhemi/scripts/iasoptions.js: 4
        var en = navigator.cookieEnabled; // stdhemi/scripts/iasoptions.js: 5
        if (!en) // stdhemi/scripts/iasoptions.js: 6
        { // stdhemi/scripts/iasoptions.js: 7
            document.getElementById('set').setAttribute('style', 'display:none'); // stdhemi/scripts/iasoptions.js: 8
            document.getElementById('error').innerHTML = 'To use this feature, cookies must be enabled!'; // stdhemi/scripts/iasoptions.js: 9
        } // stdhemi/scripts/iasoptions.js: 10
        else // stdhemi/scripts/iasoptions.js: 11
        { // stdhemi/scripts/iasoptions.js: 12
            var value = GatewayCookie.Get('HemiCookie', 'hemiparamtest'); // stdhemi/scripts/iasoptions.js: 13
            if (value == 'undefined') // stdhemi/scripts/iasoptions.js: 14
                value = '0'; // stdhemi/scripts/iasoptions.js: 15
            document.getElementById('hp').innerHTML = parseInt(value) ? "true" : "false"; // stdhemi/scripts/iasoptions.js: 16
        } // stdhemi/scripts/iasoptions.js: 17
    } // stdhemi/scripts/iasoptions.js: 18
    
    function HemiTest(value) // stdhemi/scripts/iasoptions.js: 20
    { // stdhemi/scripts/iasoptions.js: 21
        GatewayCookie.Set('HemiCookie', 'hemiparamtest', value.toString()); // stdhemi/scripts/iasoptions.js: 22
        document.getElementById('hp').innerHTML = value ? "true" : "false"; // stdhemi/scripts/iasoptions.js: 23
    } // stdhemi/scripts/iasoptions.js: 24


//* <FileEnd path="stdhemi/scripts/iasoptions.js"/>
