adImages = new Array();
adImages[0] = new Object();
adImages[0].filename = "MariaShiner1.gif";
adImages[1] = new Object();
adImages[1].filename = "MariaShiner2.gif";
adImages[2] = new Object();
adImages[2].filename = "MariaShiner3.gif";
adImages[3] = new Object();
adImages[3].filename = "MariaShiner4.gif";

var pictures;
var currentPicture;
var adsHome;

function Picture(_picName)
{
	this.mainPicture = new Image;
	this.mainPicture.src = adsHome + _picName;
	this.picName = _picName;
}

function getAdsURL()
{
 
  var docpath;
  var csspath;

  docpath = document.location.href;
  docpath = docpath.substring(0,docpath.lastIndexOf("/"));

	csspath = document.getElementsByTagName("link")[0].href;
  csspath = csspath.substring(0,csspath.lastIndexOf("/Styles"));
	//
	// Some browsers return the path as defined in the source file and others
	// return a fully resolved path, so we need to take account of these
	// differences in the test below.
  if (csspath == "")
    adsHome = docpath + "/";
  else if (csspath.indexOf("..") != -1)
    adsHome = docpath + "/" + csspath + "/";		
	else
		adsHome = csspath + "/";
		
	adsHome += "Companies/";
  return null;
}

function pageLoaded()
{

	getAdsURL();
	pictures = new Array;
	for ( i = 0; i < adImages.length; i++)
	{
		pictures[i] = new Picture(adImages[i].filename);
	}
	currentPicture = 0;
	pictures[currentPicture].showPicture();
	setInterval("cycleImage()", 5000);

}

function cycleImage()
{

	currentPicture++;
	if (currentPicture == 4)
		currentPicture = 0;
	pictures[currentPicture].showPicture();
	
}

Picture.prototype.showPicture = function()
{

	var theAdImage = document.getElementById("adImage");
	
  if (theAdImage != null)
  {
		theAdImage.src = this.mainPicture.src;
	}
}


//
// This is the bit that enables all this code to work. It
// adds the onload event handler to the page body tag. This method is used
// so that the page code is absolutely clean in the event that the user does
// not have JS enabled, and hence there is no posibility of error messages
// being generated.
window.onload=pageLoaded;