var currentPhotos;
var activePhoto;
function showPhotoFrame(comment, picture, photoArray){
	currentPhotos = photoArray;
	activePhoto=0;
	for (x in currentPhotos){
		var current = currentPhotos[x];
		if (current.toString() == picture.toString()){
			activePhoto = x;
		}
	}
	var photoFrame = document.getElementById('photoFrame');
	photoFrame.style.display = 'block';
	setPhoto(currentPhotos[activePhoto]);
	var text = document.getElementById('photoFrameTxt');
	text.innerHTML = comment;
}

function setPhoto(filename){
	var photoFrameSrc = document.getElementById('photoFrameSrc');
	photoFrameSrc.src = filename;
}

function nextPhoto(){
	if (activePhoto+1 >= currentPhotos.length){
		activePhoto = 0;
	}else{
		activePhoto++;
	}
	setPhoto(currentPhotos[activePhoto]);
}

function prevPhoto(){
	if (activePhoto <= 0){
		activePhoto = currentPhotos.length-1;
	}else{
		activePhoto--;
	}
	setPhoto(currentPhotos[activePhoto]);
}
function closePhotoFrame(){
	var photoFrame = document.getElementById('photoFrame');
	photoFrame.style.display = 'none';
}

function OpenClose(divName) {
   obj = document.getElementById(divName); 
   if (obj.style.display=='block') {
     obj.style.display='none';
   } else {
     obj.style.display='block';
   }
}

function timeout(){
	clearInterval(vTimer);
	bIdTimeout = true;
	window.status = 'Id not found.';
}

function resizeContentDiv(){
	var obj = document.getElementById('contentDiv');
	if (obj != null){
		clearTimeout(vTimeOut);
		clearInterval(vTimer);
		obj.style.height = (document.documentElement.clientHeight-225) +'px';
		window.onResize = onResizeFunc();
	}
}

function onResizeFunc(){
	var obj = document.getElementById('contentDiv');
	if (typeof obj != null){
		obj.style.height = (document.documentElement.clientHeight-225) +'px';
	}
}
//Detect IE5.5+
if (navigator.appVersion.indexOf("MSIE")!=-1){
	var temp=navigator.appVersion.split("MSIE");
	var version=parseFloat(temp[1]);
	if (version < 7){
		window.onLoad=loadTimer();
	}
}
//window.onLoad=loadTimer();
function loadTimer(){
	vTimeOut = setTimeout("timeout()", 3000); //1secs timeout
    vTimer = setInterval('resizeContentDiv()', 1);
}

//init
var bIdTimeout = false;
var vTimer;
var vTimeOut;
