function ahah(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
	ahah(name,div);
	return false;
}

function LoadGallery(imageFile,captionText,iD)
{
	load(captionText,'sub_gallery');
	changeBg(iD);
  var picture = document.getElementById('gallery');
  document.getElementById('gallery').src = imageFile;
  if (picture.filters)
  {
    picture.style.filter="blendTrans(duration=1)";
    picture.filters.blendTrans.Apply();
  }
  picture.src = imageFile;
  if (picture.filters)
  {
    picture.filters.blendTrans.Play();
  }
}

function LoadImage(imageFile)
{
  var picture = document.getElementById('gallery');
  document.getElementById('gallery').src = imageFile;
  if (picture.filters)
  {
    picture.style.filter="blendTrans(duration=1)";
    picture.filters.blendTrans.Apply();
  }
  picture.src = imageFile;
  if (picture.filters)
  {
    picture.filters.blendTrans.Play();
  }
}

function changeBg(iD)
{	
	document.getElementById('g1').style.background="url(images/buttons/gal_arbors_out.png)";
	document.getElementById('g2').style.background="url(images/buttons/gal_bbqs_out.png)";
	document.getElementById('g3').style.background="url(images/buttons/gal_tropical_out.png)";
	document.getElementById('g4').style.background="url(images/buttons/gal_flagstone_out.png)";
	document.getElementById('g5').style.background="url(images/buttons/gal_water_out.png)";
	document.getElementById('g6').style.background="url(images/buttons/gal_miscellaneous_out.png)";
	
	document.getElementById(iD).style.background="none";
}

function swapBg(iN, status)
{
	document.getElementById("g"+iN).style.background="url(images/buttons/gal"+status+"_"+iN+".png)";
}