// JavaScript Documentfunction addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      oldonload();      func();    }  }}function insertAfter(newElement,targetElement) {  var parent = targetElement.parentNode;  if (parent.lastChild == targetElement) {    parent.appendChild(newElement);  } else {    parent.insertBefore(newElement,targetElement.nextSibling);  }}function prepareSearchForm () {	var form = document.searchForm;	form.onsubmit = function() {		return validateSearchForm(this);	}	}function validateSearchForm(whichForm) {	removeErrorMsg();	var minPrice = parseInt(whichForm.Minimum_Price.value);	var maxPrice = parseInt(whichForm.Maximum_Price.value);	if (minPrice > maxPrice) {		//alert(minPrice + " is greater than " + maxPrice);		displayError("searchbutton", "Your Minimum is higher than your Maximum Price. Please select a new range.");		return false;	} else if (minPrice == maxPrice) {		//alert(minPrice + " is the same as " + maxPrice);		displayError("searchbutton", "Your Minimum is the same as your Maximum Price. Please select a new range.");		return false;	}	return true;}function removeErrorMsg() {	var paras = document.getElementsByTagName("p");	for (var i=0; i<paras.length; i++) {		if (paras[i].getAttribute("class") == "errorMsg") {			paras[i].parentNode.removeChild(paras[i]);			i--;		}	}}function displayError(where,msg) {	if (!document.createElement) return false;	if (!document.createTextNode) return false;	if (!document.getElementById) return false;	var beforeElement = document.getElementById(where);	var errorMsg = document.createElement("p");	errorMsg.setAttribute("className","errorMsg");	errorMsg.setAttribute("class","errorMsg");	var errorMsgText = document.createTextNode(msg);	errorMsg.appendChild(errorMsgText);	insertAfter(errorMsg,beforeElement);}addLoadEvent(prepareSearchForm);