//IMAGE PRELOAD
buynow = new Image();
buynow.src = "images/buynow2.jpg";

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

addLoadEvent(mouseOver);
addLoadEvent(buttonOver);

function buttonOver() {
	thewrap = document.getElementById('content');
	buttons = thewrap.getElementsByTagName('input');
	for (i=0; i<buttons.length; i++){
		if(buttons[i].getAttribute('type') == 'image') {
			buttons[i].onmouseover = function() {
				this.src = this.src.substring(0, this.src.length - 4) + "2.jpg";
			}
			buttons[i].onmouseout = function() {
				this.src = this.src.substring(0, this.src.length - 5) + ".jpg";	
			}
		}
	}
}

function mouseOver() {
	thewrap = document.getElementById('navigation');
	images = thewrap.getElementsByTagName('img');
	preLoad = new Array();
	navOn = new Array();
	for (i=0; i<images.length; i++){
		preLoad[i] = new Image();
		preLoad[i].src = "images/" + images[i].id + "2.jpg";
		
		if(images[i].src.substring(images[i].src.length - 5, images[i].src.length) == "1.jpg") {
			navOn[i] = true;
		} else {
			navOn[i] = false;
		}
		
		images[i].onmouseover = function() {
			this.src = "images/" + this.id + "2.jpg";
		}
		if(navOn[i]) {
			images[i].onmouseout = function() {
				this.src = "images/" + this.id + "1.jpg";
			}
		} else {
			images[i].onmouseout = function() {
				this.src = "images/" + this.id + ".jpg";
			}
		}
	}
}