function isBlank(testStr) 
{
	if (testStr.length == 0) 
		return true
	for (var i = 0; i <= testStr.length-1; i++) // all spaces?
		if (testStr.charAt(i) != " ")
			return false
	return true
}

function isDate(str)
{
	if(isNaN(new Date(Date.parse(str)))) {
	   return false;
	  }
	else {
	   return true;
	}
}

function checkEmail(strEmail, bRequired, strName) {
	var msg = '';
	if (isBlank(strEmail)) {
		if (bRequired) {
			msg += '\n - ' + strName + ' is Required  - You must enter a valid email address (username@domain.com)';
		}
	} else {
		if (! /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail)){
			msg += '\n - ' + strName + ' - You must enter a valid email address (username@domain.com) ';
		}	
	}
	return msg;
}

function cancelForm(LinkTo) {
	location.href=LinkTo;
}

function check_uncheck_CheckBoxes(formname, CheckboxName, check_flag){
	CheckboxName = CheckboxName.toLowerCase();
	var obj = eval("document."+formname+".elements");
	for(i=0;i<obj.length;i++){
		temptype = obj[i].type.toLowerCase();
		tempName = obj[i].name.toLowerCase();
		if(temptype=="checkbox" && CheckboxName == tempName){
			obj[i].checked = check_flag;
		}
	}
}

function stripNonAlphaNumericChars(obj, field_name){
	//alert("here")
	val = obj.value;
	//alert(val);
	newval = val.replace(/[^a-zA-Z0-9_\s]/g, "")
	if (val != newval){
		obj.value = newval;
		alert("The " + field_name + " can contain only alpha-numeric characters, underscores and spaces\nOther characters will be stripped");
	}
}

function IsAquiferNumeric(bAllowDecimal, sText) {
	var IsNumber=true;
	var Char;
	if (bAllowDecimal) 
		var ValidChars = "0123456789.";
	else
		var ValidChars = "0123456789";

	for (i = 0; i < sText.length && IsNumber == true; i++) { 
	   Char = sText.charAt(i); 
	   if (ValidChars.indexOf(Char) == -1) 
	      IsNumber = false;
	}
	return IsNumber;
}

