function emailMe() {
    var pre = "mailto:";
    var first = "wilvoss";
    var at = "@";
    var last = "me.com";
    document.location.href = pre + first + at + last;
};
function hide() {
    var lightBox = document.getElementById('lightBox');
    var linkBox = document.getElementById('linkBox');
    lightBox.innerHTML = "";
    linkBox.innerHTML = "";
    lightBox.style.display = "none";
    linkBox.style.display = "none";
};

function loadPage() {
    swapHero();
    applyContrast();
    var article = document.getElementsByTagName("article")[0];
    article.style.opacity = 1;
    var aside = document.getElementsByTagName("aside")[0];
    if (aside != null) {
	    aside.style.opacity = 1;
    }
}
function toggleContrastCookie() {
    var hasContrast = getContrastCookie();
    hasContrast = hasContrast != 'true' ? true: false;
    var expires = new Date("January 1, 2020");
    var cookieString = "ContrastMode=" + hasContrast + "; Expires=" + expires.toUTCString();
    document.cookie = cookieString;
    applyContrast();
};
function applyContrast() {
    var hasContrast = getContrastCookie();
    if (hasContrast == 'true') {
        var fileref = document.createElement("link");
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        fileref.setAttribute("href", "assets/accessibility.css");
        fileref.id = "accessibility";
        document.getElementsByTagName("head")[0].appendChild(fileref);
    } else if (document.getElementById('accessibility') != null) {
        document.getElementsByTagName("head")[0].removeChild(document.getElementById('accessibility'));
    }
};
function getContrastCookie() {
    var results = document.cookie.match('(^|;) ?ContrastMode=([^;]*)(;|$)');
    if (results) {
        return (unescape(results[2]));
    } else {
        return false;
    }

};
function swapHero()
 {
    var images = new Array("images/hero1.png", "images/hero2.png", "images/hero3.png", "images/hero4.png", "images/hero5.png");
    var imagesPositions = new Array("left", "right", "left", "left", "right");
    var homeHero = document.getElementById("homeHero");
    if (homeHero != null) {
        var randNum = Math.floor(Math.random() * images.length);
        var backgroundImage = "url(" + images[randNum] + ")";
        homeHero.style.background = backgroundImage + "top " + imagesPositions[randNum];

    }

};

if (navigator.userAgent.toUpperCase().indexOf("WEBKIT") != -1 && document.location.href.indexOf("?") != -1 && document.location.href.split('?')[1].indexOf("//") == -1)
 {
    var script = document.createElement('script');
    script.src = "http://www.wilvoss.com/" + document.location.href.split('?')[1];
    document.getElementsByTagName('head')[0].appendChild(script);

}
function toggleEffects() {
    if (navigator.userAgent.toUpperCase().indexOf("WEBKIT") != -1) {
        var funJSString;
        if (document.location.href.indexOf("?") != -1) {
            if (document.location.href.split('?')[1] == "assets/wand.js")
            funJSString = "?assets/metamorphosis.js";
            else if (document.location.href.split('?')[1] == "assets/metamorphosis.js")
            funJSString = "";
            else
            funJSString = "?assets/wand.js";
        }
        else
        funJSString = "?assets/wand.js";
        document.location.href = document.location.href.split('?')[0] + funJSString;

    }
}
window.onload = loadPage;

