﻿function endsWith(str, suffix) {
	return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
document.ShowHideLogoMenu = function(show) {
	document.getElementById("LogoPopupMenu").style.display = (show/* && document.isHomepage*/) ? 'inline' : 'none';
}
function getMouseXY(e) {
	if (!e)
		var e = window.event || window.Event;

	if ('undefined' != typeof e.pageX) {
		document.mouseX = e.pageX;
		document.mouseY = e.pageY;
	}
	else {
		document.mouseX = e.clientX + document.body.scrollLeft;
		document.mouseY = e.clientY + document.body.scrollTop;
	}
}
document.LoadPage = function () {
	document.nextSlideshowToChange = 0;
	document.RotateSlideshow(true);
	document.isHomepage = endsWith(window.location.toString().toLowerCase(), 'default.aspx') || endsWith(window.location.toString().toLowerCase(), '/');
	if (!document.isHomepage)
		document.getElementById("ContentArea").style.display = 'inline';
	if (document.OnLoadContentPage != undefined) document.OnLoadContentPage();

	if (window.Event && document.captureEvents)
		document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = getMouseXY;
	}
document.RotateSlideshow = function (initPage) {
	var tSlideshow = document.getElementById("Slideshow");
	var img = tSlideshow.childNodes[document.nextSlideshowToChange];
	if (img.imgindex === undefined) img.imgindex = document.nextSlideshowToChange*4;
	var newindex = parseInt(img.imgindex) + 1;
	if (newindex == 21) newindex = 1;
	img.imgindex = newindex;
	img.src = "Pictures/slideshow" + newindex + ".jpg";
	document.nextSlideshowToChange++;
	var interval = 200;
	if (document.nextSlideshowToChange == 5) {
		interval = 5000;
		document.nextSlideshowToChange = 0;
		initPage = false;
	}
	if (initPage) interval = 1;
	setTimeout("document.RotateSlideshow(" + initPage + ")", interval);
}
document.ShowPopupText = function (text) {
	if (document.isHomepage)
		document.getElementById("PopupText").innerHTML = text;
	document.ShowHideLogoMenu(false);
	var tt = document.getElementById("tooltip");
	if (text.length > 0) {
		tt.style.display = 'inline';

		tt.style.left = document.mouseX + 'px';
		tt.style.top = (document.mouseY + 10) + 'px';
	}
	else
		tt.style.display = 'none';

}
document.SetContentTitle = function (text) {
	var contentTitle = document.getElementById("ContentTitle");
	contentTitle.innerHTML = text;
}
