// JavaScript Document
function do_checkFieldValue_cb(res) {
	var setError = false;
	var msg = "";
	// unerlaubte zeichen oder falscher syntax
	if (res["NotAllow"]!="" || res["DobCheck"]!="" || res["MailCheck"]!="") {
		if (res["NotAllow"]!="") {
			if (res["NotAllow"]!="" && res["ReplaceNotAllowedChars"]!="") {
				$(res["ElementID"]).value=res["Result"];
				return false;
			} else {
				msg="Oops! These characters can't be used in your "+ res["FieldName"] +":\n" + res["NotAllow"] + "\nPlease change them.";
				setError=true;
			}
		}
		if (res["DobCheck"]!="") {
			if (res["DobCheck"]=="toyoung16") {
				// switch tr-visible=true
				msg="Oops! You're 14 to 16 years old, so you must fill in the two\nparent/guardian details in the Basic Details section before taking the next step.";
				$("chkParent").disabled=false;
				$("txtPhoneParent").disabled=false;
				alert("toyoung16");
				setError=true;				
			}
			if (res["DobCheck"]=="toyoung14") {
				msg="Oops! You have to be 14 years old or more to join Yooster\n - you're too young at the moment. Sorry!";
				$("chkParent").checked=false;
				$("txtPhoneParent").value="";
				$("chkParent").disabled=true;
				$("txtPhoneParent").disabled=true;	
				alert("toyoung14");				
				setError=true;
			}
			if (res["DobCheck"]!="toyoung16" && res["DobCheck"]!="toyoung14" && res["DobCheck"]!="") {
				msg=res["DobCheck"];
				setError=true;				
			}
		}
		if (res["MailCheck"]!="") {
			msg=res["MailCheck"];
			setError=true;
		}					
	}
	// diverse checks (bei yooster nur als beispiel gedacht!)
	switch (res["ElementID"]) {
		case "txtPhone1":
		case "txtPhone2":
		case "txtMobile":	
		case "txtPhoneParent":
		case "txtTelephone":		
			var inhalt = $(res["ElementID"]).value;
			if (inhalt.length>0) {
				if (inhalt.charAt(0)!="0" && inhalt.charAt(0)!="+") {
					setError=true;
					msg="Oops! These characters can't be used to tell us your telephone number:\nPlease use numbers (and +) only. Thanks.";
				}
			}
			break;
	}
	// fehler?
	if (setError==false) {
		// standart cssclass setzten
		if (res["ElementID"]=="txtDoB" && res["DobCheck"]=="") {
			$("chkParent").checked=false;
			$("txtPhoneParent").value="";
			$("chkParent").disabled=true;
			$("txtPhoneParent").disabled=true;		
		}
		if (res["CSSClass"]!="") { 
			$(res["ElementID"]).className=res["CSSClass"]; 
		} else {
			$(res["ElementID"]).className=""; 			
		}
		// postcheck
		switch (res["ElementID"]) {
			case "txtCity":
			case "txtZIP":
				do_PostCheck('fieldcheck');
				break;
		}
	} else {
		if (res["CSSClass"]!="") { 
			$(res["ElementID"]).className=res["CSSClass"]+"error"; 
		} else {
			$(res["ElementID"]).className="error";
		}
		// sonderfall
		if (res["DobCheck"]=="toyoung16") {
			if (res["CSSClass"]!="") { 
				$(res["ElementID"]).className=res["CSSClass"]; 
			} else {
				$(res["ElementID"]).className=""; 			
			}			
		}
	}
	if (msg!="") { 
		if (showAlert==true) {
			alert(msg); 
		}
	}
}
function do_checkFieldValue(strElementID, strCategory, cssClass, strFieldName, bDeleteBadChars, strReplaceBadChars) {
	if (bDeleteBadChars==undefined) { bDeleteBadChars="false"; }
	if (strReplaceBadChars==undefined) { strReplaceBadChars=""; }
	strInput = $(strElementID).value;
	if (bDeleteBadChars=="") { bDeleteBadChars="false"; }
	x_checkFieldValue(strInput, strElementID, strCategory, cssClass, strFieldName, bDeleteBadChars, strReplaceBadChars, do_checkFieldValue_cb);
}
function checkOfSyntax(ElementIDs) {
	if (ElementIDs!="") {
		if (ElementIDs.lastIndexOf(",")==-1) {
			var strCurrentCSS = $(ElementIDs).className;
			if (strCurrentCSS!="") {
				if (strCurrentCSS.lastIndexOf("error")>-1) { return false; }
			}			
		} else {
			var arrFields = ElementIDs.split(",");
			for (i=0;i<arrFields.length;i++) {
				var strCurrentCSS = $(arrFields[i]).className;
				if (strCurrentCSS!="") {
					if (strCurrentCSS.lastIndexOf("error")>-1) { return false; }
				}
			}
		}
	}
	return true;
}