MSIE = (navigator.appName.indexOf('Microsoft Internet Explorer') != -1);
Opera = (navigator.userAgent.indexOf('Opera') != -1);
Nav = ((navigator.appName.indexOf('Netscape') != -1) && (!Opera));
Nav4 = (document.layers);
Firefox = (navigator.userAgent.indexOf("Firefox") != -1);
Safari = (navigator.userAgent.indexOf("Safari") != -1);
MSIE4 = (document.all);
Win = (navigator.userAgent.indexOf("Win") != -1);
Mac = (navigator.userAgent.indexOf("mac") != -1) || (navigator.userAgent.indexOf("Mac") != -1);
OS2 = (navigator.userAgent.indexOf("os/2") != -1) || (navigator.userAgent.indexOf("OS/2") != -1);
Linux = (navigator.userAgent.indexOf("inux") != -1);
Other = (!Win && !Mac && !OS2 && !Linux);
version = parseFloat(navigator.appVersion);

Windows311 = (navigator.userAgent.indexOf("Win16") != -1);
Windows95 = (navigator.userAgent.indexOf("Windows 95") != -1) || (navigator.userAgent.indexOf("Win95") != -1) || (navigator.userAgent.indexOf("Windows_95") != -1);
Windows98 = (navigator.userAgent.indexOf("Windows 98") != -1) || (navigator.userAgent.indexOf("Win98") != -1);
Windows2000 = (navigator.userAgent.indexOf("Windows NT 5.0") != -1) || (navigator.userAgent.indexOf("Windows 2000") != -1);
WindowsXP = (navigator.userAgent.indexOf("Windows NT 5.1") != -1) || (navigator.userAgent.indexOf("Windows XP") != -1);
WindowsServer2003 = (navigator.userAgent.indexOf("Windows NT 5.2") != -1);
WindowsVista = (navigator.userAgent.indexOf("Windows NT 6.0") != -1);
Windows7 = (navigator.userAgent.indexOf("Windows NT 7.0") != -1);
WindowsNT4 = (navigator.userAgent.indexOf("Windows NT 4.0") != -1) || (navigator.userAgent.indexOf("WinNT4.0") != -1);
WindowsME = (navigator.userAgent.indexOf("Windows ME") != -1);
OpenBSD = (navigator.userAgent.indexOf("OpenBSD") != -1);
SunOS = (navigator.userAgent.indexOf("SunOS") != -1);
Linux = (navigator.userAgent.indexOf("Linux") != -1) || (navigator.userAgent.indexOf("X11") != -1);
MacOS = (navigator.userAgent.indexOf("Mac_PowerPC") != -1) || (navigator.userAgent.indexOf("Macintosh") != -1);
QNX = (navigator.userAgent.indexOf("QNX") != -1);
BeOS = (navigator.userAgent.indexOf("BeOS") != -1);
OS2 = (navigator.userAgent.indexOf("OS/2") != -1);
SearchBot = (navigator.userAgent.indexOf("nuhk") != -1) || (navigator.userAgent.indexOf("Googlebot") != -1) || (navigator.userAgent.indexOf("Yammybot") != -1) || (navigator.userAgent.indexOf("Openbot") != -1) || (navigator.userAgent.indexOf("Slurp") != -1) || (navigator.userAgent.indexOf("MSNBot") != -1) || (navigator.userAgent.indexOf("Ask Jeeves/Teoma") != -1) || (navigator.userAgent.indexOf("ia_archiver") != -1); 



if (navigator.userAgent.indexOf("Safari") != -1) {
    var versionindex = navigator.userAgent.indexOf("Version") + 8;
    var versionendindex = navigator.userAgent.indexOf("Safari");
    version = parseFloat(navigator.userAgent.substring(versionindex, versionendindex));
}
if (navigator.userAgent.indexOf("Firefox") != -1) {
    var versionindex = navigator.userAgent.indexOf("Firefox") + 8;
    version = parseFloat(navigator.userAgent.substring(versionindex, navigator.userAgent.length));
}

////if (navigator.userAgent.indexOf('Opera')!=-1) {
////    var versionindex=navigator.userAgent.indexOf("Opera")+6;
////    var versionendindex=navigator.userAgent.indexOf("(");
////    version = navigator.userAgent.substring(versionindex,versionendindex);
////}
width = screen.width;
height = screen.height;
colors = screen.colorDepth;
colorpix = screen.pixelDepth;
RealP = 0;
MediaP = 0;
CookieT = 0;
Proxy = 0;
fHasWMP52 = navigator.mimeTypes && navigator.mimeTypes["application/x-mplayer2"] && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;
fHasWMP64 = navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin && navigator.mimeTypes["video/x-ms-wmv"] && navigator.mimeTypes["video/x-ms-wmv"].enabledPlugin;
RealMode = 0;
RealPlayer5 = 0;
RealPlayer4 = 0;
RealPlayerG2 = 0;
today = new Date();
expiry = new Date(today.getTime() + 60000); // plus 1 minute

//loop through Netscape plugin directory for one called Real Player
if (navigator.userAgent.indexOf("MSIE") < 0) {
    numPlugins = navigator.plugins.length;
    for (i = 0; i < numPlugins; i++) {
        plugin = navigator.plugins[i];
        if (plugin.name.substring(0, 10) == "RealPlayer") {
            RealMode = 1;
        }
    }
}

document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('<!-- \n');
document.write('on error resume next \n');
document.write('RealPlayerG2 = (NOT IsNull(CreateObject("rmocx.RealPlayer G2 Control")))\n');
document.write('RealPlayer5 = (NOT IsNull(CreateObject("RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)")))\n');
document.write('RealPlayer4 = (NOT IsNull(CreateObject("RealVideo.RealVideo(tm) ActiveX Control (32-bit)")))\n');
document.write('//--> \n');
document.write('</SCRIPT\> \n');
document.write('<OBJECT ID="NSPlay" WIDTH=0 HEIGHT=0 classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" \n');
document.write(' CODEBASE="#Version=6,4,5,715"> \n');
document.write('</OBJECT> \n');
document.write('<SCRIPT LANGUAGE=VBScript\> \n');
document.write('<!-- \n');
document.write('on error resume next \n');
document.write('fHasWMP52 = (IsObject(CreateObject("MediaPlayer.MediaPlayer.1") ) )\n');
document.write('fHasWMP64 = (NSPlay.FileName="")\n');
document.write('//--> \n');
document.write('</SCRIPT\> \n');

/*MSIE5*/
if (MSIE4) {
    x = navigator.userAgent.lastIndexOf("MSIE");
    version = parseFloat(navigator.userAgent.substring(x + 5, x + 10));
}
/*Opera*/
if ((Opera) && (navigator.userAgent.lastIndexOf(") ") != -1)) {
    x = navigator.userAgent.lastIndexOf(") ");
    version = parseFloat(navigator.userAgent.substring(x + 2, x + 10));
}
if ((Opera) && (version == 0)) {
    x = navigator.userAgent.lastIndexOf("Opera");
    version = parseFloat(navigator.userAgent.substring(x + 6, x + 12));
}
/*MSIE3*/
if ((MSIE) && (version == 2)) {
    version = 3.0;
}
if (Nav) {
    CSS = Nav4;
    goodCSS = (version > 4.99);
    CSSP = CSS;
}
if (MSIE) {
    CSS = (version > 2.99);
    goodCSS = (version > 3.99);
    CSSP = goodCSS;
}
if (Opera) {
    CSS = (version > 3.49);
    goodCSS = CSS;
    CSSP = (version > 3.99);
}
getMediaPlayerDetails();
getRealPlayerDetails();
testCookie();

function getMediaPlayerDetails() {
    if (fHasWMP64) MediaP = "version 6.4 or higher.";
    else if (fHasWMP52) MediaP = "version 5.2 or higher.";
    else MediaP = "not installed.";
}
function getRealPlayerDetails() {
    if (RealPlayerG2) RealP = "version G2 or higher.";
    else if (RealPlayer5) RealP = "version 5.";
    else if (RealPlayer4) RealP = "version 4.";
    else if (RealMode) RealP = "installed.";
    else RealP = "not installed.";
}
function testCookie() {
    setCookie("canIcookies", "Cookies are enabled.");
    CookieT = getCookie("canIcookies") || "Please enable cookies.";
}

function getCookie(name) {
    // use: getCookie("name");
    var index = document.cookie.indexOf(name + "=");
    if (index == -1) return null;
    index = document.cookie.indexOf("=", index) + 1;
    var endstr = document.cookie.indexOf(";", index);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(index, endstr));
}

function setCookie(name, value) {
    // use: setCookie("name", value);
    if (value != null && value != "") {
        document.cookie = name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
    }
}
