function emailListing(id){
	$("body").append('<div id="dimmer"></div>');
	$("body").append('<div id="newPlacementHolder"></div>');
	$("#newPlacementHolder").append('<div id="frame_holder" style="text-align: left; margin: auto; width: 600px; height: 250px; border: 1px solid #333; background: #fff;"></div>');
	$("#frame_holder").append('<iframe src="/email_listing.htm?id=' + id + '" frameborder="0" style="width: 100%; height: 100%;"></iframe>');
}
function closeExtraWindows(){
	$("#newPlacementHolder").empty();
	$("#newPlacementHolder").remove();
	$("#dimmer").remove();
}
function toggleCheckbox(box){
	if($(box).attr("checked")){
		$(box).attr("checked",false);
	}else{
		$(box).attr("checked",true);
	}
}
function toggleCityTrigger(){
	$('#SearchCitiesHolder').toggle();
	$('#CityTrigger').toggle();
}
function changeCityDisplay(){
	if($(":checkbox[checked]").length>1){
		$("#cityValue").text("Selected Cities");
	}else if($(":checkbox[checked]").length==1){
		$("#cityValue").text( $(":checkbox[checked]").attr("value") );
	}else {
		$("#cityValue").text("Any City");
	}
}
function checkSearchCriteria(){
	var city = '';
	if( document.forms['homeSearch'].elements['City'] ){
		city = document.forms['homeSearch'].elements['City'].value;
	}
	var state = document.forms['homeSearch'].elements['State'].value;
	var zip = document.forms['homeSearch'].elements['Zip'].value;
	var mls = document.forms['homeSearch'].elements['MLS'].value;

	if(city!='' || state!='' || zip.length>4 || mls.length>4 || $(":checkbox[checked]").length>0 ){
		return true;
	}
	createDialogBox('Error','Misssing Required Information','You must first provide a City and State or a Zip Code or a MLS Number');
	return false;
}
function filterPropOptions(propType){
	//enable all options
	var options = document.forms['homeSearch'].elements;
	for(var i=0; i<options.length; i++){
		options[i].disabled=false;
	}
	if(propType==11){
		document.forms['homeSearch'].elements['Acres'].disabled=true;
	}
	if(propType==12){
		document.forms['homeSearch'].elements['Sq_Ft'].disabled=true;
		document.forms['homeSearch'].elements['Bedrooms'].disabled=true;
		document.forms['homeSearch'].elements['Bathrooms'].disabled=true;
	}
	pageSetup();
}

$(document).ready(function(){
	$("#SearchCitiesHolder").mouseleave(function(){
		$('#SearchCitiesHolder').css("display","none");
		$('#CityTrigger').css("display","");
	});
});

