
	function ValueCheck(StrValue,CheckValue, strMsg)
	{
		if (StrValue == CheckValue)
		{ 
			if (fCheck)
			{                     
				alert(strMsg)
				fCheck = false
			}
		}
	}


	function IntCheck(IntValue, strMsg)
	{
		if (isNaN(IntValue))
		{   
			if (fCheck)
			{                    
				alert(strMsg)
				fCheck = false
			}
		}
	}


	function LengthCheck(StrValue, FieldName, MaxLength)
	{
		if (StrValue.length > MaxLength)
		{   
			if (fCheck)
			{   
				var substr = StrValue.substring(StrValue.length,MaxLength) 
             
				alert("you have exceeded the " + MaxLength + " character limit for the " + FieldName + " field\nthe following text will need to be removed:\n\n" + substr)
				fCheck = false
			}
		}
	}


	function SelectCheck(OptionValue,CheckValue, strMsg)
	{
		if (OptionValue == CheckValue)
		{ 
			if (fCheck)
			{                     
				alert(strMsg)
				fCheck = false
			}
		}
	}

	function UpdateFieldValue(which_element, final_value){
		with (window.document) {
			which_element.value = final_value
			//alert(which_element.name + " = " + which_element.value)
		}
	}

	function SubmitForm(which_form, field_str)
	{
		// CHECK FOR OPTIONAL ACTION OVERIDE
		my_arr = field_str.split("~#~")
		if (my_arr.length == 2){
			which_form.action = my_arr[0]
			field_str = my_arr[1]
		} else {
			field_str = my_arr[0]
		}

		field_arr = field_str.split("|")

		with (window.document) {
			for ( i=0; i < which_form.elements.length; i++ ) {
				current_name = which_form.elements[i].name

				for (j=0; j < field_arr.length; j++){
					data_arr = field_arr[j].split("~=~")
					if (current_name == data_arr[0]) {

						UpdateFieldValue(which_form.elements[i], data_arr[1]);
						break
					}
				}
			}
		}

		which_form.submit()
	}


	function SubmitIdSearch(which_form, which_field, field_name)
	{

		fCheck = true

		ValueCheck(which_field.value, "", "Please enter a property_id");
		IntCheck(which_field.value, "The " + field_name + " should contain numbers only.\nPlease remove any non numeric characters.");

		if (fCheck)
		{
			which_form.submit()
		}
	}
	

	function AtLeastOneSelected(which_form, element_name, check_mode, alert_message){
		if (fCheck) {
			fCheck = false;
			with (window.document) {
				for ( i=0; i < which_form.elements.length; i++ ) {
					current_name = which_form.elements[i].name
					if (current_name.substring(0,element_name.length) == element_name) {
						if ((check_mode == "checkbox" && which_form.elements[i].checked == true) || (check_mode == "text_field" && which_form.elements[i].value != "")) {
							fCheck = true;
							break;
						}
					}
				}
			}
			if (fCheck == false){
				alert(alert_message);
			}
		}
	}
