/*--------------------------------------------
 Teaching Tools Web Page
 Author : Michael Rottmeier
 This file was created : 17.04.2003
 Last modified : 17.4.2003
--------------------------------------------*/

//---[ Check Registration Data ]---//
AMessages = new Array();
AMessages[0] = new Array();
AMessages[0][0] = 'Haben Sie die Lizenbedingungen gelesen?';
AMessages[0][1] = 'Have you read the Terms of License?';
AMessages[1] = new Array();
AMessages[1][0] = 'Bitte geben Sie Ihren NAMEN ein!\n';
AMessages[1][1] = 'Please enter your NAME!\n';
AMessages[2] = new Array();
AMessages[2][0] = 'Bitte geben Sie Ihren VORNAMEN ein! \n';
AMessages[2][1] = 'Please enter your FIRST (Christian) NAME!\n';
AMessages[3] = new Array();
AMessages[3][0] = 'Bitte geben Sie eine g\u00FCltige E-mail Adresse ein!\n';
AMessages[3][1] = 'Please enter a valid e-mail address!\n';
AMessages[4] = new Array();
AMessages[4][0] = 'Bitte w\u00E4hlen Sie Ihr LAND aus!';
AMessages[4][1] = 'Please choose your COUNTRY!';

function CheckRegistration(){

	var Message = '';
 
// language
	var strLanguage = document.getElementById('Language').value;
	var intLanguage = 1;
	if (strLanguage == 'english'){intLanguage = 1;}
	if (strLanguage == 'deutsch'){intLanguage = 0;}
	
// read terms of use
	if (document.getElementById('LicenceRead').checked == false){
		alert(AMessages[0][intLanguage]);
		return false;
		}	

// check family name, Christian name
	var CName = document.getElementById("Family_Name").value;
	if ((TrimString(CName) == '')||(CName.length < 3)){Message += AMessages[1][intLanguage];}
	var FName = document.getElementById('Christian_Name').value;
	if ((TrimString(FName) == '')||(FName.length < 3)){Message += AMessages[2][intLanguage];}

// country chosen
	if (document.getElementById('Country').value == 'none'){
		Message += AMessages[4][intLanguage];
		}
			
	if (Message.length > 0){
		alert(Message);	
		return false;
		}
		else{
			return true;		
			}

}

function TrimString(InString){
	if (InString.length == 0){
		return '';
		}
		
	var Spaces = '\u0020\u000A\u000D';
	var x = 0;
	
	while (Spaces.indexOf(InString.charAt(0)) > -1){
		InString = InString.substring(1, InString.length);
		}

	while (Spaces.indexOf(InString.charAt(InString.length-1)) > -1){
		InString = InString.substring(0, InString.length-1);
		}

	while (InString.indexOf('  ') > -1){
		x = InString.indexOf('  ');
		InString = InString.substring(0, x) + InString.substring(x+1, InString.length);
		}
		
	return InString;
}
