function confirm_delete()
{
  if (confirm("Weet u zeker of u dit record wilt verwijderen?")==true)
    return true;
  else
    return false;
}

function confirm_action(message)
{
  if (confirm(message)==true)
    return true;
  else
    return false;
}


function popUp(URL)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=50,height=50,left = 160,top = 100');");
}

function popUpApplicatie(URL,width,height)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+ width +',height='+ height +',left = 0,top = 0');");
}


function popUpChange(URL)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=500,left = 5,top = 5');");
}

function popUpLookup(URL)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=300,left = 5,top = 5');");
}

function changeRowColor(theRow, newColor)
{
  theRow.style.backgroundColor = newColor;
}

function gotoLink(url)
{
  location.href = url;
}

function trimAll( strValue )
{
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue))
    {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function validateDate(strValue)
{
/************************************************
DESCRIPTION: 

    Controle of de datum juist gevuld is
    Ex. dd-mm-yyyy

PARAMETERS:
   strValue - De datum die moet worden gecontroleerd

RETURNS:
   True if valid, otherwise false.
*************************************************/
  var objRegExp = /^\d{1,2}(\-)\d{1,2}\1\d{4}$/

  //check to see if in correct format

  strValue = trimAll(strValue);
  
  if(strValue.length == 0)
  {
    return true;
  }
  
  if(!objRegExp.test(strValue))
  {
    document.melden.statustekst.value = 'Datum niet juist ingevuld (dd-mm-yyyy)';
    return false; // Datum formaat klopt niet
  }
  else
  {
    var strSeparator = strValue.substring(2,3) // Zoeken naar scheidingsteken
    var arrayDate = strValue.split(strSeparator); // Splitsen van de datum
    // Controle tabel van de maanden excl. februari
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
    
    var intDay = parseInt(arrayDate[0]);

    // Controleer of de dag klopt bij de maand
    if(arrayLookup[arrayDate[1]] != null || arrayLookup[arrayDate[1]] == '02')
    {
      if(intDay <= arrayLookup[arrayDate[1]]) // && intDay != 0)
      {
        document.melden.statustekst.value = '';
        return true; // correcte datum 
      }
    }
    //else
    //{
    //    document.melden.statustekst.value = 'Ingevoerde maand is niet geldig. (xx-mm-xxxx)';
    //	return false;
    //}

    // Schrikkeljaar controle
    var intYear = parseInt(arrayDate[2]);
    var intMonth = parseInt(arrayDate[1]);
    if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
    {
      document.melden.statustekst.value = '';
      return true; // correcte datum 
    }
  }
  document.melden.statustekst.value = 'Ingevoerde datum is niet geldig.';
  return false; 
}




function validateTime(strValue)
{
/************************************************
DESCRIPTION: 

    Controle of de datum juist gevuld is
    Ex. hh:mm

PARAMETERS:
   strValue - De datum die moet worden gecontroleerd

RETURNS:
   True if valid, otherwise false.
*************************************************/
  var objRegExp = /^\d{1,2}(\:)\d{1,2}(\:)\d{1,2}$/
  var objRegExp2 = /^\d{1,2}(\:)\d{1,2}$/

  //check to see if in correct format

  strValue = trimAll(strValue);
  
  if(strValue.length == 0)
  {
    return true;
  }
  
  if(!objRegExp.test(strValue) && !objRegExp2.test(strValue))
  {
    document.melden.statustekst.value = 'Tijd niet juist ingevuld (hh:mm)';
    return false; // Datum formaat klopt niet
  }
  else
  {
    var strSeparator = strValue.substring(2,3) // Zoeken naar scheidingsteken
    var arrayTime = strValue.split(strSeparator); // Splitsen van de datum
        
    var intHour = parseInt(arrayTime[0]);
    var intMinut = parseInt(arrayTime[1]);

    if(intHour < 0 || intHour > 23)
    {
    	document.melden.statustekst.value = 'Tijd is niet goed ingevuld (hh:xx)';
    	return false;
    }
    if(intMinut < 0 || intMinut > 59)
    {
    	document.melden.statustekst.value = 'Tijd is niet goed ingevuld (xx:mm)';
    	return false;
    }
  }
  document.melden.statustekst.value = '';
  return true; // correcte tijd 
}


function validateInt(strValue)
{
  /**************************************************
  DESCRIPTION: Controleerd of het een int is
      valid integer number.
  
  PARAMETERS:
     strValue - controle waarde
  
  RETURNS:
     True als waar, anders false.
  ***************************************************/
  var objRegExp  = /(^-?\d\d*$)/;


  strValue = trimAll(strValue);
  
  if(strValue.length == 0)
  {
    return true;
  }

  // Controleerd de waarde
  
  if(!objRegExp.test(strValue))
  {
    document.melden.statustekst.value = 'De ingevulde waarde is geen getal';
    return false;
  }
  else
  {
    document.melden.statustekst.value = '';
    return true;
  }
}

function  validateNumeric( strValue )
{
/******************************************************************************
DESCRIPTION: Validates that a string contains only valid numbers.

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.
******************************************************************************/
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

  //check for numeric characters

  strValue = trimAll(strValue);
  
  if(strValue.length == 0)
  {
    return true;
  }


  if(!objRegExp.test(strValue))
  {
    document.melden.statustekst.value = 'De ingevulde waarde is geen getal (xxx.xx)';
    return false;
  }
  else
  {
    document.melden.statustekst.value = '';
    return true;
  }
}


function validateEmail( strValue) 
{
/************************************************
DESCRIPTION: Validates that a string contains a
  valid email pattern.

 PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) or valid country suffix.
*************************************************/

  //check for valid email
  if(!objRegExp.test(strValue))
  {
    document.melden.statustekst.value = 'Geen geldig email adres(xxx@xxx.xx)';
    return false;
  }
  else
  {
    document.melden.statustekst.value = '';
    return true;
  }
}


