function formChecker () {
   this.chkNumber = chkNumber;
   this.chkPath = chkPath;
   this.chkEmail = chkEmail;
   this.chkUrl = chkUrl;
   this.chkDate = chkDate;
   this.chkEmpty = chkEmpty;
   this.isEmpty = isEmpty;
   this.addErrorMessage = addErrorMessage;
   this.dispError = dispError;
   this.message = new Array();
   this.message[0] = "";
   this.index = 0;
}

/*adds Error Message to the Message Array*/
function addErrorMessage(text) {
	this.message[this.index] = text;
	this.index++;
}

function dispError() {
	var msg = document.getElementById("message");
	var error = "Es sind Fehler aufgetreten!";
	for(var i=0;i<this.message.length;i++) {
		error += "<br>* "+this.message[i];
	}
	msg.className = "error";
	msg.innerHTML = error;
}

/*checks if str is empty*/
function chkEmpty(title, str) {
	if(str == "") {
		this.addErrorMessage(title+": Dieses Feld muß ausgefüllt werden!");
		return(false);
	}
	return(true);
}

/*only checks if str is empty but gives no error*/
function isEmpty(str) {
	if(str == "")
		return(true);
    else
	    return(false);
}

/*checks if str is valid number between min and max*/
function chkNumber(title, str, min, max) {
	var expr = /^\d+$/;
	if(!expr.test(str)) {
		this.addErrorMessage(title+": Keine gültige Zahl!");
		return(false);
	}
	if(str>max || str<min) {
		this.addErrorMessage(title+": Zahl darf MAX: "+max+" und MIN: "+min+" sein!");
		return(false);
	}
	return(true);	
}

/*checks if str is a valid apache-path*/
function chkPath(title, str) {
	var expr = /^((\.{1,2}\/)?([\d\w]{1,}\/){1,})|(\.{1,2}\/)$/;
	if(!expr.test(str)) {
		this.addErrorMessage(title+": Kein gültiger Pfad!");
		return(false);
	}
	return(true);	
}

/*checks if str is a valid email address*/                                   //*** TODO!!! ***
function chkEmail(title, str) {
	var expr = /^((\.{1,2}\/)?([\d\w]{1,}\/){1,})|(\.{1,2}\/)$/;
	if(!expr.test(str)) {
		this.addErrorMessage(title+": Keine gültige Email-Adresse!");
		return(false);
	}
	return(true);	
}

/*checks if str is a valid URL*/                                            //*** TODO!!! ***
function chkUrl(title, str) {
	var expr = /^((\.{1,2}\/)?([\d\w]{1,}\/){1,})|(\.{1,2}\/)$/;
	if(!expr.test(str)) {
		this.addErrorMessage(title+": Keine gültige URL!");
		return(false);
	}
	return(true);	
}

/*checks if day/month/year is a valid date*/
function chkDate(title, day, month, year) {
    var date = new Date(year, month-1, day);
    if((date.getDate()==day) && (date.getMonth()==month-1) && (date.getFullYear()==year))
        return(true);

    this.addErrorMessage(title+": Datum ungültig!");
	return(false);	
}

