// Reload the current page without the browser cache

var ua = window.navigator.userAgent;
var browser=get_browser();
var ver = parseInt(browser.version);
//console.log('browser is ' + browser.name);
//console.log('version is ' + ver);


if (browser.name == "MSIE" && ver > 9 || browser.name == "Chrome"){
    // console.log('reloading...');
    // Create the notification
    // Read the cookie to see if this site was already reloaded
    var x = getCookie('reloaded');
    // If the page has already been reloaded, remove the cookie
    if (x) {
        // console.log('already reloaded');
        eraseCookie('reloaded');
    }
    else{
        // If the page has not bee reloaded, set the cookie to 'yes' and reload
        setCookie('reloaded','yes');
        window.location.reload(true);
    }

}else{
    //console.log('not reloading - browser is too old');
}




function get_browser() {
    var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; 
    if(/trident/i.test(M[1])){
        tem=/\brv[ :]+(\d+)/g.exec(ua) || []; 
        return {name:'IE',version:(tem[1]||'')};
        }   
    if(M[1]==='Chrome'){
        tem=ua.match(/\bOPR|Edge\/(\d+)/)
        if(tem!=null)   {return {name:'Opera', version:tem[1]};}
        }   
    M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
    if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);}
    return {
      name: M[0],
      version: M[1]
    };
 }




function setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name) {   
    document.cookie = name+'=; Max-Age=-99999999;';  
}