function setDisplay(objectID) {
	var object = document.getElementById(objectID);
	state = object.style.display;
	if(state == 'block'){
		object.style.display = 'none';
	}else{
		object.style.display = 'block';
	}
	
}
function replaceText(el, text) {
  if (el != null) {
    clearText(el);
    var newNode = document.createTextNode(text);
    el.appendChild(newNode);
  }
}

function clearText(el) {
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        el.removeChild(childNode);
      }
    }
  }
}

function getText(el) {
  var text = "";
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        if (childNode.nodeValue != null) {
          text = text + childNode.nodeValue;
        }
      }
    }
  }
  return text;
}
var request = null;
function createRequest() {
     try {
       request = new XMLHttpRequest();
     } catch (trymicrosoft) {
       try {
         request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (othermicrosoft) {
         try {
           request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (failed) {
           request = null;
         }
       }
     }

     if (request == null)
       alert("Error creating request object!");
}

function getProject(newProject,name){
	// alert('new project: ' + newProject);
    createRequest();
	var url = "_projects.php?project=" + newProject;
	url += "&name=" + name;
	request.open("GET",url,true);
    request.onreadystatechange = updatePage;
	request.send(null);
}

function updatePage() {
    if (request.readyState == 4) {
      	var newHTML = request.responseText;
	  	document.getElementById('image_navigation').innerHTML=newHTML;
	  	var first = document.getElementById('firstinlot');
//		alert("first is" + first);
		if(first){document.getElementById('bigImage').src = first.src;}
		updatePicInfo();
    }
}
function changeBigImage(newImage){
	var destination = document.getElementById('bigImage');
	destination.src = ("images/" + newImage);
	updatePicInfo();
}
function updatePicInfo(){
	var location = document.getElementById('bigImage').src;
	location = location.replace(/http:\/\/www.wallaceharding.com\/images\//,"");
//	alert('location' + location);
	var url = "inc/_picinfo.php?location=" + location;
    createRequest();
	request.open("GET",url,true);
    request.onreadystatechange = updatePicInfo2;
	request.send(null);
}
function updatePicInfo2(){
    if (request.readyState == 4) {
      	var newHTML = request.responseText;
	  	document.getElementById('picinfo').innerHTML=newHTML;
    }
}