
function swapTabs(obj, r) {
	var obj = document.getElementById(obj);
	
	document.getElementById('form-buy').style.display = 'none';
	document.getElementById('form-rent').style.display = 'none';
	
	obj.style.display = 'block';
	
	var tabs = document.getElementById('tabs-search');
	
	var rlink = tabs.getElementsByTagName('a'); 
	for (var i = 0; i < rlink.length; i++) { 
		status = rlink[i].className = ''; 
	}
			
	r.className = 'active';
}

function refreshTownOptions(county) {
   // with AJAX, load a sub set of towns just for this county
   $.getJSON('hanover_tool/getAllTownOptions_json', {county:county}, function(r) {
      // clear all options
      $('select[name="town"] option').remove();
      // insert an all
      var container = $('select[name="town"]');
      container.append($('<option>').attr('value','').text('All'));
      for (var i=0, len=r.towns.length; i<len; i++) {
         container.append($('<option>').attr('value',r.towns[i]).text(r.towns[i]));
      }
   });
}


function randomHomeImg(){
	var homeImages=new Array();
	var altText=new Array();
	
	homeImages[1]="homepage/1.jpg";
	homeImages[2]="homepage/2.jpg";
	homeImages[3]="homepage/3.jpg";
	homeImages[4]="homepage/4.jpg";
	homeImages[5]="homepage/5.jpg";
	homeImages[6]="homepage/6.jpg";
	homeImages[7]="homepage/7.jpg";
	homeImages[8]="homepage/8.jpg";
	
	altText[1]="Helping to become the leading provider for older people looking for high quality retirement housing and related services";
	altText[2]="High quality housing, individual choice and peace of mind";
	altText[3]="Providing excellent properties and services that support the independance and individuality of older people";
	altText[4]="Enjoy retirement and making a positive contribution to your community";
	altText[5]="Your choice of retirement housing - location, property features and services";
	altText[6]="Making retirement housing a positive choice for older people";
	altText[7]="Working to provide housing and services that help residents to enjoy life and maintain independance";
	altText[8]="Pioneer provider of housing and related services to older people;"
	
	var ry=Math.floor(Math.random()*homeImages.length);
	
	if (ry==0)
		ry=1;
	document.write('<img src="'+homeImages[ry]+'" alt="'+altText[ry]+'" width="705" height="266" />');
}

sfHover = function() {
	var sfEls = document.getElementById("topNavMain").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);
