//<script Language=JavaScript>
// Global variable definitions
var frms = new Array();			// An array that keeps the registered addValidation elements
var formPos = -1;				// The form object position of the registered addValidation elements

function frmObj(){

	this.fields = new Array();		// an array of field objects
	this.name = '';					// the form name

	this.addItem = addingItem;		// a method to add new items to the registering form
}

function addingItem(item, frmName){
	if(!this.created){
		this.fields[this.fields.length] = item;		// stores the field objects in this array
		this.name = frmName;						// stores the form name
	}
}

function fieldObj(name, opts, dataType, cond, msg){
	this.cond = cond;							// condition of the validating field
	this.name = name;							// the field name
	this.opts = opts;							// the option
	this.dataType = dataType;					// the data type
	this.msg = msg;								// the error message
	this.type = '';								// the field type

	this.setType = setFieldType;				// the method to set the field type
	this.getType = getFieldType;				// the method to get the field type
}

function setFieldType(type){
	if(!this.created)
		this.type = type;						// stores the field type
}

function getFieldType(){
	return this.type;							// retrieves the field type
}

function addValidation(f1, f2, f3, f4, f5, f6){
	var theField;									// the field object's object
	var form;										// the form object's object
	var existPos = -1;								// the form submitted position in the frms array
	
	// creates the field object
	theField = new fieldObj(f2, f3, f4, f5, f6);
	
	// initialises the form object
	form = new frmObj();
	if(frms.length == 0){
		frms[frms.length] = form;
		frms[frms.length-1].addItem(theField, f1);
	}
	else{
		// checks if the form name is exists
		for(var i=0; i<frms.length; i++){
			if(frms[i].name == f1){
				existPos = i;
				break;
			}
			else
				existPos = -1;
		}
		if(existPos != -1){
			// stores the field object in the existing form name
			frms[existPos].addItem(theField, f1);
		}
		else{
			// stores the field object in the new form name
			frms[frms.length] = form;
			frms[frms.length-1].addItem(theField, f1);
		}
	}
}

function recordVerification(name){

	var internalErrMsg = '';									// Internal error message string
	var internalErrMsgCount = 1;								// Internal error message count
	
	// searchs for the form in the frms array against the submitted form
	for(var i=0; i<frms.length; i++){
		if(frms[i].name == name)
			// stores the position of the form as a global variable
			formPos = i;
	}
	// if the form is found in the submitted form object
	if(formPos != -1){
		// looping for every elements in the frms array for the field object
		for(var i=0; i<frms[formPos].fields.length; i++){
			// if the submitted form object match the registered object in the frms array
			if (typeof(eval('document.' + frms[formPos].name + '.' + frms[formPos].fields[i].name)) == "undefined"){
				internalErrMsg+= internalErrMsgCount++ + ") " + frms[formPos].fields[i].name + "\n";
			}
			else{
				// if found, stores the information of the submitted form in the field object in the frms array
				var temp = eval('document.' + frms[formPos].name + '.' + frms[formPos].fields[i].name);
				// special type of the radio array
				if(typeof(temp.type) == "undefined"){
					frms[formPos].fields[i].setType("radio");
				}
				else
					frms[formPos].fields[i].setType(temp.type);
			}
		}
		
		// checks for the error message and alerts it
		if(internalErrMsg != ''){
			alert("Validation Module: The Following item(s) not exists in the form '" + frms[formPos].name + "' \n\n" + internalErrMsg);
			return "noField";
		}
		else
			return true;
	}
	return "noForm";
}

function validateConditionFields(){

	var fieldErrMsg = '';						// field error message string
	var fieldErrMsgCount = 1;					// field error message counter
	var isValid = false;						// stores the validation result
	var toFocus = false;						// stores the focusing result

	// searching through the field objects in the frms array of the condition
	for(var i=0; i<frms[formPos].fields.length; i++){
		// if no condtion
		if(frms[formPos].fields[i].cond.toLowerCase() == "null"){
			isValid = fieldValidation(i);
		}
		else{
			// if the condtion presents
			if(eval("document." + frms[formPos].fields[i].cond)){
				isValid = fieldValidation(i);
			}
			else
				isValid = true;
		}
		// if the error is found from the validation
		if(!isValid){
			// generates the error messages
			fieldErrMsg += fieldErrMsgCount++ + ") " + frms[formPos].fields[i].msg + "\n";
			// focusing on the first error field
			if(!toFocus){
				var obj = eval("document." + frms[formPos].name + "." + frms[formPos].fields[i].name);
				if(typeof(obj.type) == "undefined") {
					obj[0].focus();
					toFocus = true;
				}
				else {
					if(obj.type != "hidden") {
						obj.focus();
						toFocus = true;
					}	
				}
			}
		}
	}
	// alerts the error message
	if(fieldErrMsg != ''){
		alert("แบบฟอร์มไม่สมบูรณ์.  โปรดเช็ครายการดังต่อไปนี้:\n\n"+ fieldErrMsg);
		return false;
	}
	else
		return true;
}

function fieldValidation(index){

	var isValid = false;
	var obj = eval("document." + frms[formPos].name + "." + frms[formPos].fields[index].name);
	
	switch(frms[formPos].fields[index].type){
		case "text"				:	isValid = textChk(index, obj);
									break;
		case "textarea"			:	isValid = textChk(index, obj);
									break;
		case "radio"			:	isValid = radioChk(index, obj);
									break;
		case "select-one"		:
		case "select-multiple"	:	
									
									isValid = selectChk(index, obj);
									break;
		case "hidden"			:	isValid = textChk(index, obj);
									break;
		case "checkbox"			:	isValid = checkBoxChk(obj);
									break;
		case "password"			:	isValid = passwordChk(obj);
	}
	return isValid;
}

function textChk(frmsIndex, obj){

	var isValid = false;
	if ((frms[formPos].fields[frmsIndex].opts != 1)&&(frms[formPos].fields[frmsIndex].opts != 0)) {
		if(obj.value.length != 0){
			switch(frms[formPos].fields[frmsIndex].dataType){
				//'length'			:	Accept	->	Character + Numeric or Character only and length <= lenval
				//					:	Reject	->	Numeric only or length > lenval
				case 'length'		:	lenval=frms[formPos].fields[frmsIndex].opts;
										isValid=lengthChk(obj,lenval);
										break;

				case 'positiverange':	lenval=frms[formPos].fields[frmsIndex].opts;
										isValid=positiverangeChk(obj,lenval);
										break;
				
				//'lengthMixed'		:	Accept	->	Character + Numeric or Character only or Numeric only and length <= lenval
				//					:	Reject	->	length > lenval
				case 'lengthMixed'	:	lenval=frms[formPos].fields[frmsIndex].opts;
										isValid=lengthMixedChk(obj,lenval);
										break;
										
				case 'lengthNoSpecial'	:lenval=frms[formPos].fields[frmsIndex].opts;
										isValid=lengthNOSPChk(obj,lenval);
										break;
										
				case 'lengthNAT'	:	lenval=frms[formPos].fields[frmsIndex].opts;
										isValid=lengthNATChk(obj,lenval);
										break;

				default				:	alert("Internal Error Message: \nThere is no datatype: '" + frms[formPos].fields[frmsIndex].dataType + "'.");
			}
		}
	} 
	else {
		if(frms[formPos].fields[frmsIndex].opts == 1){
			//if(obj.value.length != 0){
				switch(frms[formPos].fields[frmsIndex].dataType.toLowerCase()){
					//'alphabet'		:	Accept	->	Character + Numeric or Character only
					//					:	Reject	->	Numeric only
					case 'alphabet'		:	isValid=alphabetChk(obj);
											break;
					case 'alphanumeric'	:	isValid=isAlphaNumeric(obj);
											break;						
					//'numeric'			:	Accept	->	Numeric only (can be float and negative number)
					//						Reject	->	Character
					case 'numeric'		:	isValid=numericChk(obj);
											break;
					
					case 'ipaddress'	:   isValid=ipChk(obj);
											break;
					
					//'date:d-m-y'		:	Accept	->	Date 
					case 'date:d-m-y'	:
					case 'date:m-d-y'	:	isValid=dateChk(frmsIndex, obj);
											break;
					case 'date:y-m-d'	:	isValid=dateChk(frmsIndex, obj);
											break;
					
					//'email'			:	Accept	->	Email format
					case 'email'		:	isValid=emailChk(obj);
											break;
					case 'emailorblank'		:	isValid=isEmailOrBlank(obj.value);
											break;									
					//'phone'			:	Accept	->	Character + Numeric or Number only
					//						Reject	->	Character only
					case 'phone'		:	isValid=PhoneChk(obj);
											break;
											
					//'positiveint'		:	Accept	->	Numeric only (must be positive integer)
					//					:	Reject	->	Negative number and decimal
					case 'positiveint'	:	isValid=PosIntChk(obj);
											break;
											
					//'positivenum'		:	Accept	->	Numeric only and . (must be positive), can be float or integer
					//					:	Reject	->	Negative number
					case 'positivenum'	:	isValid=PosChk(obj);					
											break;
											
					//'textonly'		:	Accept	->	Character only
					//					:	Reject	->	Number
					case 'textonly'		:	isValid=TextOnlyChk(obj);
											break;
					
					//'mixed'			:	Accept	->	Character only, Number only, Character+Number
					case 'mixed'		:	isValid=MixedChk(obj);
											break;
					
					case 'notnull'		:	isValid=NotNullChk(obj);
											break;
					
					default				:	alert("Internal Error Message: \nThere is no datatype: '" + frms[formPos].fields[frmsIndex].dataType + "'.");
				//}
			}
		}
		else{
			if(frms[formPos].fields[frmsIndex].opts == 0){
				if(obj.value.length != 0)
					isValid = true;
			}
			else
				alert("Internal Error Message: \nThe option of the field: '" + frms[formPos].fields[frmsIndex].name + "' should be only 1 or 0.");
		}
	}
	return isValid;
	
}

function alphabetChk(obj){

	if(isNaN(obj.value))
		return true;
	else
		return false;
}

function ipChk(obj){

	var arripelements;
	var bChk = true;
	arripelements = obj.value.split(".");
	if (arripelements.length == 4 ){
		for (i=0; i<4; i++){
			if (isNaN(arripelements[i])){
				bChk = false;
			}
			else{
				bChk = bChk & (arripelements[i] >=0) & (arripelements[i] <= 255);
			}
		}
	}
	else{
		bChk = false;
	}
	return (bChk);	
}

function positiverangeChk(obj,val){
	var numStr = "";					// initializes numeric string
	var PosIntAdd = obj.value;
	var result = true;

	// if the period is presented
	if(obj.value.indexOf(".") != -1){
		// finds if there is more than one period
		var periodArr = obj.value.split(".");
		if((periodArr.length > 2) || (periodArr[1].length == 0))
			return false;
		else{ // period is 1
			// if there are commas behides the period
			if(periodArr[1].indexOf(",") != -1)
				return false;
			// if there are commas present before the period
//			if(periodArr[1] > 59)
//				return false;
			if(periodArr[0].indexOf(",") != -1){
				// finds the commas' dimention against the numeric values
				var commaArr = periodArr[0].split(",");
				if((commaArr[0].length > 3) || (commaArr[0].length == 0))
					return false;
				if(commaArr.length > 1){
					for(var i=1; i<commaArr.length; i++){
						if(commaArr[i].length != 3)
							return false;
					}
				}
				for(var i=0; i<commaArr.length; i++)
					numStr+=commaArr[i];
				numStr+="." + periodArr[1];
			}
			else{
				if(periodArr[1].indexOf(",") != -1) // if comma comes after the period
					return false;
				numStr+= periodArr[0] + "." + periodArr[1];
			}
		}
	}
	else
		numStr+=obj.value;

	if(!isNaN(PosIntAdd)){
		if((PosIntAdd>val) || (PosIntAdd<0))
			result = false;
	}
	else
		result = false;
	
	return result;
}

function numericChk(obj,val){

	var numStr = "";					// initializes numeric string
	
	// if the period is presented
	if(obj.value.indexOf(".") != -1){
		// finds if there is more than one period
		var periodArr = obj.value.split(".");
		if((periodArr.length > 2) || (periodArr[1].length == 0))
			return false;
		else{ // period is 1
			// if there are commas behides the period
			if(periodArr[1].indexOf(",") != -1)
				return false;
			// if there are commas present before the period
			if(periodArr[0].indexOf(",") != -1){
				// finds the commas' dimention against the numeric values
				var commaArr = periodArr[0].split(",");
				if((commaArr[0].length > 3) || (commaArr[0].length == 0))
					return false;
				if(commaArr.length > 1){
					for(var i=1; i<commaArr.length; i++){
						if(commaArr[i].length != 3)
							return false;
					}
				}
				for(var i=0; i<commaArr.length; i++)
					numStr+=commaArr[i];
				numStr+="." + periodArr[1];
			}
			else{
				if(periodArr[1].indexOf(",") != -1) // if comma comes after the period
					return false;
				numStr+= periodArr[0] + "." + periodArr[1];
			}
		}
	}
	else
		numStr+=obj.value;
		
	// evaluates the newly constructed numeric string
	if(!isNaN(numStr))
		return true;
	else
		return false;
}

function dateChk(frmsIndex, obj){

	var theDate = obj.value;
	var notAllowStr = ' /-+';
	var dateArr;
	var formation;
	var toDate;
	var dateStr;
	var dateIdent;
	var str;

	// finding formation that programmer defined
	var tmp = frms[formPos].fields[frmsIndex].dataType;
	var tmpArr = tmp.split(":");
	formation = tmpArr[1];
	
	// calling the dateBreaker() function to break down user's input into array
	dateArr = dateBreaker(theDate);

	// checking to find the illegal date format from the returned date array
	if((dateArr == -1) || (dateArr.length != 3) || (dateArr[0]=='') || (dateArr[dateArr.length-1]==''))
		return false;
	
	// calling the formatting() function by the formation specified, a string of
	// date is send back
	switch(formation){
		case 'd-m-y' :	dateStr = formatting(dateArr[1], dateArr[1], dateArr[0], dateArr[2]);
						dateIdent = dateArr[0];
						break;
		case 'm-d-y' :	dateStr = formatting(dateArr[0], dateArr[0], dateArr[1], dateArr[2]);
						dateIdent = dateArr[1];
						break;
		case 'y-m-d' :	dateStr = formatting(dateArr[1], dateArr[1], dateArr[2], dateArr[0]);
						dateIdent = dateArr[2];
						break;
		default		 :	alert('Please check if the defined date format allowed.');
						return false;
	}
	

	// creating the date object by passing the dateStr into it
	var dateObj = Date.parse(dateStr);
	
	// checking if the date object is successfully created, if not, return false
	if(dateObj.toString() == "NaN"){
		return false;
	}
	else
		toDate = new Date(dateStr);
		
	// scaning through the elements in the array for not allowed strings
	for(j=0; j<dateArr.length; j++){
		for(k=0; k<dateArr[j].length; k++){
			subArray = dateArr[j].substring(k, k+1);
			if(notAllowStr.indexOf(subArray) != -1)
				return false;
		}
	}
	
	// getting a serie of date string from the successfully setup date object
	str = toDate.toString();
	
	// spliting the str into array using a blank space as a separator
	dateGen = str.split(' ');
	
	// comparing generated date to the one by the user to find the correct day
	// per month
	if(eval(dateGen[2]) != eval(dateIdent))
		return false;
	
	// simplifying the month name input by the user by setting it to be in 
	// lower case
	obj.value = obj.value.toLowerCase();
	
	// if everything is corrected, return true to the textChk()
	return true;
}
function formatting(month, elem1, elem2, elem3){

	var dateStr = ' ';
	
	if(elem3.length!=4)
		return dateStr;
	
	// checking for the month by name
	if(isNaN(month)){
		
		// if the month by name has less than 3 characters
		if(month.length < 3)
			return dateStr;
			
		// insert blank spaces as the date separators to the dateStr
		dateStr = elem1+' '+elem2+' '+elem3;
	}
	else{
	
		// if the month by digit has a proper format
		if((month>12) || (month<1) || (month.length > 2) || (elem3.length != 4))
			return dateStr;
		
		// insert '/' as the date separators to the dateStr
		dateStr = elem1+'/'+elem2+'/'+elem3;
	}
	
	// return the dateStr back to the dateChk()
	return dateStr;
}

function dateBreaker(dateIn){

	var dateArr;
	var separator = ' /-';
	var subSep;
	var isSeparator = false;

	// Searching for the standard separators
	for(j=0; j<separator.length; j++){
		subSep = separator.substring(j, j+1);
		if(dateIn.indexOf(subSep) != -1){
			dateArr = dateIn.split(subSep);
			isSeparator = true;
			break;
		}
		else
			isSeparator = false;
	}
	
	// If the standard separators are not found
	if(!isSeparator)
		return -1;
		
	// The standard separators are found and the date string is returned
	return dateArr;
}

function emailChk(obj){

	var emailAdd = obj.value;
	var emailExp = /[^\w\.@\_-]/;		// Regular expression of legal email format
	var frontAtom = /^[\._\-]/;	// RE, finds '.', '-' and '_' at the begining of string 
	var rareAtom = /[\._\-]$/;		// RE, finds '.', '-' and '_' at the ending of string
	var emailAd = /@/;				// RE, finds '@' in the string
	var underStream = /_{2,}/;		// RE, limits '_' to appear only once on it own
	var hyphenStream = /\-{2,}/;	// RE, limits '-' to appear only once on it own
	var dotStream = /\.{2,}/;		// RE, limits '.' to appear only once on it own
	var hyphenSpec = /\-/;			// RE, finds '-' in the string
	var dotSpec = /\./;			// RE, finds '.' in the string
	var addArr;						// An array keeps email address that split by '@'
	var dotArr;						// An array keeps email address that split by '.'
	var hyphenArr;					// An array keeps email address that split by '-'

	// checking for alllowed expression of email address
	if(emailExp.test(emailAdd))
		return false;

	// checking that the email address has only one '@'
	if(!emailAd.test(emailAdd))
		return false;
	if((underStream.test(emailAdd)) || (hyphenStream.test(emailAdd)) || (dotStream.test(emailAdd)))
		return false;
	
	// checking that the split '@' array is not empty
	addArr = emailAdd.split('@');
	if((addArr.length>2) || (addArr.length<1) || (addArr[0] == '') || (addArr[1] == ''))
		return false; 
	
	// looking for extra special separators in the sender part
	if((frontAtom.test(addArr[0])) || (rareAtom.test(addArr[0])))
		return false;
	
	// looking for extra special separators in the address part
	if((frontAtom.test(addArr[1])) || (rareAtom.test(addArr[1])))
		return false;
	
	// looking for at least a dot separator in the address part
	if(!dotSpec.test(addArr[1]))
		return false;
	
	// finding extra special separator by '.'
	dotArr = emailAdd.split('.');
	for(j=0; j<dotArr.length; j++){
		if((frontAtom.test(dotArr[j])) || (rareAtom.test(dotArr[j])))
			return false;
	}
	
	// finding extra special separator by '-'
	if(hyphenSpec.test(emailAdd)){
		hyphenArr = emailAdd.split('-');
		for(j=0; j<hyphenArr.length; j++){
			if((frontAtom.test(hyphenArr[j])) || (rareAtom.test(hyphenArr[j])))
				return false;
		}
	}
	
	// if there is nothing wrong, return true
	return true;
}
function lengthChk(obj,val){
	var ObjVal = obj.value;
	var Objlen = ObjVal.length;
	var len = val;
	
	result = true;
	if (Objlen>len) 
		result = false;
	
	for(var i=0; i<Objlen; i++){
		j = i+1;
		Chr = ObjVal.substring(i,j)
		if (Chr=='"') {
			result = false;
			break;
		}
	}
	return result;
}
function PhoneChk(obj){
	var PhoneAdd = obj.value;
	var FirstChr = PhoneAdd.substring(0,1);
	var PhoneExp = /[0-9]/;		
	
	if(!PhoneExp.test(FirstChr))
		return false;
	
	// if there is nothing wrong, return true
	return true;
}
function PosChk(obj){
	var PosIntAdd = obj.value;
	var Exp = /[.0-9]/;
	var result;
	var Chr;
	var j;
	var ZeroVal;
	
	ZeroVal = true;
	result = true;
	for(var i=0; i<PosIntAdd.length; i++){
		j = i+1;
		Chr = PosIntAdd.substring(i,j)
		if ((Chr!="0")&&(Chr!=".")) 
			ZeroVal = false;
		if (Exp.test(Chr)==false) result = false;
	}
	FloatVal = parseFloat(PosIntAdd);
	if (ZeroVal==true) result = false;
	if (FloatVal<0.005) result = false;
	return result;
}
function PosIntChk(obj) {
	var PosIntAdd = obj.value;
	var Exp = /[0-9]/;
	var result;
	var Chr;
	var j;
	
	result = true;
	for(var i=0; i<PosIntAdd.length; i++){
		j = i+1;
		Chr = PosIntAdd.substring(i,j)
		if (Exp.test(Chr)==false) result = false;
	}
	return result;
}
function TextOnlyChk(obj) {
	var TextAdd = obj.value;
	var Exp = /[A-Za-z]/;
	var result;
	var j;
	var Chr;
	
	result = true;
	for(var i=0; i<TextAdd.length; i++){
		j = i+1;
		Chr = TextAdd.substring(i,j)
		if (Exp.test(Chr)==false) result = false;
	}
	return result;
}
function MixedChk(obj) {
	var MixedAdd = obj.value;
	var Exp = /\w/;
	var result;
	var j;
	var Chr;
	
	result = true;
	for(var i=0; i<MixedAdd.length; i++){
		j = i+1;
		Chr = MixedAdd.substring(i,j)
		if (Exp.test(Chr)==false) result = false;
	}
	return result;
}

function textareaChk(obj){

	if(obj.value == '')
		return false;
	else
		return true;
}

function selectChk(frmsIndex, obj){

	var isValid = false;
	
	if(frms[formPos].fields[frmsIndex].opts == "Null"){
		for(var i=0; i<obj.options.length; i++){
			if(obj.options[i].selected){
				isValid = true;
				break;
			}
		}
	}
	else{
		for(var i=0; i<obj.options.length; i++){
			if(obj.options[i].selected){
				if(frms[formPos].fields[frmsIndex].opts == i){
					isValid = false;
					break;
				}
				else
					isValid = true;
			}
		}
	}
	return isValid;
}

function radioChk(frmsIndex, obj){

	var radioName = frms[formPos].fields[frmsIndex].name;
	var isValid = false;
	var singleRadio = "";
	
	singleRadio += obj.length;
	if(singleRadio.toLowerCase() == "undefined"){
		if(obj.checked)
			isValid = true;
	}
	else{
		for(var i=0; i<obj.length; i++)
			if((obj[i].name == radioName) && (obj[i].checked)){
				isValid = true;
		}
	}
	return isValid;
}

function checkBoxChk(obj){

	if(obj.checked)
		return true;
	else
		return false;
}

function passwordChk(obj){

	if(obj.value.length != 0)
		return true;
	else
		return false;
}

function validate(obj){

	var isItemExists = recordVerification(obj.name);
	// there is no such a field in the form
	if(isItemExists == "noField")
		return false;
	else{
		// there is no addValidation element of the form
		if(isItemExists == "noForm")
			return true;
		else{
			// the forma and field are found
			var isValid = validateConditionFields();
			return isValid;
		}			
	}
}

function NotNullChk(obj) {
	objVal = obj.value;
	if (objVal.length==0)
		return false;
	else
		return true;
}

function lengthMixedChk(obj,val){
	var ObjVal = obj.value;
	var Objlen = ObjVal.length;
	var len = val;
	var Exp = /\w/;
	
	result = true;
	if (Objlen>len) 
		result = false;
	
	for(var i=0; i<ObjVal.length; i++){
		j = i+1;
		Chr = ObjVal.substring(i,j)
		if ((Exp.test(Chr)==false)||(Chr=='"')) {
			result = false;
			break;
		}
	}
	return result;
}
function lengthNOSPChk(obj,val){
	var ObjVal = obj.value;
	var Objlen = ObjVal.length;
	var len = val;
	
	result = true;
	if (Objlen>len) 
		result = false;
	if(!isNaN(obj.value))
		result = false;
	for(var i=0; i<Objlen; i++){
		j = i+1;
		Chr = ObjVal.substring(i,j)
		//if ((Chr=="%")||(Chr=='"')) {
		if (Chr=='"') {
			result = false;
			break;
		}
	}
	return result;
}

function lengthNATChk(obj,val){
	var ObjVal = obj.value;
	var Objlen = ObjVal.length;
	var len = val;
	var Exp = /\w/;
	var Exp2 = /[0-9]/;
	
	result = true;
	flag = 0;
	if (Objlen>len) 
		result = false;
	
	for(var i=0; i<ObjVal.length; i++){
		j = i+1;
		Chr = ObjVal.substring(i,j)
		if (((Exp.test(Chr)==false)||(Chr=='"'))&&(Chr!='.')&&(Chr!='-')) {
			result = false;
			break;
		}
		if (Exp2.test(Chr)==true) {
			flag = 1;
		}
	}
	
	if (flag==0) result = false;
	return result;
}

//</script>