// <![CDATA[
function check_form() {
/*Is browser standards based?*/
if (document.getElementById) {
	/*Reset any validation alerts from earlier.*/
	document.getElementById('label_min_price').className = "";
	document.getElementById('label_max_price').className = "";
	if (document.getElementById('validation_alert')) {
		document.getElementById('validation_alert').style.display = "none";
		}
	
	/*Save form field values.*/
	var min_price = parseInt(document.getElementById('lop').value);
	var max_price = parseInt(document.getElementById('hip').value);
	
	/*Check min and max price range is valid.*/
	if (min_price < max_price) {
		/*Allow form submission.*/
		return true;
		}
	else {
		/*If 'validation_alert' exists we can simply unhide it.*/
		if (document.getElementById('validation_alert')) {
			document.getElementById('validation_alert').style.display = "block";
			}
		/*Else, we need to create the element.*/
		else if (!document.getElementById('validation_alert')) {
			/*Create a reference to the 'form_submit' element. This will be the container for the newly created p element.*/
			root_element = document.getElementById('form_submit');

			/*Create the p element.*/
			container = document.createElement("p");
			/*Give the new element the id 'validation_alert' so we can identify it.*/
			container.id = "validation_alert";
			/*Create a text node to hold the message text.*/
			newText = document.createTextNode("Please choose a Minimum Price which is lower than the Maximum.");
			/*Insert the text node into the p element.*/
			container.appendChild(newText);
			/*Insert the p element into root_element.*/
			root_element.appendChild(container);
			}
			
		/*Highlight the appropriate form elements.*/
		document.getElementById('label_min_price').className = "validation_highlight";
		document.getElementById('label_max_price').className = "validation_highlight";
		
		/*Suppress form submission.*/
		return false;
		}
	}
/*Browser isn't standards based, or javascript is turned off. We'll have to rely on server side error checking.*/
else {
	/*Allow form submission.*/
	return true;
	}
}
// ]]>
