/**
 * Redirect visitors to biomimicry.net if it's their first time
 * visiting the site.
 */
var CookieRedirect = {
    config: {
        cookie: 'b38_redirect',
        dest: 'http://biomimicry.net',
        exp: new Date(new Date().valueOf() + Math.pow(10, 9)).toUTCString()
    },

    hasCookie: function () {
        return document.cookie.indexOf(this.config.cookie) !== -1;
    },

    setCookie: function () {
        document.cookie = this.config.cookie + '=true; expires=' + this.config.exp;
    },

    redirect: function () {
        if (this.hasCookie() || document.referrer.match(this.config.dest)) {
            return false;
        }
        this.setCookie();
        window.location = this.config.dest;
    }
};

CookieRedirect.redirect();


