// JavaScript Document
		var numzips = 0;
		var ziplist = "";
		var county_codes = Array("PL","SA","EL","YO");
		var county_titles = Array("Pacer","Sacramento","El Dorado","Yolo");
		var last_sel = true;
		
		function removecheck(mls){
			 $("#ZipOnlyForm").unCheckCheckboxes("#" + mls); 
			 countboxes();
		}
		
		function countboxes(){
		  numzips=0;
		  var s = "";
		  ziplist="";
		  var color = "black";
		  
		  for(i=1;i<=10;i++){
		  	$("#zipvar" + i).val("");
		  }
		  
		  $("#county_container input[@type=checkbox][@checked]").each(function() {
				 numzips++;
				 ziplist += '<span class="sel_zips"><input type="checkbox" checked=true onclick="removecheck('+this.id+')" title="Click to remove this zip from your search" name="zip_sel" id="sel_zip'+ this.id + '" value="'+ this.id + '">' + "<label title=\"Click to remove this zip from your search\" for=\"sel_zip"+ this.id + "\">" + $("label[@for="+ this.id +"]").html() + "</label></span><br />";
				 $("#zipvar" + numzips).attr('value',this.id);//.val(this.id);
			});
			
			if(numzips <= 10){
					$("#zip_count").empty();
					if (numzips==10){
						$("#zip_count").append("0");
				  }else{
				  	$("#zip_count").append(10-numzips);
			 	  }
					
					
				  	if (numzips!=0){
				  		toggle_submit(true);
				  		$('#zip_sel_box').removeAttr('style');
				  		$("h3 span").removeAttr('style');
				  	}else{
				  		toggle_submit(false);
				  		$('#zip_sel_box').attr('style','border: none');
				  		$("h3 span").attr('style', 'display:none');
				  	}
				  	
					if ((10-numzips)!=1){
						s="s"; //Plural distinction
					}
					
					$("#zip_warn_text1").empty().append("You have ");								
					$("#zip_warn_text2").empty().append(" zip code"+s+" remaining.");
					
			}else{
					$("#zip_count").empty().append(numzips-10);		
					$("#zip_warn_text1").empty().append("You have selected more than 10 zip codes. <br />Deselect at least ");;
											
					if ((numzips-10)!=1){
						s="s"; //Plural distinction
					}
							
					$("#zip_warn_text2").empty().append(" zip code"+s+" to continue.");
					
					toggle_submit(false);
					
					color = "red";
			}
						
			$("#zip_sel_box").empty().append(ziplist);

			$("#zip_warn_text1").css({ color: color});
			$("#zip_warn_text2").css({ color: color});
			$("#zip_count").css({ color: color});
		}
	
	  function toggle_submit(enabled){
	  	if (enabled){
	  	  if (!last_sel){
  	  	  last_sel=true;
  	  		$("#submit_button").empty().append('<a href="javascript: HandleForm1()"><img src="/inc/mls/images/searchbtn.gif" title="Retrieve Listings" width="90" height="35" border="0"></a>');
	  	  }
	  	}else{
	  	  if (last_sel){
  	  	  last_sel=false;
  	  		$("#submit_button").empty().append('<img src="/inc/mls/images/searchbtn_disabled.gif" title="Search unavailable until requirements are met." width="90" height="35" border="0">');
  	  	}
	  	}
	  }
	
		function HandleForm1() {
			var Form1 = document.ZipSelectForm;
		  var iPrice;
		  errors = '';
		  iPrice = parseInt(Form1.MinPrice.value);
		  if (Form1.MinPrice.value != '' + iPrice) 
		    {errors += '- Min Price must contain a number.\n'};
		  iPrice = parseInt(Form1.MaxPrice.value);
		  if (Form1.MaxPrice.value != '' + iPrice) 
		    {errors += '- Max Price must contain a number.\n'};
		  if (parseInt(Form1.MinPrice.value) > parseInt(Form1.MaxPrice.value))
			{errors += '- Min Price must be less than or equal to Max Price.\n';}
		  if (Form1.MinAcreage.selectedIndex != 0 && Form1.MaxAcreage.selectedIndex != 0) {
			if (Form1.MinAcreage.selectedIndex > Form1.MaxAcreage.selectedIndex)
			  {errors += '- Min Acres must be less than or equal to Max Acres.\n';}
		  	}
		  if (errors) alert('Please correct the following error and resubmit:\n'+ errors);               
		  if (errors == '') { Form1.submit() }
		}
