
var currentdate=new Date();var day=currentdate.getDate().toString();var month=(currentdate.getMonth()+1).toString();var hour=currentdate.getHours().toString();var mins=currentdate.getMinutes().toString();var secs=currentdate.getSeconds().toString();if(day.length==1)day='0'+day;if(month.length==1)month='0'+month;if(hour.length==1)hour='0'+hour;if(mins.length==1)mins='0'+mins;if(secs.length==1)secs='0'+secs;var solrDate=currentdate.getFullYear()+'-'+month+'-'+day+'T'+hour+':'+mins+':'+secs+'Z';var url=SOLR_URL+'posts/select/?q=((type:news OR type:video OR type:company) AND (searchText:*SEARCHTERM* OR searchText:"SEARCHTERM"^3) AND (publish_date:[* TO '+solrDate+'])) OR (type:drone AND name:"SEARCHTERM")^2&sort=score+desc&rows=20&wt=json';$('#searchInput').liveSearch({url:url});$('.glassClick').click(function(){var val=$('#searchInput').val();tools.setGAevent('Search','query (glassClick)','"'+val+'"');window.location.href='/zoeken/'+val;});
$('#commentsContainer header').hide();$('#commentsContainer ol').hide();function getCommentHtml(c){var html=[];html.push('<li data-date="'+c.timestamp+'" style="background-color:#FCE1E1;">');html.push('<figure class="circle">');html.push('<img src="'+c.avatar+'" alt=""/>');html.push('</figure>');html.push('<div class="col-list-txt">');if(c.aHref)html.push('<a href="'+c.aHref+'">');html.push('<h2>'+c.name+'</h2>');if(c.aHref)html.push('</a>');html.push('<time pubdate="pubdate" style="color:red;font-weight:bold;">REACTIE WACHT OP GOEDKEURING</time>');html.push('<p>'+c.text+'</p>');html.push('</div>');html.push('</li>');return html.join('');}
tools.handleComments=function(userData){if(userData){if(userData.user){$('#postCommentForm div.formFieldWrap:nth-child(-n+2)').hide();}
aComments=[];if(userData.hasOwnProperty('user'))aComments.push(userData.user.comments);if(userData.hasOwnProperty('anonymous'))aComments.push(userData.anonymous.comments);$.each(aComments,function(k,comments){if(comments["posts"]){if(comments["posts"][277817]){var cs=comments["posts"][277817];var commentCount=$('[data-comment-count]').data('comment-count');$.each(cs,function(k,c){c.avatar='http://www.drones.nl/img/temp-profile.jpg';if(!c.hasOwnProperty('name')){c.name=userData.user.username;if(userData.user.firstname)c.name=userData.user.firstname;if(userData.user.profile_avatar)c.avatar='/user-media/avatars/'+userData.user.profile_avatar;}
if($('.col-list-reacties li').length){$('.col-list-reacties li').each(function(){if(!$('.col-list-reacties li[data-date='+c.timestamp+']').length){commentCount++;if($(this).data('date')<c.timestamp&&!$('.col-list-reacties li[data-id='+c.id+']').length){$(this).before($(getCommentHtml(c)));return false;}}});}
else{commentCount++;$('.col-list-reacties').html(getCommentHtml(c));}});$('[data-comment-count]').text(commentCount+' Reacties').data('comment-count',commentCount);$('#commentsContainer').show();}}});}}
var _RECAPTCHA=_RECAPTCHA||{};_RECAPTCHA.init=function(){grecaptcha.ready(function(){grecaptcha.execute(grecaptchaSiteKey,{action:'homepage'}).then(function(token){jQuery('#grecaptchaToken').val(token);});});}
_RECAPTCHA.init();function validateEmail(email){var re=/^([\w-\+]+(?:\.[\w-\+]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return re.test(email);}
$('#postCommentForm').submit(function(e){e.preventDefault();var error=false;var commentType='post_video';if(commentType=='profile'){var loader='addProfileComment';var parent='drone-filmt-sinterklaas-drukte-bol-com';}else{var loader='addPostComment';var parent='drone-filmt-sinterklaas-drukte-bol-com';}
var nameField=$('input[name="name"]');var emailField=$('input[name="email"]');var commentField=$('textarea[name="comment"]');if(nameField.val()==''){nameField.addClass('error');error=true;}else{nameField.removeClass('error');}
if(emailField.val()==''||!validateEmail(emailField.val())){emailField.addClass('error');error=true;}else{emailField.removeClass('error');}
if(commentField.val()==''){commentField.addClass('error');error=true;}else{commentField.removeClass('error');}
if(!error){var vals={};vals['name']=$('input[name="name"]').val();vals['email']=$('input[name="email"]').val();vals['comment']=$('textarea[name="comment"]').val();$('body').append(overlay);var capResponse='';capResponse=jQuery('#grecaptchaToken').val();$.ajax({url:AJAXFUNCTION,type:"POST",data:{loadType:loader,commentVals:vals,parentString:parent,recaptchaResponse:capResponse},dataType:"json",success:function(result){$('#overlay').remove();if(result.error){tools.showMessage('error',result.error);}else{setTimeout(function(){var html=[];html.push('<li data-comment-profile-id="'+result.addedComment.use_id+'">');html.push('<figure class="circle">');if(result.addedComment.use_img)html.push('<img src="/user-media/avatars/'+result.addedComment.use_img+'" alt=""/>');else html.push('<img src="http://www.drones.nl/img/temp-profile.jpg" alt="">');html.push('</figure>');html.push('<div class="col-list-txt">');if(result.addedComment.use_name=='Admin')html.push('<h2 style="color:#FF4F4F;">'+result.addedComment.use_name+'</h2>');else html.push('<h2>'+result.addedComment.use_name+'</h2>');html.push('<time pubdate="pubdate"></time>');html.push('<p>'+vals['comment']+'</p>');html.push('</div>');html.push('</li>');$('ol.col-list-reacties').append(html.join(''));$('#commentsContainer header').show();$('#commentsContainer ol').show();var reacties=$('#commentsContainer header h2').text().split(' ');var newReacties=parseInt(reacties[0])+1;if(newReacties==1)$('#commentsContainer header h2').text(newReacties+' Reactie');else $('#commentsContainer header h2').text(newReacties+' Reacties');tools.showMessage('success','Bedankt voor uw bericht!');nameField.val('');emailField.val('');commentField.val('');tools.checkLogin();},500);}}});}else{tools.showMessage('error','Niet alle velden zijn correct ingevuld');}});
$('.rating li').mouseenter(function(){$('.rating li:lt('+$(this).data('stars')+')').addClass('hovered');}).mouseleave(function(){$('.rating li').removeClass('hovered');}).click(function(){if(Cookies.getJSON('rating-post-277817')){tools.showMessage('error','Je kan maar 1 keer stemmen');return;}
$.ajax({type:'POST',url:AJAXFUNCTION,data:{loadType:'submitPostVote',posId:277817,rating:$(this).data('stars')},dataType:"json",cache:false,context:this,success:function(result){Cookies.set('rating-post-277817',true);tools.showMessage('success','Bedankt voor je stem!');}});});
tools.getTpl('footerPostItem',function(){var tpl=new jSmart(tools.tpls['footerPostItem']);var solrtype='type:video';var solrQuery={q:solrtype,wt:'json',sort:'publish_date desc',};solrQuery.start=0;solrQuery.rows=5;$.ajax({url:SOLR_URL+'posts/select',type:"POST",data:solrQuery,dataType:'json',jsonp:'json.wrf',success:function(result){var listData={aItems:[]};$.each(result.response.docs,function(k,doc){var itemData={};itemData.aHref=doc.url;var img='https://placehold.it/500x500';var imgId='';if(doc.type=='news'){if(doc.images)img='/media/images/posts/'+doc.images[0];}
if(doc.type=='video'){img=doc.videoThumbUrl.replace('http://','https://');}
itemData.imgId=imgId;itemData.img=img;itemData.imgAlt=doc.name;itemData.text=doc.lead;itemData.title=doc.name;itemData.pubdate=doc.publish_date;var itemHtml=tpl.fetch(itemData);$('#footerPostList').append(itemHtml);});}})});
$('.alertClose').click(function(){$(this).parents('.alertWrap').removeClass('active');});
function showOverlay(fRel){$(document).ready(function(){$(".overlayClose, .overlayCloseBottom").click(function(){$(".overlay").toggle();});$('.overlay').css('display','table');});}
function ReadCookie(cookieName){var theCookie=" "+document.cookie;var ind=theCookie.indexOf(" "+cookieName+"=");if(ind==-1)ind=theCookie.indexOf(";"+cookieName+"=");if(ind==-1||cookieName=="")return"";var ind1=theCookie.indexOf(";",ind+1);if(ind1==-1)ind1=theCookie.length;return unescape(theCookie.substring(ind+cookieName.length+2,ind1));}
var shown=ReadCookie('newWebsitePopup');shown=true;if(!shown){var today=new Date();var expire=new Date();expire.setTime(today.getTime()+3600000*24*300);document.cookie="newWebsitePopup=1;expires="+expire.toGMTString();showOverlay(1);}
var $window=$(window),$element=$('.menuWrap'),className='smaller';$(window).scroll(function(){if($window.scrollTop()>280){$element.addClass(className);}else{$element.removeClass(className);}});$(document).ready(function(){$.getScript('https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js',function(){$('.adsbygoogle').each(function(){(adsbygoogle=window.adsbygoogle||[]).push({});});});$(".mainMenuTriggerOpen").click(function(){$(".menuWrap").addClass("active");$(".mainMenuTitle").addClass("active");});$(".mainMenuTriggerClose").click(function(){$(".menuWrap").removeClass("active");$(".mainMenuTitle").removeClass("active");});$(".topBarSearch").click(function(){$(".searchFieldWrap").addClass("active");$(".searchField").focus();return false;});$(".topBarSearchClose").click(function(){$(".searchFieldWrap").removeClass("active");$('#live-search').hide();return false;});$('iframe').each(function(){var url=$(this).attr("src");$(this).attr("src",url+"?wmode=transparent");});$('.forum .display-options select, .forum .forumSearch select').addClass('noSelectBoxIt');$("select:not(.noSelectBoxIt)").selectBoxIt({autoWidth:false});$("#productSlider").owlCarousel({singleItem:true,transitionStyle:"fadeUp"});$('[data-utime]').each(function(){var newD=tools.formatYesterdayDate($(this).data('utime'));if(newD)$(this).text(newD);});$('[data-comment-profile-id]').each(function(){if($(this).data('commentProfileId')==1){$(this).find('h2').css('color','#FF4F4F');}});if($('.sourceNt').length>0){$('.sourceNt').insertBefore('#commentsContainer').css('margin-bottom','1em');$('.tag-list').first().css('margin-bottom','1em');}
var offset=500;var duration=500;$(window).scroll(function(){if($(this).scrollTop()>offset){$(".back-to-top").fadeIn(duration);}else{$(".back-to-top").fadeOut(duration);}});$(".back-to-top").click(function(event){event.preventDefault();$("html, body").animate({scrollTop:0},duration);return false;});tools.checkLogin();$('a.fancybox_image').fancybox({helpers:{overlay:{locked:false}}});});