/* <![CDATA[ */

/// window.onerror = function() { return( true ); }

if( parent.frames.length>0 ) {
 top.location.replace( document.location );
}

function Bookmark( title ) {
 var url = 'http://' + location.host;
 if( title == null ) {
  title = location.host;
 }
 if( document.all ) {
  window.external.AddFavorite( url, title );
 }
 else if( window.sidebar ) {
  window.sidebar.addPanel( title, url, '' );
 }

 return( false );
}

function CheckFormfields( form, fields ) {
 for( var index=0; index<fields.length; index++ ) {
  form[ fields[ index ][ 'name' ] ].style.backgroundColor = ''; 
  if( !fields[ index ][ 'check' ]( form ) ) {
   alert( fields[ index ][ 'error' ] );
   form[ fields[ index ][ 'name' ] ].style.backgroundColor = '#FFA0A0';
   form[ fields[ index ][ 'name' ] ].focus();
   return( false );
  }
 }
 return( true );
}

function CheckSubmitForm( sender, gender ) {
	
	var fields = new Array();
	var index = 0;

	/// female
	if( gender == 2 ) { /// female
		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'name';
		fields[ index ][ 'check' ] = new Function("form","return(form.name.value.length>=3);");
		fields[ index ][ 'error' ] = 'Ungültiger Vorname!';
		index ++;

		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'city';
		fields[ index ][ 'check' ] = new Function("form","return(form.city.value.length>=3);");
		fields[ index ][ 'error' ] = 'Ungültige Stadt!';
		index ++;

		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'age';
		fields[ index ][ 'check' ] = new Function("form","return(parseInt(form.age.value)>0);");
		fields[ index ][ 'error' ] = 'Ungültiges Alter!';
		index ++;

		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'nick';
		fields[ index ][ 'check' ] = new Function("form","return(form.nick.value.length>=3);");
		fields[ index ][ 'error' ] = 'Ungültiger Nick!';
		index ++;
	}
	/// male
	else if( gender == 1 ) { /// male
		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'name';
		fields[ index ][ 'check' ] = new Function("form","return(form.name.value.length>=3);");
		fields[ index ][ 'error' ] = 'Ungültiger Vorname!';
		index ++;

		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'city';
		fields[ index ][ 'check' ] = new Function("form","return(form.city.value.length>=3);");
		fields[ index ][ 'error' ] = 'Ungültige Stadt!';
		index ++;

		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'age';
		fields[ index ][ 'check' ] = new Function("form","return(parseInt(form.age.value)>0);");
		fields[ index ][ 'error' ] = 'Ungültiges Alter!';
		index ++;

		fields[ index ] = new Array();
		fields[ index ][ 'name' ] = 'nick';
		fields[ index ][ 'check' ] = new Function("form","return(form.nick.value.length>=3);");
		fields[ index ][ 'error' ] = 'Ungültiger Nick!';
	}

	return( CheckFormfields( sender, fields, true ) );
}

/* ]]> */