function SetFocusVal(obj, sdef) {
	if(obj.value==sdef) {
		obj.value='';
	}
}

function SetBlurVal(obj, sdef) {
	if(obj.value=='' || obj.value==sdef) {
		obj.value=sdef;
	}
}
function CheckPassw(passw) {
	if(passw=='') {
		return false;
	} else {
		if(!/^[\w]+$/i.test(passw)) {
			return false;
		} else {
			return true;
		}
	}
}
// CheckPasswField() - check password and confirmation
// fld - field object with password
// fldconf - field object with password confirmation
// errempty1 - error message when password is empty
// errempty2 - error message when password confirmation is empty
// errempty2 - error message when password confirmation is empty
// errpassw - error message when password have invalid characters
// errrepassw - error message when password confirmation have invalid characters
// errconfirm - confirmation error
function CheckPasswField(fld, fldconf, errempty1, errempty2, errpassw, errrepassw, errconfirm) {

	var passw=fld.value;

	if(passw=='') {
	        alert(errempty1);
		fld.focus();
		return false;
	} else {
		if(!/^[\w]+$/i.test(passw)) {
			alert(errpassw);
			fld.focus();
			return false;
		}
	}

	// confirmation field object exists?
	if(fldconf) {
		if(fldconf.value=='') {
			alert(errempty2);
			fldconf.focus();
			return false;
		} else {
			if(!/^[\w]+$/i.test(passw)) {
				alert(errpassw);
				fld.focus();
				return false;
			} else {
				if(fldconf.value!=fld.value) {
					alert(errconfirm);
					fldconf.value='';
					fldconf.focus();
					return false;
				}
			}
		}
	}
	return true;

}
function RemoveBlur(linkobj) {
	if(linkobj.blur()) linkobj.blur;
}
function CheckEmail(semail) {
	if(document.layers || document.all || document.getElementById) {
		return (semail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
	}
	return true;
}
function GetElemByID(selid) {
	if(document.all) {
		return document.all[selid];
	} else {
		if(document.getElementById) {
			return document.getElementById(selid);
		}
	}
	return false;
}
function LeftTrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function RightTrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function FullTrim(str) {
	return LeftTrim(RightTrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
