function setBgColor (id, color) {
  if (document.layers) {
    document[id].bgColor = color == 'transparent' ? null : color;
  } else if (document.all) {
    document.all[id].style.backgroundColor = color;
  } else if (document.getElementById) {
    document.getElementById(id).style.backgroundColor = color;
  }
}

function preloadImages()
{
	for (var i in oImages)   // i contains "nav" here
	{
	   for (var n=0; n<oImages[i].names.length; n++)
	   {
		var pre = new Image();
		var pre_on = new Image();
		if (oImages[i].ext){
		} else {
			oImages[i].ext = '.gif';
		}
	   
		  pre.src = oImages[i].location + oImages[i].names[n] +  oImages[i].off_ext + oImages[i].ext;
		  pre_on.src = oImages[i].location + oImages[i].names[n] +  oImages[i].on_ext + oImages[i].ext;
	   }
	}
}

function imageSetOn(s, i, a) {
// s = image name, i = number in array, a = array name
//reduce i to make my life easier
i--;
  image_location = oImages[a].location;
  document.images[s].src = image_location + oImages[a].names[i] + oImages[a].on_ext + oImages[a].ext;
  
}

function imageSetOff(s, i, a) {
i--;
 image_location = oImages[a].location;
 document.images[s].src = image_location + oImages[a].names[i] + oImages[a].off_ext + oImages[a].ext;
}

//for the back button

function checkback(){
//work out if last site was this site
	var thisSite = /thorntonfirkin/i;
	var lastSite = document.referrer;
	var result = thisSite.test(lastSite);
//now display back image as neccescary
if (history.length > 0 && result){ // & document.referrer = 
document.images.backb.src = '/images/shared/back_green.gif';
} else {
document.images.backb.src = '/images/shared/shim.gif';
}
return null;
}

function clickback(){
if (history.length > 0 && document.referrer){
history.go(-1);
}
}

function changeProjImage(cellid)
{
  if (document.layers) {
  	imagen = document[cellid].images[0].src;
    document[cellid].background = imagen;
    document[cellid].images[0].src = 'images/projects/hover.png';
  } else if (document.all) {
   imagen = document.all[cellid].images[0].src;
    document.all[cellid].style.background = imagen;
    document.all[cellid].images[0].src = 'images/projects/hover.png';
  } else if (document.getElementById) {
  document.
  	imagen = document.getElementById(cellid).links[0].images[0].src;
    document.getElementById(cellid).style.background = imagen;
    document.getElementById(cellid).images[0].src = 'images/projects/hover.png';
  }		
}

/*******************************************************
ACROBAT DETECT
All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
*******************************************************/
function acrodetect()
{
acrobat=new Object();

// Set some base values
acrobat.installed=false;
acrobat.version='0.0';

if (navigator.plugins && navigator.plugins.length)
{
	for (x=0; x<navigator.plugins.length; x++)
	{
		if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1)
		{
			acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);

			if (acrobat.version.toString().length == 1) acrobat.version+='.0';

			acrobat.installed=true;
			break;
		}
	}
}
else if (window.ActiveXObject)
{
	for (x=2; x<10; x++)
	{
		try
		{
			oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
			if (oAcro)
			{
				acrobat.installed=true;
				acrobat.version=x+'.0';
			}
		}
		catch(e) {}
	}

	try
	{
		oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
		if (oAcro4)
		{
			acrobat.installed=true;
			acrobat.version='4.0';
		}
	}
	catch(e) {}
}

acrobat.ver4=(acrobat.installed && parseInt(acrobat.version) >= 4) ? true:false;
acrobat.ver5=(acrobat.installed && parseInt(acrobat.version) >= 5) ? true:false;
acrobat.ver6=(acrobat.installed && parseInt(acrobat.version) >= 6) ? true:false;
acrobat.ver7=(acrobat.installed && parseInt(acrobat.version) >= 7) ? true:false;
acrobat.ver8=(acrobat.installed && parseInt(acrobat.version) >= 8) ? true:false;
acrobat.ver9=(acrobat.installed && parseInt(acrobat.version) >= 9) ? true:false; 
return acrobat;
}

function openPDForDl(link)
{
	if((link.lastIndexOf(".jpg")!=-1) || (link.lastIndexOf(".gif")!=-1))
	{
			popwin(link,"new",500,600, 'scroll', 'resize');
	} else {
	
		acrodetect();
		
		if(acrobat.installed){
			popwin(link,"new",500,600, 'scroll', 'resize');
		} else {
		   document.location=link;
		}
	}
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isFunction(a) {
    return typeof a == 'function';
}
