// ---------------------------------------
// Created:		 
// Last Modified: 
//					MPruchnicki,  2008-08-19: Funktionen Decrypt_Address und Mailto_Decrypted hinzugefügt
//					SWeiß,  			2008-08-27: target = document.all durch document.getElementById ersetzt, da document.all im Firefox nicht funktioniert
//												betrifft: function toggle, toggleVisibilty
//												Fehler: document.all is not a function
//												Quelldatei: http://men-intra/scriptread/internet.js
//												Zeile: 20
// ---------------------------------------

function popUp(popupUrl,windName,newWidth,newHeight,scroll)
{
	params = "width=" + newWidth + ",height=" + newHeight + ",locationbar=no,menubar=no,resizable=no,toolbar=no,screenX=0,screenY=0,status=no,scrollbars=" + scroll;
	var pWnd = window.open(popupUrl,windName,params);
	if (!pWnd.opener)
		pWnd.opener = self;
	if (pWnd.focus != null)
		pWnd.focus();
}


function toggle( targetId )
{
	//target = document.all( targetId );					//funktioniert nicht in Firefox
	target = document.getElementById( targetId );
		if (target.style.display == "none"){
			target.style.display = "";
		} else {
			target.style.display = "none";
		}
}

function toggleVisibility( targetId )
{
	// funktioniert nicht zuverlässig
	//target = document.all( targetId );					//funktioniert nicht in Firefox
	target = document.getElementById( targetId );
		if (target.style.visibility == "hidden"){
			target.style.visibility = "visible";
		} else {
			target.style.visibility = "hidden";
		}
}

function CheckLen(thisValue,maxTextLength)
{
	var thisLength = new String;
	thisLength = thisValue.length;
	
	if (thisLength < maxTextLength)
	{
		return true;
	}
	else
    {
    	window.alert('Der eingegebene Text ist zu lang (' + thisLength + ' Zeichen). Bitte auf ' + maxTextLength + ' Zeichen kürzen!')
   		return false;
	}
}


function CheckEmailAddr(email,splitChar)
{
	// Checks one or more e-mail addresses
	// If a splitChar is passed, email is split and becomes an array of several addresses

	var email_arr
	
	if (splitChar.length > 0)
	{
		// Make array
		email_arr = email.split(splitChar);
	}
	else
	{
		email_arr[0] = email;
	}
	
	var at_pos;
	var atCount = 0;
	var perCount = 0;
	for (var thismail in email_arr)
	{
		// Check all addresses in array
		email = email_arr[thismail];
		
		// One @ character, at least one . character

		for (i=0; i<email.length; i++)
		{
			at_pos = email.charAt(i);
			//alert(at_pos);
			if (at_pos == "@")
			{
				atCount = atCount + 1;
			}
			if (at_pos == ".")
			{
				perCount = perCount + 1;
			}
		}
		
		if ( (atCount == 1) && (perCount > 0) )
		{
			result = true;
		}
		else
		{
			alert("Please check your entry for e-mail address: " + email + ".")
			result = false;
		}
		atCount = 0;
		perCount = 0;
	}
}


function Decrypt_Address(enc)
{
	// Decodiert E-Mail-Adresse durch ASCII-Code-Verschiebung -1 (aus SPACE (ASCII 32) wird ~ (ASCII 126))
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x21 && n <= 0x7E)	{
			dec += String.fromCharCode(n-1);
		} else if (n == 0x20)	{
			dec += String.fromCharCode(0x7E);
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}

function Mailto_Decrypted(s)
{
	location.href = "mailto:" + Decrypt_Address(s);
}


function replace(mystring, regExp, teilstring)
// Die JavaScript-Methode .replace ersetzt immer nur die erste Fundstelle!
{
	var thischar;
	for (i=0; i<mystring.length; i++)
	{
		if (mystring.search(regExp) > -1)
		{
			mystring = mystring.replace(regExp,teilstring);
		}
	}
	return mystring;
}

function _private_left(inLen) {
  return this.substring(0,inLen);
}

function _private_right(inLen) {
  return this.substring((this.length-inLen),this.length);
}

String.prototype.left = _private_left;
String.prototype.right = _private_right;
