isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

var buttonList		= new Array(10);
var buttonX		= new Array(10);
var buttonY		= new Array(10);
var buttonLink		= new Array(10);

var subMenuIndex	= new Array(10);
var subMenuCount	= new Array(10);
var buttonIndex = 0;
var currentSubMenu = -1;
var buttonPressed = false;
var countSmilies = 0;

var resized_images_width = new Array();
var resized_images_height = new Array();


function init() {
	var button_home 	= new Image();
	var button_home_m	= new Image();
	var button_info		= new Image();
	var button_info_m	= new Image();
	var button_photos	= new Image();
	var button_photos_m	= new Image(); 
	var button_events	= new Image(); 
	var button_events_m	= new Image(); 
	var button_forum	= new Image(); 
	var button_forum_m	= new Image(); 
	var button_guestbook	= new Image(); 
	var button_guestbook_m	= new Image(); 
	
	button_home.src		= "mainframe/menu/home.gif";
	button_home_m.src	= "mainframe/menu/home_m.gif"; 
	button_info.src		= "mainframe/menu/info.gif";
	button_info_m.src	= "mainframe/menu/info_m.gif";
	button_photos.src	= "mainframe/menu/photos.gif";
	button_photos_m.src	= "mainframe/menu/photos_m.gif";
	button_events		= "mainframe/menu/events.gif";
	button_events_m		= "mainframe/menu/events_m.gif";
	button_forum		= "mainframe/menu/forum.gif";
	button_forum_m		= "mainframe/menu/forum_m.gif"; 
	button_guestbook	= "mainframe/menu/guestbook.gif";
	button_guestbook_m	= "mainframe/menu/guestbook_m.gif";
}

function highlight(img, path) {
	document[img].src = path + "/" + img + "_m.gif";
}

function unhighlight(img, path) {
	document[img].src = path + "/" + img + ".gif";
}

function createMenuButton(x, y, name, href) {
	buttonList[buttonIndex] = name;
	buttonX[buttonIndex] = x;
	buttonY[buttonIndex] = y;
	buttonLink[buttonIndex] = href;
	subMenuCount[buttonIndex] = 0;
	buttonIndex++;

}

function setSubMenuCount(count) {
	var button = buttonIndex - 1;
	subMenuIndex[button] = 0;
	subMenuCount[button] = count;
}


function createSubMenuButton(name, link) {
	var button = buttonIndex - 1;
	
	if (button > 0) {
		var index = subMenuIndex[button];

		var x = buttonX[button];
		var y = buttonY[button] + 20;

		if (index == 0) {
			document.write("\n<div id=\"submenu_" + button + "_hide1\" style=\"position: absolute; left: 0px; top:-45px; z-index: 100; visibility:hidden\">");
			document.write("\n<table border=\"0\" width=\"410\"><tr onMouseOver=\"hideSubMenu();\"><td width=\"400\" height=\"40\"><img src=\"images/pixel.gif\" width=\"400\" height=\"1\"/></td></tr></table></div>");

			document.write("\n<div id=\"submenu_" + button + "_hide2\" style=\"position: absolute; left: 0px; top: " + y + "px; z-index: 110; visibility:hidden\">");
			document.write("\n<table border=\"0\" width=\"410\"><tr onMouseOver=\"hideSubMenu();\"><td width=\"400\" height=\"200\"><img src=\"images/pixel.gif\" width=\"400\" height=\"1\"/></td></tr></table></div>");
			
			document.write("\n<div id=\"submenu_" + button + "\" style=\"position: absolute; left: " + x + "px; top: " + y + "px; z-index:120; visibility:hidden\">");
			document.write("\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"150\"><tr bgcolor=\"000066\"><td width=\"100%\">");
			document.write("\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">");
		}
		
		document.write("\n<tr bgcolor=\"#57A0FA\" onMouseOver=\"setPointer(this, '#000066', this, 'hand')\" onMouseOut=\"setPointer(this, '#57A0FA', this, 'default')\" onClick=\"window.location='"+link+"'\"><td width=\"100%\"><b>&nbsp;" + name + "</b></td></tr>");
		
		if (index >= (subMenuCount[button] - 1)) {
			document.write("\n</table></td></tr>");
			document.write("\n<tr><td><img src=\"images/pixel.gif\" border=\"0\" alt=\"1\" width=\"150\" height=\"1\"></td></tr></table>\n</div>");
		}

		subMenuIndex[button]++;	
	}
}

function showSubMenu(button) {
	hideSubMenu();
	currentSubMenu = button;
	showObject("submenu_" + button);
	showObject("submenu_" + currentSubMenu + "_hide1");
	showObject("submenu_" + currentSubMenu + "_hide2");
	
	var top_ads_space = document.getElementById('top_ads_space');
	if (top_ads_space != null) top_ads_space.style.visibility="hidden";
}

function hideSubMenu() {
	if (currentSubMenu >= 0) {
		var name = buttonList[currentSubMenu];
		hideObject("submenu_" + currentSubMenu + "_hide1");
		hideObject("submenu_" + currentSubMenu + "_hide2");
		hideObject("submenu_" + currentSubMenu);
		unhighlight(name, 'mainframe/menu');
		currentSubMenu = -1;
	}
	
	var top_ads_space = document.getElementById('top_ads_space');
	if (top_ads_space != null) top_ads_space.style.visibility="visible";
}

function showMenuButtons() {
	for (i=0; i<buttonIndex; i++) {
		name = buttonList[i];
		x = buttonX[i];
		y = buttonY[i];
		href = buttonLink[i];
		
		document.write("\n<div id=\"button_" + name + "\" style=\"position: absolute; left: " + x + "px; top: " + y + "px; z-index:11;\">");
		if (subMenuCount[i] <= 0) {
			document.write("<a href=\"" + href + "\" onMouseOver=\"javascript: hideSubMenu(); highlight('" + name + "', 'mainframe/menu')\" onMouseOut=\"javascript: unhighlight('" + name + "', 'mainframe/menu');\">");
		} else {
			document.write("<a href=\"" + href + "\" onMouseOver=\"javascript: highlight('" + name + "', 'mainframe/menu'); showSubMenu("+i+");\">");
		}
		document.write("<img name=\"" + name + "\" src=\"mainframe/menu/" + name + ".gif\" border=\"0\" alt=\"\"></a>");
		document.write("</div>"); 
	}
}


function showObject(name) {
	if (isNS4) {
		document.layers[name].visibility="show";
	} else if (isIE4) {
		document.all[name].style.visibility="visible";
	} else if (isIE5 || isNS6) {
		document.getElementById(name).style.visibility="visible";	
	}
}

function hideObject(name) {
	if (isNS4) {
		document.layers[name].visibility="hide";
	} else if (isIE4) {
		document.all[name].style.visibility="hidden";
	} else if (isIE5 || isNS6) {
		document.getElementById(name).style.visibility="hidden";
	}
}

function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function setPointer(theRow, thePointerColor, src, cursor) {
	if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
		return false;
	}

	if (typeof(document.getElementsByTagName) != 'undefined') {
		var theCells = theRow.getElementsByTagName('td');
	} else if (typeof(theRow.cells) != 'undefined') {
		var theCells = theRow.cells;
	} else {
		return false;
	}

	var rowCellsCnt  = theCells.length;

	for (var c = 0; c < rowCellsCnt; c++) {
		if (thePointerColor == 'none') {
			theCells[c].style.background = 'none';
		} else {
			theCells[c].style.backgroundColor = thePointerColor;
			//theCells[c].filters.alpha.opacity = 50;
		}
	}

	src.style.cursor = cursor;
	return true;
}

function postForm() {
	if (!buttonPressed) {
		buttonPressed = true;
		document.bikiniform.submit();
	}
}

function fullscreen() {
	scrollbars = 0;
	var oSource = window.event.srcElement.src;
	width = resized_images_width[oSource];
	height = resized_images_height[oSource];

	url = oSource;

	if (width > screen.availWidth) {
		width = screen.availWidth - 100;
		scrollbars = 1;
	}

	if (height > screen.availHeight) {
		height = screen.availHeight - 100;
		scrollbars = 1;
	}
	
	iLeft = (screen.availWidth / 2) - (width / 2);
	iTop = (screen.availHeight /2 ) - (height / 2);

	fullscr = window.open("image.php?action=view&src="+url, "_blank","toolbar=no,location=no,menubar=no,fullscreen="+scrollbars+",channelmode="+scrollbars+",scrollbars="+scrollbars+",status=no,left="+iLeft+",top="+iTop+",width="+width+",height="+height + "");
}

function confirmLink(confirmMsg) {
	if (confirmMsg == '') return false;
	var is_confirmed = confirm(confirmMsg);
    	return is_confirmed;
}

function addText(text) {
	if (countSmilies < 50) {
		text = ' ' + text + ' ';
		if (document.bikiniform.message.createTextRange && document.bikiniform.message.caretPos) {
			var caretPos = document.bikiniform.message.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
			document.bikiniform.message.focus();
		} else {
			document.bikiniform.message.value  += text;
			document.bikiniform.message.focus();
		}
	}
	countSmilies++;
}
	
function showSmilies() {
	showObject("smiliebox");	
}
			
function hideSmilies() {
	hideObject("smiliebox");
}

function highlight(img, path) {
	document[img].src = path + "/" + img + "_m.gif";
}

function unhighlight(img, path) {
	document[img].src = path + "/" + img + ".gif";
}

function resizeImage(img, maxWidth) {
	var width = img.width;
	var height = img.height;
	var url = img.src;
	
	if (width == 0) width = img.style.pixelWidth;
	if (height == 0) height = img.style.pixelHeight;
	
	if (width > maxWidth) {
		resized_images_width[url] = width;
		resized_images_height[url] = height;
		img.width = maxWidth;
		img.alt = 'Dit plaatje is geresized omdat hij breeder is dan ' + maxWidth + ' pixels. Originele grootte: '+width+'x'+height;
		img.style.border = "dashed 1px #000066";
		img.style.cursor = "hand";
	}
	

}

function fullscreen(maxWidth) {
	scrollbars = 0;
	var oSource = window.event.srcElement.src;
	width = resized_images_width[oSource];
	height = resized_images_height[oSource];
	
	if (width > maxWidth) {
		url = oSource;

		if(width > screen.availWidth) {
			width = screen.availWidth - 100;
			scrollbars = 1;
		}

		if (height > screen.availHeight) {
			height = screen.availHeight - 100;
			scrollbars = 1;
		}

		iLeft = (screen.availWidth / 2) - (width / 2);
		iTop = (screen.availHeight /2 ) - (height / 2);

		fullscr = window.open("system/viewimage.php?src="+url, "_blank","toolbar=no,location=no,menubar=no,fullscreen="+scrollbars+",channelmode="+scrollbars+",scrollbars="+scrollbars+",status=no,left="+iLeft+",top="+iTop+",width="+width+",height="+height + "");
	}
}

function row_hover_start(row) {
	row.style.backgroundImage='url(images/hover_bk.gif)';
}

function row_hover_end(row) {
	row.style.backgroundImage='';
}