/*
//
// APUS JS package, last modified $Date: 2005/03/15 13:55:23 $ by $Author: stamina $
//
// This script contains the logic for dynamically changing the stylesheet.
//
// NOTE: Using following conventions in <link> and <a> selectors title attributes:
//
// Tekst normaal (linksmall css)
// Tekst groter (linkmedium css)
// Tekst grootst (linkbig css)
//
*/

function setActiveStyleSheet(aTitle, aResetFlag) {
	var lElement;
	for (i=0; (lElement = document.getElementsByTagName("link")[i]); i++) {
		if (lElement.getAttribute("rel").indexOf("style") != -1 && lElement.getAttribute("title")) {
			lElement.disabled = true;
			if (lElement.getAttribute("title") == aTitle) lElement.disabled = false;
		}
	}
	if (aResetFlag == 1) { // set current style as cookie
		  document.cookie='apusstyle' + '=' + aTitle; 
	}
	pinActiveLink(aTitle); // set underline under xhtml link by adding a pinned class
}

function setStyle() {
	var lStyle = get_cookie("apusstyle");
	if (lStyle != "") {
		setActiveStyleSheet(lStyle, 0);
	} else {
		// set default style to normal
		setActiveStyleSheet("Tekst normaal", 1);
	}
}

function pinActiveLink(aTitle) {
	var lElement;
	for (i=0; (lElement = document.getElementsByTagName("a")[i]); i++) {
		if (lElement.getAttribute("title")) {
			// first clear all pinned links
		    if (lElement.getAttribute("title").indexOf('Tekst normaal') != -1) {
				lElement.className = 'linksmall';
			}
		    if (lElement.getAttribute("title").indexOf('Tekst groter') != -1) {
				lElement.className = 'linkmedium';
			}
		    if (lElement.getAttribute("title").indexOf('Tekst grootst') != -1) {
				lElement.className = 'linkbig';
			}
		}
	}
	for (i=0; (lElement = document.getElementsByTagName("a")[i]); i++) {
		if (lElement.getAttribute("title")) {
			// set pinned
		    if (lElement.getAttribute("title").indexOf(aTitle) != -1 && lElement.getAttribute("title")) {
				lElement.className += ' pinned';
			}
		}
	}
}









