var gColorScheme = "light_on_dark";
var mCookieName = "exp_color_scheme";
gColorScheme = getCookie(mCookieName,"light_on_dark");

function expChangeColors() {
    var mCookieName = "exp_color_scheme";
    if (gColorScheme == "light_on_dark") {
	gColorScheme = "dark_on_light";
    } else if (gColorScheme == "dark_on_light") {
	gColorScheme = "light_on_dark";
    }
    setCookieForDays(mCookieName, gColorScheme, 180);
    expSetColors();
}
function expSetColors() {

    var mCookieName = "exp_color_scheme";
    //    var mColorScheme = getCookie(mCookieName,"light_on_dark");
    //        alert("color cookie: " + gColorScheme);
    if (gColorScheme == "light_on_dark") {
	loadJsCssFile("/experiences/includes/exp_view.css","css","main_css");
    } else if (gColorScheme == "dark_on_light") {
	loadJsCssFile("/experiences/includes/exp_view_black_on_white.css","css", "main_css");
    }

}

function loadJsCssFile(filename, filetype, linkId){
    if (filetype=="js"){ //if filename is a external JavaScript file
	var fileref= (linkId == "") ? document.createElement('script') : document.getElementById(linkId);
	    fileref.setAttribute("type","text/javascript")
	    fileref.setAttribute("src", filename)
    }
    else if (filetype=="css"){ //if filename is an external CSS file
	var fileref= (linkId == "") ? document.createElement("link") : document.getElementById(linkId);
	    fileref.setAttribute("rel", "stylesheet")
	    fileref.setAttribute("type", "text/css")
	    fileref.setAttribute("href", filename)
    }
    if (typeof fileref!="undefined") {
	document.getElementsByTagName("head")[0].appendChild(fileref)
    }
}
