var mirrorUpgrade2018=0;var sentProductID=0;var firstProduct=0;var ex=virtooaldetectIE();if (ex==1) { throw new Error('IE is not supported by virtual mirror.');}
if (virtooalMirrorSettings['userName']==550) {
virtooalMirrorSettings['maxContentWidth']=1150;virtooalMirrorSettings['color']='ec7403';virtooalMirrorSettings['title']='Brillen Online Anprobe';virtooalMirrorSettings['titleLeft']='Brillen';virtooalMirrorSettings['titleRight']='Anprobe';virtooalMirrorSettings['model']='26';virtooalMirrorSettings['modelMale']='30';virtooalMirrorSettings['fullscreenWidth']=0;virtooalMirrorSettings['browse']=false;virtooalMirrorSettings['state']='minimized';document.getElementById("virtooal-mirror-title").innerHTML = "";}
if (virtooalMirrorSettings['userName']==871) {
virtooalMirrorSettings['model']='26';virtooalMirrorSettings['modelMale']='30';}
if (virtooalMirrorSettings['userName']==937) {
if (virtooalMirrorSettings['model']=='14') {
virtooalMirrorSettings['model']='13';}
}
if (virtooalMirrorSettings['userName']=='alza') {
virtooalMirrorSettings['fullscreenWidth']=1;virtooalMirrorSettings['demo']='no';virtooalMirrorSettings['hideIfNoProduct']='yes';virtooalMirrorSettings['color']="cf141e";virtooalMirrorSettings['color2']="cf141e";virtooalMirrorSettings['mirrorWidth']=333;virtooalMirrorSettings['model']='13';mirrorUpgrade2018=1;}
if (virtooalMirrorSettings['title']=='')
{virtooalMirrorSettings['title']='Virtual Try On';}
if (virtooalMirrorSettings['titleLeft']=='')
{virtooalMirrorSettings['titleLeft']='Virtual';}
if (virtooalMirrorSettings['titleRight']=='')
{virtooalMirrorSettings['titleRight']='Try On';};var virtooal_disableBtn=0;var uploadToFull=0;var virtooalSite='https://mirror.virtooal.com';virtooalAddCss(virtooalSite+"/assets/css/crossmirror.css.php?v=11&u="+virtooalMirrorSettings['userName']+"&c="+virtooalMirrorSettings['color']);var virtooalMirrorState=0;var virtooalMirrorStateLastOpened=0;var refreshBtnStarted=0;var virtooalSessionId=readCookieVirtooal('virtooal_session_id');var virtooalSessionId2=readCookieVirtooal('virtooal_session_id2');var appendVirtooalSessionId="";if (typeof virtooalSessionId2 !== "undefined") {
appendVirtooalSessionId="&sessionid="+virtooalSessionId2;}
if (typeof virtooalSessionId !== "undefined" && virtooalSessionId != null ) {
appendVirtooalSessionId="&sessionid="+virtooalSessionId;eraseCookieVirtooal('virtooal_session_id2');}
if (typeof virtooalMirrorSettings['sessionid'] !== "undefined") {
appendVirtooalSessionId="&sessionid="+virtooalMirrorSettings['sessionid'];}
if (appendVirtooalSessionId=='&sessionid=null' || !appendVirtooalSessionId) {
var sesId = new Uint32Array(1);window.crypto.getRandomValues(sesId);createCookieVirtooal('virtooal_session_id2',sesId,1);appendVirtooalSessionId="&sessionid="+sesId;};var virtooalMainTitle='';if (typeof virtooalMirrorSettings['title'] !== "undefined") {
virtooalMainTitle='
'+virtooalMirrorSettings['title']+'
';};var demostore='';if (virtooalMirrorSettings['demo'] == "yes") {
demostore='&demostore=1';}
if (typeof virtooalMirrorSettings['model'] !== "undefined") {
}else {
virtooalMirrorSettings['model']=14;}
if (typeof virtooalMirrorSettings['modelMale'] !== "undefined") {
}else {
virtooalMirrorSettings['mmodelMale']=18;}
if (typeof virtooalMirrorSettings['countryCode'] !== "undefined") {
}else {
virtooalMirrorSettings['countryCode']='';}
if (typeof virtooalMirrorSettings['currencyCode'] !== "undefined") {
}else {
virtooalMirrorSettings['currencyCode']='';};var virtooalButtons = document.createElement('div');virtooalButtons.style.width="100%";virtooalButtons.innerHTML=''+virtooalMirrorSettings['titleLeft']+'
'+virtooalMirrorSettings['titleRight']+'
';document.getElementById("virtooal-mirror-title").appendChild(virtooalButtons);var newWidth=virtooalMirrorSettings['mirrorWidth']-2;var pomer=258/355;if (mirrorUpgrade2018==1) {
pomer=333/578;};var globalPomer=pomer;var newHeight=newWidth/pomer;var iframe = document.createElement('iframe');iframe.setAttribute("src", virtooalSite+"/app/"+virtooalMirrorSettings['apiKey']+"/"+virtooalMirrorSettings['userName']+"?c="+virtooalMirrorSettings['color']+"&c2="+virtooalMirrorSettings['color2']+"&l="+virtooalMirrorSettings['lang']+"&cross=1&model="+virtooalMirrorSettings['model']+"&modelMale="+virtooalMirrorSettings['modelMale']+"&browse="+virtooalMirrorSettings['browse']+"&country="+virtooalMirrorSettings['countryCode']+"¤cy="+virtooalMirrorSettings['currencyCode']+demostore+appendVirtooalSessionId);iframe.setAttribute("id", "virtooal-mirror");iframe.setAttribute("width", "100%");iframe.setAttribute("height", newHeight);iframe.setAttribute("scrolling", "no");iframe.setAttribute("frameborder", "0");iframe.setAttribute("hspace", "0");iframe.setAttribute("vspace", "0");iframe.setAttribute("marginheight", "0");iframe.setAttribute("marginwidth", "0");iframe.setAttribute("allow", "camera");document.getElementById("virtooal-mirror-fix-iframe").appendChild(iframe);var virtooalObj = document.getElementById('virtooal-mirror-fix-container');virtooalObj.style.width=virtooalMirrorSettings['mirrorWidth']+"px";var virtooalObjTitle = document.getElementById('virtooal-mirror-title');virtooalObjTitle.style.backgroundColor="#ffffff";virtooalObjTitle.style.color="#"+virtooalMirrorSettings['color'];if (virtooalMirrorSettings['hideIfNoProduct']=='yes') {
virtooalObj.style.visibility="hidden";};var virtooalStateId=readCookieVirtooal('virtooal_mirror_state');var virtooalStarted=readCookieVirtooal('virtooal_mirror_started');var virtooalStartedAlza=readCookieVirtooal('virtooal_mirror_started_alza');if (virtooalMirrorSettings['state']=='minimized' && virtooalStarted!=1) {
virtooalStateId =1;}
if (virtooalMirrorSettings['userName']=='alza') {}else {
virtooalStateId =1;}
setMirrorPositions(virtooalMirrorSettings,virtooalStateId);document.getElementById('virtooal-mirror').onload = function() {
var frameVirtooal = document.getElementById('virtooal-mirror');virtooalRefreshBtns();var virtooalModalBtn = document.getElementById("virtooal-modal-open");virtooalModalBtn.addEventListener("click",function(e){
createCookieVirtooal('virtooal_mirror_started',1,1);eraseCookieVirtooal('virtooal_mirror_state');var obj = document.getElementById('virtooal-mirror-fix-container');obj.classList.remove("virtooal-main-modal-minimized");var virtooalFrame = document.getElementById("virtooal-mirror-fix-container");virtooalFrame.classList.toggle("virtooal-main-modal");if ( virtooalFrame.getAttribute('class') === 'virtooal-main-modal') {
virtooalMirrorStateLastOpened=virtooalMirrorState=3;virtooalSpecialModalClose();}else {
virtooalMirrorStateLastOpened=virtooalMirrorState=2;};var virtooalFrameHidden = document.getElementById("virtooal-mirror-fix-iframe");if ( virtooalFrameHidden.getAttribute('class') === 'virtooal-main-iframe-hidden' ) {
virtooalFrameHidden.classList.toggle("virtooal-main-iframe-hidden");};var virtooalFrame = document.getElementById("virtooal-mirror-fix-content");virtooalFrame.classList.toggle("virtooal-main-modal-content");var virtooalFrame = document.getElementById("virtooal-modal-open");virtooalFrame.classList.toggle("virtooal-collapse");if (virtooalMirrorState==3) {
setTimeout(function(){
setMirrorHeight();}, 100);}
});var virtooalCloseBtn = document.getElementById("virtooal-modal-close");virtooalCloseBtn.addEventListener("click",function(e){
if (window.innerWidth<768) {
createCookieVirtooal('virtooal_mirror_started',1,1);createCookieVirtooal('virtooal_mirror_state',0,1);var obj = document.getElementById('virtooal-mirror-fix-container');obj.style.display="none";obj.classList.add("virtooal-main-modal-closed");obj.classList.remove("virtooal-main-modal-minimized");virtooalMirrorState=0;console.log(virtooalMirrorStateLastOpened);}else {
document.getElementById('virtooal-modal-minimize').click();}
});var virtooalMinimizeBtn = document.getElementById("virtooal-modal-minimize");var minimizedFirstClick=0;if (virtooalMirrorSettings['userName']==550) {
virtooalStarted=1;virtooalMirrorStateLastOpened=2;minimizedFirstClick=3;}
virtooalMinimizeBtn.addEventListener("click",function(e){
createCookieVirtooal('virtooal_mirror_started',1,1);var virtooalFrame = document.getElementById("virtooal-mirror-fix-iframe");virtooalFrame.classList.toggle("virtooal-main-iframe-hidden");var obj = document.getElementById('virtooal-mirror-fix-container');obj.classList.add("virtooal-main-modal-minimized");if ( virtooalFrame.getAttribute('class') === 'virtooal-main-iframe-hidden' ) {
createCookieVirtooal('virtooal_mirror_state',1,1);if (virtooalMirrorStateLastOpened==3) {
var vM = document.getElementById("virtooal-mirror-fix-container");vM.classList.toggle("virtooal-main-modal");var vM = document.getElementById("virtooal-mirror-fix-content");vM .classList.toggle("virtooal-main-modal-content");var vM = document.getElementById("virtooal-modal-open");vM .classList.toggle("virtooal-collapse");}
virtooalMirrorStateLastOpened=virtooalMirrorState;virtooalMirrorState=1;}else {
obj.classList.remove("virtooal-main-modal-minimized");eraseCookieVirtooal('virtooal_mirror_state');if (virtooalMirrorStateLastOpened>0) {
if (virtooalMirrorStateLastOpened==3) {
var vM = document.getElementById("virtooal-mirror-fix-container");vM.classList.toggle("virtooal-main-modal");var vM = document.getElementById("virtooal-mirror-fix-content");vM .classList.toggle("virtooal-main-modal-content");var vM = document.getElementById("virtooal-modal-open");vM .classList.toggle("virtooal-collapse");}
virtooalMirrorState=virtooalMirrorStateLastOpened;}
}
});window.addEventListener('message', virtooalReceiveMessage);}
window.addEventListener('resize', function(event){
setMirrorPositions(virtooalMirrorSettings);var element = document.getElementById("virtooal-mirror-fix-content");if ( element.getAttribute('class') === 'virtooal-main-modal-content' ) {
setMirrorHeight();}
});function virtooalReceiveMessage(e) {
if (e.origin !== virtooalSite)
return;if ((e.data instanceof Object) || (e.data instanceof Array) ) {
var virtooalWidgets = document.querySelectorAll('.virtooal-widget');var virtooalWidget='';if (virtooalWidgets[0]) virtooalWidget = virtooalWidgets[0];if (virtooal_disableBtn==1 && e.data!='WrongId' ) {
var virtooalbtn = document.querySelectorAll('.virtooal-tryon-btn');for (var i = 0;i < virtooalbtn.length;i++) {
virtooalbtn[i].style.display = 'none';}
if (virtooalWidget) virtooalWidget.style.display='none';}
if (virtooalMirrorSettings['hideIfNoProduct']=='yes') {
virtooalObj.style.visibility="hidden";}
for (var j = 0;j < e.data.length;j++){
var a = document.querySelectorAll('[data-virtooal_id="'+e.data[j].item_id+'"]');for (var i in a) if (a.hasOwnProperty(i)) {
a[i].setAttribute('data-virtooal_idr', e.data[j].id);a[i].setAttribute('data-virtooal_cat', e.data[j].category);a[i].setAttribute('data-virtooal_sex', e.data[j].sex);a[i].setAttribute('data-virtooal_model', virtooalMirrorSettings['model']);a[i].setAttribute('data-virtooal_modelMale', virtooalMirrorSettings['modelMale']);if (a[i].classList.contains("virtooal-woocommerce")) {
a[i].style.display = '';}else {
a[i].style.display = 'block';if (virtooalMirrorSettings['userName']=='1142') {
var btnC= document.getElementById('virtooal-TryOn-idIn');if (btnC) {btnC.click();}
}
}
if (virtooalWidget) virtooalWidget.style.display='block';if (virtooalMirrorSettings['userName']=='alza' && virtooalStartedAlza!=1) {
createCookieVirtooal('virtooal_mirror_started_alza',1,1);}else {
virtooalObj.style.visibility="visible";}
}
}
}else {
if (e.data==-99) {
if (virtooalMirrorState!=3) {
uploadToFull=1;document.getElementById("virtooal-modal-open").click();}
}
if (e.data==-98) {
document.getElementById("virtooal-modal-close").click();}
if (e.data==-919) {
if (virtooalMirrorState==3 && uploadToFull==1) {
uploadToFull=0;document.getElementById("virtooal-modal-open").click();}
}else if (e.data==-899) {
if(document.getElementById("gallery-widget") && virtooalMirrorSettings['userName']=='alza' && firstProduct!=0){
(function(document, tag) {
var scriptTag = document.createElement(tag),
firstScriptTag = document.getElementsByTagName(tag)[0];scriptTag.src = '//widget.virtooal.com/magicmirror.php?uname=alza&apikey=WsUaYeEQX6ohO3Gm&lang='+virtooalMirrorSettings['lang']+'&pid='+firstProduct+'&sessionid='+virtooalMirrorSettings['sessionid'];firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag);}(document, 'script'));}
}else if (e.data==-199) {
var virtooalSessionIdX=readCookieVirtooal('virtooal_session_id');var virtooalSessionId2X=readCookieVirtooal('virtooal_session_id2');if ((typeof virtooalSessionIdX == "undefined" || virtooalSessionIdX == null) && (typeof virtooalSessionId2X !== "undefined" || virtooalSessionId2X != null)) {
createCookieVirtooal('virtooal_session_id',virtooalSessionId2X,1);eraseCookieVirtooal('virtooal_session_id2');}
}else {
try{
if (e.data.indexOf("alza_") !== -1) {
var alzaID = e.data.replace('alza_','');orderByCode(alzaID);}
}
catch (err) {
}
}
}
}
function setMirrorPositions(virtooalMirrorSettings,stateId) {
var obj = document.getElementById('virtooal-mirror-fix-container');var obj1 = document.getElementById('virtooal-modal-minimize');var obj2 = document.getElementById('virtooal-modal-open');var side=virtooalMirrorSettings['side'];var xpos=5;var screenWidth=window.innerWidth;var liveCheck=(screenWidth-virtooalMirrorSettings['maxContentWidth'])/2-(obj.offsetWidth+virtooalMirrorSettings['marginFromContent']);if (virtooalMirrorSettings['maxContentWidth']>0 && liveCheck>0) {
xpos=liveCheck;}
if (virtooalMirrorSettings['side']=='right') {
obj.style.right=xpos+"px";}else {
obj.style.left=xpos+"px";}
if (screenWidth<768) {
obj.style.display="none";virtooalMirrorState=0;if (screenWidth<450) {
obj1.style.display=obj2.style.display="none";}
virtooalMirrorState=0;virtooalMirrorStateLastOpened=3;}else if (stateId==0) {
obj.style.display="none";virtooalMirrorState=0;obj1.style.display=obj2.style.display="inline-block";virtooalMirrorState=0;}else {
obj.style.display="block";virtooalMirrorState=0;obj1.style.display=obj2.style.display="inline-block";virtooalMirrorState=2;if (stateId==1) {
virtooalMirrorState=1;var virtooalFrame = document.getElementById("virtooal-mirror-fix-iframe");obj.classList.add("virtooal-main-modal-minimized");virtooalFrame.classList.toggle("virtooal-main-iframe-hidden");}
}
}
function setMirrorHeight() {
var screenHeight=window.innerHeight;var screenWidth=window.innerWidth;var virtooalFrame = document.getElementById("virtooal-mirror-fix-content");var resizeElement=document.getElementsByClassName("virtooal-main-modal-content");if(screenHeight<870) {
var pomer =virtooalFrame.offsetHeight/virtooalFrame.offsetWidth;console.log(pomer);if (virtooalMirrorSettings['fullscreenWidth']===1)
{
if (screenWidth>1130) {
pomer=0.675;}else if (screenWidth>890) {
pomer=0.675;}else {
pomer=virtooalFrame.offsetHeight/virtooalFrame.offsetWidth;}
resizeElement[0].style.maxWidth=((screenHeight-50)/pomer)+"px";}else {
resizeElement[0].style.maxWidth=((screenHeight-100)*globalPomer)+"px";console.log((globalPomer));}
}else {
if (virtooalMirrorSettings['fullscreenWidth']===1)
{
resizeElement[0].style.maxWidth="1200px";}else {
resizeElement[0].style.maxWidth="600px";}
console.log(virtooalFrame.offsetHeight+' - '+screenHeight);}
}
function readCookieVirtooal(name) {
var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {
var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}
return null;}
function createCookieVirtooal(name,value,days) {
if (days) {
var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = ";expires="+date.toGMTString();}else var expires = "";if (window.location.protocol == 'https:') {
document.cookie = name+"="+value+expires+";path=/;secure;";}else {
document.cookie = name+"="+value+expires+";path=/;";}
}
function eraseCookieVirtooal(name) {
createCookieVirtooal(name,"",-1);}
function virtooalAddCss(fileName) {
var head = document.head
, link = document.createElement('link')
link.type = 'text/css'
link.rel = 'stylesheet'
link.href = fileName
head.appendChild(link)
}
function virtooalSpecialModalClose(){
var virtooalFrame = document.getElementById("virtooal-mirror-fix-container");if ( virtooalFrame.getAttribute('class') === 'virtooal-main-modal' ) {
document.onkeydown = function(evt) {
evt = evt || window.event;if (evt.keyCode == 27) {
document.getElementById("virtooal-modal-close").click();}
};virtooalFrame.addEventListener('click', function (e) {
if (e.target === e.currentTarget) {
document.getElementById("virtooal-modal-close").click();}
});}
}
function virtooaldetectIE() {
var ua = window.navigator.userAgent;var msie = ua.indexOf('MSIE ');var trident = ua.indexOf('Trident/');var edge = ua.indexOf('Edge/');if (msie > 0) {
return 1;}else if (trident > 0) {
return 1;}else if (edge > 0) {
return 0;}else
return 0;}
function virtooalRefreshBtns(reverse) {
if (reverse==1) virtooal_disableBtn=1;var receiver = document.getElementById('virtooal-mirror').contentWindow;var virtooalIds=new Array();var virtooalbtn = document.querySelectorAll('.virtooal-tryon-btn');for (var i = 0;i < virtooalbtn.length;i++) {
var virtooadataIdCheck = virtooalbtn[i].getAttribute('data-virtooal_id');virtooalIds.push(virtooadataIdCheck);if (i==0) {
firstProduct=virtooadataIdCheck;}
virtooalbtn[i].addEventListener('click', function (event) {
event.preventDefault();virtooalObj.style.visibility="visible";var screenWidth=window.innerWidth;for (var iI = 0;iI < virtooalbtn.length;iI++) {
virtooalbtn[iI].classList.remove('active');}
this.classList.add('active');if (virtooalMirrorState==0 || virtooalMirrorState==1 || virtooalMirrorState==2) {
eraseCookieVirtooal('virtooal_mirror_state');var obj = document.getElementById('virtooal-mirror-fix-container');obj.style.display="block";obj.classList.remove("virtooal-main-modal-closed");obj.classList.remove("virtooal-main-modal-minimized");virtooalMirrorState=0;var virtooalFrame = document.getElementById("virtooal-mirror-fix-iframe");if ( virtooalFrame.getAttribute('class') === 'virtooal-main-iframe-hidden' ) {
virtooalFrame.classList.toggle("virtooal-main-iframe-hidden");}
if (screenWidth<768 || virtooalMirrorStateLastOpened==3) {
var virtooalFrame = document.getElementById("virtooal-mirror-fix-container");if ( virtooalFrame.getAttribute('class') === 'virtooal-main-modal' ) {
}else {
virtooalFrame.classList.toggle("virtooal-main-modal");virtooalMirrorStateLastOpened=virtooalMirrorState=3;var virtooalFrame = document.getElementById("virtooal-mirror-fix-content");virtooalFrame.classList.toggle("virtooal-main-modal-content");var virtooalFrame = document.getElementById("virtooal-modal-open");virtooalFrame.classList.toggle("virtooal-collapse");if (virtooalMirrorState==3) {
setTimeout(function(){
setMirrorHeight();}, 100);}
}
}
};var virtooadataId = this.getAttribute('data-virtooal_idr');var virtooadataUpload = this.getAttribute('data-virtooal_upload');var virtooadataCat = this.getAttribute('data-virtooal_cat');var virtooadataSex = this.getAttribute('data-virtooal_sex');var virtooadataModel = this.getAttribute('data-virtooal_model');var virtooadataModelMale = this.getAttribute('data-virtooal_modelMale');var pass_data = {
'id':virtooadataId,
'upload':virtooadataUpload,
'category':virtooadataCat,
'sex':virtooadataSex,
'model':virtooadataModel,
'modelMale':virtooadataModelMale
};if (virtooadataId!=sentProductID) {
receiver.postMessage(pass_data, virtooalSite);}
sentProductID=virtooadataId;setTimeout(function () {
sentProductID=0;}, 1000);});}
receiver.postMessage(virtooalIds, virtooalSite);}