function validateEmail(textBox, errorMessage){
	result = 0;
	var textBoxObject = document.getElementById(textBox);
	var textBoxValue = textBoxObject.value;
	var regEx = /^[\w][\w\d._]+[@][\w\d]{2,25}[.][.\w]{2,10}$/
	if ( textBoxValue.search(regEx) == -1 ) {
		textBoxObject.focus(); 
		alert(errorMessage);
		return false;
	}
	return true;
}

function checkNumber(textBox, errorMessage){
	var textBoxObject = document.getElementById(textBox);
	var textBoxValue = textBoxObject.value;
	if( textBoxValue == '' || isNaN(textBoxValue) != 0 ){
		textBoxObject.focus();
		alert(errorMessage);
		return false;
	}
	return true;
}

function checkNumberNM(textBox, errorMessage){
	var textBoxObject = document.getElementById(textBox);
	var textBoxValue = textBoxObject.value;
	if( textBoxValue != '' && isNaN(textBoxValue) != 0 ){
		textBoxObject.focus();
		alert(errorMessage);
		return false;
	}
	return true;
}

function checkPlainURLString(textBox, errorMessage){
	var txtBoxObj = document.getElementById(textBox);
	var textBoxValue = txtBoxObj.value;
	var regEx = /[\w\d]/
	var regEx2 = /^[\s]*[\w\d\s]+$/
	if ( textBoxValue.search(regEx) == -1 || textBoxValue.search(regEx2) == -1) {
		alert(errorMessage);
		txtBoxObj.focus();
		return false;
	}
	return true;
}

function checkPlainString(textBox, errorMessage){
	var txtBoxObj = document.getElementById(textBox);
	var textBoxValue = txtBoxObj.value;
	var regEx = /[\w\d.&,_-]/
	var regEx2 = /^[\s]*[\w\d\s.&,_-]+$/
	if ( textBoxValue.search(regEx) == -1 || textBoxValue.search(regEx2) == -1) {
		alert(errorMessage);
		txtBoxObj.focus();
		return false;
	}
	return true;
}

function checkUsername(textBox, errorMessage){
	var txtBoxObj = document.getElementById(textBox);
	var textBoxValue = txtBoxObj.value;
	var regEx = /[\w\d_]/
	var regEx2 = /^[\s]*[\w\d_]+$/
	if ( textBoxValue.search(regEx) == -1 || textBoxValue.search(regEx2) == -1 || textBoxValue.length < 6) {
		alert(errorMessage);
		txtBoxObj.focus();
		return false;
	}
	return true;
}

function compareValues(textBox1, textBox2, errorMessage){
	var txtBoxObj1 = document.getElementById(textBox1);
	var txtBoxObj2 = document.getElementById(textBox2);
	if ( txtBoxObj1.value != txtBoxObj2.value)
	{
		alert(errorMessage);
		return false;
	} 
	return true;
}

function checkForPassword(textBox, errorMessage, minLen){
	var txtBoxObj = document.getElementById(textBox);
	var textBoxValue = txtBoxObj.value;
	if ( textBoxValue.length < minLen ) {
		alert(errorMessage);
		txtBoxObj.focus();
		return false;
	}
	return true;
}

function checkPlainStringWLen(textBox, errorMessage, minLen, maxLen){
	var ret = checkPlainString(textBox, errorMessage);
	if ( ret == false) return false;
	var txtBoxObj = document.getElementById(textBox);
	var textBoxValue = txtBoxObj.value;
	if ( textBoxValue.length < minLen ) {
		alert(errorMessage);
		return false;
	}
	
	if ( textBoxValue.length > maxLen ) {
		alert(errorMessage);
		return false;
	}
	return true;
}

function checkIndex(textBox, errorMessage){
	var listBox = document.getElementById(textBox);
	if ( listBox.length == 0 || listBox.selectedIndex == 0 ) {
		alert(errorMessage);
		listBox.focus();
		return false;
	}
	return true;
}

function validateDate(textBox, errorMessage){
	var expiryDate = document.getElementById(textBox);
	if (expiryDate.value != "") {
		var datesarr = (new String(expiryDate.value)).split("-");
		var datesx = new Date(parseInt(datesarr[0]), parseInt(datesarr[1])-1, parseInt(datesarr[2]));
		var fullday = new Date();
		var today = new Date(parseInt(fullday.getFullYear()), parseInt(fullday.getMonth()), parseInt(fullday.getDate()));
		if ( datesx < today ) {
			alert("Selected date cannot be less than Today");
			return false;
		}
	} else {
		alert(errorMessage);
		return false;
	}
}

function getClearText( strSrc ) {
	 var regex = /<[^<|>]+?>/gi
	 return  strSrc.replace(regex, "");
}