////////////////////////////////////////////////////////////////////////////////////
// ALL CODE, PHOTOS, AND CONTENTS COPYRIGHT (C) 2004-2007 NANCY HELLSTEN PHOTOGRAPHY
// All rights reserved. Using materials on this site without prior written 
// permission is expressly forbidden.
////////////////////////////////////////////////////////////////////////////////////

var currentLayer = null;
var music = false;
var currentTrack = 0;
var musicTimer;
var targetImg;
var timer;

var tracks = new Array(
	'music/01Track5.mp3',
	'music/02Track2.mp3',
	'music/03Track1.mp3');

function updatePosition() {
    var appFrame = document.getElementById("appFrame");
    appFrame.style.top = Math.max(0, getHeight() / 2 - 315) + 'px';
	appFrame.style.left = Math.max(0, getWidth() / 2 - 488) + 'px'; 	
}

function checkBrowser() {
	if (!document.getElementById) {
		alert('This site needs IE5+, NN6+, or a compatible browser to work well. We have detected that you might have problems' +
			' viewing this site. You can contact us at nancy@nancyhellsten.com. We are sorry about the inconvenience.');
	}
	if (!document.getElementById('wmPlayer').controls)
	    document.getElementById('musicButton').style.visibility = 'hidden';
}

function getWidth() {
	if (typeof(window.innerWidth) == 'number' ) {
		return window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}
	return 0;
}

function getHeight() {
	if (typeof(window.innerHeight) == 'number' ) {
		return window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		return document.body.clientHeight;
	}
	return 0;
}

function playMusic() {
	if (document.getElementById('wmPlayer').controls) {
		document.getElementById('musicButton').src = 'images/mute_button.png';
		music = true;
		document.getElementById('wmPlayer').controls.Play();
	} else
		alert('We are sorry - The player could not be loaded.');
}
    
function stopMusic() {
	music = false;
	if (document.getElementById('wmPlayer').controls) {
		document.getElementById('wmPlayer').controls.Stop();
	}
	document.getElementById('musicButton').src = 'images/music_button.png';
}
 
function doPlayStateChanges(state){
	//alert(state);
	if (state == 1) {
		if (currentTrack < tracks.length - 1)
			currentTrack++;
		else
			currentTrack = 0;
		wmPlayer.URL = tracks[currentTrack];
		if (music) {
			musicTimer = setTimeout('playMusic()', 2000);
		}
	}
}

function popUp(URL, width, height) {
	window.open(URL, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='
		+ width + ',height=' + height);
}
	
function showLayer(layer) {
	for (var i = 0; i < layers.length; i++) {
		document.getElementById(layers[i]).style.visibility = 'hidden';
	}
	document.getElementById(layer).style.visibility = 'visible';
	currentLayer = document.getElementById(layer);
	updatePosition();
}

function showHtml(id) {
	var obj = document.getElementById(id);
	
	alert(obj.innerHTML);
}

function showElement(id, visible) {
	document.getElementById(id).style.visibility = (visible ? 'visible' : 'hidden');
}

function showMenu(menu, show) {
	if (show || menu == null) {
		showElement('wedMenu', false);
		showElement('infoMenu', false);
		showElement('portraitMenu', false);
	}
	
	if (menu != null)
		showElement(menu, show);
}