function verifyString_Neutral(control, name, maxlength, required)
{
	var value = document.getElementById(control).value;
	var string_alert = "";
	
	if (required)
	{
		if (value.length <= 0)
		{
			string_alert = name + " is a required field.";
		}
	}
	
	if (value.length > maxlength)
	{
		string_alert = name + " cannot be longer than " + maxlength + ".";
	}
	
	if (string_alert.length > 0)
	{
		alert(string_alert);
		document.getElementById(control).scrollIntoView();
		return false;
	} else {
		return true;
	}
}

function verifyCombo_Neutral(control, name, hasPleaseSelect)
{
	var value = document.getElementById(control).selectedIndex;
	var string_alert = "";
	
	if (hasPleaseSelect)
	{
		if (value < 1)
		{
			string_alert = "Please select an item from the " + name + " list.";
		}
	} else {
		if (value <= 0)
		{
			string_alert = "Please select an item from the " + name + " list.";
		}
	}
	
	if (string_alert.length > 0)
	{
		alert(string_alert);
		document.getElementById(control).scrollIntoView();
		return false;
	} else {
		return true;
	}
}

function verifyDateField_Neutral(strField, strMessage) 
{
	var string_alert = "";
	
	field = document.getElementById(strField);
	strInput = field.value;
	
	if (strInput == "") return true;
	re = new RegExp("^\\d{4}/\\d{2}/\\d{2}$");
	if (!re.test(strInput)) {
		string_alert = "The " + strMessage + " must be in the format yyyy/mm/dd (e.g. 2002/12/31).";
		alert(string_alert);
		document.getElementById(strField).scrollIntoView();
		return false;
	}
	
	intDay = parseInt(strInput.substr(8, 2), 10);
	intMonth = parseInt(strInput.substr(5, 2), 10);
	intYear = parseInt(strInput.substr(0, 4), 10);
	dtVerifyDate = new Date(intYear, intMonth - 1, intDay);
	intVerifyDay = dtVerifyDate.getDate();
	intVerifyMonth = dtVerifyDate.getMonth() + 1;
	intVerifyYear = dtVerifyDate.getYear();

	//For IE: JScript returns xx for years less than 2000. 
	//For Netscape: JScript returns (Year - 1900) (eg for 2003 it returns 103!). This is covered by the next if...
	if (intYear < 2000) intVerifyYear += 1900; //covers BOTH IE and Netscape
	if (intVerifyYear < 500) intVerifyYear += 1900; //covers Netscape
	//Note: I NEED an upper bound here to check whether the getYear value "looks cool". Having picked 500 will allow all dates BEFORE 2400 (1900+500). 

	//Do the actual check
	if (intVerifyYear != intYear || intVerifyMonth != intMonth || intVerifyDay != intDay)
	{
		string_alert = "The " + strMessage + " format is incorrect!";
		alert(string_alert);
		document.getElementById(strField).scrollIntoView();
		return false;
	}
		
	return true;		
}

function verifyInt_Neutral(strField, strMessage, low, high) 
{
	var string_alert = "";
	
	field = document.getElementById(strField);
	number = field.value;

	if (number == "")
	{
		string_alert = "The " + strMessage + " must be an integer in the range " + low + " to " + high + ".";
		alert(string_alert);
		document.getElementById(strField).scrollIntoView();
		return false;
	}
	//General numeric check
	if ((isNaN(parseInt(number)))|((number - parseInt(number) != 0)))
	{
		string_alert = "The " + strMessage + " must be an integer in the range " + low + " to " + high + ".";
		alert(string_alert);
		document.getElementById(strField).scrollIntoView();
		return false;
	}

	//Range Check	
	if ((parseInt(number) < low)|(parseInt(number) > high))
	{
		string_alert = "The " + strMessage + " must be an integer in the range " + low + " to " + high + ".";
		alert(string_alert);
		document.getElementById(strField).scrollIntoView();
		return false;
	}
	
	return true;
}


//Notes

//DON'T USE document.forms[0].submit(). USE document.formname.submit()

//DON'T USE window.navigate("??"). USE location.href = "?";

//The DOT NET IDE converts any WIDTH and HEIGHT settings within the Style attribute into top-level attributes of a control. These attributes are then not understood by other browsers!
//Don't use open these aspx's in the designer view. Also, make sure that you have the width and height as ... Style="...;WIDTH: 200px; HEIGHT: 100px"

