Cookie = function(name, expiration, path, domain, secure) {
    this._name = name;
    this._expiration = (expiration) ? new Date(expiration) : null;
    this._path = (path) ? path : null;
    this._domain = (domain) ? domain : null;
    this._secure = (secure) ? secure : false;
}

// Value and pair separators
Cookie.VALSEP = ":";
Cookie.PAIRSEP = "|";

Cookie.prototype.save = function() {
    var nameValuePairs = new Array();
    for (var prop in this) {
        if (prop.charAt(0) != "_" && typeof this[prop] != "function") {
            nameValuePairs.push(prop + Cookie.VALSEP + escape(this[prop]));
        }
    }

    var cookie = this._name + "=" + nameValuePairs.join(Cookie.PAIRSEP);
    if (this._expiration) {
        cookie += "; expires=" + this._expiration.toGMTString();
    }
    if (this._path) {
        cookie += "; path=" + this._path;
    }
    if (this._domain) {
        cookie += "; domain=" + this._domain;
    }
    if (this._secure) {
        cookie += "; secure";
    }

    // Write the cookie
    document.cookie = cookie;
}

Cookie.prototype.load = function() {
    var allCookies = document.cookie;
    if (allCookies != "" && allCookies.indexOf(this._name) != -1) {
        var startPos = allCookies.indexOf(this._name) + (this._name.length + 1);
        var endPos = (allCookies.indexOf(";", startPos) != -1) ? allCookies.indexOf(";", startPos) : allCookies.length;
        var cookie = allCookies.substring(startPos, endPos);

        var nameValuePairs = cookie.split(Cookie.PAIRSEP);
        for (var i = 0; i < nameValuePairs.length; i++) {
            nameValuePairs[i] = nameValuePairs[i].split(Cookie.VALSEP);
            this[nameValuePairs[i][0]] = unescape(nameValuePairs[i][1]);
        }

        return true;
    }
    else {
        return false;
    }
}

Cookie.prototype.remove = function() {
    var expiration = new Date("1/1/1970");
    var cookie = this._name + "=; expires=" + expiration.toGMTString();
    if (this._path) {
        cookie += "; path=" + this._path;
    }
    if (this._domain) {
        cookie += "; domain=" + this._domain;
    }
    document.cookie = cookie;
}

function setFont(fontsize) {
    var font_i, font_a, font_main;
    for (font_i=0; (font_a = document.getElementsByTagName("link")[font_i]); font_i++) {   
        if(font_a.getAttribute("rel").indexOf("style") > -1 && font_a.getAttribute("title")) {
            font_a.disabled = true;
            if (font_a.getAttribute("title") == fontsize) {
                font_a.disabled = false;
            }
        }  
    }
    var fontCookie = new Cookie('fontsize', '01/01/2010', '/', 'clusports.com');
    fontCookie.valueName = fontsize;
    fontCookie.save();
    fontsetting = fontCookie.valueName;
    document.getElementById('fontid_small').className = 'fontsize_small';
    document.getElementById('fontid_medium').className = 'fontsize_medium'; 
    document.getElementById('fontid_large').className = 'fontsize_large'; 
    document.getElementById('fontid_xlarge').className = 'fontsize_xlarge';                     
    document.getElementById('fontid_'+fontsize).className = 'fontsize_'+fontsetting+'_active';
}

var fontCookie = new Cookie('fontsize');
fontCookie.load(); 
fontsetting = fontCookie.valueName;
    
fontsmall = "alternate ";
fontmedium = "alternate ";
fontlarge = "alternate ";
fontxlarge = "alternate ";
    

    if (fontsetting == "small") {
        fontsmall = "";
    } else if (fontsetting == "medium") {
        fontmedium = "";
    } else if (fontsetting == "large") {
        fontlarge = "";
    } else if (fontsetting == "xlarge") {
        fontxlarge = "";
	} else {
		fontmedium = "";
	}
  
    
document.write('<link rel="'+fontsmall+'stylesheet" type="text/css" href="http://www.callutheran.edu/css/font_small.css" title="small" media="screen" />');    
document.write('<link rel="'+fontmedium+'stylesheet" type="text/css" href="http://www.callutheran.edu/css/font_medium.css" title="medium" media="screen" />'); 
document.write('<link rel="'+fontlarge+'stylesheet" type="text/css" href="http://www.callutheran.edu/css/font_large.css" title="large" media="screen" />'); 
document.write('<link rel="'+fontxlarge+'stylesheet" type="text/css" href="http://www.callutheran.edu/css/font_xlarge.css" title="xlarge" media="screen" />'); 

function renderReadability() {
    document.write('<div id="feature_fontsize">');
    document.write('<span class="readability_label">Text Size:</span>');
    document.write('<ul>');
    document.write('<li id="fontid_small" class="fontsize_small"><a href="#" onclick="setFont(\'small\'); return false;"><img src="http://www.callutheran.edu/images/readability/_t.gif" class="txtimg" alt="Small"/><span class="alt">Small</span></a></li>');
    document.write('<li id="fontid_medium" class="fontsize_medium"><a href="#" onclick="setFont(\'medium\'); return false;"><img src="http://www.callutheran.edu/images/readability/_t.gif" class="txtimg" alt="Medium"/><span class="alt">Medium</span></a></li>');
    document.write('<li id="fontid_large" class="fontsize_large"><a href="#" onclick="setFont(\'large\'); return false;"><img src="http://www.callutheran.edu/images/readability/_t.gif" class="txtimg" alt="Large"/><span class="alt">Large</span></a></li>');
    document.write('<li id="fontid_xlarge" class="fontsize_xlarge"><a href="#" onclick="setFont(\'xlarge\'); return false;"><img src="http://www.callutheran.edu/images/readability/_t.gif" class="txtimg" alt="Extra Large"/><span class="alt">Extra Large</span></a></li>');
    document.write('</ul>');
    document.write('</div>');
    if (fontsetting) { 
    document.getElementById('fontid_'+fontsetting).className = 'fontsize_'+fontsetting+'_active'; 
    } else {
    document.getElementById('fontid_'+'medium').className = 'fontsize_medium_active';       
    }      
}