//----------------------------------------------------------
function checkname ( name )
{
    if ( name.length == 0 )
    {
        alert ( "'Naam' mag niet leeg zijn");
        $('tx_vacatures_pi1[name]').focus();
        $('tx_vacatures_pi1[name]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[name]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkcompany ( company )
{
    $('tx_vacatures_pi1[company]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checktelephone ( telephone )
{
    if ( telephone.length == 0 )
    {
        alert ( "'Telefoon' mag niet leeg zijn");
        $('tx_vacatures_pi1[telephone]').focus();
        $('tx_vacatures_pi1[telepphone]').style.backgroundColor="#e4e4e4";
        return false;
    }
    var filter  = /^(0[0-9]{9})+$/;
    if (!filter.test(telephone))
    {
        alert ( "U heeft geen geldig telefoon nummer ingevuld." );
        $('tx_vacatures_pi1[telephone]').focus();
        $('tx_vacatures_pi1[telephone]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[telephone]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkmobile ( mobile )
{
    if ( mobile.length == 0 )
    {
        alert ( "'Mobiel' mag niet leeg zijn");
        $('tx_vacatures_pi1[mobile]').focus();
        $('tx_vacatures_pi1[mobile]').style.backgroundColor="#e4e4e4";
        return false;
    }
    var filter  = /^(06[0-9]{8})+$/;
    if (!filter.test(mobile))
    {
        alert ( "U heeft geen geldig mobiel nummer ingevuld." );
        $('tx_vacatures_pi1[mobile]').focus();
        $('tx_vacatures_pi1[mobile]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[mobile]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkemail ( email )
{
    if ( email.length == 0 )
    {
        alert ( "'Email' mag niet leeg zijn");
        $('tx_vacatures_pi1[email]').focus();
        $('tx_vacatures_pi1[email]').style.backgroundColor="#e4e4e4";
        return false;
    }
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email))
    {
        alert ( "U heeft geen geldig emailadres ingevuld." );
        $('tx_vacatures_pi1[email]').focus();
        $('tx_vacatures_pi1[email]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[email]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkplace ( place )
{
    if ( place.length == 0 )
    {
        alert ( "'Plaats' mag niet leeg zijn");
        $('tx_vacatures_pi1[email]').focus();
        $('tx_vacatures_pi1[email]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[place]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkdate_available ( date_available )
{
    if ( date_available.length == 0 )
    {
        alert ( "'Datum beschikbaar' mag niet leeg zijn");
        $('tx_vacatures_pi1[date_available]').focus();
        $('tx_vacatures_pi1[date_available]').style.backgroundColor="#e4e4e4";
        return false;
    }
    if ( !isDate ( date_available ) )
    {
        $('tx_vacatures_pi1[date_available]').focus();
        $('tx_vacatures_pi1[date_available]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[date_available]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkcomment( comment )
{
    $('tx_vacatures_pi1[comment]').style.backgroundColor="#fefefe";
}
//----------------------------------------------------------
function checkFileSize ( id, mb ) {
    try {
        var size = id.files[0].fileSize; // FF
    } catch (e)
    {
        try {
            objFSO = new ActiveXObject("Scripting.FileSystemObject");  // IE
            var path = id.value;
            var file = objFSO.getFile(path);
            var size = file.size ; // This size will be in Bytes    }
        } catch (e)
            {
                alert ( "Bij het laden van grote files is het onzeker of het laden correct plaatsvind" );;
                $(id).focus();
                $(id).style.backgroundColor="#fefefe";
                return true;
            }
    }
    if ( size > mb*1024*1024 ) {
        alert ( "Maximum upload size is "+mb+"MB" );
        $(id).focus();
        $(id).style.backgroundColor="#e4e4e4";
        return false;
    }
    $(id).style.backgroundColor="#fefefe";
    return true;
}
//----------------------------------------------------------
function checkhourlyrate ( hourlyrate )
{
    if ( hourlyrate.length == 0 )
    {
        alert ( "'Uur tarief' mag niet leeg zijn");
        $('tx_vacatures_pi1[hourlyrate]').focus();
        $('tx_vacatures_pi1[hourlyrate]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[hourlyrate]').style.backgroundColor="#fefefe";
    return true;
}
//----------------------------------------------------------
function checkresume ( resume )
{
    if ( resume.length == 0 )
    {
        alert ( "'CV' mag niet leeg zijn");
        $('tx_vacatures_pi1[resume]').focus();
        $('tx_vacatures_pi1[resume]').style.backgroundColor="#e4e4e4";
        return false;
    }
    $('tx_vacatures_pi1[resume]').style.backgroundColor="#fefefe";
    return true;
}
//----------------------------------------------------------
function isDate(dateStr) {
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)20(\d{2})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?

    if (matchArray == null) {   
        alert("De ingegeven datum waarde '"+dateStr+ "' is incorrect");
        return false;
        }

    day = matchArray[1]; // p@rse date into variables
    month = matchArray[3];
    year = matchArray[5];

    if (month < 1 || month > 12) { // check month range
        alert("Maand moet tussen 1 en 12.");
        return false;
        }

    if (day < 1 || day > 31) {
        alert("Dag moet tussen 1 en 31.");
        return false;
        }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Maand "+month+" heeft geen 31 dagen!");
        return false;
        }
    
    if (month == 2) { // check for february 29th    
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
        alert("Februari " + year + " heeft geen " + day + " dagen!");
        return false;
        }
    }   
    return true; // date is valid
}
//----------------------------------------------------------
function startUpload(){
      document.getElementById('f1_upload_process').style.visibility = 'visible';
      document.getElementById('f1_upload_form').style.visibility = 'hidden';
      return true;
}
//----------------------------------------------------------
function stopUpload(success,file,id){
      var result = '';
      if (success == 2){
         result = '<span class="emsg"><b>'+file+'</b> filetype NIET ondersteund!<\/span><br/>';
      }
      else if (success == 1){
         result = '<span class="msg"><b>'+file+'</b> laden OK!<\/span><br/>';
      }
      else {
         result = '<span class="emsg"><b>'+file+'</b> NIET OK!<\/span><br/>';
      }
      document.getElementById('f1_upload_process').style.visibility = 'hidden';
      document.getElementById('f1_upload_form').innerHTML =
            result
            + '<input type="hidden" name="file" value="' + id +  '" />'
            + '<input name="uploadfile" type="file" size="30" />'
            + '<br />'
            + '<input type="submit" name="submitBtn" class="sbtn" value="Upload" />';
      document.getElementById('f1_upload_form').style.visibility = 'visible';      
      if ( success == 1 ) document.getElementById('button_versturen').focus();      
      return true;   
}
//----------------------------------------------------------
function tdVisible ( id ){
      document.getElementById(id).style.visibility = 'visible';      
}
//----------------------------------------------------------

