/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.1                   # ||
|| # ----------------------------------------- # ||
|| # Copyright 2020 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/

function lcjak_supportWidget(data,origdomain){if(data.widgethtml){var lcj_container=document.getElementById('jaklcp-support-container');lcj_container.innerHTML=data.widgethtml}return true}function extractSupportDomain(url){var domain;if(url.indexOf("://")>-1){domain=url.split('/')[2]}else{domain=url.split('/')[0]}domain=domain.split(':')[0];return domain}function createCORSRequestSupport(method,url){var xhr=new XMLHttpRequest();xhr.withCredentials=true;if("withCredentials"in xhr){xhr.open(method,url,true)}else if(typeof XDomainRequest!="undefined"){xhr=new XDomainRequest();xhr.open(method,url)}else{xhr=null}return xhr}(function(w){supportloc=JSON.parse(JSON.stringify(w.lcjUrl));lcjaksupportid=w.id;var catid=0;if(w.catID!='')catid=w.catID;if(extractSupportDomain(w.lcjUrl)==window.location.hostname){var request=new XMLHttpRequest();request.open('GET',supportloc+'include/loadiframesupport.php?oid='+lcjaksupportid+'&catid='+catid);request.timeout=3000;request.onload=function(){if(request.status>=200&&request.status<400){var data=JSON.parse(request.responseText);if(data.status){lcjak_supportWidget(data,extractSupportDomain(w.lcjUrl));return true}else{console.log(data.error)}}else{}};request.onerror=function(){};request.ontimeout=function(e){};request.send()}else{var url=supportloc+'include/loadiframesupport_cross.php?oid='+lcjaksupportid+'&catid='+catid+'&crossurl='+window.location+'&callback=LiveChatJAK';var request=createCORSRequestSupport('GET',url);if(!request){console.log('CORS not supported');return}request.onload=function(){var data=JSON.parse(request.responseText);if(data.status){lcjak_supportWidget(data,extractSupportDomain(w.lcjUrl));return true}else{console.log(data.error)}};request.onerror=function(){console.log('Woops, there was an error making the request.')};request.send()}}(window));
