		function clearAllInputFields(){
		 theForm = document.forms[0];
		 if (theForm) 
		    {
		     theForm.reset();
		     theForm["idx"].value="-1";
		     for (i = 0 ; i < theForm.length; i++)
		         {
		 	      if (theForm[i].className.toLowerCase().indexOf("textinputfield")>-1) theForm[i].value="";
		 	     } 
		 	}    
        }

		function resetImageData(){
		 theForm = document.forms[0];
		 if (theForm) 
		    {
		     theForm["Foto.originalW"].value = "";
		     theForm["Foto.originalH"].value = "";
		     theForm["Foto.neuW"].value = "";
		     theForm["Foto.neuH"].value = "";
		     theForm["Foto.CropX"].value = "";
		     theForm["Foto.CropY"].value = "";
		     theForm["Foto.AspectW"].value = "";
		     theForm["Foto.AspectH"].value = "";
		     theForm["Foto.Aspect"].value = "";
		     
		    }
		}    


        function init(){

        }

        function previewVCard(){
          if (arguments.length == 0)
          url = "/BSB/servlet/bsb.ShowVCard?action.ShowCard=true&idx="+document.forms[0].idx.value;
          else url = "/BSB/servlet/bsb.ShowVCard?action.ShowCard=true&idx="+arguments[0];
          previewWin = window.open(url, "previewWin", "width=600,height=630");
          previewWin.focus();
        }


        function showContactCard(){
          url = "";
          contactWin = window.open(url, "contactWin", "width=490,height=440");
		  document.forms[0].submit();
          contactWin.focus();
        }

        submitMe = false;      
        checkInput = true;
        
        function checkSubmit(form){
         if (submitMe && checkInput && !checkInputFields(form)) return false;
         return submitMe;
        }

        function checkInputFields(form){
         for (i=0; i<form.length;i++)
             {
              theField = form[i];
              theFieldValue = theField.value;
              theFieldName = theField.name;
              if (theField.id)
                 {
                  theFieldCheck = theField.id;
                  if (theFieldCheck.indexOf("(this)")>-1)
                    {
                     // Funktion
                     theFieldCheck = theFieldCheck.replace(/(this)/,"(theFieldValue)");
                     eval ("theFieldCheckResult = "+theFieldCheck);
                     if (!theFieldCheckResult) 
                        {
                         theField.focus();
                         return false;
                        } 
                    }
                    else
                    {
                     // Methode / Eigenschaft
                     eval ("theFieldCheckResult = theFieldValue."+theFieldCheck);
                     if (!theFieldCheckResult) 
                        {
                         alert ("Das Eingabefeld '"+theFieldName+"' darf nicht leer sein...");
                         theField.focus();
                         return false;
                        } 
                    }
                 }
             } //for
		 return true;   
		} 
		
		function isEmail(em){
		 if (checkEmailSyntax(em)) return true;
		 else 
		  alert ("Bitte geben Sie eine korrekte Email-Adresse an...");
		 return false;
		}
		 
		function checkEmailSyntax(em){
		 if (em.length <7) return false;    // so kurz kann nix sein  a@bc.de
		 atpos=em.indexOf("@",0);
		 if ((atpos==-1)||(em.indexOf("@",0)==0)||(em.lastIndexOf("@")==em.length-1)||(em.indexOf("@",atpos+1)>-1)) return false;	 // @ am anfang oder am ende oder doppelt oder gar nicht
		 if ((em.indexOf(".",0)==0)||(em.lastIndexOf(".")==em.length-1)) return false;	 // punkt am anfang oder am ende
		 if  ((em.indexOf(".",atpos+1)==atpos+1)||(em.indexOf(".",atpos+1)==-1)||(em.indexOf(".",atpos-1)==atpos-1)) return false;	 // punkt unm. vor @,nach @ oder gar nicht
		 if (em.lastIndexOf(".")>em.length-3) return false; // TLD zu kurz
		 if (em.lastIndexOf(".")<em.length-5) return false; // TLD zu lang
		
		 var x=0;
		 for (x=0;x<em.length;x++)
		     {
		      if ("abcdefghijklmnopqrstuvwxyz-_.@1234567890".indexOf(em.charAt(x).toLowerCase(),0)==-1) break;
		      if ((x>0)&&(em.charAt(x)==".")&&(em.charAt(x-1)==".")) break; 
		     }
		 if (x!=em.length) return false;    // unerlaubtes zeichen oder zwei puntke nacheinander gefunden
		return true;
		}
		

        
		function focusNext(formField, evt, nextFormField) {
            theForm = formField.form;
			evt = (evt) ? evt : event;
			var nextFocus = null;
			var charCode = (evt.charCode) ? evt.charCode :((evt.which) ? evt.which : evt.keyCode);
			if (charCode == 13 || charCode == 3) 
			   {
			    if (nextFormField) nextFocus = theForm[nextFormField];
			    else
			       for (i = 0; nextFocus==null && (i < theForm.length-1) ; i++)
			           if (theForm[i] == formField) nextFocus = theForm[i+1];
			    nextFocus.focus();
			    nextFocus.select();       
				return false;
			   }
			return true;
		}

 
       function imageMagic(theForm){
          url = "imageMagic.html";
          if (theForm.Foto.value.length==0) return;
          imageMagicWin = window.open(url, "imageMagicWin", "width=500,height=506");
          imageMagicWin.focus();
          imageMagic.theForm = theForm;
        }
        
        
// Berater bearbeiten

function selectAllOptions(srcList) 
{ 
	for( var i = srcList.options.length - 1; i >= 0; i-- ) 
	{ 
		if ( srcList.options[i] != null  )
		{
		srcList.options[i].selected=true;
		}
	}
}

function compareOptionValues(a, b) 
{ 
var sA = parseInt( a.value, 36 ); 
var sB = parseInt( b.value, 36 ); 
return sA - sB;
}
function compareOptionText(a, b) 
{ 
var sA = parseInt( a.text, 36 ); 
var sB = parseInt( b.text, 36 ); 
return sA - sB;
}
function moveDualList( srcList, destList, moveAll ) 
{
if ( ( srcList.selectedIndex == -1 ) && ( moveAll == false ) )
{
return;
}
newDestList = new Array( destList.options.length );
var len = 0;
for( len = 0; len < destList.options.length; len++ ) 
{
if ( destList.options[ len ] != null )
{
newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
}
}
for( var i = 0; i < srcList.options.length; i++ ) 
{ 
if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
{
newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
len++;
}
}
newDestList.sort( compareOptionValues ); // BY VALUES
for ( var j = 0; j < newDestList.length; j++ ) 
{
if ( newDestList[ j ] != null )
{
destList.options[ j ] = newDestList[ j ];
}
}
for( var i = srcList.options.length - 1; i >= 0; i-- ) 
{ 
if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
{
srcList.options[i] = null;
}
}
}
