moversion = 2;

pic_iconblockcompress = new Image(15,15);
pic_iconblockcompress.src = "../../global/images/iconblock-compress.gif";
pic_iconblockcompress2 = new Image(15,15);
pic_iconblockcompress2.src = "../../global/images/iconblock-compress-mo.gif";

pic_iconblockuncompress = new Image(15,15);
pic_iconblockuncompress.src = "../../global/images/iconblock-uncompress.gif";
pic_iconblockuncompress2 = new Image(15,15);
pic_iconblockuncompress2.src = "../../global/images/iconblock-uncompress-mo.gif";

pic_pfeilopen = new Image(30,30);
pic_pfeilopen.src = "../../global/images/bar2-popopen0.gif";
pic_pfeilopen2 = new Image(30,30);
pic_pfeilopen2.src = "../../global/images/bar2-popopen1.gif";

pic_pfeilclose = new Image(30,30);
pic_pfeilclose.src = "../../global/images/bar2-popclose0.gif";
pic_pfeilclose2 = new Image(30,30);
pic_pfeilclose2.src = "../../global/images/bar2-popclose1.gif";

pic_help = new Image(30,30);
pic_help.src = "../../global/images/bar2-help0.gif";
pic_help2 = new Image(30,30);
pic_help2.src = "../../global/images/bar2-help1.gif";

pic_nohelp = new Image(30,30);
pic_nohelp.src = "../../global/images/bar2-nohelp0.gif";
pic_nohelp2 = new Image(30,30);
pic_nohelp2.src = "../../global/images/bar2-nohelp1.gif";

pic_helpnotreleased = new Image(30,30);
pic_helpnotreleased.src = "../../global/images/bar2-helpnotreleased0.gif";
pic_helpnotreleased2 = new Image(30,30);
pic_helpnotreleased2.src = "../../global/images/bar2-helpnotreleased1.gif";

if (navigator.userAgent.substring(0,7) == "Mozilla")
{
    if (parseInt(navigator.userAgent.substring(8,9)) >= 3)
    {
		moversion = 1;

    }
}

function s1(imgDocID,imgObjName)
{
	if (moversion == 1) {
		document.images[imgDocID].src = eval(imgObjName + ".src");
	}
}

function CallHelp(sHelpKey,sBlockName)
{
	window.open("../../global/soft/help.php?AktSessionName="+session_name+"&sHelpKey="+sHelpKey+"&sBlockName="+sBlockName+"#"+sBlockName, "Hilfe", "scrollbars=yes,toolbar=no,width=640,height=400");
}

function EditHelp(sHelpKey,sBlockName)
{
	Hedit = window.open("../../global/soft/help_edit.php?AktSessionName="+session_name+"&sHelpKey="+sHelpKey+"&sBlockName="+sBlockName, "HilfeEditor", "scrollbars=yes,toolbar=no,width=600,height=600");
	Hedit.focus();
}

function ShowHelp(sHelpKey)
{
	window.open("../../global/soft/help_show.php?AktSessionName="+session_name+"&sHelpKey="+sHelpKey, "Hilfe", "scrollbars=yes,toolbar=no,width=640,height=400");
}

function pty_browserType()
{
	// this.name = navigator.appName;
     this.version = navigator.appVersion;			        //Version string
     this.dom=document.getElementById?1:0			                //w3-dom
     this.op5=(this.name.indexOf("Opera") > -1 && (this.dom))?1:0	 //Opera Browser
     this.ie4=(document.all && !this.dom)?1:0			           //ie4
     this.ie5=(this.dom && this.version.indexOf("MSIE ") > -1)?1:0	     //IE5, IE6?
     this.ns4=(document.layers && !this.dom)?1:0			           //NS4
     this.ns5=(this.dom && this.version.indexOf("MSIE ") == -1)?1:0 //NS6, Mozilla5
    		 /*

     //test if op5 telling "i'm ie..." (works because op5 doesn't support clip)
     //testen ob sich ein op5 als ie5 'ausgibt' (funktioniert weil op5 kein clip
     //unterst?tzt)
     if (this.ie4 || this.ie5)
     {
          document.write('<DIV id=testOpera style="position:absolute; visibility:hidden">TestIfOpera5</DIV>');
          if (document.all['testOpera'].style.clip=='rect()')
          {
               this.ie4=0;
               this.ie5=0;
               this.op5=1;
          }
     }

     this.ok=(this.ie4 || this.ie5 || this.ns4 || this.ns5 || this.op5) //any DHTML
*/
     eval ("bt=this");
}
pty_browserType();

function getObj(obj)
{
     //do not use 'STYLE=' attribut in <DIV> tags for NS4!
     //zumindest beim NS 4.08 d?rfen <DIV> Tags keine 'STYLE=' Angabe beinhalten
     //sonst werden die restlichen Layers nicht gefunden! class= ist jedoch erlaubt!

     //search layer for ns4
     //Recursive Suche nach Layer f?r NS4
     function getRefNS4(doc,obj)
     {
          var fobj=0;
          var iFor1=0;
          while (iFor1 < doc.layers.length)
          {
               if (doc.layers[iFor1].name==obj)
                    return doc.layers[iFor1];
	          fobj=getRefNS4(doc.layers[iFor1].document,obj)
	          if (fobj != 0)
	               return fobj

	          iFor1++;
          }
          return 0;
     }

     return (bt.dom)?document.getElementById(obj):(bt.ie4)?
         document.all[obj]:(bt.ns4)?getRefNS4(document,obj):0
}

function emailCheck (emailStr)
{

     var emailPat=/^(.+)@(.+)$/
     var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
     var validChars="\[^\\s" + specialChars + "\]"
     var quotedUser="(\"[^\"]*\")"
     var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
     var atom=validChars + '+'
     var word="(" + atom + "|" + quotedUser + ")"
     var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
     var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
     var matchArray=emailStr.match(emailPat)
     if (matchArray==null)
     	return 0
     var user=matchArray[1]
     var domain=matchArray[2]

     if (user.match(userPat)==null)
         return 0


     var IPArray=domain.match(ipDomainPat)
     if (IPArray!=null)
     {
          for (var i=1;i<=4;i++)
               if (IPArray[i]>255)
     		   return 0
          return 1
     }

     var domainArray=domain.match(domainPat)
     if (domainArray==null)
          return 0

     var atomPat=new RegExp(atom,"g")
     var domArr=domain.match(atomPat)
     var len=domArr.length
     if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4)
        return 0

     if (len<2)
        return 0

     return 1;
}

function URLcheck(URL)
{

     if (URL.Trim() != '')
          return (1);
     else
          return (0);

}

function CheckIpField(field)
{
	return(CheckUserInput('ip',field))

}

String.prototype.LTrim = new Function("return this.replace(/^\\s+/,'')")
String.prototype.RTrim = new Function("return this.replace(/\\s+$/,'')")
String.prototype.Trim  = new Function("return this.replace(/^\\s+|\\s+$/g,'')")

function str_replace(nach, ersetzte, source) 
{
     anzahl = nach.length;
     dummy = ""
     while (source.indexOf(nach)>=0) 
     {
          aktuell = source.indexOf(nach);
          dummy += source.substr(0, aktuell)
          if (aktuell >= 0) 
               dummy += ersetzte
          source = source.substr((aktuell+anzahl), source.length);
     }
     if (source.length >0) 
          dummy += source
     
     return dummy
}

function str_repeat(char2repeat, repeatcount) 
{
	var repString = "";
	for (iFor1 = 0; iFor1 < (repeatcount-0); iFor1++)
	{
		repString += char2repeat;
	}
     
	return (repString);
}

function CheckPoBox(Str2Test)
{
     fNoPoBox = 1
     
     Str2Test = Str2Test.toLowerCase()
     
     
     if (Str2Test.indexOf("postfach") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("postf.") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("postf") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("p.o. box") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("po box") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("pobox") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("p.o.box") != -1)
          fNoPoBox = 0;
     if (Str2Test.indexOf("po-box") != -1)
          fNoPoBox = 0;

     return (fNoPoBox);     
}

function DoNotPressEnter()
{

     if (document.all)
          InputCharCode = window.event.keyCode;
     else
          InputCharCode = FF_LastEvent.which;

     if (InputCharCode != 13)
          return(true);
     else
          return(false);

}

function FF_SaveEvent(evt)
{
     FF_LastEvent = evt;
}

if (!document.all)
{
     var FF_LastEvent = "";
     document.onkeypress = FF_SaveEvent;
}

function substr_count(String,SearchChar)
{
     counter = 0;
     for (iFor1 = 0; iFor1 < String.length; iFor1++)
     {
          if (String.charAt(iFor1) == SearchChar)
               counter++;
     }
     return (counter)               
}

function in_array(value,a_array)
{
     for (var i=0; i<a_array.length; i++) 
     {
          if (a_array[i] == value) 
          {
               return(1)
          }
     }
     return(0)
}


function GetRadioValue(rObj) 
{
    for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
    return false;
}

function CheckPhonenumber(Number2Check)
{
	Number2Check = Number2Check.Trim()
	if (Number2Check.length > 0)
	{
		// feststellen ob die nummer mit einem oder zwei + anf?ngt
		if (Number2Check.substr(0,2) == '++')
			Number2Check = '00' + Number2Check.substr(2);
		if (Number2Check.substr(0,1) == '+')
			Number2Check = '00' + Number2Check.substr(1);
			
		// alle nicht-ziffern entfernen
		expression = new RegExp("[^0-9]*","g")
		Number2Check = Number2Check.replace(expression,"");
	}
	return(Number2Check)
}

function FormatSIPForwardTargetnumber(Number2Check)
{
	Number2Check = Number2Check.Trim()
	NumberPrefix = Number2Check.substr(0,Number2Check.lastIndexOf('*')+1);
	Number = Number2Check.substr(Number2Check.lastIndexOf('*')+1);
	if (Number.length > 0)
	{
		// feststellen ob die nummer mit einem oder zwei + anf?ngt
		if (Number.substr(0,2) == '++')
			Number = '00' + Number.substr(2);
		if (Number.substr(0,1) == '+')
			Number = '00' + Number.substr(1);
			
	}
	Number2Check = NumberPrefix + Number
	// alle nicht-ziffern entfernen
	expression = new RegExp("[^0-9*]*","g")
	Number2Check = Number2Check.replace(expression,"");
	return(Number2Check)
}

function FormatMailSipAddress(Address2Check)
{
	Address = Address2Check.substr(Address2Check.lastIndexOf(':')+1);
	Address = Address.Trim()
	return(Address)
}

function CheckMailSipAddress(Address2Check)
{
	expression = new RegExp("^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$","g")
	return(Address2Check.match(expression));
}


function CheckUserInput(type,fieldvalue)
{
	type = type.toLowerCase();
	switch(type)
	{
		case 'ip':
			expression = new RegExp("^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})[.]){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'multiip':
			expression = new RegExp("^(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})[.]){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})([,]((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})[.]){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})){0,})$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'ipnetaddress':
			if (fieldvalue == '0.0.0.0')
				return(1);
			
			expression = new RegExp("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$")
			if (fieldvalue.match(expression))
			{
				/* Die Expression liefert in JS bei z.B. 192.168 auch TRUE, daher noch die enthaltenene Punkte zählen */
		           dotcount = 0;
		           for (iFor1=0; iFor1 < fieldvalue.length; iFor1++)
		           {
		                if (fieldvalue.substring(iFor1,iFor1+1) == '.')
		                     dotcount++;
		           }
				 if (dotcount == 3)
				 	return(1);
			}
			break;
		case 'ipv6':
			/* Wenn Wert mit : beginnt, zur Prüfung noch eine 0 voranstgellen */
			if (fieldvalue.substring(0,1) == ':')
				fieldvalue = '0'+fieldvalue;
			/* Wenn Wert auf :: endet, zur Prüfung noch eine 0 anhängen */
			if (fieldvalue.substring(fieldvalue.length-2,fieldvalue.length) == '::')
				fieldvalue = fieldvalue+'0';
			/* die RegExp kennt kein :: , daher vorher auf :0: umsetzen */
			if (fieldvalue.indexOf('::'))
			{
		           PointCount = 0;
		           for (iFor1=0; iFor1 < fieldvalue.length; iFor1++)
		           {
		                if (fieldvalue.substring(iFor1,iFor1+1) == ':')
		                     PointCount++;
		           }

				missingPart = str_repeat(':0',8 - PointCount)
				fieldvalue = str_replace('::',missingPart+':',fieldvalue);
			}
			expression = new RegExp("^[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'multiipv6':
			parts = fieldvalue.split(',')
			fNoError = 1;
			for (iForPart = 0; iForPart < parts.length; iForPart++)
			{
				
				fieldvalue = parts[iForPart];
				/* Wenn Wert mit : beginnt, zur Prüfung noch eine 0 voranstgellen */
				if (fieldvalue.substring(0,1) == ':')
					fieldvalue = '0'+fieldvalue;
				/* Wenn Wert auf :: endet, zur Prüfung noch eine 0 anhängen */
				if (fieldvalue.substring(fieldvalue.length-2,fieldvalue.length) == '::')
					fieldvalue = fieldvalue+'0';
				/* die RegExp kennt kein :: , daher vorher auf :0: umsetzen */
				if (fieldvalue.indexOf('::'))
				{
			           PointCount = 0;
			           for (iFor1=0; iFor1 < fieldvalue.length; iFor1++)
			           {
			                if (fieldvalue.substring(iFor1,iFor1+1) == ':')
			                     PointCount++;
			           }
	
					missingPart = str_repeat(':0',8 - PointCount)
					fieldvalue = str_replace('::',missingPart+':',fieldvalue);
				}
				expression = new RegExp("^[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}$")
				if (!fieldvalue.match(expression))
					fNoError = 0;
			
			}
			return (fNoError);
			break;
			
		case 'mac':
			expression = new RegExp("^[0-9a-fA-F]{2}(\:[0-9a-fA-F]{2}){5}$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'iporhostname':
			/* auf IP testen */
			tempvalue = str_replace(' ','a',fieldvalue);
			expression = new RegExp("^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})[.]){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$")
			if (tempvalue.match(expression))
				return (1);
			/* auf Hostnamen testen */
			expression = new RegExp("^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?[.])+[a-zA-Z]{2,6}$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'hostname':
			/* auf Hostnamen testen */
			expression = new RegExp("^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?[.])+[a-zA-Z]{2,6}$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'charorint':
			expression = new RegExp("^[a-zA-Z0-9]*$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'password':
			expression = new RegExp("^[a-zA-Z0-9_!$=+#*-]*$")
			if (fieldvalue.match(expression))
				return (1);
			break;
		case 'txt':
			return(1);
			break;
		case 'srv':
			if (fieldvalue.indexOf('|')>0)
				return(0);
			fieldvalue = str_replace(' ','|',fieldvalue);
			expression = new RegExp("^((([0-9]+)[|]){3})[a-zA-Z0-9._\-]+$")

			if (fieldvalue.match(expression))
				return (1);
			break;
		case "mailaddress":
			return (emailCheck(fieldvalue));
			break;
		default:
			alert('Unknown type')
	}
	return(0);

}

function ValidateInput(obj2check,type,extra)
{
	type = type.toLowerCase();
	switch(type)
	{
		// ### ganzzahl ohne führende null
		case "integer":
			returnValue = obj2check.value.replace(/\D/g,'')
			if (returnValue.length > 1)
				returnValue = returnValue.replace(/^0*/,'')
			break;
		// ### ganzzahl (auch mit führender null)
		case "number":
			returnValue = obj2check.value.replace(/\D/g,'')
			break;
		case "decimal":
			returnValue = str_replace(",",".",obj2check.value.Trim())
			returnValue = returnValue.replace(/^\D*/g,'');
			returnValue = returnValue.replace(/\D*$/g,'');
			// den letzten . finden
			pos = 0;
			while (returnValue.indexOf(".",pos) != -1)
			{
				pos = returnValue.indexOf(".",pos)+1
			}
			decimals = (pos ? returnValue.length -pos : 0);
			returnValue = returnValue.replace(/\D/g,'');
			returnValue = returnValue / Math.pow(10,decimals);
			
			if (extra)
				returnValue = Math.round(returnValue * Math.pow(10,extra)) / Math.pow(10,extra);
			break;
		case "signeddecimal":
			returnValue = str_replace(",",".",obj2check.value.Trim())
			sign = (returnValue.substring(0,1) == '-' || returnValue.substring(0,1) == '+' ? returnValue.substring(0,1) : '');
			returnValue = returnValue.replace(/^\D*/g,'');
			returnValue = returnValue.replace(/\D*$/g,'');
			// den letzten . finden
			pos = 0;
			while (returnValue.indexOf(".",pos) != -1)
			{
				pos = returnValue.indexOf(".",pos)+1
			}
			decimals = (pos ? returnValue.length -pos : 0);
			returnValue = returnValue.replace(/\D/g,'');
			returnValue = returnValue / Math.pow(10,decimals);
			
			if (extra)
				returnValue = Math.round(returnValue * Math.pow(10,extra)) / Math.pow(10,extra);
			if (sign)
				returnValue = sign + returnValue;
			break;
		case "phonenumber":
			returnValue = obj2check.value;
			returnValue = (returnValue.substring(0,1) == '+' ? '00'+returnValue : returnValue);
			returnValue = returnValue.replace(/\D/g,'')
			break;

		case "mailalias":
	          if (obj2check.value == '*')
	               returnValue = '*';
	          else
			{
				returnValue = obj2check.value.toLowerCase()
				returnValue = returnValue.replace(/[^A-Za-z0-9.+-_]/g,'');

				// ### CDa 03.03.2011 Diese Zeichen sind böse und müssen auch raus!
				returnValue = returnValue.replace(/[,^=/\?\\<>;:]/g,'');

				// keine . am anfang oder ende
				while (returnValue.indexOf(".") == 0)
					returnValue = returnValue.substring(1);
				while (returnValue.substring(returnValue.length-1) == '.')
					returnValue = returnValue.substring(0,returnValue.length-1);
			}
			break;
		case "mailaddress":
			returnValue = obj2check.value.toLowerCase()
			break;
		case "realname":
			returnValue = obj2check.value
			returnValue = returnValue.replace(/[^A-Za-z0-9.+_ÄäÖöÜüß\s\:-]/g,'');
			returnValue = returnValue.replace(/^[^A-Za-z]*/,'')
			break;
		case "htaccessname":
			returnValue = obj2check.value
			returnValue = returnValue.replace(/[^A-Za-z0-9\s-]/g,'');
			break;
		case "loginname":
			returnValue = obj2check.value;
/*
			returnValue = returnValue.replace(/[ü]/g,'ae');
			returnValue = returnValue.replace(/[ä]/g,'ae');
			returnValue = returnValue.replace(/[ö]/g,'oe');
			returnValue = returnValue.replace(/[ß]/g,'ss');
			returnValue = returnValue.replace(/[Ü]/g,'Ue');
			returnValue = returnValue.replace(/[Ä]/g,'Ae');
			returnValue = returnValue.replace(/[Ö]/g,'Oe');
*/

			returnValue = returnValue.replace(/[^A-Za-z0-9.+_-]/g,'');
			returnValue = returnValue.replace(/^[^A-Za-z]*/,'')
			break;

		case "url":
	          var validChars = new Array(37,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,248,249,250,251,252,253,254,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,309,311,312,314,316,318,322,324,326,328,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,378,380,382);
			returnValue = '';
          	for (iFor1 = 0; iFor1 < obj2check.value.length; iFor1++)
          	{
	          	if (in_array(obj2check.value.charCodeAt(iFor1),validChars))
	          		returnValue = returnValue + obj2check.value.substr(iFor1,1);
          	}
			break;

		case "hostnamemapping":
	          var validChars = new Array(45,46,47,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122);
			returnValue = '';
          	for (iFor1H = 0; iFor1H < obj2check.value.length; iFor1H++)
          	{
	          	if (in_array(obj2check.value.charCodeAt(iFor1H),validChars))
	          		returnValue = returnValue + obj2check.value.substr(iFor1H,1);
          	}
          	if (extra)
          		return(returnValue)
			break;

		case "portrange":
          	returnValue = obj2check.value
			returnValue = returnValue.replace(/^\D*/g,'');
			returnValue = returnValue.replace(/\D*$/g,'');
			returnValue = returnValue.replace(/[^0-9-]/g,'')
			break;


		case "facebookcontentmapping":
	          var validChars = new Array(45,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122);
			returnValue = '';
          	for (iFor1H = 0; iFor1H < obj2check.value.length; iFor1H++)
          	{
	          	if (in_array(obj2check.value.charCodeAt(iFor1H),validChars))
	          		returnValue = returnValue + obj2check.value.substr(iFor1H,1);
          	}
          	if (extra)
          		return(returnValue)
			break;


		default:
			alert('Unknown type')
			returnValue = '';
	}

	obj2check.value = returnValue;
}

function MouseOverCSSEditBlock(nr)
{
	if (CSSEditBlockStatus[nr])
	{
		document.getElementById('CSSEditBlockClose'+nr).className  =  'EditBlockToggleButtonOpenedActive';
	}
	else
	{
		document.getElementById('CSSEditBlockClose'+nr).className  =  'EditBlockToggleButtonClosedActive';
	}
}

function MouseOutCSSEditBlock(nr)
{
	if (CSSEditBlockStatus[nr])
	{
		document.getElementById('CSSEditBlockClose'+nr).className  =  'EditBlockToggleButtonOpened';
	}
	else
	{
		document.getElementById('CSSEditBlockClose'+nr).className  =  'EditBlockToggleButtonClosed';
	}
}

function ToggleCSSEditBlock(nr)
{
	if (CSSEditBlockStatus[nr])
	{
		document.getElementById('CSSEditBlockContent'+nr).className  =  'EditBlockContentHidden';
	}
	else
	{
		document.getElementById('CSSEditBlockContent'+nr).className  =  'EditBlockContent';
	}
	CSSEditBlockStatus[nr] = (CSSEditBlockStatus[nr] -1) * (-1);
	MouseOverCSSEditBlock(nr);
}

var CSSEditBlockStatus = new Array();



function toggleWebspaceDirectoryChildLevel(i)
{
     if (document.getElementById('childLevel'+i).style.display == 'none')
     {
          document.getElementById('childLevel'+i).style.display = 'block';
          document.images['childLevelImage'+i].src = '../../service/images/productgroup_open.gif';
     }
     else
     {
          document.getElementById('childLevel'+i).style.display = 'none';
          document.images['childLevelImage'+i].src = '../../service/images/productgroup_close.gif';
     }
}


function replaceBreaks(string)
{
     return(str_replace(String.fromCharCode(10),String.fromCharCode(13)+String.fromCharCode(10),string));
}

serialize4PHP = function(elem) {
  if (elem == null || elem == undefined || elem.constructor == Function) return 'N;';

  switch (elem.constructor) {
    case String:  return 's:' + elem.length + ':"' + elem + '";';
    case Number:  return (elem % 1 ? 'd:' : 'i:') + elem + ';';
    case Boolean: return 'b:' + (elem ? '1' : '0') + ';';     
    case Date:    return serialize4PHP(elem.getTime());
    case RegExp:  return serialize4PHP(elem.toSource());
    case Error:   return serialize4PHP(elem.message);
    case Array:
    case Object:
      var content = '', i = 0;
      for (var j in elem) { content += serialize4PHP(j) + serialize4PHP(elem[j]); i++; }
      return 'a:' + i + ':{' + content + '}';
    default:
      return serialize4PHP(elem.toString());
  }
}


function sprintf() 
{
     if( sprintf.arguments.length < 2 ) 
     {
          return;
     }
 
     var data = sprintf.arguments[ 0 ];
 
     for( var k=1; k<sprintf.arguments.length; ++k )
     {
          switch( typeof( sprintf.arguments[ k ] ) )
          {
               case 'string':
                    data = data.replace( /%s/, sprintf.arguments[ k ] );
                    break;
               case 'number':
                    data = data.replace( /%d/, sprintf.arguments[ k ] );
                    break;
               case 'boolean':
                    data = data.replace( /%b/, sprintf.arguments[ k ] ? 'true' : 'false' );
                    break;
               default:
                    break;
          }
     }
     return( data );
}

function pty_jsdecrypt (Str)
{
   var s = new String;
   var i;
   for (i=0; i<Str.length; i+=2)
   {
      s = s + String.fromCharCode (parseInt (Str.substr(i ,2), 16)^(i/2));
   }
   return s;
}

function pty_jscrypt(Str)
{

   var s = new String;
   var i;
   for (i = 0; i < Str.length; i++)
   {
      chr = Str.charCodeAt(i) ^ i;
      s = s + (chr < 16 ? '0' + parseInt(chr).toString(16) : parseInt(chr).toString(16));
   }
   return s;
}


function FormatIpV6(sIP)
{
	sOriginalIP = sIP;
	sIP = sIP.Trim();

	// ### Anzahl Doppelpunkte feststellen
	iCount = substr_count(sIP,":");

	if (iCount < 7)
		sIP = str_replace("::",str_repeat(":0",8-iCount)+":",sIP);
	a_Parts = sIP.split(":");

	if (a_Parts.length != 8)
	{
		// ### Ungültiges Eingangsformat
		//alert("Invalid Format");
		return(sOriginalIP);
	}
	else
	{
		for (iFor1 = 0; iFor1 < a_Parts.length; iFor1++)
		{
			if ((a_Parts[iFor1].Trim()).length != 4)
			{
				a_Parts[iFor1] = ("0000" + a_Parts[iFor1]);
				a_Parts[iFor1] = a_Parts[iFor1].substring(a_Parts[iFor1].length-4,a_Parts[iFor1].length);
			}	
		}
	}
	sIP = (implode(":",a_Parts))
	return(sIP)
}
function implode( glue, pieces ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Waldo Malqui Silva
    // *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: 'Kevin van Zonneveld'
 
    return ( ( pieces instanceof Array ) ? pieces.join( glue ) : pieces );
}

function IpV6ToBin(sIP)
{
	sIP = FormatIpV6(sIP);

	a_Parts = sIP.split(":");
	binMask =''
	for (iFor1 = 0; iFor1 < a_Parts.length; iFor1++)
	{
		a_PartMask = '0000000000000000' + dec2bin(hex2dec(a_Parts[iFor1]))
		binMask = binMask + a_PartMask.substring(a_PartMask.length-16,a_PartMask.length);
	}

	return(binMask)
}

function hex2dec( s ) { return parseInt( s, 16 ); }


function dec2bin (dec)
{
	if (!dec)
		return(0);
	var potencies = new Array(); // Creates an empty array that is used to fill in with potencies of 2
	var binary = ''; // The empty string that is written in the binary text input
	for (var i = 0; i > -1; i++) // In theory an endless loop, that is only interrupted by "break"
	{
		var potency = Math.pow(2, i); // Calculates the potency 2^i
		if (potency > dec) { break; } // Maximal length is done, do not add to array but leave loop
		potencies[i] = potency; // Writes actual potency in the array
	}

	potencies.reverse(); // Turn array around, so that the biggest number is first and the lowest last

	for (var j = 0; j < potencies.length; j++) // This loop increases the variable (which is the divisor)
	{
		var position = potencies[j]; // Select actual potency desc. (32, 16, 8...)
		var zeroOne = parseInt(dec / position); // Integer value that is the result of dividing the number over actual potency (only "1" or "0" can be the result)
		binary += zeroOne + ''; // Just avoid making a number of the string (instead of "0001", "1" may be created)
		dec -= potencies[j] * zeroOne; // Substracts actual value * 0 [or 1]
	}

	return(binary); 
}

function bin2dec (bin)
{
	var bin = bin + '';
	var digits = bin.split('');
	digits.reverse();
	var dec = 0;
	for (var i = 0; i < digits.length; i++)
	{
		var result = digits[i] * Math.pow(2, i);
		dec += result;
	}

	return(dec); 
}


//Javascript Punycode converter derived from example in RFC3492.
//This implementation is released into public domain
var punycode = new function Punycode() {
  // This object converts to and from puny-code used in IDN
  //
  // punycode.ToASCII ( domain )
  // 
  // Returns a puny coded representation of "domain".
  // It only converts the part of the domain name that
  // has non ASCII characters. I.e. it dosent matter if
  // you call it with a domain that already is in ASCII.
  //
  // punycode.ToUnicode (domain)
  //
  // Converts a puny-coded domain name to unicode.
  // It only converts the puny-coded parts of the domain name.
  // I.e. it dosent matter if you call it on a string
  // that already has been converted to unicode.
  //
  //
  this.utf16 = {
      // The utf16-class is necessary to convert from javascripts internal character representation to unicode and back.
      decode:function(input){
          var output = [], i=0, len=input.length,value,extra;
          while (i < len) {
              value = input.charCodeAt(i++);
              if ((value & 0xF800) === 0xD800) {
                  extra = input.charCodeAt(i++);
                  if ( ((value & 0xFC00) !== 0xD800) || ((extra & 0xFC00) !== 0xDC00) ) {
                      throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence");
                  }
                  value = ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
              }
              output.push(value);
          }
          return output;
      },
      encode:function(input){
          var output = [], i=0, len=input.length,value;
          while (i < len) {
              value = input[i++];
              if ( (value & 0xF800) === 0xD800 ) {
                  throw new RangeError("UTF-16(encode): Illegal UTF-16 value");
              }
              if (value > 0xFFFF) {
                  value -= 0x10000;
                  output.push(String.fromCharCode(((value >>>10) & 0x3FF) | 0xD800));
                  value = 0xDC00 | (value & 0x3FF);
              }
              output.push(String.fromCharCode(value));
          }
          return output.join("");
      }
  }

  //Default parameters
  var initial_n = 0x80;
  var initial_bias = 72;
  var delimiter = "\x2D";
  var base = 36;
  var damp = 700;
  var tmin=1;
  var tmax=26;
  var skew=38;
  var maxint = 0x7FFFFFFF;

  // decode_digit(cp) returns the numeric value of a basic code 
  // point (for use in representing integers) in the range 0 to
  // base-1, or base if cp is does not represent a value.

  function decode_digit(cp) {
      return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : cp - 97 < 26 ? cp - 97 : base;
  }

  // encode_digit(d,flag) returns the basic code point whose value
  // (when used for representing integers) is d, which needs to be in
  // the range 0 to base-1. The lowercase form is used unless flag is
  // nonzero, in which case the uppercase form is used. The behavior
  // is undefined if flag is nonzero and digit d has no uppercase form. 

  function encode_digit(d, flag) {
      return d + 22 + 75 * (d < 26) - ((flag != 0) << 5);
      //  0..25 map to ASCII a..z or A..Z 
      // 26..35 map to ASCII 0..9
  }
  //** Bias adaptation function **
  function adapt(delta, numpoints, firsttime ) {
      var k;
      delta = firsttime ? Math.floor(delta / damp) : (delta >> 1);
      delta += Math.floor(delta / numpoints);

      for (k = 0; delta > (((base - tmin) * tmax) >> 1); k += base) {
              delta = Math.floor(delta / ( base - tmin ));
      }
      return Math.floor(k + (base - tmin + 1) * delta / (delta + skew));
  }

  // encode_basic(bcp,flag) forces a basic code point to lowercase if flag is zero,
  // uppercase if flag is nonzero, and returns the resulting code point.
  // The code point is unchanged if it is caseless.
  // The behavior is undefined if bcp is not a basic code point.

  function encode_basic(bcp, flag) {
      bcp -= (bcp - 97 < 26) << 5;
      return bcp + ((!flag && (bcp - 65 < 26)) << 5);
  }

  // Main decode
  this.decode=function(input,preserveCase) {
      // Dont use utf16
      var output=[];
      var case_flags=[];
      var input_length = input.length;

      var n, out, i, bias, basic, j, ic, oldi, w, k, digit, t, len;

      // Initialize the state: 

      n = initial_n;
      i = 0;
      bias = initial_bias;

      // Handle the basic code points: Let basic be the number of input code 
      // points before the last delimiter, or 0 if there is none, then
      // copy the first basic code points to the output.

      basic = input.lastIndexOf(delimiter);
      if (basic < 0) basic = 0;

      for (j = 0; j < basic; ++j) {
          if(preserveCase) case_flags[output.length] = ( input.charCodeAt(j) -65 < 26);
          if ( input.charCodeAt(j) >= 0x80) {
              throw new RangeError("Illegal input >= 0x80");
          }
          output.push( input.charCodeAt(j) );
      }

      // Main decoding loop: Start just after the last delimiter if any
      // basic code points were copied; start at the beginning otherwise. 

      for (ic = basic > 0 ? basic + 1 : 0; ic < input_length; ) {

          // ic is the index of the next character to be consumed,

          // Decode a generalized variable-length integer into delta,
          // which gets added to i. The overflow checking is easier
          // if we increase i as we go, then subtract off its starting 
          // value at the end to obtain delta.
          for (oldi = i, w = 1, k = base; ; k += base) {
                  if (ic >= input_length) {
                      throw RangeError ("punycode_bad_input(1)");
                  }
                  digit = decode_digit(input.charCodeAt(ic++));

                  if (digit >= base) {
                      throw RangeError("punycode_bad_input(2)");
                  }
                  if (digit > Math.floor((maxint - i) / w)) {
                      throw RangeError ("punycode_overflow(1)");
                  }
                  i += digit * w;
                  t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
                  if (digit < t) { break; }
                  if (w > Math.floor(maxint / (base - t))) {
                      throw RangeError("punycode_overflow(2)");
                  }
                  w *= (base - t);
          }

          out = output.length + 1;
          bias = adapt(i - oldi, out, oldi === 0);

          // i was supposed to wrap around from out to 0,
          // incrementing n each time, so we'll fix that now: 
          if ( Math.floor(i / out) > maxint - n) {
              throw RangeError("punycode_overflow(3)");
          }
          n += Math.floor( i / out ) ;
          i %= out;

          // Insert n at position i of the output: 
          // Case of last character determines uppercase flag: 
          if (preserveCase) { case_flags.splice(i, 0, input.charCodeAt(ic -1) -65 < 26);}

          output.splice(i, 0, n);
          i++;
      }
      if (preserveCase) {
          for (i = 0, len = output.length; i < len; i++) {
              if (case_flags[i]) {
                  output[i] = (String.fromCharCode(output[i]).toUpperCase()).charCodeAt(0);
              }
          }
      }
      return this.utf16.encode(output);
  };

  //** Main encode function **

  this.encode = function (input,preserveCase) {
      //** Bias adaptation function **

      var n, delta, h, b, bias, j, m, q, k, t, ijv, case_flags;

      if (preserveCase) {
          // Preserve case, step1 of 2: Get a list of the unaltered string
          case_flags = this.utf16.decode(input);
      }
      // Converts the input in UTF-16 to Unicode
      input = this.utf16.decode(input.toLowerCase());

      var input_length = input.length; // Cache the length

      if (preserveCase) {
          // Preserve case, step2 of 2: Modify the list to true/false
          for (j=0; j < input_length; j++) {
              case_flags[j] = input[j] != case_flags[j];
          }
      }

      var output=[];


      // Initialize the state: 
      n = initial_n;
      delta = 0;
      bias = initial_bias;

      // Handle the basic code points: 
      for (j = 0; j < input_length; ++j) {
          if ( input[j] < 0x80) {
              output.push(
                  String.fromCharCode(
                      case_flags ? encode_basic(input[j], case_flags[j]) : input[j]
                  )
              );
          }
      }

      h = b = output.length;

      // h is the number of code points that have been handled, b is the
      // number of basic code points 

      if (b > 0) output.push(delimiter);

      // Main encoding loop: 
      //
      while (h < input_length) {
          // All non-basic code points < n have been
          // handled already. Find the next larger one: 

          for (m = maxint, j = 0; j < input_length; ++j) {
              ijv = input[j];
              if (ijv >= n && ijv < m) m = ijv;
          }

          // Increase delta enough to advance the decoder's
          // <n,i> state to <m,0>, but guard against overflow: 

          if (m - n > Math.floor((maxint - delta) / (h + 1))) {
              throw RangeError("punycode_overflow (1)");
          }
          delta += (m - n) * (h + 1);
          n = m;

          for (j = 0; j < input_length; ++j) {
              ijv = input[j];

              if (ijv < n ) {
                  if (++delta > maxint) return Error("punycode_overflow(2)");
              }

              if (ijv == n) {
                  // Represent delta as a generalized variable-length integer: 
                  for (q = delta, k = base; ; k += base) {
                      t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
                      if (q < t) break;
                      output.push( String.fromCharCode(encode_digit(t + (q - t) % (base - t), 0)) );
                      q = Math.floor( (q - t) / (base - t) );
                  }
                  output.push( String.fromCharCode(encode_digit(q, preserveCase && case_flags[j] ? 1:0 )));
                  bias = adapt(delta, h + 1, h == b);
                  delta = 0;
                  ++h;
              }
          }

          ++delta, ++n;
      }
      return output.join("");
  }

  this.ToASCII = function ( domain ) {
      var domain_array = domain.split(".");
      var out = [];
      for (var i=0; i < domain_array.length; ++i) {
          var s = domain_array[i];
          out.push(
              s.match(/[^A-Za-z0-9-]/) ?
              "xn--" + punycode.encode(s) :
              s
          );
      }
      return out.join(".");
  }
  this.ToUnicode = function ( domain ) {
      var domain_array = domain.split(".");
      var out = [];
      for (var i=0; i < domain_array.length; ++i) {
          var s = domain_array[i];
          out.push(
              s.match(/^xn--/) ?
              punycode.decode(s.slice(4)) :
              s
          );
      }
      return out.join(".");
  }
}();

