// Preload some images
if(document.images) {
	// Create and define the array and necessary variables.
	i = new Array(16);
	for(x = 0; x <= 14; x++) {
		i[x] = new Image();
	}
	var picpath = "graphics/";
	
	i[0].src = picpath + "layer1.img1.jpg";
	i[1].src = picpath + "layer1.img2.jpg";
	i[2].src = picpath + "layer1.img3.jpg";
	i[3].src = picpath + "btn.home.jpg";
	i[4].src = picpath + "btn.home.clicked.jpg"; // ... and so on and so forth ...
	i[5].src = picpath + "btn.profile.jpg";
	i[6].src = picpath + "btn.profile.clicked.jpg";
	i[7].src = picpath + "btn.contact.jpg";
	i[8].src = picpath + "btn.contact.clicked.jpg";
	i[9].src = picpath + "btn.products.jpg";
	i[10].src = picpath + "btn.products.clicked.jpg";
	i[11].src = picpath + "btn.lang-en.jpg";
	i[12].src = picpath + "btn.lang-en.clicked.jpg";
	i[13].src = picpath + "btn.lang-cn.jpg";
	i[14].src = picpath + "btn.lang-cn.clicked.jpg";
	
	function showmecache() { 
		// Use to to show cache list. To use, create a button in index.html 
		// nav header (before the home button.
		var cachedpics = "";
		for(y = 0; y <= 15; y++) {
			cachedpics += i[y].src + "\n";
		}
		alert(cachedpics);
	}
}
// simple icon swap on mouseover function
function swapicon(a, b) {
	var ThisObj = a;
	var PicSelected = b;
	ThisObj.src = 'graphics/' + PicSelected	;
}
// picture swap + caption change function
function menu_picswap(l, m, n) {
	// swap the pics
	document.images[l].src = '../graphics/productpics/' + m;
	// change the captions of the pics. NOTE: do not use TH or PH in the filenames
	// cos I'm using it here :) This is case sensitive
	myString = new String(l);
	mmm = myString.replace(/PH/g, 'TH');
	document.getElementById(mmm).innerHTML = n;
}
