function formsubmit()
{
	ret = validateForm();
	return ret;
}

function MM_findObj(n, d)
{
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function validateForm()
{
	var mode,tag,mon,jahr,i,p,q,felder,errors='';
	
	felder = new Array('Gehalt',2,  'Name',2  );
	
	for (i=0; i<(felder.length); i+=2)
	{
	  val=MM_findObj(felder[i]);
	  if (!val || val.value.length<felder[i+1]) {  errors+= '- Bitte korrigieren Sie '+felder[i]+'.\n'; }
}

function isTelefon(val)
{
  if (val)
  {
    val = val.value;
    val = val.replace(/[\-\/\(\)\.]/g," ");
    val = val.replace(/^\+49/,"0");
    val = val.replace(/^0049/,"0");
    testval = val.replace(/ /g,"");

    if (  (testval.search(/^019/) != -1 )          // auf 019 prüfen
       || (testval.search(/^0\d{6,50}$/) == -1 )   // min 7 Zahlen, 0 am Anfang und nichts anderes
       || (testval.search(/^0900/) != -1 )   			 // auf 0900 prüfen
       )
    {
      return false; // machs besser
    }
    else
    {
      return true;
    }
  }
}

function str_count(haystack)
{
  var i;
  var j;
  var count = 0;

  for (j = 0; j <= 9; j++)
  {
    for (i = 0; i < haystack.value.length; i++)
    {
      if (haystack.value.charAt(i) == j)
      {    
        count++;
      }
    }
    
    if (count > 6)
    {
      return 1;
    }
    count = 0;
  }
}

val=MM_findObj('TelefonP');
if (!isTelefon(val) || str_count(val))  {  errors+= '- Bitte korrigieren Sie Ihre Telefon-Nummer.\n';  }

val=MM_findObj('Kinder');
if (!val || val.options[val.options.selectedIndex].value.length == "") {  errors+= '- Bitte wählen Sie die Anzahl Ihrer Kinder aus.\n'; }

val=MM_findObj('Versicherung');
if (!val || val.options[val.options.selectedIndex].value.length <2) {  errors+= '- Bitte wählen Sie Ihren Versicherung aus.\n'; }

val=MM_findObj('Steuerklasse');
if (!val || val.options[val.options.selectedIndex].value.length == "") {  errors+= '- Bitte wählen Sie Ihren Steuerklasse aus.\n'; }

if (errors)
{  
	alert('Bitte beachten Sie:\n'+errors);  
}

return (errors != '');
}