var searchEZConfig 	  = window.location.href.indexOf("ExpereEZConfig") != -1;
var searchEZConfigTest 	  = window.location.href.indexOf("EZConfigTest") != -1;
var searchOPPSA 		= window.location.href.indexOf("OPPSA") != -1;
var searchAudRev 	   = window.location.href.indexOf("AudRevTest") != -1;
var searchOAuth 	   = window.location.href.indexOf("OAuth") != -1;
var searchOut             = window.location.href.indexOf("/out/") != -1;
var searchDDTest        = window.location.href.indexOf("Test/DefaultData") != -1;

if ( searchEZConfig || searchEZConfigTest || searchOPPSA || searchAudRev || searchOAuth || searchOut || searchDDTest) {

    // ================================
    var visited = getCookie('visited');
    var refresh = getCookie('refresh');
    // console.log(visited);
    // console.log(refresh);
    if (visited === '"'){
        // never visited
        setCookie('visit','yes');
    } else {
        // visted before

        if(refresh === "" || refresh ==='no'){
            // Do nothing
            setCookie('refresh','yes');
        }
        if (refresh === 'yes'){
            setCookie('refresh','no');
            window.location.reload(true);
        }
    }
    

    
};

function setCookie(key, value, expiry) {
    var expires = new Date();
    expires.setTime(expires.getTime() + (expiry * 24 * 60 * 60 * 1000));
    document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}

function getCookie(key) {
    var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
    return keyValue ? keyValue[2] : null;
}

function eraseCookie(key) {
    var keyValue = getCookie(key);
    setCookie(key, keyValue, '-1');
}

