/* Javascript File for Goldsmith Computer Services */
var ajax = null;
var target = "";
// Ajax Stuff

function getgallery(tgt) {
//initBrowser(); // load up any other page elements before calling ajax routine
document.getElementById('gallerydiv').style.display = "block";
target = tgt;
ajax=GetXmlHttpObject();
if (ajax==null)  // browser does not support AJAX
  {
  alert ("Your browser does not support AJAX!"); // let them know!
  return;
  }
var scripturl = "http://www.philipenglish.ie/cgi-bin/gallery.pl?type=ajax";
ajax.onreadystatechange=stateChanged;
ajax.open("GET",scripturl,true);
ajax.send(null);
}

function getimage(filename) {
//initBrowser(); // load up any other page elements before calling ajax routine
target = "image";
document.getElementById('overlay').style.display = "block";
document.getElementById('image').style.display = "block";
var file = filename; 
ajax=GetXmlHttpObject();
if (ajax==null)  // browser does not support AJAX
  {
  alert ("Your browser does not support AJAX!"); // let them know!
  return;
  }
var scripturl = "http://www.philipenglish.ie/cgi-bin/gallery.pl?type=ajax&action=view&file="+file;
ajax.onreadystatechange=stateChanged;
ajax.open("GET",scripturl,true);
ajax.send(null);
}

// ajax stuff

function GetXmlHttpObject()
{
try
  {
  // Firefox, Opera 8.0+, Safari
  ajax=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    ajax=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    ajax=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return ajax;
}


function stateChanged()
{
if (ajax.readyState==4) // when request has completed
  {
  if(target == "gallerydiv") 
    {  
	document.getElementById(target).innerHTML =  ajax.responseText; //return the repsonse to the browser
	}
  else
    {
	if(target == "image")
	  {
	  var text = ajax.responseXML;
	  //document.getElementById(target).innerHTML =  ajax.responseText;  //return the repsonse to the browser
	  document.getElementById(target).innerHTML = ajax.responseText;
	  }
	}
  }
//ajax = null;
return;
}

function closepage() {
document.getElementById('overlay').style.display = "none";
document.getElementById('image').style.display = "none";
}
