(function(){
    var version_no = 0;
    var tempArr;
    var clientArr;
    var type_no = 0;
    var oldUrl = "";
    // if the client cookie is there:
    if (document.cookie.indexOf("client") != -1) {
        var cooArr = document.cookie.split("; ");
        for (z = 0; z < cooArr.length; z++) {
            if (cooArr[z].indexOf("client") != -1) {
                tempArr = cooArr[z].split("=");
                clientArr = tempArr[1].split("|");
            }
        }
        version_no = clientArr[0];
        type_no    = clientArr[4];
    }
    
    var adult_warning = "This glossary is for adults only!\n\n\
You must be 18 years old to register to it, since it contains sexually explicit material.\n\
By choosing to download or subscribe to this glossary you are aware that you will be nviewing material of a sexual nature.\n\n\
I am voluntarily choosing to register to this glossary, because I want to view,\n\
read and/or hear the various materials, which are available.\n\n\
I will not permit any person(s) under 18 years of age to have access to any of the\n\
materials contained within this glossary.\n\n\
I do not find images of nude adults, adults engaged in sexual acts, or other sexual\n\
material to be offensive or objectionable."; 
    
    window.downloadPop = function(newUrl, oldtUrl, isNewDict, uri, adult) {
    
        if (adult && !confirm(adult_warning)) { return; }
        
        if ((parseInt(version_no) >= 7000) || (parseInt(type_no) == 5) || (parseInt(type_no) == 10) || (parseInt(type_no) == 9)) {
            document.location = newUrl;
            return;
        } else {
            document.cookie= "Uri="+uri+"; expires=Fri, 1 Jan 2100 20:47:11 UTC; path=/";
            document.location = 'http://www.babylon.com/redirects/download.cgi?type=7094';
        }
        // if version is less than 3238 (or no cookie exsists) and glossary is a BGL one
        // open the build_pop.html popup:
        var old_and_new = newUrl + oldUrl;

        // default is download:
        document.location = newUrl;
    };
    
})();