
/* 
 * Navigatie menu's laten zien.
 */

var navi				= navigator.appVersion;
var lastTarget	= -1;

function show(target, caller)
{
  if(lastTarget > -1)
	{
		try {
			ty = document.getElementById( "mnu" + lastTarget );
			ty.style.display = "none";
		} catch(err) {}
		
		try {
			ty = document.getElementById( "opt" + lastTarget );
			ty.style.backgroundColor = "transparent";
			ty.style.color = "#FFFFFF";
		} catch(err) {}

	}
	
	lastTarget = target;
			
	try {
  	ty = document.getElementById( "mnu" + target );
	  ty.style.display = "block";
	} catch(err) {}
		
	try {
  	ty = document.getElementById( "opt" + lastTarget );
	  ty.style.backgroundColor = "#F5F5F5";
		ty.style.color = "#000000";
	}	catch(err){}		
}

function addToPostForm(aVar)
{
	document.postform.r_tekst.value = document.postform.r_tekst.value + aVar;
}

function askPopup(aVar,pre,post)
{
	var myVar = prompt(aVar);
	if (myVar != null) addToPostForm("\n" + pre + myVar + post);
}

function hideAll()
{
	limit = 10;
		
	for(i=1;i<=limit;i++)
	{
		try {
			ty = document.getElementById( "mnu" + i );
			ty.style.display = "none";
		} catch(err) {}
		
		try {
			ty = document.getElementById( "opt" + i );
			ty.style.backgroundColor = "transparent";
			ty.style.color = "#FFFFFF";
		} catch(err) {}
	}
}

/*
 * AJAX-functies
 */
 
function getObject() 
{
  var xmlHttp;

  try {
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) {
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {
        alert("Your browser does not support AJAX!");
				return false;
      }
    }
  }

  return xmlHttp;
}

function addElftal(elftal)
{
	try {
		ty = document.getElementById("feed");
		
		xmlHttp = getObject();
		xmlHttp.onreadystatechange=function()
	  {
      if(xmlHttp.readyState==4)
        document.getElementById("addElftal").innerHTML=xmlHttp.responseText;
    }
	
    xmlHttp.open("GET","_includes/_handler.php?do=addElftal&elftal=" + elftal,true);
    xmlHttp.send(null);		
	} catch(err) {}
}

function showWindow(source,args,location)
{
  width		= (getWidth() + 20) + "px";
  height	= (getHeight() + 20) + "px";

	try {
		ty = document.getElementById("winback");
		ty.style.width = width;
		ty.style.height = height;
		
		xmlHttp = getObject();
		xmlHttp.onreadystatechange=function()
	  {
      if(xmlHttp.readyState==4)
        document.getElementById("wintext").innerHTML=xmlHttp.responseText;
    }
	
	  if(location == undefined)
		  location = "";
			
    xmlHttp.open("GET","_includes/_popup.php?do=" + source + "&location=" + location + "&args=" + args,true);
    xmlHttp.send(null);

		ty.style.display = "block";
		
	} catch(err) {}
}

function hideWindow()
{
	try {
		ty = document.getElementById("winback");
		ty.style.display = "none";
	} catch(err) {}
}

function resizeWindow()
{
  width		= (getWidth() + 20) + "px";
	height	= (getHeight() + 20) + "px";
	
	try {
		ty = document.getElementById("winback");
		ty.style.width = width;
		ty.style.height = height;
	} catch(err) {}
}

function getWidth()
{
  w = 0;
 
  if (window.innerWidth || window.innerHeight)
    w = window.innerWidth; 

  if (document.body.clientWidth || document.body.clientHeight)
    w = document.body.clientWidth; 

  return w; 
}

function getHeight()
{
  h = 0;

  if (window.innerWidth || window.innerHeight)
    h = window.innerHeight; 
 
  if (document.body.clientWidth || document.body.clientHeight)
    h = document.body.clientHeight; 
 
  return h;
}

function openWin(str)
{
	window.open(str,"plaatje","width=704,height=528,scrollbars=1,toolbar=no,menubar=no,location=no,scrolling=yes,resizable=yes");
}

function setNavBallenhok()
{
		var str = "";
	
		str = "<a href=\"page_ballenhok.php\">Het ballenhok</a>";
		str = str + "<a href=\"forum.php\">Het forum</a>";
		str = str + "<a href=\"page_faq.php\">Hulp</a>";
		str = str + "<a href=\"page_links.php\">Links</a>";
    str = str + "<a href=\"page.php?p=prikbord\">Het prikbord</a>";
		str = str + "<a href=\"index.php?do=logout\">Uitloggen</a>";
		
		document.getElementById("mnu7").innerHTML = str;
}
