var initial_font_size = 0.8;
var font_unity = 'em';
var delta = 0.1;
var fsize = initial_font_size;

function init_FontSize (ifs, fu, del)
{
	if (!isNaN(ifs))
		initial_font_size = parseFloat(ifs);
	if ("pt,pc,in,mm,cm,px,em,ex,%".indexOf (fu) != -1)
		font_unity = fu;
	if (!isNaN(del))
		delta = parseFloat(del);
	if (isNaN(parseFloat(document.getElementsByTagName('body')[0].style.fontSize)) || parseFloat(document.getElementsByTagName('body')[0].style.fontSize) == 0)
		fsize = getFontSize ();
	else
		fsize = parseFloat(document.getElementsByTagName('body')[0].style.fontSize);
	if (fsize != initial_font_size)
		addFontSizeToLinks ();
	document.getElementsByTagName('body')[0].style.fontSize = fsize + font_unity;
}

function incFontSize ()
{
	if (!isNaN(delta))
		setFontSize (Math.round((parseFloat(fsize) + parseFloat(delta)) * 100) / 100);
}

function decFontSize ()
{
	if (!isNaN(delta))
		setFontSize (Math.round((parseFloat(fsize) - parseFloat(delta)) * 100) / 100);
}

function setFontSize (newsize)
{
	if (!isNaN(newsize))
	{
		fsize = Math.round((parseFloat(newsize)) * 100) / 100;
		document.getElementsByTagName('body')[0].style.fontSize = fsize + font_unity;
		addFontSizeToLinks ();
	}
}

function getFontSize ()
{
	var fs;

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

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

function addFontSizeToLinks ()
{
	for (i = 0; i < document.links.length; 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 (getDomainURL (self.location.href)) != -1
		    )
		{
			if ((document.links[i].href).match (/fsize=[0-9]+\.?[0-9]{0,2}/i))
				document.links[i].href = (document.links[i].href).replace (/fsize=[0-9]+\.?[0-9]{0,2}/i, ("fsize=" + fsize));
			else
				if ((document.links[i].href).indexOf ('?') != -1)
					document.links[i].href = document.links[i].href + "&fsize=" + fsize;
				else
					document.links[i].href = document.links[i].href + "?fsize=" + fsize;
		}
	}
}


function frameCheck ()
{
	if (self != top)
		top.location.href = self.location.href;
}


function decodeString (text)
{
	var decoded = '';

	for (i = 0; i < text.length; i++)
		decoded += String.fromCharCode ((text.charCodeAt (i) - 5));
	return decoded;
}


function mkEmAdr (aID)
{
	var emadr = '';
	var unme = '(((';

	switch (aID)
	{
		case 0:
			unme += '|zgrfxyzw';
			unme = decodeString (unme);
			unme = unme.replace (/u/gi, String.fromCharCode (101));
			break;
		case 1:
			unme += 'FMk}fsikw&Rzkqqkw';
			unme = decodeString (unme);
			unme = unme.replace (/f/gi, String.fromCharCode (0x65));
			unme = unme.replace (/H/gi, String.fromCharCode (108));
			break;
	}
	emadr += String.fromCharCode (0x40);
	emadr += String.fromCharCode (0x47, 97,0x64, 103, 0x65, 116, 0x73);
	emadr += String.fromCharCode (52);
	emadr += String.fromCharCode (0x57, 101, 0x62);
	emadr += '!';
	emadr += String.fromCharCode (110, 0x65, 116);
	emadr = unme.concat (emadr);
	emadr = emadr.replace (/!/gi, String.fromCharCode (46));
	emadr = emadr.replace (/###/, String.fromCharCode (0x6D, 97, 105, 0x6C, 0x74, 0x6f, 58));
	return emadr;
}

function check () {
	if (window.location.search != '')
		document.forms.kontakt.kw.value = window.location.search.substr (1).match (/.*q=([^&]+).*/i)[1];
	document.forms.kontakt.ref.value = document.referrer;
	produkt = -1;
	for (i = 0; i < document.forms.kontakt.produktoption.length; i++)
		if (document.forms.kontakt.produktoption[i].checked) {
			produkt = i;
			break;
		}
	if (produkt == -1) {
		alert ('Bitte w\u00e4hlen Sie unter Schritt 1 ein Produkt aus!');
		document.forms.kontakt.produktoption[0].focus ();
		return false;
	}
	if (!document.forms.kontakt.name.value.match (/\w/i)) {
		alert ('Bitte geben Sie Ihren Namen ein!');
		document.forms.kontakt.name.focus ();
		return false;
	}
	if (!document.forms.kontakt.email.value.match (/^[\w.+-]{2,}\@[\w.-]{2,}\.[a-z]{2,6}$/i)) {
		alert ('Bitte geben Sie Ihre E-Mail-Adresse ein!');
		document.forms.kontakt.email.focus ();
		return false;
	}
	if (!document.forms.kontakt.phone.value.match (/^[0-9+-. \/()]{6,}$/i)) {
		alert ('Bitte geben Sie Ihre Telefonnummer ein!');
		document.forms.kontakt.phone.focus ();
		return false;
	}
	//if (document.forms.kontakt.domain.value && !document.forms.kontakt.phone.value.match (/^(http:\/\/)?([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$/i)) {
	//	alert ('Der von Ihnen angegebene Domainname ist nicht korrekt!');
	//	document.forms.kontakt.domain.focus ();
	//	return false;
	//}
	document.forms.kontakt.action = '/kontakt.php';
}

