﻿function GetFlashEnabled() {
var plugin = 0;
if (window.ActiveXObject) {
    try {
        var control = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
    }
    catch (e) {
        control = null;
    }
    if (control)
    {
        plugin = 1;
        control = null;
    }
}
else
{
    plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
}
if ( plugin ) {
return "true";
} else {
 return "false";
}
}
function GetScreenWidth() {
if (typeof(screen)=='object') {
 return screen.width;
}
}
function GetScreenHeight() {
if (typeof(screen)=='object') {
 return screen.height;
}
}
function GetColorDepth() {
if (typeof(screen)=='object') {
 return screen.colorDepth;
}
}

function GetSilverlightVersion() {
    var version = '';
    var container = null;
    try {
        var control = null;
        if (window.ActiveXObject) {
            try {
                control = new ActiveXObject('AgControl.AgControl');
            }
            catch (e) {
                control = null;
            }
        }
        else {
            if (navigator.plugins['Silverlight Plug-In']) {
                container = document.createElement('div');
                document.body.appendChild(container);
                container.innerHTML= '<embed type="application/x-silverlight" src="data:," />';
                control = container.childNodes[0];
            }
        }
        if (control) {
            if (control.isVersionSupported('3.0')) { version = '3.0'; }
            else if (control.isVersionSupported('2.0')) { version = '2.0'; }
            else if (control.isVersionSupported('1.0')) { version = '1.0'; }
        }
    }
    catch (e) { version=e; }
    if (container) {
        document.body.removeChild(container);
    }
    return version;
}

function SetCookie (name, value) {var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + " = " + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function SetCaps()
{

var colorDepth = GetColorDepth();
var sWidth = GetScreenWidth();
var sHeight = GetScreenHeight();
var flashEnabled = GetFlashEnabled();
var silverlightVersion = GetSilverlightVersion();

SetCookie("colorDepth", colorDepth, null, "/" );
SetCookie("screenWidth", sWidth, null, "/" );
SetCookie("screenHeight", sHeight, null, "/" );
SetCookie("flashEnabled", flashEnabled, null, "/" );
SetCookie("silverlightVersion", silverlightVersion, null, "/" );
}