// JavaScript Document

//showing images in sub level pages
function showImage(imgMain)
{
	if (!document.getElementById){ return; }
	
	var rndmImg = document.getElementById(imgMain);
	
	// Set up the image files to be used.
	var images = new Array();

	images[0] = 'p_cityplace.jpg';
	images[1] = 'p_cityplace2.jpg';
	images[2] = 'p_intel.jpg';
	images[3] = 'p_winnersh.jpg';
	images[4] = 'p_reuters.jpg';
	
	images[5] = 'p_nldc00.jpg';
	images[6] = 'p_nldc01.jpg';
	images[7] = 'p_nldc02.jpg';
	images[8] = 'p_nldc03.jpg';
	images[9] = 'p_nldc04.jpg';
	images[10] = 'p_nldc05.jpg';
	images[11] = 'p_nldc06.jpg';
	images[12] = 'p_nldc07.jpg';
	images[13] = 'p_nldc08.jpg';
	images[14] = 'p_nldc09.jpg';
	images[15] = 'p_nldc10.jpg';
	images[16] = 'p_nldc11.jpg';
	images[17] = 'p_nldc12.jpg';
	images[18] = 'p_nldc13.jpg';
	images[19] = 'p_nldc14.jpg';
	images[20] = 'p_nldc15.jpg';
	images[20] = 'p_nldc16.jpg';
	
	//var image_dir = '../images/'; //need to not hardcode this, need to grab current src value and just replace filename so directory linkage stays the same...
	
	var image_dir = rndmImg.src; //store current source value
	
	//get the index of the last '/' character
	var lastSlash = image_dir.lastIndexOf("/");
	
	//store everything until the first '/' character
	image_dir = image_dir.slice(0, lastSlash + 1);
	
	var whichImage = Math.round(Math.random()*(images.length-1));
	
	rndmImg.src = image_dir + images[whichImage];
}

function init()
{
	showImage('randomImage');
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
    	window.onload = func;
	}
	
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

addLoadEvent(init);	// run initSwap onLoad