/* Formchecks voor formulieren 
 * 18.11.2008 - Edgar: aangemaakt en alle functies gemigreerd naar dit bestand.
 */
 
 
/* function to highlight the background of formfield on error */
function HiLite(fieldname) {
	$(fieldname).style.backgroundColor  = "#ff0000";
	
	}
	
/* function to reset the background color formfield  */
function LoLite(fieldname) {
	$(fieldname).style.backgroundColor  = "#ffffff";
	}
 
 
function ValiderEmail(email)
  {
    //alert(email.length);
	  var pos  = email.indexOf('@');
	  var pos2 = email.indexOf('.');
	  var error = 0;

    if (email.length == 0) return false;

    if (pos < 1) error++;
    else  
    if (email.indexOf(".",pos) < pos+2) error++;

    if (pos2 == email.length-1)   error++;

    if (email.indexOf(" ") > 0)
    {
      return false;
    }

    if (error)
    {
      return false;
    }
    return true;
  }



// Check if a string contains only numbers
  function IsNumber(str)
  {
    var validChars = '0123456789';
    for(var i = 0; i < str.length; i++)
    {
      if(validChars.indexOf(str.charAt(i)) < 0)
        return false;
    }
    return true;
  }


// Check if a string contains only characters
 function IsCharacter(str)
  {
    var validChars = '0123456789';
    for(var i = 0; i < str.length; i++)
    {
      if(validChars.indexOf(str.charAt(i)) > 0)
      return false;
    }
    return true;
  }


 function RadioCheckBox(Form,Field,length,minReq,maxReq) 
  { 
    // Set the checked var to a default value of 0 
    var checked = 0; 
    // Loop through the number of items 
    for (i=0; i<length; i++) { 
      // If an item is checked, increment the 
      // checked var 
      if (eval("document." + Form + "." + Field + "[" + i + "].checked")) 
      { checked++; } 
    } 
    // If the checked var is between the min and 
    // max, return true, otherwise, false 
    if (checked < minReq || checked > maxReq) 
    { return false; } else { return true; } 
  } 
  
  

function sendform() {
  teller=0;
  error_message="";
  with (window.document.QucikfrmAdvanced)
  {
    if (document.QucikfrmAdvanced.freetext.value.length <2) {
      error_message=error_message+"Zoeken op een trefwoord met minder dan 1 teken is niet mogelijk, pas het trefwoord aan";
    }
  }//einde with{}
  
  if (error_message != "") {
    alert(error_message);	
  } else {
    document.QucikfrmAdvanced.submit();
    return true;
  } 
}


function checkIkdoemee() {
      teller=0
	    error_message="De uitnodiging kan niet verstuurd worden omdat:\n\n";
  	  with (window.document.ikdoemee)
  	  {
		    //alert(document.ikdoemee.aan.value);
		    //alert(document.ikdoemee.van.value);
    		if (!ValiderEmail(document.ikdoemee.aan.value))
	    	{
		    	error_message=error_message+"* Emailadres ontvanger ontbreekt of het is geen geldig email adres\n";
    		}
			
	      if (document.ikdoemee.naam.value.length <1 || document.ikdoemee.naam.value == 'uw naam') 
  	  	{
	  	  	error_message=error_message+"* U heeft uw naam niet ingevuld\n";
  		  }

    		if (!ValiderEmail(document.ikdoemee.van.value))
	    	{
		    	error_message=error_message+"* Uw emailadres ontbreekt of het is geen geldig email adres\n";
    		}

	    	if (error_message != "De uitnodiging kan niet verstuurd worden omdat:\n\n") 
		    {
			    alert(error_message);		
    		} else {
	    		document.ikdoemee.submit();
		    } 
    	}
    }
    
/* 18.11.2008 - Edgar
 * functie voor het controleren van Uitmail actie lightbox
 */
 
function actieUitmailHome() {
	if (!ValiderEmail($F('uitmailactie_email'))) {
			HiLite('uitmailactie_email');
	} else {
		$('uitmailactie').submit();
	}
}










