var isKonq = false;
var isNS4 = false;
var isIE4only = false;
var isIE4 = false;
var isMoz = false;
var isLinux = false;
var isOpera = false;
var isMac = false;
var isSafari = false;
var validDom = false;
var hidden = "hidden"
var visible = "visible"

if (document.getElementById) validDom = true;
if (navigator.appVersion.indexOf("Mac") > -1) isMac = true;
if (navigator.appVersion.indexOf("Safari") > -1) isSafari = true;
if (document.layers) isNS4 = true;
else if (document.all) {
	isIE4 = true
	if (navigator.appVersion.indexOf("MSIE 4") > -1) isIE4only = true;
} else if (document.getElementsByTagName("*")) isMoz = true;

if (navigator.userAgent.indexOf("Opera") > -1) isOpera = true;
if (navigator.appVersion.indexOf("Linux") > -1 || navigator.userAgent.indexOf("Linux") > -1) {
	isLinux = true;
}
if (navigator.appVersion.indexOf("Konqueror") > -1) isKonq = true;

//****************************************//

function swapImage(which,how) {
	if (which == whichSection) return;	
	if (document.getElementById(which.split("Arrow")[0]+"Div") != null) {
		var blockStyle = document.getElementById(which.split("Arrow")[0]+"Div").style.display;
	}
	if (blockStyle != "block" || (blockStyle == "block" && which.indexOf("Arrow") == -1)) {
  		eval("document.images['" + which + "Img'].src = " + which + "_" + how + ".src");
	}
}

//****************************************//

function toggleDiv(which) {	
	if (document.getElementById(which+"Div") == null) return;
	if (document.getElementById(which+"Div").style.display != "block") {
		var how = "on";
		var display = "block";
	} else {
		var how = "off";
		var display = "none";
	}
	//swapImage(which,how);
	swapImage(which+"Arrow",how);
	document.getElementById(which+"Div").style.display = display;
}

//****************************************//

function openMedia(which) {
	if (isMac) {
		location = which;
		return;
	}
	window.open(which);
}

//****************************************//

function imgCache(which) {
	var whichSrc = which;
	if (which.indexOf("Arrow") > -1) whichSrc = "navarrow";
	eval(which+"_off = new Image()");
	eval(which+"_off.src = '/pix/" + whichSrc + "_off.gif'");
	eval(which+"_on = new Image()");
	eval(which+"_on.src = '/pix/" + whichSrc + "_on.gif'");
}

//****************************************//

function doNav() {	
	if (typeof whichPage != "undefined" && whichPage != "") {	// highlighting the correct leftnav page
		var tempDiv = document.getElementById(whichSection+"Div").childNodes	
		for (var i=0; i<tempDiv.length; i++) {
			if (typeof tempDiv[i].innerHTML != "undefined" && tempDiv[i].innerHTML.indexOf(whichPage) > -1) {
				var re = /nav/gi
				tempDiv[i].innerHTML = tempDiv[i].innerHTML.replace(re,"navOn");
			}
		}
	}
	eval("document.images['" + whichSection + "Img'].src = " + whichSection + "_on.src");

	toggleDiv(whichSection);
	document.getElementById("navTable").style.visibility = "visible";
}

//****************************************//

function init() {
	if (whichSection == "home") {
		var imgArray = new Array("about_home","neighborhood_home","contacts_home","news_home","development_home");
	} else {
		var imgArray = new Array("about","aboutArrow","neighborhood","neighborhoodArrow","contacts","news","development");
	}
	for (i=0; i<imgArray.length; i++) {
		imgCache(imgArray[i]);
	}
}

//****************************************//

function showProps(obj,objName) {
   var result = ""
   var count = 0
   for (var i in obj) {
      result += objName + "." + i + " = " + obj[i] + "\n"
      count++
      if (count == 25) {
         alert(result)
         result = ""
         count = 0
      }
   }
   if (count != 0) alert(result)
}

//****************************************//

init();
