
// Metavolley.be 2.0
function stringFilter (input) {
  var s = input;
  filteredValues = "1234567890,.";     // Characters stripped out
  var i;
  var returnString = "";
  var TmpString = "";
  for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
    var c = s.charAt(i);
    if (filteredValues.indexOf(c) != -1) TmpString += c;
  }
  returnString = ReplaceComma(TmpString);
  return returnString;
}


// Metavolley.be 2.0
function ReplaceComma (input) {
  var s = input;
  var filteredValues = ",";     // Characters stripped out
  var i;
  var returnString = "";
  for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
    var c = s.charAt(i);
    if (filteredValues.indexOf(c) == -1) {
      returnString += c;
    }
    else {
      returnString += ".";
    }
  }
  return returnString;
}

// Metavolley.be 2.0
function Replacequote (input) {
  var s = input;
  var filteredValues = "'";     // Characters stripped out
  var i;
  var returnString = "";
  for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
    var c = s.charAt(i);
    if (filteredValues.indexOf(c) == -1) {
      returnString += c;
    }
    else {
      returnString += "´";
    }
  }
  return returnString;
}

// Metavolley.be 2.0

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
  // otherwise, update 'characters left' counter
   else 
   countfield.value = maxlimit - field.value.length;
}

// Metavolley.be 1.0
function AddFavorites2() {
<!--
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {

var url="http:\/\/www.Metavolley.be";
var title="MetaVolley - Tornooikalender";

//document.write('<font face="Verdana, Arial, Helvetica, sans-serif" size="1">');
document.write('<A HREF="javascript:window.external.AddFavorite(url,title);" ');
document.write('onMouseOver=" window.status=');
document.write("'Voeg MetaVolley.be toe aan uw favorieten!'; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">Voeg MetaVolley.be <br> toe aan uw favorieten!</a></font>');
}
else {
var msg = "Vergeet Metavolley.be niet toe te voegen aan uw favorieten!";
if(navigator.appName == "Netscape") msg += " (CTRL-D)";
document.write(msg);
}

// -->
}

// Metavolley.be 1.0
function AddFavorites() {
<!--
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
var url="http:www.Metavolley.be";
var title="MetaVolley - Tornooikalender";
javascript:window.external.AddFavorite(url,title);
}
else {
var msg = "Vergeet Metavolley.be niet toe te voegen aan uw favorieten!";
if(navigator.appName == "Netscape") msg += " (CTRL-D)";
document.write(msg);
}

// -->
}

 today=new Date();
 // Build an array initializer
 function isnArray() {
 	argnr=isnArray.arguments.length
 	for (var i=0;i<argnr;i++) {
 		this[i+1] = isnArray.arguments[i];
 	}
 }
 // And months and day arrays
 var isnMonths=new isnArray("Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
 var isnDays= new isnArray("Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag","Zondag");
 isnDays[0]="Zondag";

function checkbox3 (type, nme, lbl) {
         document.write ('<font face="Verdana, Arial, Helvetica" size=1><input type=' + type + ' name=' + nme + '>' + lbl + '</font><br>');
}

function headcell(lbl){
   document.write('<td bgcolor="#004080"><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF" size="1"><p align="center">' +lbl+ '</p></font></td>')
}

function IsValidTime(timeStr) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Het uur is geen geldig formaat. Het formaat moet zijn: uu:mm");
return false;
}

hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Het uur moet tussen 0 en 23 uur zijn");
return false;
}

if (minute<0 || minute > 59) {
  alert ("Het aantal minuten moet tussen 0 en 59 zijn.");
  return false;
}

return false;
}

function Validateform(frm)
{

  if (frm.vo_trn.value == "")
  { alert("Gelieve het tornooi een naam te geven"); frm.vo_trn.focus(); return false;  }

  if (frm.vd_dta_beg.value == "")
  { alert("Gelieve de datum van het tornooi op te geven"); frm.vd_dta_beg.focus(); }

  if (frm.vd_dta_end.value == "")
  { alert("Gelieve de einddatum van het tornooi op te geven"); frm.vd_dta_end.focus();  }

  //if (frm.User_email.value.indexOf('@', 0) == -1 ||
  //    frm.User_email.value.indexOf('.', 0) == -1)
  //{ alert("Gelieve een geldig emailadres in te vullen"); frm.User_email.focus();  }

  if (frm.vc_zip.value == "")
  { alert("Gelieve de postcode in te vullen."); frm.vc_zip.focus();  }

  //IsValidTime(document.frm.vh_bgn.value);


}

// Metavolley.be 2.0
function verify_updtrn() {

  var themessage = "Het volgende veld moet ingevuld zijn: ";
  var themessage2 = "";
  var jddtabeg = document.updtrn.vd_dta_beg.value;
  var jddtaend = document.updtrn.vd_dta_end.value;
  var jddtasub = document.updtrn.vd_dta_sub.value;

  if (document.updtrn.vo_trn.value=="") {
    themessage = themessage + " - Tornooi";
  }
  else {
    document.updtrn.vo_trn.value=Replacequote(document.updtrn.vo_trn.value);
  }
  if (document.updtrn.vd_dta_beg.value=="") {
    themessage = themessage + " -  Datum";
  }
  if (document.updtrn.vd_dta_end.value=="") {
    themessage = themessage + " -  Datum einde";
  }
  if (jddtabeg.length!=10) {
    themessage2 = themessage2 + "Het formaat voor `Datum` moet het volgende zijn: dd/mm/yyyy.";
  }
  if (jddtaend.length!=10) {
    themessage2 = themessage2 + "Het formaat voor `Datum einde` moet het volgende zijn: dd/mm/yyyy.";
  }
  //alert if fields are empty and cancel form submit;
  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
    if (themessage2 == "") {
      document.updtrn.vm_loc.value=Replacequote(document.updtrn.vm_loc.value);
      document.updtrn.vm_str.value=Replacequote(document.updtrn.vm_str.value);
      document.updtrn.vm_des.value=Replacequote(document.updtrn.vm_des.value);
      document.updtrn.va_sub.value=stringFilter(document.updtrn.va_sub.value);
      document.updtrn.submit();
    }
    else {
    alert(themessage2);
    return false;
    }
  }
  else {
  alert(themessage);
  return false;
  }
}

// Metavolley.be 2.0
function verify() {

  var themessage = "Het volgende veld moet ingevuld zijn: ";
  var themessage2 = "";
  var jddtabeg = document.addtrn.vd_dta_beg.value;
  var jddtaend = document.addtrn.vd_dta_end.value;
  var jddtasub = document.addtrn.vd_dta_sub.value;

  if (document.addtrn.vo_trn.value=="") {
    themessage = themessage + " - Tornooi";
  }
  else {
    document.addtrn.vo_trn.value=Replacequote(document.addtrn.vo_trn.value);
  }
  if (document.addtrn.vd_dta_beg.value=="") {
    themessage = themessage + " -  Datum";
  }
  if (document.addtrn.vd_dta_end.value=="") {
    themessage = themessage + " -  Datum einde";
  }
  if (jddtabeg.length!=10) {
    themessage2 = themessage2 + "Het formaat voor `Datum` moet het volgende zijn: dd/mm/yyyy.";
  }
  if (jddtaend.length!=10) {
    themessage2 = themessage2 + "Het formaat `Datum einde` moet het volgende zijn: dd/mm/yyyy.";
  }
  //alert if fields are empty and cancel form submit;
  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
    if (themessage2 == "") {
      document.addtrn.vm_loc.value=Replacequote(document.addtrn.vm_loc.value);
      document.addtrn.vm_str.value=Replacequote(document.addtrn.vm_str.value);
      document.addtrn.vm_des.value=Replacequote(document.addtrn.vm_des.value);
      document.addtrn.va_sub.value=stringFilter(document.addtrn.va_sub.value);
      document.addtrn.submit();
    }
    else {
    alert(themessage2);
    return false;
    }
  }
  else {
  alert(themessage);
  return false;
  }
}

// Metavolley.be 2.0
function verify_addorg(Yrec) {

  var dosubmit = "1";
  var themessage = "Het volgende veld moet ingevuld zijn: ";

  if (Yrec==0) {
    if (document.addorg.vm_org.value=="") {
      themessage = themessage + " - Organisatie";
    }

    if (themessage == "Het volgende veld moet ingevuld zijn: ") {
      dosubmit = "1";
    }
    else {
      alert(themessage);
      return false;
    }
    document.addorg.vm_org.value=Replacequote(document.addorg.vm_org.value);
    document.addorg.vm_str.value=Replacequote(document.addorg.vm_str.value);
  }
  else {
    if (document.addorg.oldorg.checked == 0) {
      if (document.addorg.vm_org.value=="") {
        themessage = themessage + " - Organisatie";
      }

      if (themessage == "Het volgende veld moet ingevuld zijn: ") {
        dosubmit = "1";
      }
      else {
        alert(themessage);
        return false;
      }
      document.addorg.vm_org.value=Replacequote(document.addorg.vm_org.value);
      document.addorg.vm_str.value=Replacequote(document.addorg.vm_str.value);
    }
  }
//  var themessage = "Het volgende veld moet ingevuld zijn: ";
//  var dosubmit = "0";
      
//  if (document.addorg.vm_org.value=="") {
//    themessage = themessage + " - Organisatie";
//  }
  //alert if fields are empty and cancel form submit;
//  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
//    dosubmit = "1";
//  }
//  else {
//  alert(themessage);
//  return false;
//  }
//  if (document.addorg.vm_eml.value<>"") {
//    if (emailCheck(document.addorg.vm_eml.value)) {
//      dosubmit = "1";
//      return false;
//    }
//  }
  if (dosubmit == "1") {
      document.addorg.submit();
  }
}

// Metavolley.be 2.0
function verify_updorg() {

  document.updorg.vm_org.value=Replacequote(document.updorg.vm_org.value);
  document.updorg.vm_str.value=Replacequote(document.updorg.vm_str.value);

//  var themessage = "Het volgende veld moet ingevuld zijn: ";
//  var dosubmit = "0";
      
//  if (document.addorg.vm_org.value=="") {
//    themessage = themessage + " - Organisatie";
//  }
  //alert if fields are empty and cancel form submit;
//  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
//    dosubmit = "1";
//  }
//  else {
//  alert(themessage);
//  return false;
//  }
//  if (document.addorg.vm_eml.value<>"") {
//    if (emailCheck(document.addorg.vm_eml.value)) {
//      dosubmit = "1";
//      return false;
//    }
//  }
//  if (dosubmit == "1") {
      document.updorg.submit();
//  }
}

function addrks_1() {
  document.addrks.vactrks1.value = 1;
  document.addrks.vactrks2.value = 0;
  verify_addrks();
}

function addrks_2() {
  document.addrks.vactrks1.value = 0;
  document.addrks.vactrks2.value = 1;
  verify_addrks();
}

function addrks_3() {
  document.addrks.vactrks1.value = 3;
  document.addrks.vactrks2.value = 0;
  verify_addrks();
}

function verify_addrks() {

  var themessage = "Het volgende veld moet ingevuld zijn: ";
  if (document.addrks.vc_rks.value=="-1") {
    themessage = themessage + " - Reeks";
  }
  if (document.addrks.vc_typ_rks.value=="-1") {
    themessage = themessage + " - Type Reeks";
  }

  //alert if fields are empty and cancel form submit;
  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
    document.addrks.submit();
  }
  else {
   alert(themessage);
  return false;
  }
}


// Metavolley.be 2.0
function verify_updrks() {

//  var themessage = "Het volgende veld moet ingevuld zijn: ";
//  if (document.updrks.vc_rks.value=="-1") {
//    themessage = themessage + " - Reeks";
//  }
  //alert if fields are empty and cancel form submit;
//  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
    document.updrks.submit();
//  }
//  else {
//   alert(themessage);
//  return false;
//  }
}

// Metavolley.be 2.0
function addprs_1() {

  document.addprs.vaction1.value = 1;
  document.addprs.vaction2.value = 0;
  verify_addprs();
}

// Metavolley.be 2.0
function addprs_2() {

  document.addprs.vaction1.value = 0;
  document.addprs.vaction2.value = 1;
  verify_addprs();
}

function addprs_3() {

  document.addprs.vaction1.value = 3;
  document.addprs.vaction2.value = 0;
  verify_addprs();
}


// Metavolley.be 2.0
function verify_addprs() {

  var themessage = "Het volgende veld moet ingevuld zijn: ";
  if (document.addprs.vm_prs.value=="") {
    themessage = themessage + " - Naam persoon";
  }
  //alert if fields are empty and cancel form submit;
  if (themessage == "Het volgende veld moet ingevuld zijn: ") {

  document.addprs.vm_prs.value=Replacequote(document.addprs.vm_prs.value);
  document.addprs.vm_str.value=Replacequote(document.addprs.vm_str.value);

  document.addprs.submit();
  }
  else {
  alert(themessage);
  return false;
  }
}

// Metavolley.be 2.0
function updprs_1() {
  document.updprs.vaction1.value = 3;
  verify_updprs();
}

// Metavolley.be 2.0
function verify_updprs() {

  var themessage = "Het volgende veld moet ingevuld zijn: ";
  if (document.updprs.vm_prs.value=="") {
    themessage = themessage + " - Naam persoon";
  }
  //alert if fields are empty and cancel form submit;
  if (themessage == "Het volgende veld moet ingevuld zijn: ") {
  //  if (emailCheck(document.updprs.vm_eml.value)) {
    document.updprs.vm_prs.value=Replacequote(document.updprs.vm_prs.value);
    document.updprs.vm_str.value=Replacequote(document.updprs.vm_str.value);
    document.updprs.submit();
  //  }
  }
  else {
  alert(themessage);
  return false;
  }
}

function verify_frmlgn() {

  if(emailCheck(document.frmlgn.email.value)) {
    document.frmlgn.submit();
  }
}

function format_1() {

  //alert("format_1");
  if (document.addtrn.vn_agm.value.length == 15) {
    var prefix = document.addtrn.vn_agm.value.substr(0,3);
    var middenblok = document.addtrn.vn_agm.value.substr(4,7);
    var sufix  = document.addtrn.vn_agm.value.substr(12,2);
    document.addtrn.vn_agm.value = prefix + "-" + middenblok + "-" + sufix;
  }
  else {
  alert("Formaat moet xxx-xxxxxxx-xx zijn");
  }
  return true;
}


function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Emailadres is foutief (controleer @ en .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("De naam bevat foutieve tekens.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("De domein naam bevat foutieve tekens.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("De naam is niet geldig.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Het IP adres is niet geldig!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("De domein naam is niet geldig.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Het emailadres moet eindigen met een geldig domin of een 2-letter woord " + "land.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("Er ontbreekt een hostname in het emailadres!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

function checkedtemlPw() {

  pw1 = document.frmedteml.pwd1.value;
  if (pw1 == null || pw1 == "") {
    alert ("Vul een paswoord in a.u.b.")
    return false;
  }
  if (emailCheck(document.frmedteml.email.value)) {
    document.frmedteml.submit();
  }
}


function checkPw() {
//alert ("\nEntered function checkPw")
pw1 = document.frmlgn.pwd1.value;
pw2 = document.frmlgn.pwd2.value;

if (pw1 == null || pw1 == "") {
  alert ("Vul een paswoord in a.u.b.")
  return false;
}

if (pw2 == null) {
  alert ("Gelieve het paswoord te bevestigen a.u.b.")
  return false;
}

if (pw1 != pw2) {
  alert ("Het paswoord is niet bevestigd.  Bevestig het paswoord a.u.b.")
//  emailCheck(document.frmlgn.email.value);
  return false;
}
else 
  if (emailCheck(document.frmlgn.email.value)) {
    document.frmlgn.submit();
  }
}

function sndpwd() {
  if(emailCheck(document.frmlgn.email.value)) {
    document.frmsndpwd.email.value = document.frmlgn.email.value ;
    document.frmsndpwd.pwd1.value = document.frmlgn.pwd1.value ;
    document.frmsndpwd.submit();
  } 
}

function PassSessId() {
    document.frmSessId.submit();
}


function open_win_disclaimer()
{
window.open("http://www.metavolley.be/disclaimer.html","my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=300")
}

function open_win_privacy()
{
window.open("http://www.metavolley.be/privacy.html","my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=300")
}
