var imgs = new Array();
var images_loaded = false;
presentation_menu_timeout = 0;
presentation_menu_timein = 0;
slides_timeout = 0;
time_slides_timeout = 25000;

function redir(url)
{
	window.document.location.href = url;
}

function preloadImages() {
	if (document.images && !images_loaded) {
		imgs[0] = new Image;
		imgs[0].src = "images/button.gif";
		imgs[1] = new Image;
		imgs[1].src = "images/button_active.gif";
		images_loaded = true;
		return true;
	}
}

function switchActive(id, active) {
	if (active)
		//id.style.backgroundImage = "url("+imgs[1].src+")";
		id.style.backgroundColor = "#CC0000";
	else
		id.style.backgroundColor = "#FF0000";
		//id.style.backgroundImage = "url("+imgs[0].src+")";
}

function popSlides() {
	clearTimeout(presentation_menu_timein);
	switchActive(document.getElementById("menu_present"), true);
	document.getElementById("presentation_menu").style.display = "block";
}

function hideSlides() {
	clearTimeout(presentation_menu_timeout);
	clearTimeout(presentation_menu_timein);
	switchActive(document.getElementById("menu_present"), false);
	document.getElementById("presentation_menu").style.display = "none";
}

window.onresize = centerBorder;


function centerBorder() {
	 border1 = document.getElementById("border");
	if (document.body.clientWidth || document.body.clientHeight) {
	 	sw = document.body.clientWidth;
		sh = document.body.clientHeight;
	}
	else {
		sw = 0;
		sh = 0;
	}

	 border1.style.left = ((sw - border1.scrollWidth) <= 0)?0:(sw/2 - border1.scrollWidth/2);
	 border1.style.top =  ((sh - border1.scrollHeight) <= 0)?0:(sh/2 - border1.scrollHeight/2);
	 document.getElementById("HIDE_ALL").style.display="none";
}

function advanceSlides(slide_id) {
	redir("?view=presentation&slide="+slide_id);
}


function picPop(pic_id) {
	win_params = 'menubar=no,scrollbars=no,statusbar=no,toolbar=no,width=1,height=1,left=3000,top=3000';
	dest_win = window.open('viewpic.php?id='+pic_id, 'screenshot', win_params);
}

