// on page load with default day theme
if (typeof(Storage) !== "undefined") { // check browser support for localStorage

	// Code for localStorage/sessionStorage.
	if (localStorage.imglinks) {
		if (localStorage.imglinks == "invisible") {
			// append Night Theme stylesheet
			var imglinkscss = document.createElement("link")
			imglinkscss.setAttribute("rel", "stylesheet")
			imglinkscss.setAttribute("type", "text/css")
			imglinkscss.setAttribute("id", "imglinkscsslink")
			imglinkscss.setAttribute("href", "../css/sjj-imglinks_2019-12-01.css")

			document.head.appendChild(imglinkscss)

			// set checked state of checkbox
			document.getElementById("imgLinksCheckBox").checked = false
		}
		else {
			// set checked state of checkbox
			document.getElementById("imgLinksCheckBox").checked = true
		}
	}
	else {
		// initialize localStorage.imglinks with value "visible"
		localStorage.imglinks = "visible"

		// set checked state of checkbox
		document.getElementById("imgLinksCheckBox").checked = true
	}
}


function switchImgLinks() {
	if (typeof(Storage) !== "undefined") {
		if (localStorage.imglinks == "visible") {
			// append Night Theme stylesheet
			var switchimglinkcss = document.createElement("link")
			switchimglinkcss.setAttribute("rel", "stylesheet")
			switchimglinkcss.setAttribute("type", "text/css")
			switchimglinkcss.setAttribute("id", "imglinkscsslink")
			switchimglinkcss.setAttribute("href", "../css/sjj-imglinks_2019-12-01.css")

			document.head.appendChild(switchimglinkcss)

			//set localStorage.imglinks
			localStorage.imglinks = "invisible"

			// set checked state of checkbox
			document.getElementById("imgLinksCheckBox").checked = false
		}
		else {
			//remove Night Theme stylesheet
			document.head.removeChild(document.getElementById('imglinkscsslink'))

			//set localStorage.imglinks
			localStorage.imglinks = "visible"

			// set checked state of checkbox
			document.getElementById("imgLinksCheckBox").checked = true
		}
	}
}