/********************************************************
  CSS CLASS SWITCHER
  
  use this function to apply a new css class to an html
  element, or switch back and forth between css classes
********************************************************/
function changeCSSClass(id, newClass) {
	document.getElementById(id).className = newClass;
	return;
}

/********************************************************
  POP UP WINDOW
  
  use this function to open a fixed sized window
********************************************************/
function changeCSSClass(id, newClass) {
	document.getElementById(id).className = newClass;
	return;
}
popupWins = new Array();

function windowOpener(url, name, args) {
/*******************************
the popupWins array stores an object reference for
each separate window that is called, based upon
the name attribute that is supplied as an argument
*******************************/
if ( typeof( popupWins[name] ) != "object" ){
	popupWins[name] = window.open(url,name,args);
} else {
	if (!popupWins[name].closed){
		popupWins[name].location.href = url;
	} else {
		popupWins[name] = window.open(url, name,args);
	}
}

popupWins[name].focus();
}

/********************************************************
  CSS CLASS MANAGER
  
  use this function to switch back and forth between css
  class on multiple entries
********************************************************/
var header = new Array();
header[0] = "";
header[1] = "";
header[2] = "";
header[4] = "village";
header[5] = "apartments";
header[6] = "steps";
header[7] = "walking";
header[8] = "minutes";

var list = new Array();
list[0] = "";
list[1] = "";
list[2] = "";
list[4] = "villageList";
list[5] = "apartmentsList";
list[6] = "stepsList";
list[7] = "walkingList";
list[8] = "minutesList";
function switchGroup(heading, headingList) {
	for(i = 4; i <= 8; i++) {
		changeCSSClass(header[i], 'closed');
		changeCSSClass(list[i], 'hidden');
	}
	header[9] = heading;
	list[9] = headingList;
	changeCSSClass(header[9], 'open');
	changeCSSClass(list[9], 'visable');
	return;
}
/********************************************************
 POP-UP WINDOWS
********************************************************/
popupWins = new Array();

function windowOpener(url, name, args) {

	/**
	 * the popupWins array stores an object reference for
	 * each separate window that is called, based upon
 	 * the name attribute that is supplied as an argument
 	**/

	if ( typeof( popupWins[name] ) != "object" ){
		popupWins[name] = window.open(url,name,args);
	} else {
		if (!popupWins[name].closed){
			popupWins[name].location.href = url;
		} else {
			popupWins[name] = window.open(url, name,args);
		}
	}
	popupWins[name].focus();
}

/********************************************************
  NEW BROWSER WINDOW
  use this function to recreate the tarbet=_blank effect
********************************************************/
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
  	var anchor = anchors[i];
  		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "newwin")
    			anchor.target = "_blank";
	}
}
window.onload = externalLinks;
