function ShowDropDown() { document.getElementById("DropMenu").style.display = "block"; }
function HideDropDown() { document.getElementById("DropMenu").style.display = "none"; }
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox() 
})
window.name="mainwindow";
function jumpBox(list) {
  location.href = list.options[list.selectedIndex].value
}
function selectFieldValue(formName,fieldName,val){
	var i,frmObj,fieldObj,fieldLength;
	frmObj=document.all[formName];
	fieldObj=frmObj[fieldName];
	fieldLength=fieldObj.options.length;
	for(i=0;i<fieldLength;i++){
	if(fieldObj.options[i].value==val)
			fieldObj.options[i].selected=true;
	}
}
function selectFieldValue_HS(formName,fieldName,val){
	var i,frmObj,fieldObj,fieldLength;
	frmObj=document.all[formName];
	fieldObj=frmObj[fieldName];
	fieldLength=fieldObj.options.length;
	for(i=0;i<fieldLength;i++){
		if(fieldObj.options[i].value==val)
			fieldObj.options[i].selected=true;
	}
	sendReq()
}
function showNoKent()
{
jQuery.facebox('<div style="color: #FF0000; font-size: 24px; padding: 50px; border: 2px solid #000000; background: #FEFEFE;" align="center">Unfortunately, you may only search under Sussex County at this time.<br><br>Kent County will be available soon! Please check back.</div>');
}
function CheckNumberOnly(theField){
  if(theField.value.match(/\D/)){
    theField.value = theField.value.replace(/\D/g,"");
  };
}
function sendReq() {
varUID = GenerateRandomNumber();
// Find City Values
var CityArray = new Array();
for (var j = 1; j < document.Homesearch.City.options.length; j++)
if (document.Homesearch.City.options[ j ].selected)
CityArray.push(document.Homesearch.City.options[ j ].value);
// Find Property Type Values
var PropertyTypeArray = new Array();
for (var j = 1; j < document.Homesearch.Property_Type.options.length; j++)
if (document.Homesearch.Property_Type.options[ j ].selected)
PropertyTypeArray.push(document.Homesearch.Property_Type.options[ j ].value);
// Find Property Type Values
var CommunityArray = new Array();
for (var j = 1; j < document.Homesearch.Community.options.length; j++)
if (document.Homesearch.Community.options[ j ].selected)
CommunityArray.push(document.Homesearch.Community.options[ j ].value);

varCriteria = "homesearch_count.asp?UID="  + varUID
+ "&City=" + CityArray
+ "&PropertyType=" + PropertyTypeArray
+ "&Community=" + CommunityArray
+ "&County=" + document.Homesearch.County.value
+ "&Min_Price=" + document.Homesearch.Min_Price.value
+ "&Max_Price=" + document.Homesearch.Max_Price.value
+ "&Min_Beds=" + document.Homesearch.Min_Beds.value
+ "&Min_Baths=" + document.Homesearch.Min_Baths.value
+ "&Year_Built=" + document.Homesearch.Year_Built.value
+ "&SqFt=" + document.Homesearch.SqFt.value
if (document.Homesearch.PhotoYN.checked){
varCriteria = varCriteria + "&PhotoYN=" + document.Homesearch.PhotoYN.value
}
include(varCriteria,"ResultsCount") 
}
function GenerateRandomNumber() {
	var randomnumber= Math.floor(Math.random()*80000000)+10000000;
	return (randomnumber);
}
function window_open(filename, x, y)
{
  windowops = eval("'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=" + x + ",height=" + y + "'");
  window.open(filename, 'New1', windowops);
  return;
}
function window_open_noscroll(filename, x, y)
{
  windowops = eval("'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=" + x + ",height=" + y + "'");
  window.open(filename, 'New1', windowops);
  return;
}

function popup(url, name, width, height, resizable)
{
	var popwin;
	var opts = "toolbar=no,status=no,location=no,menubar=no,scrollbars=yes";
	opts += ",height=" + height + ",width=" + width + ",resizable=" + resizable;
	popwin = window.open("", name, opts);
	popwin.focus();
	popwin.location = url;
	popwin.opener = self;
}
function DoNothing(){
jQuery(document).trigger('close.facebox')
}