         $(document).ready(function (e){
         $("#frmEnquiry").on('submit',(function(e){
         	e.preventDefault();
         	//$('#loader-icon').show();
         	var valid;
         	valid = validateContact();
         	if(valid) {
         		$.ajax({
         		url: "../controller/admin_phpmailer.php",
         		type: "POST",
         		data:  new FormData(this),
         		contentType: false,
         		cache: false,
         		processData:false,
         		success: function(result){
                if(result!=''){
                  var a = result.split('|***|');
                  if(a[1]=="success"){
					//https://developer.snapappointments.com/bootstrap-select/methods/#selectpickertoggle
                    $('.selectpicker').selectpicker('deselectAll');
                    document.getElementById("subject").value ="";
                    tinyMCE.get(0).setContent("");
                  }
                  $('#msg').show().delay(5000).fadeOut(500);
                  $('#msg').html(a[0]);
                }
                //alert(data);
         		//$("#mail-status").html(data);
         		//$('#loader-icon').hide();
         		},
         		error: function(){}

         		});
         	}
         }));

         function validateContact() {
         	var valid = true;
         	$(".InputBox").css('background-color','');
         	$(".info").html('');
//         	$("#userName").removeClass("invalid");
//         	$("#userEmail").removeClass("invalid");
//            $('.selectpicker').removeClass('invalid').selectpicker('setStyle');
            //https://github.com/snapappointments/bootstrap-select/issues/1891
            $('.selectpicker').removeClass('invalid').selectpicker('setStyle').parent().removeClass('invalid ');


         	$("#subject").removeClass("invalid");
         	$("#content").removeClass("invalid");
         	// Bei TinyMCE geht das anders
         	var t = tinyMCE.get(0);
         	var color = '#fff';
            t.getBody().style.backgroundColor = color;

         	if($("#empfaenger").val()=='') {
         		$('.selectpicker').addClass('invalid').selectpicker('setStyle');
                 valid = false;
         	}
/*
             if(!$("#userEmail").val()) {
                 $("#userEmail").addClass("invalid");
                 $("#userEmail").attr("title","Required");
                 valid = false;
             }
             if(!$("#userEmail").val().match(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/)) {
                 $("#userEmail").addClass("invalid");
                 $("#userEmail").attr("title","Invalid Email");
                 valid = false;
             }
*/
         	if(!$("#subject").val()) {
         		$("#subject").addClass("invalid");
                 $("#subject").attr("title","Required");
         		valid = false;
         	}
           if($("#content").val()=='') {
              var color = '#fbf2f2';
              t.getBody().style.backgroundColor = color;
              $("#content").attr("title","Required");
              valid = false;
           }

         	return valid;
         }

         });
