function updateGallery(url) {
	var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function() {
	if(xmlHttp.readyState==4) {
		eval('var gallery = '+xmlHttp.responseText);
		document.getElementById('photo').src='images/photos/'+gallery.imgsrc;
		document.getElementById('photo').setAttribute('alt',gallery.alt);
		document.getElementById('photonumber').innerHTML=gallery.photo;
		document.getElementById('caption').innerHTML=gallery.caption;
		document.getElementById('previous').setAttribute('href',gallery.previousbutton);
		document.getElementById('next').setAttribute('href',gallery.nextbutton);
		popUpsAndTrackingFunctions();
	}
  }
  xmlHttp.open("GET",url+'&json=true',true);
  xmlHttp.send(null);
}

function photoNav() {
	var links = document.getElementsByTagName('a');
	for (i=0;i<links.length;i++) {
        var link = links[i];
        if (( link.getAttribute ( 'href' ) ) && ( link.getAttribute ( 'rel' ) == 'photonav' ) ) {
            link.onclick = function() {
				updateGallery(this.href);
                return false;
        	}
		}
	}
}

addLoadEvent(photoNav);
