/*  JavaScript for Microsoft NZ IE6 Upgrade Message
*  Kris McGlashan
*  081030 - v1.0
*/
function ie6CloseMessage() {
    ie6CreateCookie('iedetect', 'shown', 1);
    document.getElementById('detectie6').style.display = "none";
}

function ie6CreateCookie(name, value, days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
    }
    else expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function ie6ReadCookie(name) {
    var ca = document.cookie.split(';');
    var nameEQ = name + "=";
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length); //delete spaces
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function ie6EraseCookie(name) {
    createCookie(name, "quit", -1);
}

function triggerIe6() {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { 								//if it's IE
        var ieversion = new Number(RegExp.$1)
        if (ieversion < 7) {															//and less than version 7
            if (navigator.cookieEnabled == true) {									//with cookies enabled
                var ie6cookie = ie6ReadCookie('iedetect');
                if (ie6cookie != "shown") {											//and the message hasn't been shown today
                    document.getElementById('detectie6').style.display = "inline"; //then... show the message
                }
            }
        }
    }
}