// Schriftgröße
var schriftgroesse = 12;
var akt_groesse = schriftgroesse;

function init_schriftgroesse(isg) {
	sg = getSize();
	if (sg != schriftgroesse) {
		akt_groesse = sg;
		makeLinks();
	}

	document.getElementsByTagName('body')[0].style.fontSize = akt_groesse + 'px';
}

function setSize(nsg) {
    akt_groesse = nsg
    document.getElementsByTagName('body')[0].style.fontSize = akt_groesse + 'px';
    makeLinks();
}

function getSize() {
	var sg;

	if (document.location.search != "" && (document.location.search).match (/sg=[0-9]+\.?[0-9]*/i)) {
		sg = ("" + (document.location.search).match (/sg=[0-9]+\.?[0-9]*/i)).replace (/sg=/i, '');
	} else {
		sg = schriftgroesse;
	}

	return sg;
}

function getURL(domain) {
	if (domain.match (/^((http:\/\/)?(www\.)?((([0-9a-z][0-9a-z-]+\.)+)([a-z]{2,3}))).*/)) {
		return domain.match (/^((http:\/\/)?(www\.)?((([0-9a-z][0-9a-z-]+\.)+)([a-z]{2,3}))).*/)[1];
	} else {
		return "";
	}
}

function makeLinks() {
	links = document.links.length;
	for (i = 0; i < links; i++) {
		if (!(document.links[i].href).match(/^mailto:/) && !(document.links[i].href).match(/^(http:\/\/)?(www\.)?((([0-9a-z][0-9a-z-]+\.)+)([a-z]{2,3}))[\/]+$/) && (document.links[i].href).indexOf(getURL(self.location.href)) != -1) {
			if ((document.links[i].href).match(/sg=[0-9]+\.?[0-9]{0,2}/i)) {
				document.links[i].href = (document.links[i].href).replace(/sg=[0-9]+\.?[0-9]{0,2}/i, ("sg=" + akt_groesse));
			} else {
				if ((document.links[i].href).indexOf('?') != -1) {
					document.links[i].href = document.links[i].href + "&sg=" + akt_groesse;
				} else if((document.links[i].href).indexOf('#') == -1) {
					document.links[i].href = document.links[i].href + "?sg=" + akt_groesse;
				} else {
					document.links[i].href = (document.links[i].href).replace(/#([a-z]*)([0-9])+/i, ('?sg=' + akt_groesse + '#$1$2'));
				}
			}
		}
	}
}

function callContent(data) {
	location.href=data.options[data.selectedIndex].value;
}
