function submitWWForm()
{
	var value = document.wwFrm.email.value;
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

  if (value == '' ||  value.search(validRegExp) == -1)
  {
    alert("Emailadres klopt niet");
    return false;
  }
  else
  {
		document.wwFrm.submit();
		return true;
  }
}

function submitLoginForm()
{
	if (document.loginFrm.inlognaam.value.length > 0 && document.loginFrm.wachtwoord.value.length > 0)
	{
		document.loginFrm.submit();
		return true;		
	}
	else
	{
		alert("Voer gebruikersnaam en wachtwoord in");
		return false;
	}
	
}

function checkEnter(e)
{ //e is event object passed from function invocation
	e = e || window.event;
	var key = e.which || e.keyCode;
	
	if(e.keyCode == 13)
	{ //if generated character code is equal to ascii 13 (if enter key)
	return true;
	}
	else
	{
	return false;
	}

}


// hier algemene functies plaatsen

function openEdit(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 800 ) / 2;
  mtop = (screen.height - 600) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 800 + ',height=' + 600 ;

  }
  w = window.open(theURL, winname, features);
  w.focus();
}

function openOrgInfoAanvraag(theURL)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  	mleft = (screen.width - 900 ) / 2;
  	mtop = (screen.height - 600) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 900 + ',height=' + 600 ;

  }
  w = window.open(theURL, 'infoaanvraag', features);
  w.focus();
}

function openGarminActie(theURL)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  	mleft = (screen.width - 900 ) / 2;
  	mtop = (screen.height - 600) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 900 + ',height=' + 600 ;

  }
  w = window.open(theURL, 'infoaanvraag', features);
  w.focus();
}

function openList(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 950 ) / 2;
  mtop = (screen.height - 500) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 950 + ',height=' + 500 ;

  }
  w = window.open(theURL, winname, features);
  //w.focus();
}

function openBericht(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 600 ) / 2;
  mtop = (screen.height - 350) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 600 + ',height=' + 350 ;

  }
  w = window.open(theURL, winname, features);
  w.focus();
}

// hier algemene functies plaatsen
function openLog(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';
	
	if (screen)
  {

  mleft = (screen.width - 1000 ) / 2;
  mtop = (screen.height - 700) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 1000 + ',height=' + 700 ;

  }
  w = window.open(theURL, winname, features);
  w.focus();
}

function openLidWorden(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 600 ) / 2;
  mtop = (screen.height - 400) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 600 + ',height=' + 400 ;

  }
  w = window.open(theURL, winname, features);
  w.focus();
}

function openInfoAanvraag(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 600 ) / 2;
  mtop = (screen.height - 320) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 600 + ',height=' + 320 ;

  }
  w = window.open(theURL, winname, features);
  w.focus();
}

function openWW(theURL)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 500 ) / 2;
  mtop = (screen.height - 220) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 500 + ',height=' + 220 ;

  }
  w = window.open('/public/ww_opvragen.php', 'wwopvragen', features);
  w.focus();
}


function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' is geen emailadres.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
    } if (errors) alert('Controleer uw invoer:\n'+errors);
    return (errors == '');
} }

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}


function remove_mesg_in(id)
{
	
	verder = confirm("Dit bericht echt verwijderen? Dit kan niet ongedaan worden.")
	
	if (verder == true)
	{
		document.location.href="mesg_list.php?kind=in&action=remove&id=" + id;
	}
}

function remove_group_mesg_in(id, group_id)
{
	
	verder = confirm("Dit bericht echt verwijderen? Dit kan niet ongedaan worden.")
	
	if (verder == true)
	{
		document.location.href="mesg_list.php?kind=in&action=remove&id=" + id +"&group_id="  + group_id;
	}
}

function remove_mesg_out(id)
{
	
	verder = confirm("Dit bericht echt verwijderen? Het blijft zichtbaar voor de ontvanger. Verwijderen kan niet ongedaan worden.")
	
	if (verder == true)
	{
		document.location.href="mesg_list.php?kind=out&action=remove&id=" + id;
	}
}

function remove_group_mesg_in(id, group_id)
{
	
	verder = confirm("Dit bericht echt verwijderen? Het blijft zichtbaar voor de ontvanger. Verwijderen kan niet ongedaan worden.")
	
	if (verder == true)
	{
		document.location.href="mesg_list.php?kind=out&action=remove&id=" + id +"&group_id="  + group_id;
	}
}

function remove_applied_training( group_id, training_users_id)
{
	
	verder = confirm("Dit trainingsschema echt verwijderen? Eventuele gelogde gegevens blijven bestaan.")
	
	if (verder == true)
	{
		openTrainingApply("mijn.php?action=remove_applied_training&group_id=" + group_id +"&training_users_id=" + training_users_id, "rm");
	}
}

function openTrainingApply(theURL, winname)
{
	var features;
	var w;
	var mleft, mtop;
	features='scrollbars=yes,toolbars=no,status=no';

	if (screen)
  {

  mleft = (screen.width - 600 ) / 2;
  mtop = (screen.height - 350) / 2;

    features = features + ',top=' + mtop + ',left=' + mleft + ',width=' + 600 + ',height=' + 350 ;

  }
  w = window.open(theURL, winname, features);
  w.focus();
}