// JavaScript Document

var __busy = false;
var timerID = 0;
var eventsStack = new Array();
function accordion2(el) {
	if ($('visible') == el) {
		return;
	}
	if (!__busy) {
		__busy = true;
    changeText(el);
		timerID = setTimeout(	"clearFlag()",250);
		accordion(el);
	} else {
    eventsStack[eventsStack.length] = el;
  }
}
function changeText(theDiv) {
  var Ltitle = $("viewImageTitle");

  switch(getObjInnerText(theDiv)) {
    case "Condominiums at the Heritage":
      Ltitle.innerHTML = "<p>Condominiums at the Heritage situated in York, PA.</br>Established in 1993 and the last home was sold in 2000.</p>"
      break;
    case "Fountains at the Heritage":
      Ltitle.innerHTML = "<p>Fountains at the Heritage is a condominium neighborhood situated in York, PA.</br>Construction in this development began in 2002 and the last home was sold in 2005.</p>"
      break;
    case "River Bend Park":
      Ltitle.innerHTML = "<p>River Bend Park is a condominium neighborhood situated in York, PA.</br>Established in 1990. The last home was sold in 2001.</p>"
      break;
    case "Rosenmiller Woods":
      Ltitle.innerHTML = "<p>Rosenmiller Woods is a condominium neighborhood situated in York, PA.</br>Established in 1998. The last home was sold in 2001.</p>"
      break;
    case "Avalong Place":
      Ltitle.innerHTML = "<p>Avalong Place is a condominium neighborhood situated in York, PA.</br>Established in 1989. The last home was sold in 1993.</p>"
      break;			
    case "Blossom Hill":
      Ltitle.innerHTML = "<p>Blossom Hill is a Single Family Home neighborhood situated in Dallastown, PA.</br>Established in 1999 and the last home was sold in 2005.</p>"
      break;
    default:
      Ltitle.innerHTML = "<p>SELECT NEIGHBORHOODS AND CLICK ON IMAGES TO VIEW ENLARGED PHOTOS</p>"
      break;
  }
}
function getObjInnerText(obj) {
  if (document.all) { // IE;
    return obj.innerText;
  } else if (obj.textContent) {
    return obj.textContent;
  } else if (obj.text) {
    return obj.text;
  }
  return "";
}
function clearFlag() {
  var popNext = false;
  var el;
	clearTimeout(timerID);
  if (eventsStack.length > 0) {
    popNext = true;
    el = eventsStack[0];
    eventsStack.splice(0,1);
  }
	__busy = false;
  if (popNext) {
    accordion2(el);
  }
}
function accordion(el) {
	if ($('visible')) {
		var eldown = el.parentNode.id+'-body';
		var elup = $('visible').parentNode.id+'-body';
		new Effect.Parallel(
		[
			new Effect.SlideUp(elup),
			new Effect.SlideDown(eldown)
		], {
			duration: 0.2
		});
		$('visible').id = '';
	}
	el.id = 'visible';
}

function init() {
	__busy = false;
	// hide all elements apart from the one with id visible
	var acc = document.getElementById('connectButtons');
	var apanels = acc.getElementsByTagName('div');
	for (i = 0; i < apanels.length; i++) {
			if (apanels[i].className == 'showArea') {
				apanels[i].style.display = 'none';
			}
	}
	var avis = document.getElementById('visible').parentNode.id+'-body';
	document.getElementById(avis).style.display = 'block';
}
function addEvent(elm, evType, fn, useCapture) {
	elm["on"+evType]=fn;return;
}

addEvent(window, "load", init);


