function bodyLoaded() {
	//setTimeout('switchRootImage()', switchTime);
}


var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
//var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );

function viewport() {
    this.windowX = (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth;
    this.windowY = (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight;
    this.scrollX = (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft;
    this.scrollY = (document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop;
    this.pageX = (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth;
    this.pageY = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
}

function $( id ) {
    return document.getElementById(id);
}

var photos = new Array();
var photosText = new Array();
var currentPhotoNR = 0;

function showPhoto( pid, open ) {

	if (!open) open = false;
    currentPhotoNR = pid;

	if (currentPhotoNR == 1) {
		$('photo-prev').className = 'disable';
	} else {
		$('photo-prev').className = '';
	}

	if (currentPhotoNR == photos.length - 1) {
		$('photo-next').className = 'disable';
	} else {
		$('photo-next').className = '';
	}
	
	var win = new viewport();
	if (is_ie) {
		$('photo-layer').style.width = win.pageX+'px';
		//$('photo-layer-bg').style.width = win.width+'px';
	}
	
	//alert(win.pageY+":"+win.windowY);
	
	if (win.pageY > win.windowY) var layerHeight = win.pageY;
	else var layerHeight = win.windowY;
	
	$('photo-layer-bg').style.height = layerHeight+'px';
	$('photo-layer-bg').style.display = '';
	
	var preLoad = new Image();
	preLoad.onload = function() {
 
		var top = Math.ceil((win.windowY - preLoad.height - 30)/2) + win.scrollY;
		if (top < 10) top = 10 + win.scrollY;
		$('photo-layer').style.top = top+'px';
		$('photo-image').src = photos[ currentPhotoNR ];
		$('photo-text').innerHTML = photosText[currentPhotoNR];
		//$('photo-text').style.width = preLoad.width - 18 + 'px';
		$('photo-layer').style.display = '';

	}
	preLoad.src = photos[currentPhotoNR];
	return false;

}

function nextPhoto( direction ) {
   
    var newNR = currentPhotoNR + direction;
    if (newNR < 1 || newNR > photos.length - 1) {
		return;
	}

	showPhoto(newNR, true);
	
}

function hidePhoto() {
	$('photo-layer-bg').style.display = 'none';
	$('photo-layer').style.display = 'none';
}

function hide( id ) {
	
	if ($( id ).style.display != 'none') {
		$( id ).style.display = 'none';
	}
	
}

function show( id ) {

	//if ($( id ).style.display == 'none') {
		$( id ).style.display = 'block';
	//}

}