function preloadImages(the_image_array)
{
  for(loop=0;loop<the_image_array.length;loop++)
  {
    var an_image = new Image();
    an_image.src = the_image_array[loop];
  }
}

function setMinPrice () {
    var i = document.searchForm.FRM_max_price.selectedIndex;
    if (i > 0 && i < document.searchForm.FRM_min_price.selectedIndex) {
        document.searchForm.FRM_min_price.options[i-1].selected = true;
    }
}
function setMaxPrice () {
    var i = document.searchForm.FRM_min_price.selectedIndex;
    if (i > 0 && i < (document.searchForm.FRM_min_price.length - 1)) {
        if (i > document.searchForm.FRM_max_price.selectedIndex) {
            document.searchForm.FRM_max_price.options[i+1].selected = true;
        }
    } else {
        document.searchForm.FRM_max_price.options[0].selected = true;
    }
}

function openWindow(page,width,height) {
	windowFeatures = "";
	window_width = width;
	window_height = height;
	window_top = (screen.availHeight-window_height)/2;
	window_left = (screen.availWidth-window_width)/2;
	windowFeatures += "width=" + window_width + ",height=" + window_height + ",top=";
	windowFeatures += window_top;
	windowFeatures += ",left=";
	windowFeatures += window_left;
	windowFeatures += ',status=0,scrollbars=1';

	window.open(page,"mywindow", windowFeatures);
}


function openWindowViaForm(width,height) {
	windowFeatures = "";
	window_width = width;
	window_height = height;
	window_top = (screen.availHeight-window_height)/2;
	window_left = (screen.availWidth-window_width)/2;
	windowFeatures += "width=" + window_width + ",height=" + window_height + ",top=";
	windowFeatures += window_top;
	windowFeatures += ",left=";
	windowFeatures += window_left;
	windowFeatures += ',status=0,scrollbars=1,location=no,toolbar=0';
        window.open( '','remote', windowFeatures);
}


function searchCheck(width, height) {

       var r ="";
       var city = document.searchForm.FRM_city.selectedIndex;
       var min = document.searchForm.FRM_min_price.selectedIndex;
       var max = document.searchForm.FRM_max_price.selectedIndex;

       page ="http://www.mlsfinder.com/nj_trend/billmulhern/";
       page +="?action=newsearchsession&searchtype=city";
       page +="&city=" + document.searchForm.FRM_city.options[city].value + "&min_price="+  document.searchForm.FRM_min_price.options[min].value + "&max_price=" + document.searchForm.FRM_max_price.options[max].value;	


	if (city ==0) {
		r += "   City\n";
	}
	

	if (document.searchForm.FRM_email.value =="") {
		r += "   E-mail Address\n";
	}	

	
	if (r.length >0) {
	   alert("The following items are not complete:\n\n" + r + "\nPlease complete all fields");
	   return(false)
	} else {
	   openWindow(page,width,height);
	   return(true);
	}
}