if(typeof(DD)=="undefined"){
	var DD = new Object();
}
DD.validation = new Object();

function chkText(fname,ftext,stext){
	if (!fname.value){
		alert("Please fill in " + stext + " " +  ftext + "!");
		fname.focus();
		return false;
	}
}

function chkAlphanum(fname,ftext,stext){
	if (fname.value.length > 0){
		var x = fname.value;
		var filter  = /([a-zA-Z0-9])/;
		if (!filter.test(x)){
			alert("The field " + ftext + " may contain only numbers and letter!");
			fname.focus();
			fname.select();
			return false;
		}
	} else {
		alert("Please insert " + stext + " " + ftext + "!");
		fname.focus();
		return false;
	}
}

function chkRadio(fname){
	var retBoolSuccess=false;
	if(fname.length){
		for(var i=0;i<fname.length;i++){
			if(fname[i].checked){retBoolSuccess=true;break;}
		}
	}
	return retBoolSuccess;
}

function chkNumber(fname,ftext,stext){
	if (fname.value.length > 0){
		var x = fname.value;
		var filter  = /^([0-9]+)$/;
		if (!filter.test(x)){
			alert("The field " + ftext + " may contain only numbers!");
			fname.focus();
			fname.select();
			return false;
		}
	} else {
		alert("Please insert "+stext + " " +  ftext + "!");
		fname.focus();
		return false;
	}
}

function chkEmail(fname, ftext, stext){
	if (fname.value.length > 0){
		var x = fname.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(x)){
			alert("Please insert " + stext + " correct " + ftext +"!");
			fname.focus();
			return false;
		}
	} else {
		alert("Please insert " + stext + " " + ftext + "!");
		fname.focus();
		return false;
	}
}

function chkFile(fname,ftext,stext,SYS_allowedExtensions) {
	if(fname.value.length > 0){
		var ext1 = fname.value;
		ext1 = ext1.substring(ext1.length-3,ext1.length);
	  ext1 = ext1.toLowerCase();
		var isAllowedExt=false;
		var allExts="";
		for(var fx=0;fx<SYS_allowedExtensions.length;fx++){
			if(ext1==SYS_allowedExtensions[fx]){isAllowedExt=true;}
			allExts+=((allExts=="") ? "*." + SYS_allowedExtensions[fx] : ( ( (fx+1)<SYS_allowedExtensions.length) ? ", " : " or " ) + "*." + SYS_allowedExtensions[fx]);
		}
  	if(!isAllowedExt){ 
  		alert("You choose as : \"" + stext + " " + ftext + "\" a ." + ext1 + " File, please select only " + allExts + " Files!");
			//fname.focus();
			return false;
	  }
	}else{
		alert("Please select " + stext + " " + ftext + "!");
		//fname.focus();
		return false;
	}
}