

// used for bookmarks
//
prepareMenuIE = function() 
{
	if (document.all && document.getElementById)
	{
		menuRoot = document.getElementById("menu"); //"menu" is name of top-level-div-id
		if (menuRoot)
		{
			for (i=0; i<menuRoot.childNodes.length; i++) 
			{
				node = menuRoot.childNodes[i];
				if (node.nodeName=="LI") 
				{
					node.onmouseover=function() 
					{
						this.className+=" over";
					}
					node.onmouseout=function() 
					{
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
		bm_listRoot = document.getElementById("bm_list"); //"bm_perm" is name of top-level-div-id
		if(bm_listRoot)
		{
			for (i=0; i<bm_listRoot.childNodes.length; i++) 
			{
				node = bm_listRoot.childNodes[i];
				if (node.nodeName=="LI") 
				{
					node.onmouseover=function() 
					{
						this.className+=" over";
					}
					node.onmouseout=function() 
					{
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
		menu_wizardRoot = document.getElementById("menu_wizard"); //"menu_wizard" is name of top-level-div-id
		if (menu_wizardRoot)
		{
			for (i=0; i<menu_wizardRoot.childNodes.length; i++) 
			{
				node = menu_wizardRoot.childNodes[i];
				if (node.nodeName=="UL") 
				{
					node.onmouseover=function() 
					{
						this.className+=" over";
					}
					node.onmouseout=function() 
					{
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}



// Check for netscape or internet explorer
var gAppName   = navigator.appName.toLowerCase();
var gUserAgent = navigator.userAgent.toLowerCase();
var gNetscape  = gAppName.indexOf("netscape") >= 0;
var gMacOS     = gUserAgent.indexOf("mac") >= 0;
var gW3C       = document.getElementById != null;

// Popup
//
function popup(thg_id,label,l,t,w,h) 
{ 
	if (l == null) l = 100;
	if (t == null) t = 100;
	if (w == null) w = 400;
	if (h == null) h = 400;

	var aPopupWin=window.open('','PopupWin','scrollbars=yes,menubar=no,location=no,directories=no,statusbar=no,toolbar=no,resizable=yes,width='+w+',height='+h+',top='+t+',left='+l);
	aPopupWin.document.open(); 
	aPopupWin.document.close();
	var p = 'popup.php?id='+thg_id+'&label='+label;
	aPopupWin.document.location.href = p;
	if(aPopupWin&&!aPopupWin.closed) {
		aPopupWin.focus();
	}	
}


var isNN;
var mw = 400;

if (parseInt(navigator.appVersion.charAt(0))>=4)
{
	NN = (navigator.appName=="Netscape") ? 1 : 0;
}

function resizePopup()
{
	if (document.images[0])
	{
		ww=(screen.width);
		wh=(screen.height);

		if (NN)
		{
			rw = document.images[0].width + 80;
			rh = document.images[0].height;
			if (ww < rw) {rw = ww;}
			if (rw < mw) {rw = mw;}
			if (wh < rh) {rh = wh;}
			if (rh < wh - 140) {rh = rh + 160}
			window.top.innerWidth  =rw;
			window.top.innerHeight =rh;
		}
		else
		{
			rw=document.images[0].width + 80;
			rh=document.images[0].height;
			if (ww < rw) {rw = ww;}
			if (rw < mw) {rw = mw;}
			if (wh < rh) {rh = wh;}
			if (rh < wh - 140) {rh = rh + 160}
			window.top.resizeTo(rw,rh);
		}
		parent.window.moveTo((screen.width - rw)/2, (screen.height - rh)/2);
	}
}


// Function:	getObj
// Parameters:	name of object
// Returns:		object
// Description:	creates object with right DOM
//
function getObj(name)
{
  if (document.getElementById && document.getElementById(name))
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all && document.all[name])
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers && document.layers[name])
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

// Function:	getObjNN4
// Parameters:	name of object
// Returns:		layer
// Description:	creates object with right nested layers for NN4 
//
function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function showObj(o)
{
	var x = new getObj(o);
	if (x.obj) x.style.display = "block";
}

function hideObj(o) 
{
	var x = new getObj(o);
	if (x.obj) x.style.display = "none";
}

function swapHideShowObj(o) {
	var x = new getObj(o);
	if(x.style.display == "block")
		hideObj(o)
	else 
		showObj(o);
}

function moveObj ( nm, x, y )
{
	// Move the animation
	//elt = anyMapGetElt(nm);
	elt = new getObj(nm);
	if (nm)
	{
		if (gW3C || !gNetscape)
		{
			elt.style.top  = eval('"'+y+'px"');
			elt.style.left = eval('"'+x+'px"');
		}
		else
		{
			elt.top  = y;
			elt.left = x;
		}
	}
}


// Function:	trim
// Parameters:	strText (string)
// Returns:		string without leading and trailing spaces
// Description:	trims leading and trailing spaces from a given string
//
function trim(strText) 
{ 
	while (strText.substring(0,1) == ' ') 
    	strText = strText.substring(1, strText.length);
    while (strText.substring(strText.length-1,strText.length) == ' ')
    	strText = strText.substring(0, strText.length-1);
	return strText;
}


// Function:	getvalue
// Parameters:	ffield
// Returns:		value of the formfield
//
function getvalue(ffield)
{
  v="";
  t=ffield.type;
  if(!t)t=ffield[0].type;
  if(t=="checkbox")if(ffield.checked)v=ffield.value;
  if(t=="file") v=ffield.value;
  if(t=="hidden") v=ffield.value;
  if(t=="password") v=ffield.value;

  if(t=="radio")
  {
  	if(ffield.length){for(gv_i=0;gv_i<ffield.length;gv_i++)if(ffield[gv_i].checked) v=ffield[gv_i].value;}  
    else{if(ffield.checked) v=ffield.value;}	
  }
    
  if(t=="select-multiple")  v=ffield.options[ffield.selectedIndex].value;
  if(t=="select-one")  v=ffield.options[ffield.selectedIndex].value;
  if(t=="text") v=ffield.value;
  if(t=="textarea") v=ffield.value;
  
  return v;
}

// Function:	isSizeSmaller
// Parameters:	v		value (form value)
//				size	compare size
// Returns:		boolean
//
function isSizeSmaller(v, size)
{
	if (v.length < size) return true;
	else return false;
}

// Function:	isSizeGreater
// Parameters:	v		value (form value)
//				size	compare size
// Returns:		boolean
//
function isSizeGreater(theValue, size)
{
	if (theValue.length > size) return true;
	else return false;
}

// Function:	isSizeGreater
// Parameters:	v		value (form value)
// Returns:		boolean
// Description: checks if emailadres is a valid one
//
function isEmailAddress(v)
{
	mailvalid=true
	if(v.indexOf('@')<1)mailvalid=false;
	else if(v.lastIndexOf('.') < v.indexOf('@'))isvalid=false;
	aapje=v.indexOf('@');  puntje=v.indexOf('.');  if(puntje-aapje==1)isvalid=false;
	return mailvalid;
}


