//************************* ADVANCED SEARCH PAGE CODE
//*****************************************************************

var countyData = new Array();
countyData[countyData.length] = "ChittendenCounty|Bolton|Richmond|Burlington|Shelburne|Charlotte|StGeorge|Colchester|SouthBurlington|Essex|Underhill|Hinesburg|Westford|Huntington|Williston|Jericho|Winooski|Milton";
countyData[countyData.length] = "FranklinCounty|Bakersfield|Georgia|Berkshire|Highgate|Enosburg|Montgomery|Fairfax|Richford|Fairfield|Sheldon|Fletcher|StAlbansTown|Franklin|Swanton";
countyData[countyData.length] = "AddisonCounty|Addison|NewHaven|Bridport|Orwell|Bristol|Panton|Cornwall|Ripton|Ferrisburg|Salisbury|Goshen|Shoreham|Granville|Shoreham|Granville|Starksboro|Hancock|Vergennes|Leicester|Waltham|Lincoln|Weybridge|Middlebury|Whiting|Monkton";
countyData[countyData.length] = "GrandIsleCounty|Alburg|GrandIsle|SouthHero|IsleLaMotte|NorthHero";
countyData[countyData.length] = "WashingtonCounty|Middlesex|Moretown|Waitsfield|Warren|Waterbury";
countyData[countyData.length] = "LamoilleCounty|Cambridge|HydePark|Morristown|Stowe";


var cindex = new Array();
var cdata = new Array();
for( var i=0; i<countyData.length; i++ ){
	var towns = countyData[i].split("|");
	cindex[ towns[0] ] = towns[0];
	for( var ii=1; ii<towns.length; ii++ ){
		cdata[ towns[ii] ] = cindex[ towns[0] ];
	}
}
  function swapPic(img) {
    document['mainPhoto'].src = img;
  }
  

function toggle( obj ){
	if( cindex[ obj.name ] ){ // We are working with the county
		//alert( "County: " + cindex[ obj.name ] );
		var ie = document.all;
		if( obj.checked ){
			for( var i in cdata ){
				if( cdata[i] == cindex[ obj.name ] && obj.form.elements[i].checked == true ){
					obj.form.elements[i].checked = false;
				}
			}
		}
   }
	
	if( cdata[ obj.name ] ){ // We are working with towns
		obj.form.elements[cdata[ obj.name ]].checked = false;
	}

}

function doSave(){
	var saveName = document.nameForm.saved_name.value;
	var input = document.createElement("input");
	input.setAttribute("name", 'saved_name');
	input.setAttribute("value", saveName);
	document.searchProperties.appendChild(input);	
	var input2 = document.createElement("input");
	input2.setAttribute("name", 'saveSearch');
	input2.setAttribute("value", '1');
	document.searchProperties.appendChild(input2);			
	document.searchProperties.action='advanced-vermont-home-search.php';	
	document.searchProperties.submit();
}

function clearForms(){
	document.searchProperties.reset();
}
