// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// File:	theovanderhelm.js
// Description:	Client script for Theo van der Helm website
// Author:	Martin Joon (martin.joon@inspirity.nl)
// Copyright:	2003-2004 Inspirity
// Date:	01-11-2004
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------

// Preload images
function preload()
{
    if (document.images)
    {
    	var logo = new Image(); logo.src = "images/logo.gif";
    	var badbody = new Image(); badbody.src = "images/badbody.gif";
        var image0 = new Image(); image0.src = "images/menu0.gif";
        var image1 = new Image(); image1.src = "images/menu1.gif";
        var image2 = new Image(); image2.src = "images/menu2.gif";
        var image3 = new Image(); image3.src = "images/menu3.gif";
        var image4 = new Image(); image4.src = "images/menu4.gif";
        var image5 = new Image(); image5.src = "images/menu5.gif";
        var image6 = new Image(); image6.src = "images/menu6.gif";
        var image9 = new Image(); image9.src = "images/menu9.gif";
    }
}

// Assigns the new image to the menu image
function changeMenuImage(img)
{
    if (document.images)
    {
    	document["menu"].src = "images/"+img+".gif";
    }
}

// Opens a centered window and sets the focus to that window
function openWindow(source, width, height) {
	var left = screen.width ? (screen.width-width)/2 : 0;
	var top = screen.height ? (screen.height-height)/2 : 0;
	var newWindow = window.open(source,null,"top="+top+",left="+left+",width="+width+",height="+height+",location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no");
	newWindow.focus()
}

// Closes a window
function closeWindow() {
	window.close();
}

// Displays a photo in its own window
function showPhoto(photo) {
	openWindow("photo.asp?photo="+photo, 200, 40);
}

// Callback called when image is loaded
function onloadImage(image)
{
	//window.alert("Image (" + image.width + "," + image.height + ")")
	resizeWindow(window, image.width, image.height);
}

// Resize and center the window to exactly fit the image
function resizeWindow(window, width, height)
{
	// Adjust size
	width += 10; // Add sides of window to width (5+5)
	height += 29; // Add titlebar + bottom to height (24+5)
	

	// Center window
	var left = screen.width ? (screen.width-width)/2 : 0;
	var top = screen.height ? (screen.height-height)/2 : 0;
	
	// Move and resize window
	window.moveTo(left, top);
	window.resizeTo(width, height);
}
