var NEUEINTRAGUNG=1;
var AENDERUNG=2;
var EINZELUNTERNEHMEN=1;
var GBR=2;
var OHG=3;
var KG=4;
var GMBHCOKG=5;
var GMBH=6;
var AG=7;
var KGAA=8;
var EK=14;
var von;
var bis;
var JANUAR=1;
var FEBRUAR=2;
var MAERZ=3;
var APRIL=4;
var MAI=5;
var JUNI=6;
var JULI=7;
var AUGUST=8;
var SEPTEMBER=9;
var OKTOBER=10;
var NOVEMBER=11;
var DEZEMBER=12;
var monatsTage = new Array (13);
var wstatus=new Array(20);
var HERR=0;
var FIRMA=2;
var GDBR=3;
var INFO=15;
var DOWNLOAD=16;
var GETPASSWORD=17;
var GETLOGIN=18;
var LOGIN=19;
var eintgrund = new Array(6);
eintgrund[1] = new Array(6);
eintgrund[2] = new Array(5);
eintgrund[5] = new Array(5);
var eintgrundvalue = new Array(6);
eintgrundvalue[1] = new Array(6);
eintgrundvalue[2] = new Array(5);
eintgrundvalue[5] = new Array(5);
eintgrund[1][0]="";
eintgrund[1][1]="Handwerksmeister";
eintgrund[1][2]="Ingenieur";
eintgrund[1][3]="Techniker";
eintgrund[1][4]="Industriemeister";
eintgrund[1][5]="sonstige Prüfungen";
eintgrundvalue[1][0]="-1";
eintgrundvalue[1][1]="710";
eintgrundvalue[1][2]="722";
eintgrundvalue[1][3]="723";
eintgrundvalue[1][4]="724";
eintgrundvalue[1][5]="725";
eintgrund[2][0]="";
eintgrund[2][1]="Inhaber handwerksähnlicher Gewerbe mit Meisterprüfung";
eintgrund[2][2]="Inhaber handwerksähnlicher Gewerbe mit vergleichbarer Prüfung";
eintgrund[2][3]="Inhaber handwerksähnlicher Gewerbe mit Gesellenprüfung";
eintgrund[2][4]="Inhaber handwerksähnlicher Gewerbe ohne Qualifikation";
eintgrundvalue[2][0]="-1";
eintgrundvalue[2][1]="181";
eintgrundvalue[2][2]="182";
eintgrundvalue[2][3]="183";
eintgrundvalue[2][4]="184";
eintgrund[5][0]="";
eintgrund[5][1]="Inhaber zulassungsfreies Handwerk mit Meisterprüfung";
eintgrund[5][2]="Inhaber zulassungsfreies Handwerk mit vergleichbarer Prüfung";
eintgrund[5][3]="Inhaber zulassungsfreies Handwerk mit Gesellenprüfung";
eintgrund[5][4]="Inhaber zulassungsfreies Handwerk ohne Qualifikation";
eintgrundvalue[5][0]="-1";
eintgrundvalue[5][1]="170";
eintgrundvalue[5][2]="171";
eintgrundvalue[5][3]="172";
eintgrundvalue[5][4]="173";

monatsTage[JANUAR]=31;
monatsTage[FEBRUAR]=28;
monatsTage[MAERZ]=31;
monatsTage[APRIL]=30;
monatsTage[MAI]=31;
monatsTage[JUNI]=30;
monatsTage[JULI]=31;
monatsTage[AUGUST]=31;
monatsTage[SEPTEMBER]=30;
monatsTage[OKTOBER]=31;
monatsTage[NOVEMBER]=30;
monatsTage[DEZEMBER]=31;

wstatus[0]='HTO-Start';
wstatus[1]='Angaben zum Betrieb';
wstatus[2]='Personenbezogene Angaben';
wstatus[3]='Allgemeine Angaben';
wstatus[4]='Vertrag';
wstatus[5]='Ausbilder';
wstatus[6]='Beschulungsorte';
wstatus[7]='Datei-Upload';
wstatus[8]='PDF-Dokument';
wstatus[9]='Hilfe';
wstatus[10]='Kalender';
wstatus[11]='Ort suchen';
wstatus[12]='Fachrichtungen anzeigen';
wstatus[13]='Ausbilder anzeigen';
wstatus[14]='Upload starten';
wstatus[15]='Nähere Informationen';
wstatus[16]='Download von Acrobat Reader';
wstatus[17]='Passwort vergessen';
wstatus[18]='Login beantragen';
wstatus[19]='Anmelden';

verberuf = new Array(16);
for (i=0;i<verberuf.length;i++)
{
	verberuf[i] = new Array(3);
}
verberuf[0][0]="Bäcker";
verberuf[0][1]="Konditoren";
verberuf[1][0]="Konditoren";
verberuf[1][1]="Bäcker";
verberuf[2][0]="Informationstechniker";
verberuf[2][1]="Elektrotechniker";
verberuf[3][0]="Elektrotechniker";
verberuf[3][1]="Informationstechniker";
verberuf[3][2]="Elektromaschinenbauer";
verberuf[4][0]="Elektromaschinenbauer";
verberuf[4][1]="Elektrotechniker";
verberuf[5][0]="Kraftfahrzeugtechniker";
verberuf[5][1]="Zweiradmechaniker";
verberuf[6][0]="Zweiradmechaniker";
verberuf[6][1]="Kraftfahrzeugtechniker";
verberuf[7][0]="Landmaschinenmechaniker";
verberuf[7][1]="Metallbauer";
verberuf[7][2]="Feinmechaniker";
verberuf[8][0]="Metallbauer";
verberuf[8][1]="Landmaschinenmechaniker";
verberuf[9][0]="Maler und Lackierer";
verberuf[9][1]="Stuckateur";
verberuf[10][0]="Stuckateur";
verberuf[10][1]="Maler und Lackierer";
verberuf[11][0]="Dachdecker";
verberuf[11][1]="Klempner";
verberuf[12][0]="Klempner";
verberuf[12][1]="Dachdecker";
verberuf[13][0]="Orthopädietechniker";
verberuf[13][1]="Orthopädieschuhmacher";
verberuf[14][0]="Orthopädieschuhmacher";
verberuf[14][1]="Orthopädietechniker";

vwberuf = new Array(20);
for (i=0;i<vwberuf.length;i++)
{
	vwberuf[i] = new Array(3);
}
/*
vwberuf[0][0]="";
vwberuf[0][1]="";
vwberuf[1][0]="";
vwberuf[1][1]="";
vwberuf[2][0]="";
vwberuf[2][1]="";
vwberuf[3][0]="";
vwberuf[3][1]="";
vwberuf[4][0]="";
vwberuf[4][1]="";
vwberuf[5][0]="";
vwberuf[5][1]="";
vwberuf[6][0]="";
vwberuf[6][1]="";
vwberuf[7][0]="";
vwberuf[7][1]="";
vwberuf[8][0]="";
vwberuf[8][1]="";
vwberuf[9][0]="";
vwberuf[9][1]="";
vwberuf[10][0]="";
vwberuf[10][1]="";
vwberuf[11][0]="";
vwberuf[11][1]="";
vwberuf[12][0]="";
vwberuf[12][1]="";
vwberuf[13][0]="";
vwberuf[13][1]="";
vwberuf[14][0]="";
vwberuf[14][1]="";
vwberuf[15][0]="";
vwberuf[15][1]="";
vwberuf[16][0]="";
vwberuf[16][1]="";
vwberuf[17][0]="";
vwberuf[17][1]="";
vwberuf[18][0]="";
vwberuf[18][1]="";
vwberuf[19][0]="";
vwberuf[19][1]="";
*/
vwberuf[0][0]="";
vwberuf[0][1]="";
vwberuf[0][2]="";
vwberuf[1][0]="";
vwberuf[1][1]="";
vwberuf[1][2]="";
vwberuf[2][0]="";
vwberuf[2][1]="";
vwberuf[2][2]="";
vwberuf[3][0]="";
vwberuf[3][1]="";
vwberuf[3][2]="";
vwberuf[4][0]="";
vwberuf[4][1]="";
vwberuf[4][2]="";
vwberuf[5][0]="";
vwberuf[5][1]="";
vwberuf[5][2]="";
vwberuf[6][0]="";
vwberuf[6][1]="";
vwberuf[6][2]="";
vwberuf[7][0]="";
vwberuf[7][1]="";
vwberuf[7][2]="";
vwberuf[8][0]="";
vwberuf[8][1]="";
vwberuf[8][2]="";
vwberuf[9][0]="";
vwberuf[9][1]="";
vwberuf[9][2]="";
vwberuf[10][0]="";
vwberuf[10][1]="";
vwberuf[10][2]="";
vwberuf[11][0]="";
vwberuf[11][1]="";
vwberuf[11][2]="";
vwberuf[12][0]="";
vwberuf[12][1]="";
vwberuf[12][2]="";
vwberuf[13][0]="";
vwberuf[13][1]="";
vwberuf[13][2]="";
vwberuf[14][0]="";
vwberuf[14][1]="";
vwberuf[14][2]="";
vwberuf[15][0]="";
vwberuf[15][1]="";
vwberuf[15][2]="";
vwberuf[16][0]="";
vwberuf[16][1]="";
vwberuf[16][2]="";
vwberuf[17][0]="";
vwberuf[17][1]="";
vwberuf[17][2]="";
vwberuf[18][0]="";
vwberuf[18][1]="";
vwberuf[18][2]="";
vwberuf[19][0]="";
vwberuf[19][1]="";
vwberuf[19][2]="";

function checkLoginAendern (controlUser, controlAlt, controlNeu, controlWh, actionvalue, action)
{
	if (controlUser.value != '')
	{
		if (controlAlt.value != '')
		{
			if ((controlNeu.value != '') && (controlWh.value != ''))			
			{
				if (controlNeu.value != controlAlt.value)
				{
			
					if (controlNeu.value == controlWh.value)
					{
						if (controlNeu.value.length >= 6)
						{
							j=0;
							for (i=0; i<controlNeu.value.length; i++)
							{
								if ((controlNeu.value.charAt(i) >='0') && (controlNeu.value.charAt(i) <= '9'))
								{
									j++;						
								}
							}
							if (j==2)
							{
								setActionValue (actionvalue);
								setAction (action);
							}
							else
							{
								alert ("Ihr Passwort muss zwei Zahlen enthalten !");
							}
						}
						else
						{
							alert ("Sie müssen ein Passwort mit mindestens sechs Zeichen eingeben !");
						}		
					}					
					else
					{
						alert ("Sie müssen Ihr neues Passwort korrekt bestätigen !");
					}
				}
				else
				{
					alert ("Das alte und das neue Passwort müssen sich unterscheiden !");
				}
			}
			else
			{
				alert ("Sie müssen Ihr neues Passwort eingeben und bestätigen !");	
			}
		}
		else
		{
			alert ("Sie müssen Ihr altes Passwort angeben !");
		}
	}
	else
	{
		alert ("Sie müssen Ihren Benutzernamen (E-Mail-Adresse) eingeben !");
	}
}

function openWindow (url)
{
	window.open (url,'','width=360px,height=400px,scrollbars=yes,resizable=yes,left=342px,top=180px');
}

function checkModule (actionvalue, action)
{
	if ((document.frmHandwerksrolle.log_module[0].checked==false) && (document.frmHandwerksrolle.log_module[1].checked==false))
	{
		alert ("Bitte wählen Sie mindestens ein Modul aus !");
	}
	else
	{
		setActionValue(actionvalue);
		setAction(action);
	}
}

function checkAccount (actionvalue, action, frm)
{	
	if (document.frmUser.username.value != '')
	{
		document.frmUser.op.value=actionvalue;
		document.frmUser.action = action;
		document.frmUser.submit ();		
	}
	else
	{
		alert ("Bitte geben Sie eine gültige Email-Adresse ein !");
	}
}

function logFormReset ()
{
	document.frmHandwerksrolle.reset();	
}

function testOverflow ()
{
	if (document.body.clientWidth < 1020)
	{
		document.body.style.overflow='scroll';
	}
	else
	{
		document.body.style.overflow='hidden';
	}	
}

function writeEintgrund (controlBeruf, controlEintgrund, datId)
{
	if ((controlBeruf.selectedIndex != -1) && (controlBeruf.options[controlBeruf.selectedIndex].value != -1)) // Beruf ausgewählt
	{
		// 11010;1 11010;2 11010;5
		value = controlBeruf.options[controlBeruf.selectedIndex].value;
		pos = value.indexOf(';'); 
		c = value.substring(pos+1);	
		if (controlEintgrund.length)
		{
			for (i=0; i<controlEintgrund.length; i++)
			{
				controlEintgrund.options[i]=null;
			}
			for (i=0; i<controlEintgrund.length; i++)
			{
				controlEintgrund.options[i]=null;
			}
			for (i=0; i<controlEintgrund.length; i++)
			{
				controlEintgrund.options[i]=null;
			}						
		}
		if (c != '')
		{
			for (i=0; i<eintgrund[c].length; i++)
			{
				newOption = new Option (eintgrund[c][i], eintgrundvalue[c][i], false, false);			
				controlEintgrund.options[i] = newOption;				
			}
		}		
		controlEintgrund.selectedIndex=0;	
	}
}

function checkQuali (controlEintgrund, datId, ortId)
{	
	if ((controlEintgrund.options[controlEintgrund.selectedIndex].value == '725')||
		(controlEintgrund.options[controlEintgrund.selectedIndex].value == '173')||
		(controlEintgrund.options[controlEintgrund.selectedIndex].value == '184'))
	{
		document.getElementById(datId).style.backgroundColor='#FFFFFF';
		document.getElementById(ortId).style.backgroundColor='#FFFFFF';
	}
	else if (controlEintgrund.options[controlEintgrund.selectedIndex].value == '-1')
	{
		document.getElementById(datId).style.backgroundColor='#FFFFFF';
		document.getElementById(ortId).style.backgroundColor='#FFFFFF';
	}	
	else
	{
		document.getElementById(datId).style.backgroundColor='#D6E3F8';
		document.getElementById(ortId).style.backgroundColor='#D6E3F8';
	}
}

function checkPerBerAuswahl (controlPerBer, actionvalue, action)
{
	if (controlPerBer.selectedIndex != -1)
	{
		setActionValue (actionvalue);
		setAction (action);
	}
}

function makeDatum (control)
{
	// vereinfachte Datumseingabe: 101104 => 10.11.2004
	if (control.value.length>0)
	{
		if (control.value.indexOf(".") == -1) // Angabe darf noch keinen Punkt enthalten
		{
			if ((control.value.length==6) || (control.value.length==8)) // entweder 101104 oder 10112004
			{
				var dd = control.value.substr(0,2);
				var mm = control.value.substr(2,2);
				var yy = control.value.substr(4,4);
				//alert (dd + " " + mm + "  " + yy);
				
				if (isNaN(yy) == false)
				{
					if (yy.length == 2)
					{
						if (parseInt(yy,10) < 20)
						{
							yy = parseInt(2000+parseInt(yy,10),10);					
						}
						else
						{
							yy = parseInt(1900+parseInt(yy,10),10);
						}
					}
					control.value=dd+"."+mm+"."+yy;
				}
			}
			else
			{
				control.focus();
			}
		}
	}
}

function checkRechtsform (control)
{
	/* Ansichtsoptionen:
	 * -default: 			nur Rechtsform sichtbar
	 * -Einzelunternehmen: 	Anrede, Vor- und Nachname sichtbar
	 * -GbR: 				Anrede und Firmenbezeichnung sichtbar
	 * -Rest: 				Anrede, Handelsregistereintrag und Firmenbezeichnung sichtbar
	 */
	if (control.options[control.selectedIndex].value==EINZELUNTERNEHMEN) // Einzelunternehmen
	{		
		with( document )
		{
			// Feld 'Anrede' sichtbar, vorbelegt mit Anrede 'Herr'
			getElementById ('bet_anrede').style.visibility='visible';
			// Felder 'Vor- und Nachname' sichtbar
			getElementById ('bet_name').style.visibility='visible';
			// Felder 'Handelsregister' unsichtbar
			getElementById ('bet_hanreg').style.visibility='hidden';			
			// Feld 'Firmenbezeichnung' unsichtbar
			getElementById ('bet_firma').style.visibility='hidden';

			// Vorbelegungen setzen bzw. wieder löschen
			with( frmHandwerksrolle )
			{
				bet_anr_nr.selectedIndex=HERR;
				bet_anr_bezeich.value='Herr';
				han_reg_nr.value='';
				han_reg_ort.value='';
				bet_nam_vorname.value='';
				bet_nam_name1.value='';
				bet_bezeich.value='';
			}
		}
	}
	else if (control.options[control.selectedIndex].value==GBR) // GbR
	{
		with( document )
		{
			// Feld 'Anrede' sichtbar, vorbelegt mit Anrede 'GbR'
			getElementById ('bet_anrede').style.visibility='visible';
			// Felder 'Vor- und Nachname' unsichtbar
			getElementById ('bet_name').style.visibility='hidden';
			// Felder 'Handelsregister' unsichtbar
			getElementById ('bet_hanreg').style.visibility='hidden';			
			// Feld 'Firmenbezeichnung' sichtbar
			getElementById ('bet_firma').style.visibility='visible';

			// Vorbelegungen setzen bzw. wieder löschen
			with( frmHandwerksrolle )
			{
				bet_anr_nr.selectedIndex=GDBR;
				bet_anr_bezeich.value='GbR';
				han_reg_nr.value='';
				han_reg_ort.value='';
				bet_nam_vorname.value='';
				bet_nam_name1.value='';
				bet_bezeich.value='';
			}
		}				
	}	
	else if (control.options[control.selectedIndex].value>GBR)
	{
		val=control.options[control.selectedIndex].value
		with( document )
		{
			// Feld 'Anrede' sichtbar, vorbelegt mit Anrede 'Firma'
			getElementById ('bet_anrede').style.visibility='visible';
			// Felder 'Vor- und Nachname' unsichtbar
			getElementById ('bet_name').style.visibility='hidden';
			// Felder 'Handelsregister' sichtbar
			getElementById ('bet_hanreg').style.visibility='visible';			
			// Feld 'Firmenbezeichnung' sichtbar
			getElementById ('bet_firma').style.visibility='visible';

			// Vorbelegungen setzen bzw. wieder löschen
			with( frmHandwerksrolle )
			{
				bet_anr_nr.selectedIndex=FIRMA;
				bet_anr_bezeich.value='Firma';
				bet_nam_vorname.value='';
				bet_nam_name1.value='';
				bet_bezeich.value='';				
				if( ( this.val==OHG ) || ( this.val==KG ) || ( this.val==EK ) || ( this.val==GMBHCOKG ) )
				{
					han_reg_nr.value='HRA';					
				}
				else if( ( this.val==AG ) || ( this.val==GMBH ) || ( this.val==KGAA ) )
				{
					han_reg_nr.value='HRB';					
				}
				else
				{
					han_reg_nr.value='';
				}
				han_reg_ort.value='';
			}
		}		
	}

}


function checkHanReg (control)
{
	if ((control.options[control.selectedIndex].text=='Einzelunternehmen')||(control.options[control.selectedIndex].text=='GbR'))
	{
		document.getElementsByName('han_reg_nr')[0].style.backgroundColor='#FFFFFF';
		document.getElementsByName('han_reg_ort')[0].style.backgroundColor='#FFFFFF';
	}
	else
	{
		document.getElementsByName('han_reg_nr')[0].style.backgroundColor='#D6E3F8';
		document.getElementsByName('han_reg_ort')[0].style.backgroundColor='#D6E3F8';
	}
}

function removeFromTo (controlFrom, controlTo, controlMeta)
{
	if (controlFrom.selectedIndex != -1)
	{
		indexFrom=controlFrom.selectedIndex;
		//newOption= new Option(controlFrom.options[indexFrom].text,controlMeta.options[indexFrom].text, false, true);
		//controlTo.options[controlTo.length]=newOption;
		controlFrom.options[indexFrom]=null;
		controlMeta.options[indexFrom]=null;
		controlTo.selectedIndex=0;
	}
}

function copyFromTo (controlFrom, controlTo)
{
	indexFrom = controlFrom.selectedIndex;
	controlTo.value = controlFrom.options[indexFrom].text;
}

function copyFromToText (controlFrom, controlTo, flag)
{
	if (flag == 0)
	{	 
		controlTo.value = controlFrom.value;
	}
	else if (flag == 1)
	{
		if (controlTo.value.length == 0)
		{
			controlTo.value = controlFrom.value;
		}
	}
}

function checkBerGruppenKz (control, controlkz)
{
	// 11010;1 11010;2 11010;5
	value = control.options[control.selectedIndex].value;
	pos = value.indexOf(';'); 
	c = value.substring(pos+1);
	
	//alert(c);
	if (c==1)
	{
		for (i=0; i<document.frmHandwerksrolle.einzelbep_qualiart.options.length; i++)
		{
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].value=0;
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].text="";
		}
		for (i=0; i<eintgrund[c].length; i++)
		{
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].value=eintgrundvalue[c][i];
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].text=eintgrund[c][i];
		}
	}
	else
	{
		for (i=0; i<document.frmHandwerksrolle.einzelbep_qualiart.options.length; i++)
		{
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].value=0;
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].text="";
		}		
		for (i=0; i<eintgrund[c].length; i++)
		{
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].value=eintgrundvalue[c][i];
			document.frmHandwerksrolle.einzelbep_qualiart.option[i].text=eintgrund[c][i];
		}		
		for (i=1;i<11;i++)
		{
			name="ebp"+i;
			document.getElementById(name).style.backgroundColor='#F3F5F7';
		}	
	}
	if ((controlkz.value != c) && (c > 0))
	{
		//alert (controlkz.value + " - "+c);		
		controlkz.value=c;
		//setActionValue(actionvalue);
		//setAction(action);	
	}
	else
	{
		controlkz.value=c;
	}	
}

function checkBerGruppenKzGbp (control, controlkz)
{
	// 11010;1
	value = control.options[control.selectedIndex].value;
	pos = value.indexOf(';'); 
	c = value.substring(pos+1);
	
	//alert(c);
	if (c==1)
	{
		for (i=1;i<11;i++)
		{
			name="ebp"+i;
			document.getElementById(name).style.backgroundColor='#D6E3F8';
		}		
	}
	else
	{
		for (i=1;i<11;i++)
		{
			name="ebp"+i;
			document.getElementById(name).style.backgroundColor='#F3F5F7';
		}	
	}
}

function copyFromTextToSelect (controlFrom, controlTo)
{
	newOption = new Option (controlFrom.value, controlFrom.value, false, true);
	controlTo.options[controlTo.length]=newOption;
}

function selectAll (control)
{
	for (i=0; i<control.length; i++)
	{
		control.options[i].selected=true;
	}
}

function setAction (action)
{
	document.frmHandwerksrolle.action = action;
	document.frmHandwerksrolle.submit ();	
}

function getActionValue (control)
{
	return (control.value=='x');
}

function changeBerufInput ()
{
	if (document.frmHandwerksrolle.gesellschaftbp_per_id.options[document.frmHandwerksrolle.gesellschaftbp_per_id.selectedIndex].value == '-1')
	{		
		document.getElementById ('gbp_ber_dd').style.visibility='visible';
		document.getElementById ('gbp_ber_txt').style.visibility='hidden';	
		document.getElementById ('gbp_kom').style.visibility='visible';	
	}
	else
	{
		document.getElementById ('gbp_ber_dd').style.visibility='hidden';
		document.getElementById ('gbp_ber_txt').style.visibility='visible';			
		document.getElementById ('gbp_kom').style.visibility='hidden';
	}
}

function confirmGesellschaftBp (actionvalue, action)
{
	//if (checkGesellschaftBpPersfunk () == true)
	//{
		var check=confirm ("Wenn Sie für Ihre ausgewählten Berufe alle Betriebsleiter eingetragen haben, klicken Sie auf 'OK'.\nSonst klicken Sie auf 'Abbrechen'.");
		if (check == true)
		{
			setActionValue (actionvalue);		
			setAction (action);
		}
		else
		{
			// do nothing
		}
	//}
	/*else
	{
		alert ("Sie müssen mindestens einen Betriebsleiter eintragen !");
	}*/
}

function checkGesellschaftBpPersfunk ()
{
	if (document.frmHandwerksrolle.gesellschaftbp_persfunk.length<1)
	{
		return false;
	}
	return true;
}

function confirmEinzelbep (actionvalue, action)
{
	
	//if (checkPersfunk () == true)
	//{
		var check=confirm ("Wenn Sie für Ihre ausgewählten Berufe alle Betriebsleiter eingetragen haben, klicken Sie auf 'OK'.\nSonst klicken Sie auf 'Abbrechen'.");
		if (check == true)
		{
			setActionValue (actionvalue);		
			setAction (action);
		}
		else
		{
			// do nothing
		}
	//}
	/*else
	{
		alert ("Sie müssen mindestens einen Betriebsleiter eintragen !");
	}*/
}

function confirmGesellschaftPefu (actionvalue, action)
{
	//if (checkGesellschaftPefuPersfunk () == true)
	//{		
		setActionValue (actionvalue);
		setAction (action);
	//}
	/*else
	{
		alert ("Sie müssen mindestens einen Gesellschafter/Geschäftsführer/Vorstand eintragen !");
	}*/
}

function checkGesellschaftPefuPersfunk ()
{
	if (document.frmHandwerksrolle.gesellschaftpefu_persfunk.length<1)
	{
		return false;
	}
	return true;
}

function checkPersfunk ()
{
	if (document.frmHandwerksrolle.einzelbep_persfunk.length<1)
	{
		return false;
	}
	return true;
}

function checkGpfPersfunkAuswahl (actionvalue, action)
{
	if ((document.frmHandwerksrolle.gesellschaftpefu_persfunk.length<1) || (document.frmHandwerksrolle.gesellschaftpefu_persfunk.selectedIndex==-1))
	{
		alert ("Sie müssen zuerst eine Person auswählen !");
	}
	else
	{
		setActionValue (actionvalue);
		setAction (action);
	}
}

function checkGbpPersfunkAuswahl (actionvalue, action)
{
	if ((document.frmHandwerksrolle.gesellschaftbp_persfunk.length<1) || (document.frmHandwerksrolle.gesellschaftbp_persfunk.selectedIndex==-1))
	{
		alert ("Sie müssen zuerst einen Betriebsleiter auswählen !");
	}
	else
	{
		setActionValue (actionvalue);
		setAction (action);
	}
}

function checkGbpPerIdAuswahl (actionvalue, action)
{
	if (document.frmHandwerksrolle.gesellschaftbp_per_id.value > 0)
	{
		setActionValue (actionvalue);
		setAction (action);
	}
}

function checkPersfunkAuswahl (actionvalue, action)
{
	if ((document.frmHandwerksrolle.einzelbep_persfunk.length<1) || (document.frmHandwerksrolle.einzelbep_persfunk.selectedIndex==-1))
	{
		alert ("Sie müssen zuerst eine Person auswählen !");
	}
	else
	{
		setActionValue (actionvalue);
		setAction (action);
	}
}

function checkPersfunkUpdate (actionvalue, action)
{	
	if (document.frmHandwerksrolle.einzelbep_persfunk_s.value.length < 1)
		{
			alert ("Sie müssen zuerst eine Person auswählen");
		}
		else
		{
			setActionValue (actionvalue);
			setAction (action);
		}
}

function checkGbpPersfunkUpdate (actionvalue, action)
{
	if (document.frmHandwerksrolle.gesellschaftbp_persfunk_s.value.length < 1)
	{
		alert ("Sie müssen zuerst einen Betriebsleiter auswählen");
	}
	else
	{
		setActionValue (actionvalue);
		setAction (action);
	}
}

function setTarget (target) // neues fenster = '_new'; gleiches fenster='_parent'
{
	document.frmHandwerksrolle.target = target;
}

function setActionValue (actionvalue)
{
	document.frmHandwerksrolle.op.value=actionvalue;
}

function deleteActionValue (control)
{
	control.value='';
}

function setStatus (s)
{
	status=wstatus[s];
}

function clearStatus ()
{
	status='';
}

function loeschen (control)
{
	for (i=0; i<control.options.length; i++)
	{
		control.options[i].text="";
		control.options[i].value=0;
		control.selectedIndex=0;
	}
}

function saveValue (source, target)
{		
	target.value = source.options[source.selectedIndex].text;	
	//alert (target.value);
}

function saveSubmit (button)
{
	document.frmHandwerksrolle.submitButton.value = button;
	alert ("saveSubmit: "+button);	
}

function teileEingabeAuf (von, flag)
{	
	if ((flag == VONFLAG) || (flag == BEGINNFLAG))
	{
		tagVon = von.slice (0,2);
		monatVon = von.slice (3,5);
		jahrVon = von.slice (6);
		tagVon=tagVon.replace (/\s/, "");
		monatVon=monatVon.replace (/\s/, "");
		jahrVon=jahrVon.replace (/\s/, "");	
		if (jahrVon.length < 4)
		{
			jahrVon = parseInt(jahrVon,10)+2000;
		}

	}
	else
	{
		tagBis = von.slice (0,2);
		monatBis = von.slice (3,5);
		jahrBis = von.slice (6);
		tagBis=tagBis.replace (/\s/, "");
		monatBis=monatBis.replace(/\s/, "");
		jahrBis=jahrBis.replace (/\s/, "");
		if (jahrBis.length < 4)
		{
			jahrBis = parseInt (jahrBis,10)+2000;
		}
	}	
}

function setSchaltjahr (jahr)
{
	if ((((jahr%4) == 0) && ((jahr%100)!=0)) || ((jahr%400) == 0))
	{
		monatsTage[FEBRUAR]=29;
	}
	else
	{
		monatsTage[FEBRUAR]=28;
	}	
}

function checkDateInput (flag)
{
	var jahr, tag, monat, control;
	if (flag == VONFLAG)
	{		
		tag=tagVon;
		monat=monatVon;
		jahr=jahrVon;
		control = document.frmHandwerksrolle.vha_von;
	}
	else if (flag == BISFLAG)
	{
		tag=tagBis;
		monat=monatBis;
		jahr=jahrBis;				
		control = document.frmHandwerksrolle.vha_bis;
	}		
	else
	{
		tag=tagVon;
		monat=monatVon;
		jahr=jahrVon;
		control = document.frmHandwerksrolle.ved_vbeginn;		
	}
	if ((isNaN (tag)==true) || (isNaN (monat)==true) || (isNaN (jahr)==true))
	{
		alert ("Ungültiges Datumsformat !\nErforderlich: TT.MM.JJJJ !");
		return false;
	}
	else if ((tag <= 0) || (monat <= 0) || (jahr <= 0) || (monat > 12) || (jahr.length < 4))
	{
		alert ("Ungültige Tages-, Monats- oder Jahresangaben !");
		return false;
	}
	else if (tag > monatsTage[parseInt(monat,10)])
	{
		alert ("Tag- und Monatsangabe passen nicht zusammen !");
		return false;
	}
	if (tag.length < 2)
	{
		tag="0"+tag;
	}
	if (monat.length < 2)
	{
		monat="0"+monat;
	}		
	control.value = tag+"."+monat+"."+jahr	
	return true;	
}


function checkEnter (value, control, action)
{
	if (value == 13) // value = window.event.keyCode
	{
		control.value='x';
		setAction (action);
	}
}

function checkLogin (control, action)
{	
	if ((document.frmHandwerksrolle.user.value.length==0) || (document.frmHandwerksrolle.password.value.length==0))
	{
		alert ("Sie müssen einen Benutzernamen UND das zugehörende Passwort eingeben !");
	}
	else
	{
		setActionValue (control);
		setAction (action);
	}
}

function replaceWs (control)
{
	while (control.value.match (/\s/))
	{
		control.value = control.value.replace (/\s/, "");
	}
}

function checkVerwandteHandwerke (control, modus)
{	
	//Ablauf:
	// 1) aus db alle verwandten Handwerke in Array schreiben: 15570 - 15580 - Konditoren
	// Bedeutung: (ber_id Handwerk - ber_id verwandtes Handwerk - Bezeichnung verwandtes Handwerk)
	// 2) ausgwählter Listeneintrag: ber_id:ber_nr;gruppenkennzeichen
	// 3) zu ausgwähltem Listeintrag alle verwandten Handwerke suchen
	// 4) Bezeichnungen der verwandten Handwerke zwischenspeichern
	// 5) bei Bestätigung alle verwandten Handwerke kopieren
	//Array befüllen	
	doVwHwe(document.frmHandwerksrolle.vwhwe);
	var flag=false;
	var msg = "Aufgrund Ihres ausgewählten Berufs haben Sie die Möglichkeit sich zusätzlich für nachstehende Handwerke eintragen zu lassen:\n\n";		
	var verwandteHandwerke=new Array();
	var counter=0;
	var i;	
	temp = control.options[control.selectedIndex].value;//11010:11010;1
	temp = temp.substring(0,5);//ber_id
	for (i=0; i<vwberuf.length; i++)
	{		
		if (vwberuf[i][0] == temp)
		{			
			var j=1;
			flag=true;			
			msg += "\t\t" + vwberuf[i][2] + "\n"; 
			verwandteHandwerke[counter++]=vwberuf[i][2];						
		}
	}
	if( modus==NEUEINTRAGUNG )
	{
		addFromTo(document.frmHandwerksrolle.gewerbe, document.frmHandwerksrolle.gewerbe_auswahl, document.frmHandwerksrolle.gewerbe_auswahl_ber_nr);
	}
	else if( modus==AENDERUNG )
	{
		addFromTo(document.frmHandwerksrolle.gewerbe, document.frmHandwerksrolle.aen_gewerbe_auswahl, document.frmHandwerksrolle.aen_gewerbe_auswahl_ber_nr);
	}
	if (flag == true)
	{
		if (confirm (msg) == true)
		{
			copyVerwandteHandwerke ( verwandteHandwerke, modus );
		}
	}
}

function addFromTo (controlFrom, controlTo, controlMeta)
{
	found=false; 	
	// Nummer des ausgewählten Elements
	indexFrom = controlFrom.selectedIndex;	
	
	// Mehrfacheintragungen ausschließen
	for (i=0; i<controlTo.length; i++)
	{
		if (controlTo.options[i].text == controlFrom.options[indexFrom].text)
		{
			found=true;
		}
	}	
	if (found == false)
	{
		// Neues Feld (text, value);
		newOption = new Option (controlFrom.options[indexFrom].text, controlFrom.options[indexFrom].text, false, true);
		controlTo.options[controlTo.length] = newOption;
		// in unsichtbarem Feld Nummern zu Texten in controlTo speichern
		newOption = new Option (controlFrom.options[indexFrom].value, controlFrom.options[indexFrom].value, false, true);
		controlMeta.options[controlMeta.length]=newOption;
		// gewähltes Element in controlFrom löschen
		//controlFrom.options[indexFrom]=null;
		controlFrom.selectedIndex=0;
	}	
}

function copyVerwandteHandwerke( berufe, modus )
{				
	//Ablauf
	// 1) Eingabefelder bestimmen in Abhängigkeit von Neueintragung oder Änderungsdienst
	// 2) zu jedem verwandten Handwerk in berufe den entsprechenden Listeneitrag finden, kopieren
	var i, j;
	var controlFrom, controlTo, controlMeta;
	if( modus==NEUEINTRAGUNG )
	{
		controlFrom=document.frmHandwerksrolle.gewerbe; 
		controlTo=document.frmHandwerksrolle.gewerbe_auswahl;
		controlMeta=document.frmHandwerksrolle.gewerbe_auswahl_ber_nr; 		
	}
	else if( modus==AENDERUNG )
	{
		controlFrom=document.frmHandwerksrolle.gewerbe;
		controlTo=document.frmHandwerksrolle.aen_gewerbe_auswahl; 
		controlMeta=document.frmHandwerksrolle.aen_gewerbe_auswahl_ber_nr;		
	}
	
	for( i=0; i<berufe.length; i++ )
	{		
		for( j=0; j<controlFrom.options.length; j++ )
		{
			if( berufe[i]==controlFrom.options[j].text )
			{
				controlFrom.selectedIndex=j;
				addFromTo(controlFrom, controlTo, controlMeta);
			}
		}	
	}
}

function doVwHwe(control){
	var hw = '';

	for (i=0; i<control.length; i++)
	{
		//hw = control.options[i].text.split('/');
		hw = control.options[i].text;
		vwberuf[i][0] = hw.substring(0,5);
		vwberuf[i][1] = hw.substring(6,11);
		vwberuf[i][2] = hw.substring(12);
		//alert(vwberuf[i][0]+" - "+vwberuf[i][1]+" - "+vwberuf[i][2]);
	}
}

function wopen (control)
{	
	var flag=false;
	for (i=0; i<verberuf.length; i++)
	{
		if (verberuf[i][0] == control.options[control.selectedIndex].text)
		{			
			flag=true;
		}
	}
	if (flag == true)
	{		
		f=window.open ("/hto/view/hrolle/verlauf.html","fenster","width=450px,height=200px,left=437px,top=390px,status=no,menubar=no,scrollbars=no");	
		f.document.open ();
		f.document.write ("<html><head><title>Verwandte Handwerke</title><link rel=\"stylesheet\" href=\"/hto/css/hrolle/help.css\" type=\"text/css\"></link></head><body>");
		f.document.write ("<table class=\"tabelle\" cellpadding=\"0\" cellspacing=\"0\">");
		f.document.write ("<tr><td class=\"table_head\">Verwandte Handwerke</td></tr>");
		f.document.write ("<tr><td class=\"td_spacer\">&#160;</td></tr>");
		f.document.write ("<tr><td class=\"input_title\">Sie können sich zusätzlich für folgende verwandte Handwerke eintragen:</td></tr>");			
		f.document.write ("<tr><td class=\"input_td\"><ul>");
		for (i=0; i<verberuf.length; i++)
		{
			if (verberuf[i][0] == control.options[control.selectedIndex].text)
			{			
				f.document.write ("<li>"+verberuf[i][1]+"</li>");	
			}
		}					
		f.document.writeln ("</ul></td></tr></table");
		f.document.writeln ("<br/>");
		f.document.write ("<p align=\"center\"><a href=\"javascript:window.close()\">Fenster schlie&szlig;en</a></p>");
		f.document.write ("</body></html>");
		f.document.close ();		
	}
}

function persoenlichLoeschen ()
{
	document.frmHandwerksrolle.einzelbep_anr_nr.selectedIndex=0;
	document.frmHandwerksrolle.einzelbep_nam_bertitel.value="";
	document.frmHandwerksrolle.einzelbep_nam_vorname.value="";
	document.frmHandwerksrolle.einzelbep_nam_name1.value="";
	document.frmHandwerksrolle.einzelbep_per_gebdat.value="";
	document.frmHandwerksrolle.einzelbep_per_gebort.value="";
	document.frmHandwerksrolle.einzelbep_sta_nr.selectedIndex=0;
	document.frmHandwerksrolle.einzelbep_per_gebname.value="";
	document.frmHandwerksrolle.einzelbep_ans_strasse.value="";
	document.frmHandwerksrolle.einzelbep_ans_hausnr.value="";
	document.frmHandwerksrolle.einzelbep_ans_plz.value="";
	document.frmHandwerksrolle.einzelbep_ans_ort.value="";
	document.frmHandwerksrolle.einzelbep_land_kz.selectedIndex=0;
	document.frmHandwerksrolle.einzelbep_telvorwahl.value="";
	document.frmHandwerksrolle.einzelbep_telnummer.value="";
	document.frmHandwerksrolle.einzelbep_faxvorwahl.value="";
	document.frmHandwerksrolle.einzelbep_faxnummer.value="";
	document.frmHandwerksrolle.einzelbep_mobilvorwahl.value="";
	document.frmHandwerksrolle.einzelbep_mobilnummer.value="";
	document.frmHandwerksrolle.einzelbep_email.value="";	
}

function persoenlichLoeschenAendern()
{
	document.frmHandwerksrolle.aen_anr_nr.selectedIndex=0;
	document.frmHandwerksrolle.aen_nam_bertitel.value="";
	document.frmHandwerksrolle.aen_nam_vorname.value="";
	document.frmHandwerksrolle.aen_nam_name1.value="";
	document.frmHandwerksrolle.aen_per_gebdat.value="";
	document.frmHandwerksrolle.aen_per_gebort.value="";
	document.frmHandwerksrolle.aen_sta_nr.selectedIndex=0;
	document.frmHandwerksrolle.aen_per_gebname.value="";
	document.frmHandwerksrolle.aen_ans_strasse.value="";
	document.frmHandwerksrolle.aen_ans_hausnr.value="";
	document.frmHandwerksrolle.aen_ans_plz.value="";
	document.frmHandwerksrolle.aen_ans_ort.value="";
	document.frmHandwerksrolle.aen_telvorwahl.value="";
	document.frmHandwerksrolle.aen_telnummer.value="";
	document.frmHandwerksrolle.aen_faxvorwahl.value="";
	document.frmHandwerksrolle.aen_faxnummer.value="";
	document.frmHandwerksrolle.aen_mobilvorwahl.value="";
	document.frmHandwerksrolle.aen_mobilnummer.value="";
	document.frmHandwerksrolle.aen_email.value="";	
}

function gesellschaftBpLoeschen ()
{
	//document.frmHandwerksrolle.gesellschaftbp_ber_nr.selectedIndex=0;
	//document.frmHandwerksrolle.gesellschaftbp_beruf.value="";
	//document.frmHandwerksrolle.gesellschaftbp_qualiart.selectedIndex=0;
	//document.frmHandwerksrolle.gesellschaftbp_qualidatum.value="";
	//document.frmHandwerksrolle.gesellschaftbp_qualiort.selectedIndex=0;
	//document.frmHandwerksrolle.gesellschaftbp_gruppenkz.value="";
	//document.frmHandwerksrolle.gesellschaftbp_per_id_s.value="";
	document.frmHandwerksrolle.gesellschaftbp_anr_nr.selectedIndex=0;
	document.frmHandwerksrolle.gesellschaftbp_nam_bertitel.value="";
	document.frmHandwerksrolle.gesellschaftbp_nam_vorname.value="";
	document.frmHandwerksrolle.gesellschaftbp_nam_name1.value="";
	document.frmHandwerksrolle.gesellschaftbp_per_gebdat.value="";
	document.frmHandwerksrolle.gesellschaftbp_per_gebort.value="";
	document.frmHandwerksrolle.gesellschaftbp_per_gebname.value="";
	//document.frmHandwerksrolle.gesellschaftbp_bl_suchen.value="";
	document.frmHandwerksrolle.gesellschaftbp_sta_nr.selectedIndex=0;
	document.frmHandwerksrolle.gesellschaftbp_ans_strasse.value="";
	document.frmHandwerksrolle.gesellschaftbp_ans_hausnr.value="";
	document.frmHandwerksrolle.gesellschaftbp_ans_plz.value="";
	document.frmHandwerksrolle.gesellschaftbp_ans_ort.value="";
	document.frmHandwerksrolle.gesellschaftbp_land_kz.selectedIndex=0;
	document.frmHandwerksrolle.gesellschaftbp_telvorwahl.value="";
	document.frmHandwerksrolle.gesellschaftbp_telnummer.value="";
	document.frmHandwerksrolle.gesellschaftbp_faxvorwahl.value="";
	document.frmHandwerksrolle.gesellschaftbp_faxnummer.value="";
	document.frmHandwerksrolle.gesellschaftbp_mobilvorwahl.value="";
	document.frmHandwerksrolle.gesellschaftbp_mobilnummer.value="";
	document.frmHandwerksrolle.gesellschaftbp_email.value="";
	document.frmHandwerksrolle.gesellschaftbp_persfunk_s.value="";
}

function gesellschaftBpAenLoeschen ()
{
	document.frmHandwerksrolle.aen_anr_nr.selectedIndex=0;
	document.frmHandwerksrolle.aen_nam_bertitel.value="";
	document.frmHandwerksrolle.aen_nam_vorname.value="";
	document.frmHandwerksrolle.aen_nam_name1.value="";
	document.frmHandwerksrolle.aen_per_gebdat.value="";
	document.frmHandwerksrolle.aen_per_gebort.value="";
	document.frmHandwerksrolle.aen_per_gebname.value="";
	document.frmHandwerksrolle.aen_sta_nr.selectedIndex=0;
	document.frmHandwerksrolle.aen_ans_strasse.value="";
	document.frmHandwerksrolle.aen_ans_hausnr.value="";
	document.frmHandwerksrolle.aen_ans_plz.value="";
	document.frmHandwerksrolle.aen_ans_ort.value="";
	document.frmHandwerksrolle.aen_telvorwahl.value="";
	document.frmHandwerksrolle.aen_telnummer.value="";
	document.frmHandwerksrolle.aen_faxvorwahl.value="";
	document.frmHandwerksrolle.aen_faxnummer.value="";
	document.frmHandwerksrolle.aen_mobilvorwahl.value="";
	document.frmHandwerksrolle.aen_mobilnummer.value="";
	document.frmHandwerksrolle.aen_email.value="";
	//document.frmHandwerksrolle.aen_persfunk_s.value="";
}

function eintgrundLoeschen ()
{
	//document.frmHandwerksrolle.gesellschaftbp_ber_nr.selectedIndex=0;
	//document.frmHandwerksrolle.gesellschaftbp_beruf.value="";
	document.frmHandwerksrolle.gesellschaftbp_qualiart.selectedIndex=0;
	document.frmHandwerksrolle.gesellschaftbp_qualidatum.value="";
	document.frmHandwerksrolle.gesellschaftbp_qualiort.value="";
}

function checkGeschlecht (controlAnr, controlGes)
{
	if (controlAnr.options[controlAnr.selectedIndex].value==1)
	{
		controlGes[0].checked=true;		
	}								
	else
	{
		controlGes[1].checked=true;
	}											
}

function checkPersoenlich(id,flag)
{
	if (id == 'ebp')
	{
		if (document.frmHandwerksrolle.einzelbep_leitung_flag[0].checked==true)
		{
			makePersoenlich(id,flag);
		}
	}
}

function checkPersoenlichAendern(id)
{
	if (id == 'ebp')
	{
		if (document.frmHandwerksrolle.aen_leitung_flag[0].checked==true)
		{
			makePersoenlichAendern(id);
		}
	}
}

function blurPersonAendern (control) // Gesellschaft: Persondendaten Gesellschafter<->Betriebsleiter unveränderlich
{
	if (document.frmHandwerksrolle.aen_per_id.options[document.frmHandwerksrolle.aen_per_id.selectedIndex].value != -1)
	{
		if (control.name=='aen_anr_nr')
		{
			for (i=0; i<control.length; i++)
			{
				if (control.options[i].value==document.frmHandwerksrolle.tmp_pers_anr.value)
				{
					control.options[i].selected=true;
				}
			}
		}
		else if (control.name=='aen_sta_nr')
		{
			for (i=0; i<control.length; i++)
			{
				if (control.options[i].value==document.frmHandwerksrolle.tmp_pers_sta.value)
				{
					control.options[i].selected=true;
				}
			}
		}
		else
		{
			control.blur();
		}
	}
}

function blurPerson (control) // Gesellschaft: Persondendaten Gesellschafter<->Betriebsleiter unveränderlich
{
	if (document.frmHandwerksrolle.gesellschaftbp_per_id.options[document.frmHandwerksrolle.gesellschaftbp_per_id.selectedIndex].value != -1)
	{
		if (control.name=='gesellschaftbp_anr_nr')
		{
			for (i=0; i<control.length; i++)
			{
				if (control.options[i].value==document.frmHandwerksrolle.tmp_pers_anr.value)
				{
					control.options[i].selected=true;
				}
			}
		}
		else if (control.name=='gesellschaftbp_sta_nr')
		{
			for (i=0; i<control.length; i++)
			{
				if (control.options[i].value==document.frmHandwerksrolle.tmp_pers_sta.value)
				{
					control.options[i].selected=true;
				}
			}
		}
		else
		{
			control.blur();
		}
	}
}

function blurPersoenlich (control) // Einzelunternehmen: Personendaten Betriebsinhaber<->Betriebsleiter unveränderlich
{
	if (document.frmHandwerksrolle.einzelbep_leitung_flag[0].checked==true)
	{
		if (control.name=='einzelbep_anr_nr')
		{
			if (control.options[control.selectedIndex].text != document.frmHandwerksrolle.tmp_einzelbep_anr_bezeich.value)
			{		
				for (i=0; i<document.frmHandwerksrolle.einzelbep_anr_nr.length; i++)
				{
					if (control.options[i].text==document.frmHandwerksrolle.tmp_einzelbep_anr_bezeich.value)
					{
						control.options[i].selected=true;
					}
				}
			}
		}
		else if (control.name=='einzelbep_per_ges_kz')
		{
			if (document.frmHandwerksrolle.tmp_einzelbep_per_ges_kz.value=='M')
			{
				document.frmHandwerksrolle.einzelbep_per_ges_kz[0].checked=true;
			}
			else
			{
				document.frmHandwerksrolle.einzelbep_per_ges_kz[1].checked=true;
			}
		}
		else if (control.name=='einzelbep_sta_nr')
		{
			if (control.options[control.selectedIndex].text != document.frmHandwerksrolle.tmp_einzelbep_sta_land.value)
			{		
				for (i=0; i<document.frmHandwerksrolle.einzelbep_sta_nr.length; i++)
				{
					if (control.options[i].text==document.frmHandwerksrolle.tmp_einzelbep_sta_land.value)
					{
						control.options[i].selected=true;
					}
				}
			}			
		}
		else
		{
			control.blur();
		}		
		
	}
}

function blurPersoenlichAendern(control)
{
	if (document.frmHandwerksrolle.aen_leitung_flag[0].checked==true)
	{
		if (control.name=='aen_anr_nr')
		{
			if (control.options[control.selectedIndex].text != document.frmHandwerksrolle.tmp_einzelbep_anr_bezeich.value)
			{		
				for (i=0; i<control.length; i++)
				{
					if (control.options[i].text==document.frmHandwerksrolle.tmp_einzelbep_anr_bezeich.value)
					{
						control.options[i].selected=true;
					}
				}
			}
		}
		else if (control.name=='aen_sta_nr')
		{
			if (control.options[control.selectedIndex].text != document.frmHandwerksrolle.tmp_einzelbep_sta_land.value)
			{		
				for (i=0; i<control.length; i++)
				{
					if (control.options[i].text==document.frmHandwerksrolle.tmp_einzelbep_sta_land.value)
					{
						control.options[i].selected=true;
					}
				}
			}			
		}
		else
		{
			control.blur();
		}		
		
	}
}

function blurAllgemein(control)
{	
	if (document.frmHandwerksrolle.aenalg[1].checked==true)
	{
		if (control.name=="aen_bio_org_id")
		{
			if (document.frmHandwerksrolle.tmp_alg_ihk.value=='')
			{
				control.selectedIndex=0;
			}
			else
			{		
				for (i=0; i<control.length; i++)
				{
					if (control.options[i].value==document.frmHandwerksrolle.tmp_alg_ihk.value)
					{
						control.options[i].selected=true;
					}
				}
			}
		}
		else if (control.name=="aen_leb_ausbldkz")
		{
			if (document.frmHandwerksrolle.tmp_alg_ausbldkz.value=='')
			{
				control.selectedIndex=0;
			}
			else
			{
				for (i=0; i<control.length; i++)
				{
					if (control.options[i].value==document.frmHandwerksrolle.tmp_alg_ausbldkz.value)
					{
						control.options[i].selected=true;
					}
				}
			}			
		}
		else if (control.name=="aen_bet_dskz")
		{
			if (document.frmHandwerksrolle.tmp_alg_dskz.value=='')
			{
				control.selectedIndex=0;				
			}
			else
			{
				for (i=0; i<control.length; i++)
				{
					if (control.options[i].value==document.frmHandwerksrolle.tmp_alg_dskz.value)
					{
						control.options[i].selected=true;
					}
				}
			}			
		}
		else
		{
			control.blur();
		}
	}	
}

function makePersoenlich (id,flag)
{
	if (id == 'ebp') // Formular einzelbep
	{			
		for (i=0; i<document.frmHandwerksrolle.einzelbep_anr_nr.options.length; i++)
		{
			if (document.frmHandwerksrolle.einzelbep_anr_nr.options[i].text == document.frmHandwerksrolle.tmp_einzelbep_anr_bezeich.value)
			{
				document.frmHandwerksrolle.einzelbep_anr_nr.options[i].selected=true;
			}
		}
		document.frmHandwerksrolle.einzelbep_nam_vorname.value = document.frmHandwerksrolle.tmp_einzelbep_nam_vorname.value;
		document.frmHandwerksrolle.einzelbep_nam_name1.value = document.frmHandwerksrolle.tmp_einzelbep_nam_name1.value;
		document.frmHandwerksrolle.einzelbep_per_gebdat.value = document.frmHandwerksrolle.tmp_einzelbep_per_gebdat.value;
		document.frmHandwerksrolle.einzelbep_per_gebort.value = document.frmHandwerksrolle.tmp_einzelbep_per_gebort.value;
		for (i=0; i<document.frmHandwerksrolle.einzelbep_sta_nr.options.length; i++)
		{
			if (document.frmHandwerksrolle.einzelbep_sta_nr.options[i].text == document.frmHandwerksrolle.tmp_einzelbep_sta_land.value)
			{
				document.frmHandwerksrolle.einzelbep_sta_nr.options[i].selected=true;
			}
		}
		document.frmHandwerksrolle.einzelbep_nam_bertitel.value = document.frmHandwerksrolle.tmp_einzelbep_nam_bertitel.value;
		document.frmHandwerksrolle.einzelbep_per_gebname.value = document.frmHandwerksrolle.tmp_einzelbep_per_gebname.value;	
		if (document.frmHandwerksrolle.tmp_einzelbep_per_ges_kz.value=='M')
		{
			document.frmHandwerksrolle.einzelbep_per_ges_kz[0].checked=true;
		}
		else
		{
			document.frmHandwerksrolle.einzelbep_per_ges_kz[1].checked=true;
		}
		document.frmHandwerksrolle.einzelbep_ans_strasse.value = document.frmHandwerksrolle.tmp_einzelbep_ans_strasse.value;
		document.frmHandwerksrolle.einzelbep_ans_hausnr.value = document.frmHandwerksrolle.tmp_einzelbep_ans_hausnr.value;
		document.frmHandwerksrolle.einzelbep_ans_plz.value = document.frmHandwerksrolle.tmp_einzelbep_ans_plz.value;
		for( i=0; i<document.frmHandwerksrolle.einzelbep_land_kz.options.length; i++)
		{
			if( document.frmHandwerksrolle.einzelbep_land_kz.options[i].value == document.frmHandwerksrolle.tmp_einzelbep_land_kz.value )
			{
				document.frmHandwerksrolle.einzelbep_land_kz.options[i].selected=true;
			}
		}
		document.frmHandwerksrolle.einzelbep_ans_ort.value = document.frmHandwerksrolle.tmp_einzelbep_ans_ort.value;
		if( flag=='kom' )
		{
			document.frmHandwerksrolle.einzelbep_telvorwahl.value = document.frmHandwerksrolle.tmp_einzelbep_telvorwahl.value;
			document.frmHandwerksrolle.einzelbep_telnummer.value = document.frmHandwerksrolle.tmp_einzelbep_telnummer.value;
			document.frmHandwerksrolle.einzelbep_faxvorwahl.value = document.frmHandwerksrolle.tmp_einzelbep_faxvorwahl.value;
			document.frmHandwerksrolle.einzelbep_faxnummer.value = document.frmHandwerksrolle.tmp_einzelbep_faxnummer.value;
			document.frmHandwerksrolle.einzelbep_mobilvorwahl.value = document.frmHandwerksrolle.tmp_einzelbep_mobilvorwahl.value;
			document.frmHandwerksrolle.einzelbep_mobilnummer.value = document.frmHandwerksrolle.tmp_einzelbep_mobilnummer.value;
			document.frmHandwerksrolle.einzelbep_email.value = document.frmHandwerksrolle.tmp_einzelbep_email.value;
		}
	}
}

function makePersoenlichAendern (id)
{
	if (id == 'ebp') // Formular einzelbep
	{			
		for (i=0; i<document.frmHandwerksrolle.aen_anr_nr.options.length; i++)
		{
			if (document.frmHandwerksrolle.aen_anr_nr.options[i].text == document.frmHandwerksrolle.tmp_einzelbep_anr_bezeich.value)
			{
				document.frmHandwerksrolle.aen_anr_nr.options[i].selected=true;
			}
		}
		document.frmHandwerksrolle.aen_nam_vorname.value = document.frmHandwerksrolle.tmp_einzelbep_nam_vorname.value;
		document.frmHandwerksrolle.aen_nam_name1.value = document.frmHandwerksrolle.tmp_einzelbep_nam_name1.value;
		document.frmHandwerksrolle.aen_per_gebdat.value = document.frmHandwerksrolle.tmp_einzelbep_per_gebdat.value;
		document.frmHandwerksrolle.aen_per_gebort.value = document.frmHandwerksrolle.tmp_einzelbep_per_gebort.value;
		for (i=0; i<document.frmHandwerksrolle.aen_sta_nr.options.length; i++)
		{
			if (document.frmHandwerksrolle.aen_sta_nr.options[i].text == document.frmHandwerksrolle.tmp_einzelbep_sta_land.value)
			{
				document.frmHandwerksrolle.aen_sta_nr.options[i].selected=true;
			}
		}
		document.frmHandwerksrolle.aen_nam_bertitel.value = document.frmHandwerksrolle.tmp_einzelbep_nam_bertitel.value;
		document.frmHandwerksrolle.aen_per_gebname.value = document.frmHandwerksrolle.tmp_einzelbep_per_gebname.value;	
		if (document.frmHandwerksrolle.tmp_einzelbep_per_ges_kz.value=='M')
		{
			document.frmHandwerksrolle.aen_per_ges_kz[0].checked=true;
		}
		else
		{
			document.frmHandwerksrolle.aen_per_ges_kz[1].checked=true;
		}		
	}
}

function putFiliale (bet_id)
{
	document.frmHandwerksrolle.bet_fil_id.value=bet_id;
}

function showTable (id)
{
	document.getElementById (id).style.visibility='visible';
}

function hideTable (id)
{
	document.getElementById (id).style.visibility='hidden';
}

function setChangeModus (s)
{
	document.frmHandwerksrolle.chg_modus.value = s;
}

function getChangeModus()
{
	return document.frmHandwerksrolle.chg_modus.value;
}

function checkPersfunkAendern (control, actionvalue, action)
{
	if (control)
	{
		if (control.length)
		{				
			for (i=0; i<control.length; i++)
			{
				if (control[i].checked==true)
				{
					setActionValue(actionvalue);
					setAction(action);
				}
			}
		}
		else 
		{
			if (control.checked==true)
			{
				setActionValue(actionvalue);
				setAction(action);			
			}
		}
	}
}

function checkDsk()
{
	document.getElementById ('content_dsk').style.visibility='hidden';
	document.getElementById ('verlauf_dsk').style.visibility='hidden';
	document.getElementById ('content_dsko').style.visibility='hidden';
	document.getElementById ('hinweis').style.visibility='visible';	
}

/*function checkDsk (control)
{
	if (control[0].checked==true)
	{
		//setActionValue(actionvalue);
		//setAction(action);
		document.getElementById ('content_dsk').style.visibility='hidden';
		document.getElementById ('verlauf_dsk').style.visibility='hidden';
		document.getElementById ('content_dsko').style.visibility='hidden';
		document.getElementById ('hinweis').style.visibility='visible';		
	}
	else
	{
		alert ("Damit Ihre Daten gespeichert werden können, müssen Sie die Datenschutzbestimmungen akzeptieren !");
	}
}*/

function checkExigruend (control)
{
	if (control.value==4)
	{
		document.getElementById('riRolleHwk').style.backgroundColor='#D6E3F8';
		document.getElementById('riRolleV').style.backgroundColor='#D6E3F8';
		document.getElementById('riRolleB').style.backgroundColor='#D6E3F8';
	}
	else
	{
		document.getElementById('riRolleHwk').style.backgroundColor='#FFFFFF';
		document.getElementById('riRolleV').style.backgroundColor='#FFFFFF';
		document.getElementById('riRolleB').style.backgroundColor='#FFFFFF';	
	}
}

function checkBank (controlBlz, controlKnr, actionvalue, action)
{
	//alert ("BLZ: " + controlBlz.value + "\nKonto: "+controlKnr.value);
	if ((controlBlz.value > 9999999) && (controlKnr.value > 0))
	{
		setActionValue(actionvalue);
		setAction(action);
	}
}

function checkAenderung (aendercontrol, metacontrol, actionvalue, action)
{
	if (aendercontrol.value != metacontrol.value)
	{
		setActionValue(actionvalue);
		setAction(action);
	}
}

function setFileValue (filecontrol, targetcontrol, filevalue, dokutype, actionvalue, action)
{	
	if (filecontrol.value.length>0)
	{
		targetcontrol.value = filevalue;
		document.frmHandwerksrolle.dokutype.value=dokutype;
		setActionValue (actionvalue);
		setAction (action);
	}
}

function setHomeLocation( href )
{
	window.location.href=href;	
}

function toggleVisibility( id )
{
	document.getElementById( id ).style.visibility=(document.getElementById( id ).style.visibility=='hidden')?'visible':'hidden';
}

function copyCheckBoxValue( from, to )
{
	to.value=( from.checked )?'0':'1';	
}

function checkSelectValue( control, value )
{	
	for(i=0; i<control.options.length; i++ )
	{
		if( control.options[i].value==value )
		{			
			control.options[i].selected=true;
			break;
		}
	}
}