﻿$(document).ready(function() {
    EnableTimeout();
});
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}
function open_win() {
    window.open("http://www.microsoft.com/download/en/details.aspx?id=43");
}

function EnableTimeout() {
    var _body = document.getElementsByTagName('body')[0];
    var _div = document.getElementById('IEControl');
   
    var browserName = navigator.appName;
    var ShowrHide = false;
    if (browserName != "Microsoft Internet Explorer") {
        //_div.innerHTML = "<div style='width:96%;'>You are not using Internet Explorer.Connect4M is best viewed in Internet Explorer 8. Please upgrade to <a Class='aIE' onclick='open_win();' href='#'>IE8</a></div><div style='width:3%;'><a id='Hide' onclick='HideMsg();' href='#'>X</a></div>";
        _div.innerHTML = "<div style='text-align:center;'> <a Class='aIE' onclick='open_win();' href='#'>Connect4M is best viewed with IE 8 & above.</a></div>";
    }
    else {
        var _ver = getInternetExplorerVersion();
        if (_ver > -1) {
            if (_ver < 8.0) {
                               //_div.innerHTML = "<div style='text-align:center;'><b>Connect4M</b> is best viewed in Internet Explorer 8. You are using Internet Explorer Version " + _ver + ". Please upgrade to <a Class='aIE' onclick='open_win();' href='#'>Internet Explorer 8</a></div>";
               _div.innerHTML = "<div style='text-align:center;'> <a Class='aIE' onclick='open_win();' href='#'>Connect4M is best viewed with IE 8 & above.</a></div>";
            }
            else {
                ShowrHide = true;
            }
        }
        else {
            //_div.innerHTML = "<b>Connect4M</b> is best viewed in Internet Explorer 8. Please upgrade to <a Class='aIE' href='#'>IE8</a><a id='Hide' onclick='HideMsg();' href='#'>X</a>";
            ShowrHide = true;
        }

    }
    if (!ShowrHide) {
//        if (document.body.firstChild) {
//            document.body.insertBefore(_div, document.body.firstChild);
//        }
//        else {
//            document.body.appendChild(_div);
//        }
//        $("#idletimeout").slideDown(600, function() {
//            setTimeout("$('#idletimeout').slideUp();", 100000)
//        });
        document.getElementById("IEControl").style.display="block";
    }
}
function HideMsg() {
    $("#IEControl").slideUp("fast");
}
