function stuurCallme() {
  if (document.getElementById('callmeNaam').value != '') {
    document.callmeForm.submit();
  } else {
    alert("Geef de benodigde informatie op.");
  }
}

function stuurVacancy(curForm) {
  facebox = document.getElementById("facebox");
  elem = facebox.getElementsByClassName("vacancyForm")[0];
  if (elem.naam != '') {
    elem.submit();
  } else {
    alert("Geef de benodigde informatie op.");
  }
}

function stuurInschrijven() {
  elem= document.getElementById("inschrijfForm");
  
  if ((elem.naam == '') || (!(elem.privacyverklaring.checked)) ||
   ((elem.email == ''))) {
    alert("Geef de benodigde informatie op.");
  } else {
    elem.submit();
  }
}

function mkUploadForm (token) {
	var button = $('#uploadButton'), interval;
	var tekst = $('#uploadStatus');
	var allowed = ['txt', 'doc', 'docx', 'TXT','DOC','DOCX'];

	
	$.ajax_upload(button,{
                    action: '/cvupload.php?token='+token,
                    name: 'mijncv',
                    onSubmit : function(file, ext){
                    
                    if ($.inArray(ext, allowed ) === -1){
                          // extension is not allowed
                          tekst.text('Alleen .txt en .doc toegestaan.');
                          // cancel upload
                          return false;
                    }
  
                    
                    // change button text, when user selects file			
                    tekst.text('Uploading');
                    
                    // If you want to allow uploading only 1 file at time,
                    // you can disable upload button
                    this.disable();
                    
                    // Uploading -> Uploading. -> Uploading...
                    interval = window.setInterval(function(){
                            if (tekst.text().length < 13){
                                    tekst.text(tekst.text() + '.');		
                            } else {
                                    tekst.text('Uploading');			
                            }
                    }, 200);
                  },
                  onSuccess: function(file){
                          tekst.text('Geslaagd');
                          document.getElementById("inschrijfUploaded").value = file;
                          // Although plugins emulates hover effect automatically,
                          // it doens't work when button is disabled
                          button.removeClass('hover');
                          
                          window.clearInterval(interval);
                                                  
                          // enable upload button
                          this.enable();
                          
                          // add file to the list
                          tekst.text('Geslaagd:'+file);						
                  },
                  onError: function(file, response){
                          tekst.text('Mislukt, probeer opnieuw');
                          
                          alert(response);
                          
                          // Although plugins emulates hover effect automatically,
                          // it doens't work when button is disabled
                          button.removeClass('hover');
                          
                          window.clearInterval(interval);
                                                  
                          // enable upload button
                          this.enable();
                  }

		});
	}

function mkImgUploadForm (uploadElementName,sname,token) {
	var veld = $('#'+uploadElementName);
	var interval;
	var tekst = $('#uploadStatus');
	var allowed = ['png', 'jpg', 'PNG', 'JPG'];
        
        var waarde = veld.val();
        
        var newHtml = "<div id=\""+uploadElementName+"_elem\" style=\"float: clear;min-height: 100px; width: 800px\">"+
                        "<img style=\"float: left\" id=\""+uploadElementName+"_img\" height=\"60\" width=\"76\" \" />"+
                        "<input id=\""+uploadElementName+"\" type=\"hidden\" value=\"\" name=\""+sname+"\" />"+
                        "<div style=\"float: left; width: 500px;\" id=\""+uploadElementName+"_status\"/>"+
                      "</div>";
        
        veld.parent().html(newHtml);
	
	var tekst = $('#'+uploadElementName+"_status");
	
	var knop =  $('#'+uploadElementName+"_img");
	
	var nveld = $('#'+uploadElementName);
	if (waarde != '') {
	  nveld.val(waarde);
	  knop.attr('src', waarde);
	} else {
	  nveld.val("/images/defaultThumb.png");
	  knop.attr('src', "/images/defaultThumb.png");
	}
	
	$.ajax_upload(knop,{
                  action: '/admin/imageupload.php?token='+token,
                  name: 'image',
                  onSubmit : function(file, ext){
                    
                    if ($.inArray(ext, allowed ) === -1){
                          // extension is not allowed
                          tekst.text('Alleen .jpg en .png toegestaan.');
                          // cancel upload
                          return false;
                    }
  
                    
                    // change button text, when user selects file			
                    tekst.text('Uploading');
                    
                    // If you want to allow uploading only 1 file at time,
                    // you can disable upload button
                    this.disable();
                    
                    // Uploading -> Uploading. -> Uploading...
                    interval = window.setInterval(function(){
                            if (tekst.text().length < 13){
                                    tekst.text(tekst.text() + '.');		
                            } else {
                                    tekst.text('Uploading');			
                            }
                    }, 200);
                  },
                  onSuccess: function(file){
                          tekst.text('Geslaagd');
                          //document.getElementById("inschrijfUploaded").value = file;
                          // Although plugins emulates hover effect automatically,
                          // it doens't work when button is disabled
                          knop.removeClass('hover');
                          
                          var filenam = '/uploads/img/'+token+file;
                          
                          nveld.val(filenam);
                          
                          knop.attr('src', filenam+'.thumb.png');
                          
                          window.clearInterval(interval);
                                                  
                          // enable upload button
                          this.enable();
                          
                          // add file to the list
                          tekst.text('Geslaagd:'+file);						
                  },
                  onError: function(file, response){
                          tekst.text('Mislukt, probeer opnieuw');
                          
                          alert(response);
                          
                          // Although plugins emulates hover effect automatically,
                          // it doens't work when button is disabled
                          knop.removeClass('hover');
                          
                          window.clearInterval(interval);
                                                  
                          // enable upload button
                          this.enable();
                  }

		});
	}