var images = new Array(
	"../gfx/imgWelcome.jpg",
	"../gfx/imgWelcome-2.jpg",
	"../gfx/imgWelcome-3.jpg",
	"../gfx/imgWelcome-4.jpg",
	"../gfx/imgMenusandWineList.jpg",
	"../gfx/imgMenusandWineList-2.jpg",
	"../gfx/imgMenusandWineList-3.jpg",
	"../gfx/imgBios.jpg",
	"../gfx/imgBios-2.jpg",
	"../gfx/imgBios-3.jpg",
	"../gfx/imgPress.jpg",
	"../gfx/imgPress-2.jpg",
	"../gfx/imgPress-3.jpg",
	"../gfx/imgPrivateDining.jpg",
	"../gfx/imgPrivateDining-2.jpg",
	"../gfx/imgPrivateDining-3.jpg",
	"../gfx/imgHours.jpg",
	"../gfx/imgHours-2.jpg",
	"../gfx/imgHours-3.jpg",
	"../gfx/imgContact.jpg",
	"../gfx/imgContact-2.jpg",
	"../gfx/imgContact-3.jpg",
	"../gfx/imgEmployment.jpg",
	"../gfx/imgEmployment-2.jpg",
	"../gfx/imgEmployment-3.jpg",
	"../gfx/imgBuyGiftCertificates.jpg",
	"../gfx/imgBuyGiftCertificates-2.jpg",
	"../gfx/imgBuyGiftCertificates-3.jpg"
);

var currText = "Welcome";
var currBio = "";
var currImgIdx = 1;
var currTimer = null;
function preload() {
	var img = new Image();
	for (i = 0;i < images.length;i++)
		img.src = images[i];
}

function getElem(item) {
	if (document.getElementById) { // this is the way the standards work
		return document.getElementById(item);
	}
	else if(document.all) { // this is the way old msie versions work
		return document.all[item];
	}
	else if(document.layers) { // this is the way nn4 works
		return document.layers[item];
	}
}
function menuOver(item) {
	var elem = getElem(item);
	elem.style.backgroundColor = "#000000";
}
function menuOut(item) {
	var elem = getElem(item);
	elem.style.backgroundColor = "#A7A77A";
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = getElem(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function blendImage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);

	getElem(divid).style.backgroundImage = "url(" + getElem(imageid).src + ")";
	changeOpac(0, imageid);
	setTimeout("getElem('" + imageid + "').src = '" + imagefile + "';", 50);

	for (i = 0;i <= 100;i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(i * speed) + 50);
	}
}
function imageFader(name) {
	var suffix = "";
	if (currImgIdx == 3) currImgIdx = 1;
	else {
		currImgIdx++;
		suffix = "-" + currImgIdx;
	}
	blendImage("mainImageCont", "mainImage", "../gfx/img" + name + suffix + ".jpg", 1500);
}
function startFader(name) {
	if (currTimer) clearInterval(currTimer);
	if (name == "Welcome") {
		currImgIdx = 1;
		currTimer = setInterval("imageFader('" + name + "')", 5000);
	}
}
startFader("Welcome");

function swapText(newText) {
	if (currText == newText) return;

	startFader(newText);

	getElem(currText).style.display = 'none';
	getElem(newText).style.display = 'block';

	currText = newText;

	getElem("mainImage").src = '../gfx/img' + newText + '.jpg';
}
function swapBio(newBio) {
	if (currBio == newBio) {
		if (newBio != "") getElem(newBio).style.display = 'none';
		currBio = '';
	}
	else {
		if (currBio != "") getElem(currBio).style.display = 'none';
		if (newBio != "") getElem(newBio).style.display = 'block';
		currBio = newBio;
	}
}
