function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;

var sliceOverArray = new Array(19);
var	mapTextArray = new Array(21);

function preloadImages(type) {
	if (document.images) {
		if (type == 'tp')	
			imgPath = "tripPlanning/tp_mapimages/TP-web-index-map_";
		else
			imgPath = "stopPassingTimes/spt_mapimages/TP-web-index-map_";
		zero = "0";
		for(i=3;i<21;i++)
		{
			if (i > 9)			
				zero = "";
			tempSrc = imgPath + zero + i + "_over.gif";
			sliceOverArray[i] = newImage(tempSrc);
		}
		zero = "0";
		for(i=3;i<21;i++)
		{
			if (i > 9)
				zero = "";
			tempSrc = imgPath + "02TP-we-" + zero + i + ".gif";
			mapTextArray[i] = newImage(tempSrc);
		}			
		preloadFlag = true;
	}
}

function swap(sliceNo,mode,type)
{
	zero = "0";
	if (type == 'tp')
		imgPath = "tripPlanning/tp_mapimages/TP-web-index-map_";	
	else
		imgPath = "stopPassingTimes/spt_mapimages/TP-web-index-map_";	
		
	if (sliceNo > 9)
		zero = "";
	if (mode == 'on')
	{
		tempSrc = sliceOverArray[sliceNo].src;
		textSrc = mapTextArray[sliceNo].src;
	}
	else
	{
		tempSrc= imgPath + zero + sliceNo + ".gif";
		textSrc = imgPath + "02.gif";
	}
	changeImages("slice" + zero + sliceNo, tempSrc, "slice02", textSrc);
	return true;
}