let nodes=document.querySelectorAll("input[type=text]");if(nodes!==null){for(let i=0;i<nodes.length;i++){if(nodes[i].getAttribute('data-clearfield')!=='no'){if(nodes[i].getAttribute('data-role')!=='clearfield'&&!nodes[i].hasAttribute('readonly')&&!nodes[i].hasAttribute('disabled')&&(nodes[i].offsetWidth==0||nodes[i].offsetWidth>120)){let wrapper=document.createElement('div');wrapper.setAttribute('data-role','clearbox');wrapper.setAttribute('class','clearboxes');nodes[i].setAttribute("data-role","clearfield");nodes[i].parentNode.insertBefore(wrapper,nodes[i]);wrapper.appendChild(nodes[i]);let icon=document.createElement('span');if(etis!=null&&[1,3,5,6,7,8,11,12,15,17,18,23,24,25,29,38,43,56].includes(etis)){icon.setAttribute("class","icb-cloc");}else{icon.setAttribute("class","icon icon-clearable");}
let span=document.createElement('span');span.appendChild(icon);span.setAttribute("data-role","clearlink");span.setAttribute("class","clearlink");span.style.display=nodes[i].value.length?'block':'none';wrapper.appendChild(span);nodes[i].addEventListener('keyup',function(){this.nextSibling.style.display=this.value.length?'block':'none';});span.addEventListener('click',function(){this.previousSibling.value='';this.style.display='none';});}}}}
function callAjax(opts){return new Promise(function(resolve,reject){let xrq=new XMLHttpRequest();xrq.open(opts.method?opts.method:'POST',opts.url,true);xrq.timeout=20000;xrq.onload=function(){if(this.status>=200&&this.status<300){resolve(xrq.response);}else{reject({status:this.status,statusText:xrq.statusText});}};xrq.onerror=function(){reject({status:this.status,statusText:xrq.statusText});};if(opts.headers){Object.keys(opts.headers).forEach(function(key){xrq.setRequestHeader(key,opts.headers[key]);});}else{xrq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');}
xrq.responseType=(typeof(opts.dataType)!=='undefined')?opts.dataType:'json';var params=opts.data;if(params&&typeof params==='object'){var searchParams=new URLSearchParams();for(const[key,value]of Object.entries(params)){if(typeof value==='object'){for(const[key1,value1]of Object.entries(value)){searchParams.append(`${key}[${key1}]`,value1);}
for(let i=0;i<value.length;i++){searchParams.append(`${key}[]`,value[i]);}}else{searchParams.append(key,value);}}
params=searchParams.toString();}
xrq.send(params);});};var prCookie=document.querySelector('#close-cc-bar');if(prCookie!==null){prCookie.addEventListener('click',function(){setCookie('concookie',1,365);},false);}
function setCookie(cname,cvalue,exdays){callAjax({url:'/../data.php?action=setCookie'}).then(function(response){document.querySelector('#cookie-statement').style.display='none';});};var toTop=document.querySelector('#toTop');if(toTop!==null){toTop.addEventListener('click',function(){scrollToTop();});};function scrollToTop(){var position=document.body.scrollTop||document.documentElement.scrollTop;if(position){window.scrollBy(0,-Math.max(1,Math.floor(position/10)));scrollAnimation=setTimeout("scrollToTop()",10);}else clearTimeout(scrollAnimation);};var insertCookie=function(name,value,days){let expires;if(days){let date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString();}else{expires="";}
document.cookie=encodeURIComponent(name)+"="+encodeURIComponent(value)+expires+"; path=/";};var getCookie=function(name){let nameEQ=encodeURIComponent(name)+"=",ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){let c=ca[i];while(c.charAt(0)===' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)===0)return decodeURIComponent(c.substring(nameEQ.length,c.length));}
return false;};var deleteCookie=function(name){insertCookie(name,"",-1);};let lazyImages=[].slice.call(document.querySelectorAll("img.lazy"));let active=false;const lazyLoad=function(){if(active===false){active=true;setTimeout(function(){lazyImages.forEach(function(lazyImage){if((lazyImage.getBoundingClientRect().left<=window.innerWidth&&lazyImage.getBoundingClientRect().top<=window.innerHeight&&lazyImage.getBoundingClientRect().bottom>=0)&&getComputedStyle(lazyImage).display!=="none"){lazyImage.src=lazyImage.dataset.src;lazyImage.classList.remove("lazy");if(lazyImage.dataset.ga!==undefined){ga('send','event',lazyImage.dataset.ga,'viewport','');}
lazyImages=lazyImages.filter(function(image){return image!==lazyImage;});if(lazyImages.length===0){document.removeEventListener("scroll",lazyLoad);window.removeEventListener("resize",lazyLoad);window.removeEventListener("orientationchange",lazyLoad);}}});active=false;},200);}};lazyLoad();document.addEventListener("scroll",lazyLoad);window.addEventListener("resize",lazyLoad);window.addEventListener("orientationchange",lazyLoad);var scate=document.getElementById('scate');if(scate){scate.addEventListener('scroll',lazyLoad,false)}
var hscroll=document.querySelector('[data-tool="block_ajax_presents"] [data-role="list"]');if(hscroll){hscroll.addEventListener('scroll',lazyLoad,false)}
var cosi=document.querySelector('.coSi');if(cosi){cosi.addEventListener('scroll',lazyLoad,false)}
var lnks=document.querySelectorAll('[data-role="lnk"]');for(i=0;i<lnks.length;i++){lnks[i].addEventListener('click',lnkOpen,false);}
function lnkOpen(){var ldi=this.dataset.display!=undefined?this.dataset.display:false;var lsu=this.dataset.sub!=undefined?this.dataset.sub:false;var ldo=this.dataset.domain!=undefined?this.dataset.domain:false;var lht=this.dataset.http!=undefined?this.dataset.http:false;var lta=this.dataset.target!=undefined?this.dataset.target:false;var lca=this.dataset.can!=undefined?this.dataset.can:false;var lco=this.dataset.lco!=undefined?this.dataset.lco:false;var out=this.dataset.out!=undefined?this.dataset.out:false;var sam=this.dataset.sam!=undefined?this.dataset.sam:false;if(out){window.open(out,'_blank');}else if(sam){location=sam;}else{if(lca){location=document.querySelector('link[rel="canonical"]').getAttribute("href")+(document.querySelector('link[rel="canonical"]').getAttribute("href").indexOf('?')!==-1?'&':'?')+"c="+lca;}else if(lco){location=document.querySelector('link[rel="canonical"]').getAttribute("href")+(document.querySelector('link[rel="canonical"]').getAttribute("href").indexOf('?')!==-1?'&':'?')+lco;}else{if(lta){window.open((lht?'http:':location.protocol)+"//"+(lsu?lsu+'.':'')+(ldo?ldo:domain)+(ldi?'/'+ldi:''),'_blank');}else{location=(lht?'http:':location.protocol)+"//"+(lsu?lsu+'.':'')+(ldo?ldo:domain)+(ldi?'/'+ldi:'');}}}}
const lkns=document.querySelectorAll('.lkn');for(i=0;i<lkns.length;i++){lkns[i].addEventListener('click',lknOpen,false);}
function lknOpen(){const classes=this.classList;const iterator=classes.values();for(const value of iterator){if(value!='lkn'){switch(value){case'mailto':location='mailto:gradbg@gmail.com';break;case'icb-fb':location=http+'facebook.com/'+this.dataset.display;break;case'icb-pint':location=http+'pinterest.com/'+this.dataset.display;break;case'icb-twi':location=http+'x.com/'+this.dataset.display;break;case'icb-ply':location=http+'youtube.com/'+this.dataset.display;break;case'icb-rss':location=http+domain+'/rss_all';break;case'measures':location=http+'gotvach.bg/faq?id=114#114';break;case'measuresrs':location=http+'bonapeti.rs/faq?id=115#115';break;case'privacy':[7,11,18,20,23,24,26,29,56].includes(etis)?location=http+domain+'/'+value:window.open(http+'gradbg.com/'+value,'_blank');break;default:location=http+domain+'/'+value;break;}}}}
var nsrchlnk=document.querySelectorAll('[data-role="nsrchlnk"]');for(i=0;i<nsrchlnk.length;i++){nsrchlnk[i].addEventListener('click',nsrchlnkOpen,false);}
function nsrchlnkOpen(){var ldi=this.dataset.display!=undefined?this.dataset.display:false;var lmo=this.dataset.more!=undefined?this.dataset.more:false;var lni=this.dataset.nid!=undefined?this.dataset.nid:false;var lur=this.dataset.url!=undefined?this.dataset.url:false;location=location.protocol+"//"+lur+'?text='+ldi.replace(/\s/g,'_')+(lmo?'&more='+lmo:'')+(lni?'&nid='+lni:'');}
var urlswitch=document.querySelectorAll('[data-role="urlswitch"]');for(i=0;i<urlswitch.length;i++){urlswitch[i].addEventListener('click',function(e){e.preventDefault();location=this.getAttribute('href').replace(this.dataset.torepl,this.dataset.repl);});}
var urlswitch=document.querySelectorAll('#ursw a');for(i=0;i<urlswitch.length;i++){urlswitch[i].addEventListener('click',function(e){e.preventDefault();const searchParams=new URLSearchParams(this.getAttribute('href'));if(searchParams.has('dr')&&searchParams.has('dtr')){let dr=searchParams.get('dr');let dtr=searchParams.get('dtr');location=this.getAttribute('href').replace(dr,dtr).replace('&dr='+dr,'').replace('&dtr='+dtr,'');}else{location=this.getAttribute('href').replace(this.dataset.torepl,this.dataset.repl);}});}
window.attachEvent||window.addEventListener(window.attachEvent?'onmessage':'message',function(e){let msgData=parseJson(e.data);if(e.origin===http+domain&&msgData&&typeof msgData=='object'&&msgData.user==true){getUserData(msgData);}});getUserData=function(arr){callAjax({url:'/../data.php?action=getUser',data:new URLSearchParams(arr).toString()}).then(function(response){if(response.user){top.location.href=top.location.href;}else{alert(response.text);}});};parseJson=function(code){try{return JSON.parse(code);}catch(e){return false;}}
logout=function(){window.open(http+'grad.bg/files/lib/content/misc/login.php?action=logout','Logout');callAjax({url:'/data.php?action=doLogout&user='+user}).then(function(response){window.location.reload();});};var btn=document.querySelector('#ratingButton');if(btn!==null){var box=document.querySelector('#ratingBox'),step=parseInt(btn.dataset.step),stepspace=parseInt(btn.dataset.stepspace),classes=["s0","s1","s2","s3","s4","s5"],tempClasses=["c0","c1","c2","c3","c4","c5"],status=false,curls='';btn.addEventListener('mousemove',function(e){this.classList.remove(...tempClasses);this.classList.add("c"+Math.ceil(e.offsetX/(step+stepspace)));});btn.addEventListener('mouseout',function(){this.classList.remove(...tempClasses);});btn.addEventListener('click',function(e){if(parseInt(uid)){status=true;}
if(!status&&typeof rating_free!="undefined"){status=true;curls='_free';}
let mBox=document.createElement("div");mBox.class='message';if(status){callAjax({url:"/../data.php?action=rating"+curls+"&id="+id+"&contenttype="+contenttype+"&rsite_id="+rsite_id+"&rsub_id="+rsub_id+"&rating="+Math.ceil(e.offsetX/(step+stepspace))}).then(function(response){mBox.innerHTML='<div class="message">'+response.message+'</div>';btn.replaceWith(mBox);});}else{mBox.innerHTML='<div class="message"><a href="'+loginurl+'" target="_blank" style="text-decoration:underline">'+tr.only_for_registered_users+'</a></div>';btn.replaceWith(mBox);this.classList.remove(...tempClasses);}});};var rbtn=document.querySelector('#rtnBtn');if(rbtn!==null){var box=document.querySelector('#ratingBox'),step=parseInt(rbtn.dataset.step),stepspace=parseInt(rbtn.dataset.stepspace),classes=["s0","s1","s2","s3","s4","s5","s6"],status=false,curls='';rbtn.addEventListener('mousemove',function(e){this.classList.remove(...classes);this.classList.add("s"+Math.ceil(e.offsetX/(step+stepspace)));this.style.setProperty('--rtbwidth',Math.ceil(e.offsetX/(step+stepspace))*20+'%');});rbtn.addEventListener('mouseout',function(){this.classList.remove(...classes);this.classList.add("s0");});rbtn.addEventListener('click',function(e){if(parseInt(uid)){status=true;}
if(status=='false'&&typeof rating_free!="undefined"){status=true;curls='_free';}
let mBox=document.createElement("div");mBox.classList.add('message');if(status){callAjax({url:"/../data.php?action=rating"+curls+"&id="+id+"&contenttype="+contenttype+"&rsite_id="+rsite_id+"&rsub_id="+rsub_id+"&rating="+Math.ceil(e.offsetX/(step+stepspace))}).then(function(response){mBox.innerHTML=response.message;rbtn.replaceWith(mBox);});}else{mBox.innerHTML='<a href="'+loginurl+'" target="_blank" style="text-decoration:underline">'+tr.only_for_registered_users+'</a>';rbtn.replaceWith(mBox);this.classList.remove(...classes);}});};var fv=document.querySelector('.fv');if(fv!==null){fv.addEventListener('click',function(){if(parseInt(uid)){callAjax({url:'/data.php',data:{action:"addFavourites",title:encodeURIComponent(document.querySelector('meta[property="og:title"]').getAttribute('content')),url:encodeURIComponent(document.location),site_id:etis,img:document.querySelector('meta[property="og:image"]').getAttribute("content"),comment:"",contenttype:(typeof(contenttype)!='undefined'?contenttype:0),id:id,fromuid:fromuid}}).then(function(response){var l=loginurl.replace("login",document.querySelector('#msg_favlink').value);var n=document.querySelector('#msg_insert').value.replace("##",'<a target="_blank" href="'+l+'">').replace("#","</a>");document.querySelector('p.mymsg').innerHTML=n;document.querySelector('p.mymsg').classList.add("m");});}else{document.querySelector('p.mymsg').innerHTML=fv.querySelector("#msg_reg").value.replace("##",'<a target="_blank" href="'+loginurl+'">').replace("#","</a>");document.querySelector('p.mymsg').classList.add("m");}});};var fvn=document.querySelector('.fvn');if(fvn!==null){var stopFvn=false;fvn.addEventListener('click',function(){if(!stopFvn){stopFvn=true;var h1s=document.getElementsByTagName("h1"),h1title='';if(h1s!==null){for(var i=0;i<h1s.length;i++){if(h1s[i].innerHTML.length){h1title=h1s[i].innerHTML;}}}
callAjax({url:'/data.php?action=handleFavouriteSoc',dataType:'text',data:{title:(h1title.length?h1title:encodeURIComponent(document.querySelector('meta[property="og:title"]').getAttribute('content'))),url:encodeURIComponent(document.location),site_id:etis,img:document.querySelector('meta[property="og:image"]')!=null?document.querySelector('meta[property="og:image"]').getAttribute("content"):'',comment:"",contenttype:(typeof(contenttype)!='undefined'?contenttype:0),id:id,fromuid:fromuid}}).then(function(response){openModal(response,false);stopFvn=false;});}});};if(device==1&&typeof(contenttype)!='undefined'&&contenttype>0&&typeof(id)!='undefined'&&id>0&&!mobile){callAjax({url:'/data.php?action=makePopular&pagetype='+pagetype+"&contenttype="+contenttype+"&etis="+etis+"&domain="+domain+"&nid="+(typeof(cusid)!='undefined'?cusid:id)+"&type="+type+"&ref="+((typeof(ref)!='undefined')?ref:'')+(typeof blocking!='undefined'?'&adbw='+blocking:'')});};var ifb=document.querySelectorAll('.ifb');if(ifb!==null){let i;for(i=0;i<ifb.length;i++){ifb[i].addEventListener('click',function(){window.open("https://www.facebook.com/sharer.php?u="+encodeURIComponent(location.href)+"&t="+encodeURIComponent(document.title),"sharer","width=700,height=350,toolbar=0,status=0");return false});}};var itweet=document.querySelectorAll('.itweet');if(itweet!==null){let i;for(i=0;i<itweet.length;i++){itweet[i].addEventListener('click',function(){window.open("http://twitter.com/intent/tweet?text="+document.querySelector("meta[property='og:title']").getAttribute("content").replace("|","-")+"&url="+encodeURIComponent(location.href),"Tweeter","width=700,height=450,toolbar=0,status=0");return false});}};var ipin=document.querySelectorAll('.ipin');if(ipin!==null){let i;for(i=0;i<ipin.length;i++){ipin[i].addEventListener('click',function(){window.open('//www.pinterest.com/pin/create/button/?url='+window.location.href+'&media='+document.querySelector('meta[property="og:image"]').getAttribute('content')+'&description='+document.querySelector('meta[property="og:description"]').getAttribute('content'),'Pinterest','width=800,height=400,scrollbars=yes');});}};var icopy=document.querySelector('.icopy');if(icopy!==null){icopy.addEventListener('click',function(){let aux=document.createElement("input");aux.setAttribute("value",window.location.href);document.body.appendChild(aux);aux.select();document.execCommand("copy");document.body.removeChild(aux);icopy.classList.add('done');setTimeout(function(){icopy.classList.remove('done')},3000);});}
openModal=function(list,close=true){if(list.length){let p=document.createElement('div');p.id='modalBox';p.innerHTML='<div class="modalpad">'+'<div class="modalcontent'+(close?'':' slim')+'" data-role="modalcontent">'+
(close?'<div class="modalclose"><img width="16" height="16" src="data:image/svg+xml;base64,PHN2ZyBpZD0iQ2FwYV8xIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA0MTMuMzQ4IDQxMy4zNDgiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgNDEzLjM0OCA0MTMuMzQ4IiB3aWR0aD0iNTEyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Im00MTMuMzQ4IDI0LjM1NC0yNC4zNTQtMjQuMzU0LTE4Mi4zMiAxODIuMzItMTgyLjMyLTE4Mi4zMi0yNC4zNTQgMjQuMzU0IDE4Mi4zMiAxODIuMzItMTgyLjMyIDE4Mi4zMiAyNC4zNTQgMjQuMzU0IDE4Mi4zMi0xODIuMzIgMTgyLjMyIDE4Mi4zMiAyNC4zNTQtMjQuMzU0LTE4Mi4zMi0xODIuMzJ6Ii8+PC9zdmc+" alt=""/></div>':'')+''+list+'</div></div>';document.body.appendChild(p);let modbox=document.getElementById('modalBox');modbox.addEventListener('click',function(e){let target=e.target;if(target.classList.contains('modalpad')||target.closest('.modalclose')!==null||target.closest('[data-action="cancel"]')!==null){modbox.remove();}
if(target.closest('[data-action="reload"]')!==null){location.reload();}});document.addEventListener('keydown',function(event){const key=event.key;if(document.getElementById('modalBox')!==null&&key==="Escape"){document.getElementById('modalBox').remove();}});return modbox;}};closeModal=function(){let modal=document.getElementById('modalBox');if(modal!=null){modal.remove();}};var smilies=document.querySelector('#smilies');if(smilies!==null){smilies.addEventListener('click',function(e){if(e.target.nodeName=='IMG'){Smilies.setBBCode('fld_text',e.target.getAttribute('src'));}});};var bbcode=document.querySelector('#controls');if(bbcode!==null){bbcode.addEventListener('click',function(e){if(e.target.nodeName=='INPUT'){BBCode.setBBCode('fld_text',e.target.getAttribute('id'));}});};window.onerror=function(msg,url,lineNo,columnNo,error){let msgStr=msg,substring="Script error.";if((typeof msgStr==='string'||msgStr instanceof String)&&msgStr.indexOf(substring)>-1){}else{var message=['Message: '+msg,'Link: '+window.location.href,'URL: '+typeof url!='undefined'?url:'No Url','Line: '+lineNo,'Column: '+columnNo,'Error object: '+JSON.stringify(error)].join(' - ');if(typeof url!='undefined'&&url.indexOf('.js')>=0){callAjax({url:'/data.php?action=logJs',data:{log:message}});}}
return false;};function slideShop(boxId,height){const element=document.getElementById(boxId);const visibleThreshold=100;let assignajax={};if(typeof assignajax!=='undefined'){assignajax.height=parseInt(height);assignajax.sort=assignajax.nums?assignajax.nums.shift():undefined;assignajax.box=boxId;}else{assignajax={height:parseInt(height),nums:[1,2,3,4,5,6,7,8,9],sort:[1,2,3,4,5,6,7,8,9].sort(()=>Math.random()-0.5).shift(),box:boxId,title:document.querySelector('h1')?document.querySelector('h1').innerHTML:''};}
const lazyLoadBox=function(){callAjax({url:'/data.php?action=getSlideShop',data:assignajax,dataType:'text'}).then(function(response){element.innerHTML=response;lazyImages=[].slice.call(document.querySelectorAll("img.lazy"));const parnt=element.querySelector('.list');if(parnt){parnt.parentElement.addEventListener('scroll',lazyLoad,false);}});};const observer=new IntersectionObserver((entries,observer)=>{entries.forEach(entry=>{if(entry.isIntersecting||entry.intersectionRatio>0){lazyLoadBox();observer.unobserve(element);}});},{root:null,rootMargin:'0px',threshold:0.1});observer.observe(element);}
var mailimg=document.querySelectorAll('.mailimg');if(mailimg!==null){let i;for(i=0;i<mailimg.length;i++){mailimg[i].addEventListener('click',function(e){e.preventDefault();activateMail(this.getAttribute("id"));});}};function runClever(id,nm){var a,c=document.createElement("script"),f=window.frameElement;c.id=id;c.src="https://scripts.cleverwebserver.com/"+nm+".js";c.async=!0;c.type="text/javascript";c.setAttribute("data-target",window.name||(f&&f.getAttribute("id")));c.setAttribute("data-callback","put-your-callback-macro-here");try{a=parent.document.getElementsByTagName("script")[0]||document.getElementsByTagName("script")[0];}catch(e){a=!1;}
a||(a=document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]);a.parentNode.insertBefore(c,a);}
function activateMail(e){var t=e.split("_");var n=document.querySelector("#"+e+" img").getAttribute("src").indexOf("tick.png")>=0?0:1;callAjax({url:'/data.php?action='+action+'&id='+t[1]+'&v='+n,method:'GET'}).then(function(response){if(response.Result){var n=response.Data==1?"tick":"cancel";document.querySelector("#"+e+" img").setAttribute("src","/files/icons/"+n+".png")}});};function isLSon(){try{var test='test';localStorage.setItem(test,test);localStorage.removeItem(test);return true;}catch(e){return false;}}
if(lid==1&&uid==0){document.addEventListener('copy',function(event){var selectedText=window.getSelection().toString();var modifiedText=selectedText.replace(/а/g,'a').replace(/о/g,'o').replace(/е/g,'e').replace(/с/g,'c').replace(/р/g,'p');event.clipboardData.setData('text/plain',modifiedText);event.preventDefault();});}
var HeadNav=function(){this.open=false;this.elements=document.querySelectorAll('[data-role="head-controller"] [data-box="drop"]');this.search=document.querySelector('[data-role="head-controller"] [data-role="search"]');this.init();};HeadNav.prototype.init=function(){document.addEventListener("click",(e)=>{let target=e.target,element=target.closest('[data-box="drop"]');if(element===null){if(this.open){let i;for(i=0;i<this.elements.length;i++){let matches=this.elements[i].querySelector('[data-box="box"]');matches.style.display="none";}
this.open=false;}}else{let attr=element.getAttribute('data-role'),elementBox=element.querySelector('[data-box="box"]');if(this.open){let sibling=element.parentNode.firstChild;while(sibling){if(sibling.nodeName==='DIV'&&sibling!==element){sibling.querySelector('[data-box="box"]').style.display='none';}
sibling=sibling.nextSibling;}}
if(elementBox.innerHTML.length){if(target.closest('[data-box="icon"]')!==null){let show=((window.getComputedStyle?getComputedStyle(elementBox,null):elementBox.currentStyle).display=='none')?'block':'none';elementBox.style.display=show;if(show=='none'){this.open=false;}else{this.open=true;}}}else{callAjax({url:'/data.php?action=getHeader'+attr,dataType:'text'}).then(function(response){elementBox.innerHTML=response;elementBox.style.display='block';if(attr=='notifications'){let setSeen=elementBox.querySelector('[data-role="set_seen"]');if(setSeen!==null){elementBox.querySelector('[data-role="set_seen"]').addEventListener("click",function(e){let notids=this.dataset.id;callAjax({url:'/data.php?action=setSeenNotifications',data:{'ids':notids}}).then(function(response){let activity=elementBox.previousSibling.querySelector('.activity');let notids_count=notids.toString().split(",").length;if(parseInt(activity.innerHTML)>notids_count){activity.innerHTML(parseInt(activity.innerHTML)-notids_count);}else{activity.remove();}
elementBox.innerHTML='';elementBox.style.display='none';});e.preventDefault();});}}
if(attr=='search'){HeadNav.search.querySelector('form').addEventListener('submit',HeadNav.formSubmited);}});this.open=true;}}});if(this.search!=null){this.search.addEventListener('submit',this.formSubmited);}
var images=document.querySelectorAll('#newsGal img');if(images.length){let i;for(i=0;i<images.length;i++){images[i].addEventListener('contextmenu',function(e){e.preventDefault();});}}};HeadNav.prototype.formSubmited=function(evt){evt.preventDefault();var searchText=HeadNav.search.querySelector('#userSearchText').value.trim(),searchType=HeadNav.search.querySelector('#userSearchType').value.trim(),url='';switch(parseInt(searchType)){case 1:url=http+domain+'/recepti/?kw='+searchText;break;case 2:url=http+domain+'/nsearch?text='+searchText;break;}
if(searchText.length){window.location=url;}};var HeadNav=new HeadNav();var VerticalMenu=function(){this.open=false;this.button=document.querySelector('[data-role="verticalmenubtn"]');this.menu=document.querySelector('[data-role="verticalmenu"]');};VerticalMenu.prototype.init=function(){if(this.button!=null){this.button.addEventListener('click',this.getMenu);}};VerticalMenu.prototype.getMenu=function(){if(VerticalMenu.menu.innerHTML.length){let show=((window.getComputedStyle?getComputedStyle(VerticalMenu.menu,null):VerticalMenu.menu.currentStyle).display=='none')?'block':'none';VerticalMenu.menu.style.display=show;if(show=='none'){VerticalMenu.open=false;}else{VerticalMenu.open=true;}}else{callAjax({url:'/data.php?action=getVerticalMenu',dataType:'text'}).then(function(response){VerticalMenu.menu.innerHTML=response;VerticalMenu.menu.style.display='block';VerticalMenu.menu.addEventListener('click',VerticalMenu.closeMenu);});VerticalMenu.open=true;}};VerticalMenu.prototype.closeMenu=function(e){if(e.target.closest('[data-role]').dataset.role!==null){switch(e.target.closest('[data-role]').dataset.role){case'verticalmenuclose':VerticalMenu.menu.style.display='none';VerticalMenu.open=false;break;case'togglesubmenu':let li=e.target.closest('li');li.classList.toggle("pselected");let sibling=li.parentNode.firstChild;while(sibling){if(sibling.nodeType===1&&sibling!==e.target.closest('li')){sibling.classList.remove("pselected");}
let selected=sibling.querySelector('.selected');if(selected!==null){selected.classList.remove("selected");}
sibling=sibling.nextSibling;}
break;case'togglesubsubmenu':let subli=e.target.closest('li');subli.classList.toggle("selected");let subsibling=subli.parentNode.firstChild;while(subsibling){if(subsibling.nodeType===1&&subsibling!==e.target.closest('li')){subsibling.classList.remove("selected");}
subsibling=subsibling.nextSibling;}
break;}}};var VerticalMenu=new VerticalMenu();VerticalMenu.init();function RecipeEntity(){this.cookedBtn=document.querySelectorAll('#cookedBox [data-role="cook"]');this.cookedBtn2=document.querySelectorAll('[data-role="cook2"]');this.ref=document.querySelectorAll('[data-ref]');this.galleryUpload=document.querySelector('#recipeGallery [data-role="add_image"]');this.galleryForm=document.getElementById('uploadImageForm');this.galleryFile=document.getElementById('uploadImageFile');this.youtube=document.getElementById('ytp');this.prep=document.querySelectorAll('#rE .prep p');this.init();};RecipeEntity.prototype.init=function(){if(this.cookedBtn!==null){for(let i=0;i<this.cookedBtn.length;i++){this.cookedBtn[i].addEventListener('click',function(){RecipeEntity.cook(this);});}}
if(this.cookedBtn2!==null){for(let i=0;i<this.cookedBtn2.length;i++){this.cookedBtn2[i].addEventListener('click',function(){RecipeEntity.cook(this);});}}
if(this.galleryUpload!==null){this.galleryUpload.addEventListener('click',function(){if(uid){RecipeEntity.galleryFile.click();}else{RecipeEntity.alert(tr.only_reg_users);}});}
if(this.prep!==null){for(let i=0;i<this.prep.length;i++){this.prep[i].addEventListener('click',function(){this.classList.toggle('chk');});}}
if(this.galleryFile!==null){this.galleryFile.addEventListener('change',function(){RecipeEntity.alertPreloader();let formData=new FormData();for(var i=0;i<this.files.length;i++){formData.append('pic[]',this.files[i]);}
var xhr=new XMLHttpRequest();xhr.open('POST',RecipeEntity.galleryForm.getAttribute('action'),true);xhr.onload=function(){document.querySelector('#popupAlert').remove();if(xhr.status==200){if(xhr.response.status){RecipeEntity.alertWithRefresh(tr.photo_done_upload);}else{RecipeEntity.alert(xhr.response.message);}}else{}};xhr.responseType='json';xhr.send(formData);});}
if(this.youtube!==null){this.youtube.addEventListener('click',function(){var tag=document.createElement('script');tag.src="https://www.youtube.com/player_api";var firstScriptTag=document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);var ytuid=this.dataset.ytp;var player;function onYouTubeIframeAPIReady(){YT.ready(function(){player=new YT.Player('ytp',{height:RecipeEntity.youtube.offsetHeight,width:RecipeEntity.youtube.offsetWidth,videoId:ytuid,playerVars:{'autoplay':1},events:{'onReady':onPlayerReady}});});}
function onPlayerReady(event){event.target.playVideo();}
tag.onload=function(){onYouTubeIframeAPIReady();}});}
if(this.ref!==null){for(let i=0;i<this.ref.length;i++){this.ref[i].addEventListener('click',function(e){e.preventDefault();var parts=this.getAttribute('href').split('/r-');if(this.dataset.ref=='pages'){window.location=http+domain+'/r-'+parts[1];}else{window.location=http+this.dataset.ref+'.'+domain+'/r-'+parts[1];}});}}};RecipeEntity.prototype.cook=function(button){if((typeof button.dataset.cookstatus)!=='undefined'){if(!parseInt(button.dataset.cookstatus)){let h1=document.querySelector('h1');var arr={'uid':uid,'rid':id,'title':h1!==null?h1.innerHTML:''};callAjax({url:'/data.php?action=cookRecipe',data:arr}).then(function(response){if(response.status){RecipeEntity.alertWithRefresh(response.message);}else{RecipeEntity.alert(response.message);}});}else{RecipeEntity.alert(tr.already_cooked_recipe);}}else{RecipeEntity.alert(tr.only_reg_users);}};RecipeEntity.prototype.alertWithRefresh=function(msg){let p=document.createElement('div');p.id='popupAlert';p.innerHTML='<div class="wrapper"><div id="alertBox" class="content">'+msg+'<div><input type="button" class="obtn" value="Ок"/></div></div></div>';document.body.appendChild(p);document.querySelector('#popupAlert .obtn').addEventListener('click',function(e){location.reload(true);});};RecipeEntity.prototype.alert=function(msg){let p=document.createElement('div');p.id='popupAlert';p.innerHTML='<div class="wrapper"><div id="alertBox" class="content">'+msg+'<div><input type="button" class="obtn" value="Ок"/></div></div></div>';document.body.appendChild(p);document.querySelector('#popupAlert .obtn').addEventListener('click',function(e){document.querySelector('#popupAlert').remove();});};RecipeEntity.prototype.alertPreloader=function(){let p=document.createElement('div');p.id='popupAlert';p.innerHTML='<div class="wrapper"><div id="alertPreloader" class="content"><img class="preloader" src="'+http+domain+'/files/lib/preloader.gif"></div></div>';document.body.appendChild(p);};var RecipeEntity=new RecipeEntity();if(typeof callAjax!=="function"){function callAjax(opts){return new Promise(function(resolve,reject){let xrq=new XMLHttpRequest();xrq.open(opts.method?opts.method:'POST',opts.url,true);xrq.timeout=20000;xrq.onload=function(){if(this.status>=200&&this.status<300){resolve(xrq.response);}else{reject({status:this.status,statusText:xrq.statusText});}};xrq.onerror=function(){reject({status:this.status,statusText:xrq.statusText});};if(opts.headers){Object.keys(opts.headers).forEach(function(key){xrq.setRequestHeader(key,opts.headers[key]);});}else{xrq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');}
xrq.responseType=(typeof(opts.dataType)!=='undefined')?opts.dataType:'json';var params=opts.data;if(params&&typeof params==='object'){var searchParams=new URLSearchParams();for(const[key,value]of Object.entries(params)){if(typeof value==='object'){for(let i=0;i<value.length;i++){searchParams.append(`${key}[]`,value[i]);}}else{searchParams.append(key,value);}}
params=searchParams.toString();}
xrq.send(params);});};};function LocStor(){this.box=document.getElementById('favloc');this.favbox=this.box.querySelector('[data-role="favbox"]');this.fav=this.favbox.querySelector('[data-role="fav"]');this.favlist=this.favbox.querySelector('[data-role="list"]');this.social=this.box.querySelector('[data-role="social"]');this.totop=this.box.querySelector('[data-role="totop"]');this.search=this.box.querySelector('[data-role="search"]');this.srchbox=this.box.querySelector('[data-role="srchbox"]');this.type=this.box.dataset.type;this.counter=0;this.page=0;this.stop=false;this.stopFvn=false;this.init();};LocStor.prototype.init=function(){this.initScroll();this.initFavbox();this.initSrch();this.initSrchbox();};LocStor.prototype.initScroll=function(){let scrollVis=window.scrollY>=100?true:false;if(window.scrollY>=100){this.totop.style.display='block';}
document.addEventListener('scroll',function(e){if(scrollVis){if(window.scrollY<100){LocStor.totop.style.display='none';scrollVis=false;}}else{if(window.scrollY>=100){LocStor.totop.style.display='block';scrollVis=true;}}});this.totop.addEventListener('click',function(e){LocStor.scrollToTop();});};LocStor.prototype.scrollToTop=function(){var position=document.body.scrollTop||document.documentElement.scrollTop;if(position){window.scrollBy(0,-Math.max(1,Math.floor(position/10)));scrollAnimation=setTimeout("LocStor.scrollToTop()",10);}else clearTimeout(scrollAnimation);};LocStor.prototype.initFavbox=function(){if(this.fav!==null){this.fav.addEventListener('click',function(e){if(!LocStor.stopFvn){LocStor.stopFvn=true;var h1s=document.getElementsByTagName("h1"),h1title='';if(h1s!==null){for(var i=0;i<h1s.length;i++){if(h1s[i].innerHTML.length){h1title=h1s[i].innerHTML;}}}
callAjax({url:'/data.php?action=handleFavouriteSocNew',dataType:'text',data:{title:(h1title.length?h1title:encodeURIComponent(document.querySelector('meta[property="og:title"]').getAttribute('content'))),url:encodeURIComponent(document.location),site_id:etis,img:document.querySelector('meta[property="og:image"]')!=null?document.querySelector('meta[property="og:image"]').getAttribute("content"):'',comment:"",contenttype:(typeof(contenttype)!='undefined'?contenttype:0),id:(typeof(cusid)!='undefined'?cusid:id),fromuid:fromuid,count:1}}).then(function(response){LocStor.favlist.innerHTML=response;LocStor.stopFvn=false;});requestAnimationFrame(()=>new Bubble());}});}
if(this.favlist!==null){this.favlist.addEventListener('click',function(e){LocStor.page=0;LocStor.stop=false;LocStor.srchbox.dataset.kind='fav';LocStor.srchbox.innerHTML='';LocStor.getFavourites();});}};LocStor.prototype.getFavourites=function(inc){if(!LocStor.stop){if(inc!==undefined){LocStor.page++;}
LocStor.stop=true;let preload=LocStor.createPreloader();LocStor.srchbox.appendChild(preload);let arr={'title':LocStor.srchbox.querySelector('[data-role="title"]')!==null?LocStor.srchbox.querySelector('[data-role="title"]').value:'','page':LocStor.page};callAjax({url:'/data.php?action=favouriteBox',dataType:'text',data:arr}).then(function(response){if(response.length){LocStor.stop=false;preload.remove();if(!LocStor.page){document.body.style.overflow='hidden';LocStor.srchbox.classList.add('close');LocStor.srchbox.innerHTML=response;}else{LocStor.srchbox.querySelector('.list').innerHTML+=response;}}else{preload.remove();}});}};LocStor.prototype.createPreloader=function(){let preload=document.createElement("img");preload.width=160;preload.height=20;preload.src=http+domain+'/files/lib/preloader.gif';preload.classList.add("preloader");return preload;};LocStor.prototype.getLastVisited=function(){LocStor.srchbox.innerHTML='';LocStor.srchbox.dataset.kind='last';LocStor.srchbox.appendChild(LocStor.createPreloader());callAjax({url:'/data.php?action=favouriteLastVisited',dataType:'text'}).then(function(response){LocStor.srchbox.innerHTML=response;document.body.style.overflow='hidden';LocStor.srchbox.classList.add('close');});};LocStor.prototype.initSrch=function(){if(this.search!==null){this.search.addEventListener('click',function(e){LocStor.getLastVisited();});}};LocStor.prototype.initSrchbox=function(){this.srchbox.addEventListener('click',function(e){let target=e.target;if(target.closest('[data-role="close"]')!==null){LocStor.srchbox.classList.remove('close');document.body.style.overflow='auto';}
if(target.closest('[data-role="submit"]')!==null){LocStor.page=0;LocStor.getFavourites();}
if(target.closest('[data-role="delete"]')!==null){let arr={'favid':target.dataset.fid};callAjax({url:'/data.php?action=favouriteDelete',data:arr}).then(function(response){if(response.status){LocStor.srchbox.querySelector('[data-fid="'+arr.favid+'"]').parentNode.remove();}});}});this.srchbox.addEventListener('keyup',function(e){let target=e.target;if(target.closest('[data-role="title"]')!==null){if(e.keyCode===13){LocStor.page=0;LocStor.getFavourites();}}});this.srchbox.addEventListener('scroll',function(){if(LocStor.srchbox.dataset.kind=='fav'){let boxList=LocStor.srchbox.querySelector('.list');if(device==1){let choosen=boxList.childNodes[boxList.childNodes.length-1];if((choosen.getBoundingClientRect().left<=window.innerWidth&&(choosen.getBoundingClientRect().top+(choosen.offsetHeight/2))<=window.innerHeight&&choosen.getBoundingClientRect().bottom>=0)&&getComputedStyle(choosen).display!=="none"){LocStor.getFavourites(true);}}
if(device==3){let choosen=boxList.childNodes[boxList.childNodes.length-3];if((choosen.getBoundingClientRect().left<=window.innerWidth&&choosen.getBoundingClientRect().top<=window.innerHeight&&choosen.getBoundingClientRect().bottom>=0)&&getComputedStyle(choosen).display!=="none"){LocStor.getFavourites(true);}}
let closeBtn=LocStor.box.querySelector('.boxClose');let boxLst=LocStor.box.querySelector('.boxList').getBoundingClientRect();if(boxLst.top>0){closeBtn.classList.remove('stop');}else{closeBtn.classList.add('stop');}}});};var LocStor=new LocStor();const root=document.querySelector('[data-role="favbox"] [data-role="hearts"]');let{innerHeight,innerWidth}=window;if(innerHeight<300){innerHeight=350;}
if(innerWidth<300){innerWidth=750;}
class Bubble{constructor(){this.bubbleSpan=undefined;this.posX=12;this.posY=35;this.handleNewBubble();this.height=20;this.width=20;}
handleNewBubble(){this.bubbleSpan=document.createElement("span");this.bubbleSpan.classList.add("fic");this.bubbleSpan.classList.add("ic-favr");this.bubbleSpan.style.opacity=1;this.bubbleSpan.style.position=`absolute`;this.bubbleSpan.style.transition=`transform 0.3s linear`;this.bubbleSpan.style.transform=`translate3d(${this.posX}px,${this.posY}px,0)`;root.append(this.bubbleSpan);this.handlePosition();}
handlePosition(){const randomY=this.randomNumber(60,-60);const randomX=this.randomNumber(60,-60);this.bubbleSpan.style.backgroundColor=this.color;this.bubbleSpan.style.height=this.height+"px";this.bubbleSpan.style.width=this.height+"px";let randomNum=this.randomNumber(10,1);if(randomNum<7&&this.posX>-200){this.posX=this.posX-10;}else if(this.posX<0){this.posX=this.posX+10;}
this.posY=this.posY-15;this.bubbleSpan.style.transform=`translate3d(${this.posX}px,${this.posY}px,0)`;if(this.posY>-700){if(this.posY<-200){this.bubbleSpan.style.opacity=this.bubbleSpan.style.opacity-0.05;}
const randomSec=this.randomNumber(200,30);setTimeout(this.handlePosition.bind(this),80);}else{this.bubbleSpan.remove();}}
randomNumber(max,min){return Math.floor(Math.random()*(max-min+1)+min);}
randomColor(){return`rgba(${this.randomNumber(0,255)},${this.randomNumber(0,255)},${this.randomNumber(0,255)},${this.randomNumber(0.1,1)})`;}
bubbleEnd(removingTime=0){this.remove();}}