//---[ Open a new browser window ]--------------------------------------------------------------------------------------
function openAwindow(url, scrollbars) {
	if (isNaN(window.screenLeft)) {
		var offsetX = 0;
		var offsetY = 0;
	}else{
		var offsetX = window.screenLeft;
		var offsetY = window.screenTop;
	}
	var AWindow=window.open(url,"win","resizable=no,scrollbars="+scrollbars+",status=0,menubar=no,left=" + (offsetX + 150) + ",top=" + (offsetY + 100) + ",height=300,width=500");
	if (parseInt(navigator.appVersion)>=3) AWindow.focus();
}

function winresize() {
	if (window.opener) {
		var o_tabel = (document.getElementById) ? document.getElementById("tabel") : document.all["tabel"];
		var t_height = getHeight(o_tabel) + 3;
		var w_height = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;
		if (t_height > 0 && w_height > 0) {
			window.resizeBy(0, t_height - w_height);
		}
	}
}

//---[ Find offset of an object ]---------------------------------------------------------------------------------------
function offsetLeft(object) {
	xPos = object.offsetLeft;
	tempEl = object.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

function offsetTop(object) {
	yPos = object.offsetTop;
	tempEl = object.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}

//---[ Get Object Height ]----------------------------------------------------------------------------------------------
function getHeight(object) {
	if (object) {
		if (object.clientHeight) {
			return parseInt(object.clientHeight);
		}else if (window.getComputedStyle(object,null).getPropertyValue('height')) {
			return parseInt(window.getComputedStyle(object,null).getPropertyValue('height')) + parseInt(window.getComputedStyle(object,null).getPropertyValue('padding-top')) + parseInt(window.getComputedStyle(object,null).getPropertyValue('padding-bottom'));
		}else{
			return 0;
		}
	}
}

function getWidth(object) {
	if (object) {
		if (object.clientWidth) {
			return parseInt(object.clientWidth);
		}else if (window.getComputedStyle(object,null).getPropertyValue('width')) {
			return parseInt(window.getComputedStyle(object,null).getPropertyValue('width')) + parseInt(window.getComputedStyle(object,null).getPropertyValue('padding-left')) + parseInt(window.getComputedStyle(object,null).getPropertyValue('padding-right'));
		}else{
			return 0;
		}
	}
}

//---[ Stop settimeout ]------------------------------------------------------------------------------------------------
function stopTimer(timerObj) {
        if (timerObj) {
                clearTimeout(timerObj);
        }
}

//---[ Start scrolling image ]------------------------------------------------------------------------------------------
function startScroller() {
	o_scrollimg = (document.getElementById) ? document.getElementById("scrollimg") : document.all["scrollimg"];
	var o_content = (document.getElementById) ? document.getElementById("content") : document.all["content"];
	var o_container = (document.getElementById) ? document.getElementById("container") : document.all["container"];
	var o_side = (document.getElementById) ? document.getElementById("side") : document.all["side"];

	// Get heights
	var w_height = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;
	var t_height = getHeight(o_content) + 90;

	// Set the container height to table height or window height, whatever is largest
	o_container.style.height = Math.max(w_height, t_height);

	// Calculate number of copies needed for the sidebar
	var copies = Math.ceil(Math.max(w_height, t_height) / 617);
	for (var idx=0; idx < copies; idx++) {
		var trObj = o_side.rows[0].cloneNode(true);
		o_side.appendChild(trObj);
	}

	// Start scroller
	o_scrolltmr = setTimeout("doScroll();", 40);
}

//---[ Next scrolling image step ]--------------------------------------------------------------------------------------
function doScroll() {
	var cur_top = parseInt(o_scrollimg.style.top);
	if (cur_top > -616) {
		o_scrollimg.style.top = cur_top - 1;
	} else {
		o_scrollimg.style.top = 0;
	}
	o_scrolltmr = setTimeout("doScroll();", 40);
}

//---[ Show popup menu ]------------------------------------------------------------------------------------------------
function showmenu(object, menunr, offsetX, offsetY) {
	if ((actmenu > 0) && (menunr != actmenu)) {
		hidemenu2();
	}
	var o_menu = (document.getElementById) ? document.getElementById("menu" + menunr) : document.all["menu" + menunr];
	if (o_menu) {
		stopTimer(o_timer);
		var xPos = offsetLeft(object) + offsetX;
		var yPos = offsetTop(object) + offsetY;
		o_menu.style.left = xPos;
		o_menu.style.top = yPos;
		o_menu.style.visibility = "visible";
	}
	actmenu = menunr;
}

//---[ Hide popup menu ]------------------------------------------------------------------------------------------------
function hidemenu(timeout) {
	if (actmenu > 0) {
		o_timer = setTimeout("hidemenu2();", timeout);
	}
}

function hidemenu2() {
	if (actmenu > 0) {
		var o_menu = (document.getElementById) ? document.getElementById("menu" + actmenu) : document.all["menu" + actmenu];
		if (o_menu) {
			o_menu.style.visibility = "hidden";
			o_menu.style.left = 0;
			o_menu.style.top = 0;
			actmenu = 0;
		}
	}
}

//---[ Reload guestbook (show all toggle) ]-----------------------------------------------------------------------------
function guestReload(object) {
	if (object.checked) {
		document.location = "guestbook.php?all=true";
	} else {
		document.location = "guestbook.php";
	}
}

//---[ In case of a mouse click in document ]---------------------------------------------------------------------------
function evtClick() {
	hidemenu2();
}

//---[ Main Line ]------------------------------------------------------------------------------------------------------
var actmenu = 0;
var o_scrollimg = "";
var o_scrolltmr = false;
var o_timer = false;
document.onclick=evtClick;
if ((window.screen.width > 0) && (window.screen.width <= 800)) {
	document.write("<LINK rel=stylesheet type='text/css' href='/smallfont.css' title='Small font Stylesheet'>");
}else{
	document.write("<LINK rel=stylesheet type='text/css' href='/default.css' title='Default Stylesheet'>");
}

