//setCookie('en')
function setCookie(lang) {
        var now = new Date();
        var expire = new Date(now.getTime() + 1000*60*60*24*365);
        var expireGMT = expire.toGMTString();
        document.cookie = "lang=" + lang + "; path=/; domain=signagate.de; expires=" + expireGMT;
}

//getCookie('lang')

function getCookie(cookieName) {
        var theCookie=""+document.cookie;
        var ind=theCookie.indexOf(cookieName);
        if (ind==-1 || cookieName=="") return "";
        var ind1=theCookie.indexOf(';',ind);
        if (ind1==-1) ind1=theCookie.length;
        return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function CheckLanguage() {
        var curLang = getCookie('lang');
        if (curLang == null) {
                //first visit or NO cookies...
                setCookie('de');
        }
        else
        {
                switch(curLang) {
                        case "de":      if (window.location.pathname != "/index.html")
                                        {
                                                window.location = "/index.html";
                                        }
                                        break;
                        case "en":      if (window.location.pathname != "/en/index.html")
                                        {
                                                window.location = "/en/index.html";
                                        }
                                        break;
                }
        }
}

function ChangeLanguage(lang) {
        setCookie(lang);
        switch(lang) {
                case "de":      if (window.location != "/index.html")
                                window.location = "/index.html";
                                break;
                case "en":      if (window.location != "/en/index.html")
                                window.location = "/en/index.html";
                                break;
        }
}

