function SGPopup(config){var integrations=config.integrations;var popupName=config.popupName;var initialConfig=config;var prefix=config.prefix||'sgpb';var isInited=false;var mainDiv=null;var contentDiv=null;var DIV=null;var opened=false;var resizeTimeout=null;var overlayDiv=null;var defaultZIndex=config.contentBox.zIndex||9999;var defaultWidth="640px";var defaultHeight=config.autoHeight;var closeButtonImage=null;var popupId=config.id;var showOnce=config.showOnce||false;var events=config.events||[];var openDelay=config.openDelay||0;var popupTheme=config.popupTheme;var popupType=config.popupType;var fitBackgroundImg=null;var parentThis=this;var openAnimation=config.openAnimation||{type:"none",speed:0};var closeAnimation=config.closeAnimation||{type:"none",speed:0};var closeBehavior=config.closeBehavior||{allowed:true,showButton:true,buttonPosition:'topLeft',buttonInside:true,autoclose:false,overlayShouldClose:true,contentShouldClose:false,escShouldClose:true};var closeButton=config.closeButton||{data:sgpbPublicUrl+'img/close.png',width:16,height:16,widthType:'px',heightType:'px',closeButtonType:'IMG',closeButtonText:'Close'};var overlay=config.overlay||{visible:true,color:"#000",opacity:0.7};var contentBox=config.contentBox||{padding:8,showBackground:true,backgroundColor:"#fff",borderStyle:"solid",borderColor:"#ccc",borderRadius:config.contentBox.borderRadius,borderRadiusType:config.contentBox.borderRadiusType,borderWidth:1,shadowColor:"#ccc",shadowSpread:0,shadowBlur:10,scrollingEnabled:true,backgroundPosition:''};var contents=config.contents||"";var inline=config.inline||false;var href=config.href||false;var position=config.position||{left:"center",top:"center"};if((typeof position.left==="undefined"||(isNaN(parseInt(position.left))&&position.left!=="center"))&&(typeof position.right==="undefined"||(isNaN(parseInt(position.right))&&position.right!=="center"))){position.left="center";}
if((typeof position.top==="undefined"||(isNaN(parseInt(position.top))&&position.top!=="center"))&&(typeof position.bottom==="undefined"||(isNaN(parseInt(position.bottom))&&position.bottom!=="center"))){position.top="center";}
var sizingRanges=config.sizingRanges||[{screenFrom:{width:-1,height:-1},screenTo:{width:-1,height:-1},width:defaultWidth,height:defaultHeight,maxWidth:-1,maxHeight:-1,minWidth:-1,minHeight:-1}];var shouldOpen=config.shouldOpen||function(){return true;};var willOpen=config.willOpen||function(){};var didOpen=config.didOpen||function(){};var shouldClose=config.shouldClose||function(){return true;};var willClose=config.willClose||function(){};var didClose=config.didClose||function(){};SGPopup.inlinePrevTarget=SGPopup.inlinePrevTarget||{};function resetInlineContent(){if(inline){var htmlElement=document.getElementById(inline);if(SGPopup.inlinePrevTarget.hasPreviousElement){if(typeof SGPopup.inlinePrevTarget.parentNode!=='undefined'){SGPopup.inlinePrevTarget.parentNode.insertBefore(htmlElement,SGPopup.inlinePrevTarget.node.nextSibling);}}else{SGPopup.inlinePrevTarget.node.appendChild(htmlElement);}}}
var OPEN_ANIMATION_POP="@-webkit-keyframes popin{from{-webkit-transform:scale(.8);opacity:0}to{-webkit-transform:scale(1);opacity:1}}@-moz-keyframes popin{from{-moz-transform:scale(.8);opacity:0}to{-moz-transform:scale(1);opacity:1}}@keyframes popin{from{transform:scale(.8);opacity:0}to{transform:scale(1);opacity:1}}";var OPEN_ANIMATION_FADE="@-webkit-keyframes fadein{from{opacity:0}to{opacity:1}}@-moz-keyframes fadein{from{opacity:0}to{opacity:1}}@keyframes fadein{from{opacity:0}to{opacity:1}}";var OPEN_ANIMATION_FLIP="@-webkit-keyframes flipintoright{from{-webkit-transform:rotateY(90deg) scale(.9)}to{-webkit-transform:rotateY(0)}}@-moz-keyframes flipintoright{from{-moz-transform:rotateY(90deg) scale(.9)}to{-moz-transform:rotateY(0)}}@keyframes flipintoright{from{transform:rotateY(90deg) scale(.9)}to{transform:rotateY(0)}}";var OPEN_ANIMATION_SLIDELEFT="@-webkit-keyframes slideinfromright{from{-webkit-transform:translate3d({start},0,0)}to{-webkit-transform:translate3d(0,0,0)}}@-moz-keyframes slideinfromright{from{-moz-transform:translateX({start})}to{-moz-transform:translateX(0)}}@keyframes slideinfromright{from{transform:translateX({start})}to{transform:translateX(0)}}";var OPEN_ANIMATION_SLIDERIGHT="@-webkit-keyframes slideinfromleft{from{-webkit-transform:translate3d({start},0,0)}to{-webkit-transform:translate3d(0,0,0)}}@-moz-keyframes slideinfromleft{from{-moz-transform:translateX({start})}to{-moz-transform:translateX(0)}}@keyframes slideinfromleft{from{transform:translateX({start})}to{transform:translateX(0)}}";var OPEN_ANIMATION_FLOW="@-webkit-keyframes flowinfromright{0%{-webkit-transform:translateX(100%) scale(.7)}30%,40%{-webkit-transform:translateX(0) scale(.7)}100%{-webkit-transform:translateX(0) scale(1)}}@-moz-keyframes flowinfromright{0%{-moz-transform:translateX(100%) scale(.7)}30%,40%{-moz-transform:translateX(0) scale(.7)}100%{-moz-transform:translateX(0) scale(1)}}@keyframes flowinfromright{0%{transform:translateX(100%) scale(.7)}30%,40%{transform:translateX(0) scale(.7)}100%{transform:translateX(0) scale(1)}}";var OPEN_ANIMATION_SLIDEUP="@-webkit-keyframes slideinfrombottom{from{-webkit-transform:translateY({start})}to{-webkit-transform:translateY(0)}}@-moz-keyframes slideinfrombottom{from{-moz-transform:translateY({start})}to{-moz-transform:translateY(0)}}@keyframes slideinfrombottom{from{transform:translateY({start})}to{transform:translateY(0)}}";var OPEN_ANIMATION_SLIDEDOWN="@-webkit-keyframes slideinfromtop{from{-webkit-transform:translateY({start})}to{-webkit-transform:translateY(0)}}@-moz-keyframes slideinfromtop{from{-moz-transform:translateY({start})}to{-moz-transform:translateY(0)}}@keyframes slideinfromtop{from{transform:translateY({start})}to{transform:translateY(0)}}";var CLOSE_ANIMATION_SLIDELEFT="@-webkit-keyframes slideouttoleft{from{-webkit-transform:translate3d(0,0,0)}to{-webkit-transform:translate3d({end},0,0)}}@-moz-keyframes slideouttoleft{from{-moz-transform:translateX(0)}to{-moz-transform:translateX({end})}}@keyframes slideouttoleft{from{transform:translateX(0)}to{transform:translateX({end})}}";var CLOSE_ANIMATION_SLIDERIGHT="@-webkit-keyframes slideouttoright{from{-webkit-transform:translate3d(0,0,0)}to{-webkit-transform:translate3d({end},0,0)}}@-moz-keyframes slideouttoright{from{-moz-transform:translateX(0)}to{-moz-transform:translateX({end})}}@keyframes slideouttoright{from{transform:translateX(0)}to{transform:translateX({end})}}";var CLOSE_ANIMATION_POP="@-webkit-keyframes popout{from{-webkit-transform:scale(1);opacity:1}to{-webkit-transform:scale(.8);opacity:0}}@-moz-keyframes popout{from{-moz-transform:scale(1);opacity:1}to{-moz-transform:scale(.8);opacity:0}}@keyframes popout{from{transform:scale(1);opacity:1}to{transform:scale(.8);opacity:0}}";var CLOSE_ANIMATION_FADE="@-webkit-keyframes fadeout{from{opacity:1}to{opacity:0}}@-moz-keyframes fadeout{from{opacity:1}to{opacity:0}}@keyframes fadeout{from{opacity:1}to{opacity:0}}";var CLOSE_ANIMATION_FLIP="@-webkit-keyframes flipouttoright{from{-webkit-transform:rotateY(0)}to{-webkit-transform:rotateY(90deg) scale(.9)}}@-moz-keyframes flipouttoright{from{-moz-transform:rotateY(0)}to{-moz-transform:rotateY(90deg) scale(.9)}}@keyframes flipouttoright{from{transform:rotateY(0)}to{transform:rotateY(90deg) scale(.9)}}";var CLOSE_ANIMATION_FLOW="@-webkit-keyframes flowouttoright{0%{-webkit-transform:translateX(0) scale(1)}60%,70%{-webkit-transform:translateX(0) scale(.7)}100%{-webkit-transform:translateX(100%) scale(.7)}}@-moz-keyframes flowouttoright{0%{-moz-transform:translateX(0) scale(1)}60%,70%{-moz-transform:translateX(0) scale(.7)}100%{-moz-transform:translateX(100%) scale(.7)}}@keyframes flowouttoright{0%{transform:translateX(0) scale(1)}60%,70%{transform:translateX(0) scale(.7)}100%{transform:translateX(100%) scale(.7)}}";var CLOSE_ANIMATION_SLIDEUP="@-webkit-keyframes slideouttotop{from{-webkit-transform:translateY(0)}to{-webkit-transform:translateY({end})}}@-moz-keyframes slideouttotop{from{-moz-transform:translateY(0)}to{-moz-transform:translateY({end})}}@keyframes slideouttotop{from{transform:translateY(0)}to{transform:translateY({end})}}";var CLOSE_ANIMATION_SLIDEDOWN="@-webkit-keyframes slideouttobottom{from{-webkit-transform:translateY(0)}to{-webkit-transform:translateY({end})}}@-moz-keyframes slideouttobottom{from{-moz-transform:translateY(0)}to{-moz-transform:translateY({end})}}@keyframes slideouttobottom{from{transform:translateY(0)}to{transform:translateY({end})}}";function addAnimationClass(classString){var style=document.createElement('style');style.type='text/css';style.innerHTML=classString;style.id=prefix+"-effect-custom-style";document.getElementsByTagName('head')[0].appendChild(style);}
function setMainDivStyles(sizeConfig){jQuery(window).trigger('sgpbPopupBuilderAdditionalDimensionSettings');contentDiv.style.zIndex=defaultZIndex+10;mainDiv.style.boxSizing='content-box';if(sizeConfig.minHeight!=-1){var minHeight=sizeConfig.minHeight;var popupMinHeight=window.innerHeight;if(typeof minHeight==='string'&&minHeight.indexOf('%')!==-1){var popupMinhHeight=(popupMinhHeight/100)*parseInt(minHeight);mainDiv.style.minHeight=popupMinhHeight+'px';}else{mainDiv.style.minHeight=parseInt(minHeight)+'px';}}
if(sizeConfig.minWidth!=-1){var popupMinhWidth=window.innerWidth;var minWidth=sizeConfig.minWidth;if(typeof minWidth==='string'&&minWidth.indexOf('%')!==-1){popupMinhWidth=(popupMinhWidth/100)*parseInt(minWidth);mainDiv.style.minWidth=popupMinhWidth+'px';}else{mainDiv.style.minWidth=parseInt(minWidth)+'px';}}
if(sizeConfig.maxHeight!=-1&&sizeConfig.maxHeight){var maxHeight=sizeConfig.maxHeight;var popupMaxHeight=window.innerHeight;if(maxHeight.indexOf('%')!==-1){popupMaxHeight=(popupMaxHeight/100)*parseInt(maxHeight);this.calculatedMaxHeight=calculateMaxHeight(popupMaxHeight);mainDiv.style.maxHeight=this.calculatedMaxHeight;}else{this.calculatedMaxHeight=calculateMaxHeight(parseInt(maxHeight));mainDiv.style.maxHeight=this.calculatedMaxHeight;}}else{var popupMaxHeight=window.innerHeight;mainDiv.style.maxHeight=calculateMaxHeight(popupMaxHeight);}
if(sizeConfig.maxWidth!=-1&&sizeConfig.maxWidth){var maxWidth=sizeConfig.maxWidth;var popupMaxWidth=window.innerWidth;if(maxWidth.indexOf('%')!==-1){popupMaxWidth=(popupMaxWidth/100)*parseInt(maxWidth);this.calculatedMaxWidth=calculateMaxWidth(popupMaxWidth);mainDiv.style.maxWidth=this.calculatedMaxWidth;}else{this.calculatedMaxWidth=calculateMaxWidth(parseInt(maxWidth));mainDiv.style.maxWidth=this.calculatedMaxWidth;}}else{var popupMaxWidth=window.innerWidth;mainDiv.style.maxWidth=calculateMaxWidth(popupMaxWidth);}
if(contentBox.borderStyle){mainDiv.style.borderStyle=contentBox.borderStyle;}
if(contentBox.borderColor){mainDiv.style.borderColor=contentBox.borderColor;}
if(contentBox.borderRadius){var borderRadiusMeasure='%';if(contentBox.borderRadiusType){borderRadiusMeasure=contentBox.borderRadiusType;}
mainDiv.style.borderRadius=contentBox.borderRadius+borderRadiusMeasure;}
mainDiv.style.borderWidth=contentBox.borderWidth+"px";if(contentBox.padding){mainDiv.style.padding=contentBox.padding+"px";}
var widthToSet=sizeConfig.width||defaultWidth;if(widthToSet.indexOf("%")>-1){var widthNum=parseFloat(widthToSet);if(widthToSet.indexOf("fullScreen")>-1){widthNum=window.innerWidth;}
var closeButtonWidthToSubtract=parseInt(closeButton.width);if(closeBehavior.showButton===false||config.closeButton.type==='button'){closeButtonWidthToSubtract=0;}
widthToSet=(((widthNum/100)*window.innerWidth)-(2*(contentBox.padding?contentBox.padding:0))-parseFloat(mainDiv.style.borderLeftWidth)-parseFloat(mainDiv.style.borderRightWidth)-(parseFloat(contentBox.shadowSpread)/2)-closeButtonWidthToSubtract)+'px';}else{widthToSet=parseFloat(widthToSet)-2*(contentBox.padding?contentBox.padding:0)+'px';}
mainDiv.style.width=widthToSet;if(config.popupType==='image'){mainDiv.style.backgroundImage="url("+contentBox.backgroundImage+")";}
if(contentBox.showBackground){if(contentBox.backgroundImage){mainDiv.style.backgroundImage="url("+contentBox.backgroundImage+")";}
if(contentBox.backgroundMode==="cover"){mainDiv.style.backgroundSize="cover";mainDiv.style.backgroundRepeat="no-repeat";}
else if(contentBox.backgroundMode==="contain"){mainDiv.style.backgroundSize="contain";mainDiv.style.backgroundRepeat="no-repeat";}
else if(contentBox.backgroundMode==="repeat"){mainDiv.style.backgroundRepeat="repeat";}
else if(contentBox.backgroundMode==='fit'){if(!fitBackgroundImg){fitBackgroundImg=document.createElement('img');fitBackgroundImg.style.position='fixed';fitBackgroundImg.style.bottom='-9999999999999px';fitBackgroundImg.className='sgpb-background-image-'+config.popupId;document.body.appendChild(fitBackgroundImg);fitBackgroundImg.onload=function(){changePopupDimensionRelatedImage(this);};fitBackgroundImg.src=contentBox.backgroundImage;mainDiv.style.backgroundSize='100% 100%';mainDiv.style.backgroundRepeat='no-repeat';}}else{mainDiv.style.backgroundRepeat="no-repeat";}}
if(window.sgWindowOldWidth!==window.innerWidth||window.sgWindowOldHeight!==window.innerHeight){window.sgWindowOldWidth=window.innerWidth;window.sgWindowOldHeight=window.innerHeight;var images=document.getElementsByClassName('sgpb-background-image-'+config.popupId);if(images.length){changePopupDimensionRelatedImage(images[0]);}}
mainDiv.style.backgroundPosition=contentBox.backgroundPosition;var heightToSet=sizeConfig.height||defaultHeight;if(typeof heightToSet!=='undefined'&&heightToSet.indexOf("%")>-1){var heightNum=parseFloat(heightToSet);heightToSet=(((heightNum/100)*window.innerHeight)-(2*(contentBox.padding?contentBox.padding:0))-parseInt(mainDiv.style.borderTopWidth)-parseInt(mainDiv.style.borderBottomWidth))+"px";}else{heightToSet=parseInt(heightToSet)-2*(contentBox.padding?contentBox.padding:0)+"px";if(sizeConfig.width.indexOf("fullScreen")>-1){heightToSet=(window.innerHeight)+"px";}}
mainDiv.style.height=heightToSet;if(contentBox.showBackground&&contentBox.backgroundColor){mainDiv.style.backgroundColor=contentBox.backgroundColor;}
if(contentBox.shadowColor){mainDiv.style.boxShadow="0 0 "+contentBox.shadowBlur+"px "+contentBox.shadowSpread+"px "+contentBox.shadowColor;}
if(contentBox.scrollingEnabled){mainDiv.style.overflow="auto";}else{mainDiv.style.overflow="hidden";}}
function changePopupDimensionRelatedImage(image){var result=resizeConfig(image);var oldSizeConfig=getSizeConfig();oldSizeConfig.width=result.width+'px';oldSizeConfig.height=result.height+'px';oldSizeConfig.modified=true;this.sizeConfig=oldSizeConfig;windowResizeHandler();}
function resizeConfig(backgroundImage){var maxWidth=parseInt(this.calculatedMaxWidth);var maxHeight=parseInt(this.calculatedMaxHeight);var imageWidth=backgroundImage.width;var imageHeight=backgroundImage.height;var windowMaxHeight=parseInt(calculateMaxHeight(window.innerHeight));var windowMaxWidth=parseInt(calculateMaxWidth(window.innerWidth));if(isNaN(maxHeight)||maxHeight>windowMaxHeight){maxHeight=windowMaxHeight;}
if(isNaN(maxWidth)||maxWidth>windowMaxWidth){maxWidth=windowMaxWidth;}
var widthDifference=imageWidth-maxWidth;var heightDifference=imageHeight-maxHeight;if(heightDifference>widthDifference){if(imageHeight>maxHeight){var modifiedHeightPercent=100-(maxHeight/imageHeight)*100;var withMustDecrease=(imageWidth*modifiedHeightPercent)/100;var modifiedWidth=imageWidth-withMustDecrease;imageWidth=modifiedWidth;imageHeight=maxHeight;}}
else if(imageWidth>maxWidth){var modifiedWidthPercent=Math.floor((widthDifference/imageWidth)*100);var heightMustDecrease=Math.floor((imageHeight*modifiedWidthPercent)/100);var modifiedHeight=imageHeight-heightMustDecrease;imageWidth-=widthDifference;imageHeight-=heightMustDecrease;}
var result={width:imageWidth,height:imageHeight};return result;}
function calculateMaxWidth(maxWidth){var sizeConfig=getSizeConfig();var dimension=sizeConfig.width;var contentPadding=(contentBox.padding||0)*2;var shadowSpread=(contentBox.shadowSpread||0)*2;var borderWidth=(contentBox.borderWidth||0)*2;var boxBorderWidth=(contentBox.boxBorderWidth||0)*4;var closeButtonRight=(parseInt(closeBehavior.right)||0)*2;var closeButtonLeft=(parseInt(closeBehavior.left)||0)*2;if(dimension.indexOf('fullScreen')=='-1'){maxWidth-=contentPadding;maxWidth-=34;maxWidth-=shadowSpread;maxWidth-=borderWidth;maxWidth-=boxBorderWidth;}
if(!closeBehavior.buttonInside){if(closeButtonRight){maxWidth-=Math.abs(closeButtonRight);}
if(closeButtonLeft){maxWidth-=Math.abs(closeButtonLeft);}}
if(maxWidth<0){return'30px';}
return maxWidth+'px';}
function setFitBackground(){if(!fitBackgroundImg){return;}
var imgHeight=fitBackgroundImg.height;var imgWidth=fitBackgroundImg.width;var winHeight=window.innerHeight;var winWidth=window.innerWidth;var minMargin=40;var popupWidth=0,popupHeight=0;if(imgWidth<(winWidth-2*minMargin)&&imgHeight<(winHeight-2*minMargin)){popupWidth=imgWidth;popupHeight=imgHeight;}else{var widthDif=winWidth-imgWidth;var heightDif=winHeight-imgHeight;if(widthDif<heightDif){popupWidth=winWidth-2*minMargin;popupHeight=popupWidth*imgHeight/imgWidth;}else{popupHeight=winHeight-2*minMargin;popupWidth=popupHeight*imgWidth/imgHeight;}}
var sizeConfig=getSizeConfig();var maxWidth=sizeConfig.maxWidth;var maxHeight=sizeConfig.maxHeight;var border=contentBox.borderWidth||0;var padding=contentBox.padding||0;var shadow=contentBox.shadowSpread||0;popupWidth=parseInt(popupWidth-2);sizeConfig.height=popupHeight+'px';}
function calculateMaxHeight(maxHeight){var sizeConfig=getSizeConfig();var dimension=sizeConfig.width;var contentPadding=(contentBox.padding||0)*2;var shadowSpread=(contentBox.shadowSpread||0)*4;var borderHeight=(contentBox.borderWidth||0)*2;var boxBorderHeight=(contentBox.boxBorderWidth||0)*4;var closeButtonTop=(parseInt(closeBehavior.top)||0)*2;var closeButtonBottom=(parseInt(closeBehavior.bottom)||0)*2;if(dimension.indexOf('fullScreen')!='-1'){}else{maxHeight-=contentPadding;if(shadowSpread){maxHeight-=shadowSpread;maxHeight-=35;}
maxHeight-=borderHeight;maxHeight-=boxBorderHeight;if(!closeBehavior.buttonInside){if(closeButtonBottom){maxHeight-=Math.abs(closeButtonBottom);}
if(closeButtonTop){maxHeight-=Math.abs(closeButtonTop);}}}
if(maxHeight<0){return'30px';}
return maxHeight+'px';}
function positionPopup(){contentDiv.style.position="fixed";var border=contentBox.borderWidth||0;var padding=contentBox.padding||0;if(typeof position.left!=="undefined"&&(!isNaN(parseInt(position.left))||position.left==="center")){if(position.left==="center"){contentDiv.style.left=(window.innerWidth-parseInt(mainDiv.clientWidth)-2*border)/2+"px";}else{contentDiv.style.left=parseInt(position.left)+"px";}}else{if(position.right==="center"){contentDiv.style.left=(window.innerWidth-parseInt(mainDiv.clientWidth)-2*border)/2+"px";}else{contentDiv.style.left=(window.innerWidth-parseInt(position.right)-parseInt(mainDiv.clientWidth)-2*border)+"px";}}
if(typeof position.top!=="undefined"&&(!isNaN(parseInt(position.top))||position.top==="center")){if(position.top==="center"){contentDiv.style.top=(window.innerHeight-parseInt(mainDiv.clientHeight)-2*border)/2+"px";}else{contentDiv.style.top=position.top+"px";}}else{if(position.bottom==="center"){contentDiv.style.top=(window.innerHeight-parseInt(mainDiv.clientHeight)-2*border)/2+"px";}else{contentDiv.style.bottom=position.bottom+"px";}}}
function getSizeConfig(){var windowWidth=window.innerWidth;var windowHeight=window.innerHeight;var config=null;var candidates=[];for(var i=0;i<sizingRanges.length;i++){var tmpConf=sizingRanges[i];if((tmpConf.screenFrom.width===-1&&tmpConf.screenTo.width===-1)||(tmpConf.screenFrom.width===-1&&windowWidth<tmpConf.screenTo.width)||(tmpConf.screenTo.width===-1&&windowWidth>tmpConf.screenFrom.width)||(windowWidth<tmpConf.screenTo.width&&windowWidth>tmpConf.screenFrom.width)){candidates.push(tmpConf);}}
for(var i=0;i<candidates.length;i++){var tmpConf=candidates[i];if((tmpConf.screenFrom.height==-1&&tmpConf.screenTo.height==-1)||(tmpConf.screenFrom.height==-1&&windowHeight<tmpConf.screenTo.height)||(tmpConf.screenTo.height==-1&&windowHeight>tmpConf.screenFrom.height)||(windowHeight<tmpConf.screenTo.height&&windowHeight>tmpConf.screenFrom.height)){continue;}else{candidates.splice(i,1);i--;}}
config=candidates[0];if(!config){config={screenFrom:{width:-1,height:-1},screenTo:{width:-1,height:-1},width:"640px",height:defaultHeight,maxWidth:-1,maxHeight:-1,minWidth:-1,minHeight:-1}}
return config;}
function drawOverlay(){if(!overlay.visible){return;}
overlayDiv=document.createElement("DIV");overlayDiv.style.zIndex=defaultZIndex;overlayDiv.style.backgroundColor=overlay.color;overlayDiv.style.opacity=overlay.opacity/100;overlayDiv.style.position="fixed";overlayDiv.style.left="0";overlayDiv.style.top="0";overlayDiv.style.width="100%";overlayDiv.style.height="100%";if(overlay.addClass){overlayDiv.className=overlay.addClass;}
if(closeBehavior.overlayShouldClose){overlayDiv.onclick=closePopup;}
document.body.appendChild(overlayDiv);}
function removeOverlay(){if(overlayDiv){overlayDiv.style.display="none";document.body.removeChild(overlayDiv);overlayDiv=null;}}
function setCloseButton(mainDiv){if(!closeButton.data){return;}
if(closeBehavior.showButton===false){return;}
closeButtonImage.style.zIndex=defaultZIndex+20;closeButtonImage.style.position="absolute";closeButtonImage.style.float="left";closeButtonImage.style.top=closeBehavior.top;closeButtonImage.style.right=closeBehavior.right;closeButtonImage.style.bottom=closeBehavior.bottom;closeButtonImage.style.left=closeBehavior.left;closeButtonImage.alt=SGPB_JS_LOCALIZATION.closeButtonAltText;closeButtonImage.title=SGPB_JS_LOCALIZATION.closeButtonAltText;if(closeButton.type=='button'){closeButtonImage.id=prefix+'-close-button';closeButtonImage.innerHTML=config.closeButton.text;}
closeButtonImage.style.width=closeButton.width+closeButton.widthType;closeButtonImage.style.cursor="pointer";closeButtonImage.style.height=closeButton.height+closeButton.heightType;closeButtonImage.src=closeButton.data;closeButtonImage.style.backgroundRepeat="no-repeat";closeButtonImage.style.backgroundSize="cover";closeButtonImage.onclick=closePopup;positionCloseButton(mainDiv);}
function positionCloseButton(mainDiv){if(closeBehavior.buttonPosition=="left"){closeButtonImage.style.left=(closeButton.width/2+parseFloat(closeBehavior.leftPosition))+"px";}
else if(closeBehavior.buttonPosition=="right"){var border=contentBox.borderWidth||0;var left=0;var mainDivWidth=mainDiv.style.width;if(mainDiv.style.maxWidth&&parseInt(mainDivWidth)>parseInt(mainDiv.style.maxWidth)){mainDivWidth=mainDiv.style.maxWidth;}
left=parseFloat(mainDivWidth)-Math.ceil(closeButton.width/2)+2*contentBox.padding+2*border;if(closeBehavior.leftPosition){left-=parseFloat(closeBehavior.leftPosition);}
closeButtonImage.style.left=left+"px";}
closeButtonImage.style.top=parseFloat(closeBehavior.topPosition)+"px";}
function onWindowRsize(){clearTimeout(resizeTimeout);resizeTimeout=setTimeout(function(){resizeBox();positionPopup();positionCloseButton(mainDiv);jQuery(window).trigger('sgpbPopupReload')},0);}
function windowResizeHandler(){resizeBox();positionPopup();positionCloseButton(mainDiv);jQuery(window).trigger('sgpbPopupReload')}
function setOpenAnimation(){if(!openAnimation.status){return false;}
contentDiv.style.animationTimingFunction="linear";var border=contentBox.borderWidth||0;var padding=contentBox.padding||0;if(openAnimation.type=="slideleft"){var start=window.innerWidth-parseInt(contentDiv.style.left)+2*border;addAnimationClass(OPEN_ANIMATION_SLIDELEFT.replace(/\{start\}/g,start+"px"));contentDiv.style.animationName="slideinfromright";}
else if(openAnimation.type=="slideright"){var start=parseInt(mainDiv.style.width)+parseInt(contentDiv.style.left)+2*border+2*padding;addAnimationClass(OPEN_ANIMATION_SLIDERIGHT.replace(/\{start\}/g,"-"+start+"px"));contentDiv.style.animationName="slideinfromleft";}
else if(openAnimation.type=="pop"){addAnimationClass(OPEN_ANIMATION_POP);contentDiv.style.transform="scale(1)";contentDiv.style.animationName="popin";contentDiv.style.opacity="1";}
else if(openAnimation.type=="fade"){addAnimationClass(OPEN_ANIMATION_FADE);contentDiv.style.animationName="fadein";contentDiv.style.opacity="1";}
else if(openAnimation.type=="flip"){addAnimationClass(OPEN_ANIMATION_FLIP);contentDiv.style.animationName="flipintoright";contentDiv.style.transform="translateX(0)";}
else if(openAnimation.type=="turn"){addAnimationClass(OPEN_ANIMATION_FLIP);contentDiv.style.animationName="flipintoright";contentDiv.style.transform="translateX(0)";contentDiv.style.transformOrigin="0";}
else if(openAnimation.type=="flow"){addAnimationClass(OPEN_ANIMATION_FLOW);contentDiv.style.animationName="flowinfromright";contentDiv.style.transformOrigin="50% 30%";}
else if(openAnimation.type=="slideup"){var bottom=0;if(contentDiv.style.bottom){bottom=parseInt(mainDiv.style.height)+2*border+parseInt(contentDiv.style.bottom)+2*padding;}else{bottom=window.innerHeight-parseInt(contentDiv.style.top)+2*border;}
var start=bottom;addAnimationClass(OPEN_ANIMATION_SLIDEUP.replace(/\{start\}/g,start+"px"));contentDiv.style.animationName="slideinfrombottom";}
else if(openAnimation.type=="slidedown"){var top=0;if(contentDiv.style.top){top=parseInt(contentDiv.style.top)+2*border+2*padding;}else{top=window.innerHeight-parseInt(contentDiv.style.bottom)-parseInt(mainDiv.style.height);}
var start=top+parseInt(mainDiv.style.height);addAnimationClass(OPEN_ANIMATION_SLIDEDOWN.replace(/\{start\}/g,"-"+start+"px"));contentDiv.style.animationName="slideinfromtop";}else{contentDiv.className+=' sg-animated '+openAnimation.type;}
contentDiv.style.animationDuration=openAnimation.speed+"ms";}
function setCloseAnimation(){contentDiv.style.animationTimingFunction="linear";var border=contentBox.borderWidth||0;var padding=contentBox.padding||0;if(closeAnimation.type=="slideleft"){var end=parseInt(mainDiv.style.width)+parseInt(contentDiv.style.left)+2*border+2*padding;addAnimationClass(CLOSE_ANIMATION_SLIDELEFT.replace(/\{end\}/g,"-"+end+"px"));contentDiv.style.animationName="slideouttoleft";}
else if(closeAnimation.type=="slideright"){var end=window.innerWidth-parseInt(contentDiv.style.left)+2*border;addAnimationClass(CLOSE_ANIMATION_SLIDERIGHT.replace(/\{end\}/g,end+"px"));contentDiv.style.animationName="slideouttoright";}
else if(closeAnimation.type=="pop"){addAnimationClass(CLOSE_ANIMATION_POP);contentDiv.style.animationName="popout";contentDiv.style.transform="scale(0)";contentDiv.style.opacity="0";}
else if(closeAnimation.type=="fade"){addAnimationClass(CLOSE_ANIMATION_FADE);contentDiv.style.animationName="fadeout";contentDiv.style.opacity="0";}
else if(closeAnimation.type=="flip"){addAnimationClass(CLOSE_ANIMATION_FLIP);contentDiv.style.animationName="flipouttoright";contentDiv.style.transform="rotateY(-90deg) scale(.9)";}
else if(closeAnimation.type=="turn"){addAnimationClass(CLOSE_ANIMATION_FLIP);contentDiv.style.animationName="flipouttoright";contentDiv.style.transform="rotateY(-90deg) scale(.9)";contentDiv.style.transformOrigin="0";}
else if(closeAnimation.type=="flow"){addAnimationClass(CLOSE_ANIMATION_FLOW);contentDiv.style.animationName="flowouttoright";contentDiv.style.transformOrigin="50% 30%";}
else if(closeAnimation.type=="slideup"){var top=0;if(contentDiv.style.top){top=parseInt(contentDiv.style.top)+2*border+2*padding;}else{top=window.innerHeight-parseInt(contentDiv.style.bottom)-parseInt(mainDiv.style.height);}
var end=top+parseInt(mainDiv.style.height);addAnimationClass(CLOSE_ANIMATION_SLIDEUP.replace(/\{end\}/g,"-"+end+"px"));contentDiv.style.animationName="slideouttotop";}
else if(closeAnimation.type=="slidedown"){var bottom=0;if(contentDiv.style.bottom){bottom=parseInt(mainDiv.style.height)+2*border+parseInt(contentDiv.style.bottom)+2*padding;}else{bottom=window.innerHeight-parseInt(contentDiv.style.top)+2*border;}
var end=bottom;addAnimationClass(CLOSE_ANIMATION_SLIDEDOWN.replace(/\{end\}/g,end+"px"));contentDiv.style.animationName="slideouttobottom";}else{contentDiv.className=prefix+'-popup-dialog-main-div-theme-wrapper-'+config.popupTheme+' sg-animated '+closeAnimation.type;}
contentDiv.style.animationDuration=closeAnimation.speed+"ms";window.setTimeout(function(){contentDiv.className=prefix+'-popup-dialog-main-div-theme-wrapper-'+config.popupTheme;contentDiv.style.animationName="";contentDiv.style.transform="";contentDiv.style.transformOrigin="";contentDiv.style.opacity="";},parseInt(closeAnimation.speed)+10);}
function setOpenEvents(){for(var i=0;i<events.length;i++){var event=events[i];switch(event.type){case"load":setOpenOnLoadEvent();break;case"click":setOpenOnClickEvent(event);break;case"hover":setOpenOnHoverEvent(event);break;case"scroll":setOpenOnScrollEvent(event);break;case"exit":setOpenOnExitEvent(event);break;case"inactivity":setOpenInactivityEvent(event);}}}
function setOpenOnExitEvent(config){switch(config.mode){case"soft":setSoftExitEvents(config);break;case"agressive1":setAgressive1ExitEvents(config);break;case"agressive2":setAgressive2ExitEvents(config);break;case"full":setFullExitEvents(config);break;}}
function setAgressive1ExitEvents(config){window.addEventListener("beforeunload",function(e){(e||window.event).returnValue=config.message;return config.message})}
function setAgressive2ExitEvents(config){window.addEventListener("beforeunload",function(e){openPopup(false,'onExit');e.returnValue=config.message;return config.message});}
function setFullExitEvents(config){setSoftExitEvents(config);setAgressive2ExitEvents(config);}
function setSoftExitEvents(config){document.addEventListener("mouseout",function(event){if(event.toElement==null&&event.relatedTarget==null){openPopup(false,'onExit');}})}
function setOpenOnScrollEvent(config){var scrollPos=parseInt(config.position);if(config.position.indexOf("%")>0){scrollPos=document.body.scrollHeight*(scrollPos/100)-window.innerHeight/2;}
var scrollEventFunction=function(){if(document.body.scrollTop>=scrollPos||document.documentElement.scrollTop>=scrollPos){openPopup(false,'onScroll');window.removeEventListener("scroll",scrollEventFunction);}};window.addEventListener("scroll",scrollEventFunction);}
function setOpenOnLoadEvent(){if(document.readyState==="complete"){openPopup(false,'onLoad');}else{window.addEventListener("load",function(){openPopup(false,'onLoad');},false);}}
function setOpenOnClickEvent(config){var target=config.target;if(!target){return;}
var elements=document.getElementsByClassName(target);for(var i=0;i<elements.length;i++){elements[i].addEventListener("click",function(){openPopup(false,'onClick');});}}
function setOpenOnHoverEvent(config){var target=config.target;if(!target){return;}
var elements=document.getElementsByClassName(target);for(var i=0;i<elements.length;i++){elements[i].addEventListener("mouseover",function(){openPopup(false,'onHover');});}}
function setOpenInactivityEvent(config){var timer;var handler=function(){if(timer){clearInterval(timer);}
timer=setInterval(function(){openPopup();},config.timeout*1000);};document.addEventListener("mousemove",handler);document.addEventListener("mousedown",handler);document.addEventListener("keydown",handler);document.addEventListener("scroll",handler);handler();}
function initPopup(){DIV=document.createElement("div");DIV.id=prefix+"-popup-dialog-main-div-wrapper";DIV.className=prefix+"-popup-dialog-main-div-wrapper";mainDiv=document.createElement("div");mainDiv.id=prefix+"-popup-dialog-main-div";var sizeConfig=getSizeConfig();contentDiv=document.createElement("div");contentDiv.className=prefix+'-popup-dialog-main-div-theme-wrapper-'+config.popupTheme;setMainDivStyles(sizeConfig);if(contentBox.addClass){mainDiv.className=contentBox.addClass;}
DIV.style.display="none";var popupContent=getInlineContent();if(contents){var divElement=document.createElement('div');divElement.setAttribute('style','height:100%;width:100%;overflow:'+(contentBox.scrollingEnabled?'auto':'hidden')+';');divElement.appendChild(contents);mainDiv.appendChild(divElement);}else{mainDiv.innerHTML='<div style="height:100%;width:100%;overflow:'+(contentBox.scrollingEnabled?"auto":"hidden")+';">'+popupContent.innerHTML+'</div>';}
if(typeof config.closeButton.type!=='undefined'&&config.closeButton.type=='button'){closeButtonImage=document.createElement(config.closeButton.type);}else{closeButtonImage=document.createElement("IMG");}
if(config.closeBehavior.showButton!==false){closeButtonImage.className=prefix+"-popup-close-button-"+config.popupTheme;contentDiv.appendChild(closeButtonImage);}
contentDiv.appendChild(mainDiv);DIV.appendChild(contentDiv);document.body.appendChild(DIV);isInited=true;setOpenEvents();}
function getInlineContent(){var divElement=document.createElement("div");divElement.innerHTML='';if(inline){var hrefHtml=document.getElementById(inline);if(hrefHtml.previousElementSibling){SGPopup.inlinePrevTarget={hasPreviousElement:true,node:hrefHtml.previousElementSibling}}else{SGPopup.inlinePrevTarget={hasPreviousElement:false,node:hrefHtml.parentNode}}
divElement.appendChild(hrefHtml);return divElement;}
return divElement;}
function openPopup(forced,action){if(opened){return;}
coockieValue=SGPopup.getCookie(popupId);if(coockieValue){return;}
if(showOnce){SGPopup.setCookie(popupId,"true",parseInt(showOnce));}
if(forced!==true){if(shouldOpen&&typeof shouldOpen=="function"){if(shouldOpen()===false){return;}}}
if(!isInited){initPopup();}
opened=true;var self=this;window.addEventListener("resize",onWindowRsize);if(closeBehavior.contentShouldClose){mainDiv.onclick=closePopup;}
setTimeout(function(){if(willOpen&&typeof willOpen=="function"){willOpen();}
drawOverlay();DIV.style.display="";positionPopup();setOpenAnimation();setCloseButton(mainDiv);if(didOpen){var callbackArgs=parentThis.getCallbackArgs();if(typeof didOpen=="function"){didOpen(callbackArgs);}}},openDelay);if(closeBehavior.autoclose&&closeBehavior.autoclose>0){setTimeout(closePopup,closeBehavior.autoclose*1000);}
if(closeBehavior.escShouldClose){document.onkeydown=function(e){e=e||window.event;if(e.keyCode==27){closePopup();}};}}
function closePopup(forced){if(forced!==true){if(shouldClose&&typeof shouldClose=="function"){if(shouldClose()===false){return;}}}
if(closeBehavior.allowed===false&&forced!==true){return;}
if(willClose&&typeof willClose=="function"){willClose();}
window.removeEventListener("resize",onWindowRsize);var closeFunction=function(){if(!DIV){return;}
DIV.style.display="none";removeOverlay();if(didClose&&typeof didClose=="function"){didClose();opened=false;}
if(resetInlineContent&&typeof resetInlineContent=="function"){resetInlineContent();}};if(closeAnimation.type!="none"&&closeAnimation.speed>0){setCloseAnimation();setTimeout(closeFunction,closeAnimation.speed);}else{closeFunction();}}
var resizeBox=function(){var sizeConfig=getSizeConfig();setMainDivStyles(sizeConfig)};this.getCallbackArgs=function(){var args={event:this.customEvent}
return args;};this.open=function(forced){openPopup(forced);};this.init=function(){initPopup();};this.close=function(forced){closePopup(forced);};this.resize=function(){resizeBox();};this.setOpenDelay=function(delay){openDelay=delay;if(isInited){initPopup();}};this.getOpenDelay=function(){return openDelay;};this.setOpenAnimation=function(animation){openAnimation=animation;if(isInited){initPopup();}};this.getOpenAnimation=function(){return openAnimation;};this.setCloseAnimation=function(animation){closeAnimation=animation;if(isInited){initPopup();}};this.getCloseAnimation=function(){return closeAnimation;};this.setCloseBehavior=function(config){closeBehavior=config;if(isInited){initPopup();}};this.getCloseBehavior=function(){return closeBehavior;};this.setCloseButton=function(button){closeButton=button;};this.getCloseButton=function(){return closeButton;};this.setOverlay=function(config){overlay=config;if(isInited){initPopup();}};this.getOverlay=function(){return overlay;};this.setContentBox=function(config){contentBox=config;if(isInited){initPopup();}};this.getContentBox=function(){return contentBox;};this.setContents=function(content){contents=content;if(isInited){initPopup();}};this.getContents=function(){return contents;};this.setPosition=function(config){position=config;};this.getPosition=function(){return position;};this.setSizingRanges=function(ranges){sizingRanges=ranges;if(isInited){initPopup();}};this.getSizingRanges=function(){return sizingRanges;};this.setShouldOpen=function(func){shouldOpen=func;if(isInited){initPopup();}};this.getShouldOpen=function(){return shouldOpen;};this.setWillOpen=function(func){willOpen=func;if(isInited){initPopup();}};this.getWillOpen=function(){return willOpen;};this.setDidOpen=function(func){didOpen=func;if(isInited){initPopup();}};this.getDidOpen=function(){return didOpen;};this.setShouldClose=function(func){shouldClose=func;if(isInited){initPopup();}};this.getShouldClose=function(){return shouldClose;};this.setWillClose=function(func){willClose=func;if(isInited){initPopup();}};this.getWillClose=function(){return willClose;};this.setDidClose=function(func){didClose=func;if(isInited){initPopup();}};this.getDidClose=function(){return didClose;};}
SGPopup.sendGetRequest=function(url,responseHandler,params){var req;if(window.XMLHttpRequest){req=new XMLHttpRequest();}
else if(window.ActiveXObject){req=new ActiveXObject("Microsoft.XMLHTTP");}
req.onreadystatechange=function(){if(req.readyState==4){if(req.status<400){responseHandler(req,params);}else{}}};req.open("GET",url,true);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');req.send(null);};SGPopup.getCookie=function(cname){var name=cname+"=";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);}
if(c.indexOf(name)==0){return c.substring(name.length,c.length);}}
return"";};SGPopup.setCookie=function(cname,cvalue,exdays){var sameSite='Lax';var exdate=new Date();if(!exdays||isNaN(exdays)){exdays=365*50;}
exdate.setDate(exdate.getDate()+exdays);var value=cvalue+((exdays==null)?";":"; expires="+exdate.toUTCString()+'; SameSite='+sameSite);document.cookie=cname+"="+value;};SGPopup.getPopup=function(el){var id=null;while(el&&el!=document){if(el.hasAttribute("data-sg-popup-hash-id")){id=el.getAttribute("data-sg-popup-hash-id");break;}
el=el.parentNode;}
if(id){return SGPopupLoader.popups[id];}};SGPopup.openSGPopup=function(){var ids=SGPopupLoader.ids;var linkTag=document.createElement("link");linkTag.rel="stylesheet";linkTag.type="text/css";linkTag.href=SG_APP_URL+'public/assets/lib/SGPopup.css';document.head.appendChild(linkTag);var responseFunction=function(response,id){var config=JSON.parse(response.responseText);var popup=new SGPopup(config);SGPopupLoader.popups[id]=popup;popup.init();};for(var i=0;i<ids.length;i++){SGPopup.sendGetRequest(SG_APP_URL+'api/popups/'+ids[i],responseFunction,ids[i]);}};
function PopupConfig(){this.prefix='sgpb';this.popupId;this.popupData;this.openDelay=0;this.currentObj={};this.allowed=true;this.showButton=true;this.buttonPosition='topRight';this.buttonInside=true;this.autoclose=false;this.overlayShouldClose=true;this.contentShouldClose=false;this.escShouldClose=true;this.closeButtonImage='img/close.png';this.popupTheme=1;this.popupType='html';this.closeButtonWidth=21;this.closeButtonHeight=21;this.closeButtonWidthType='px';this.closeButtonHeightType='px';this.closeButtonType='IMG';this.closeButtonText='Close';this.closeButtonDelay=0;this.overlayVisible=true;this.overlayColor='black';this.overlayOpacity=80;this.overlayAddClass='sgpb-popup-overlay sg-popup-overlay';this.contentPadding=8;this.zIndex=9999;this.contentShowBackground=true;this.contentBackgroundColor='#ffffff';this.contentBackgroundImage='';this.contentBackgroundMode='none';this.contentBackgroundPosition='';this.contentBorderStyle='solid';this.contentBorderRadius=0;this.contentBorderRadiusType='%';this.contentBorderColor='#f00';this.contentBorderWidth=0;this.boxBorderWidth=0;this.contentShadowColor='#ccc';this.contentShadowBlur=0;this.scrollingEnabled=false;this.shadowSpread=0;this.contentAddClass='class2';this.contents=false;this.positionRight=false;this.positionTop=false;this.positionBottom=false;this.positionLeft=false;this.width='-1';this.height='-1';this.maxWidth='-1';this.maxHeight='-1';this.minWidth='-1';this.minHeight='-1';this.srcElement='';this.openAnimationEffect='';this.openAnimationSpeed=0;this.openAnimationStatus=false;this.closeAnimationEffect='';this.closeAnimationSpeed=0;this.closeAnimationStatus=false;this.customShouldOpen=false;this.customShouldClose=false;}
PopupConfig.firstToUpperCase=function(string){return string[0].toUpperCase()+string.slice(1);};PopupConfig.firstToLowerCase=function(string){return string[0].toLowerCase()+string.slice(1);};PopupConfig.prototype.magicCall=function(functionName,arrgname){if(functionName.indexOf('get')!=-1){var param=functionName.replace(/^get/g,"");var param=PopupConfig.firstToLowerCase(functionName.replace(/^get/g,""));return this[param];}else{var param=PopupConfig.firstToLowerCase(functionName.replace(/^set/g,""));this[param]=arrgname;}};PopupConfig.prototype.isIE=function(){var ua=navigator.userAgent;var isIE=ua.indexOf('MSIE ')>-1||ua.indexOf('Trident/')>-1;return isIE;};PopupConfig.prototype.addCustomEvent=function(eventName,args){if(this.isIE()){var event=document.createEvent('CustomEvent');event.initCustomEvent(eventName,true,true,args);}else{var event=new CustomEvent(eventName,{detail:args,bubbles:true,cancelable:true});}
window.dispatchEvent(event);};PopupConfig.prototype.combineConfigObj=function(){var that=this;var eventSendArgs={'popupId':that.popupId,'popupData':that.popupData,'currentObj':that.currentObj};window.sgWindowOldWidth=window.innerWidth;window.sgWindowOldHeight=window.innerHeight;var config={popupId:that.popupId,openDelay:this.openDelay,popupTheme:this.popupTheme,popupType:this.popupType,closeBehavior:{allowed:this.allowed,showButton:this.showButton,buttonPosition:this.buttonPosition,buttonInside:this.buttonInside,autoclose:this.autoclose,overlayShouldClose:this.overlayShouldClose,contentShouldClose:this.contentShouldClose,escShouldClose:this.escShouldClose,right:this.closeButtonPositionRight,top:this.closeButtonPositionTop,bottom:this.closeButtonPositionBottom,left:this.closeButtonPositionLeft},openAnimation:{type:this.openAnimationEffect,speed:this.openAnimationSpeed,status:this.openAnimationStatus},closeAnimation:{type:this.closeAnimationEffect,speed:this.closeAnimationSpeed,status:this.closeAnimationStatus},closeButton:{data:this.buttonImage,width:this.closeButtonWidth,height:this.closeButtonHeight,widthType:this.closeButtonWidthType,heightType:this.closeButtonHeightType,type:this.closeButtonType,text:this.closeButtonText},overlay:{visible:this.overlayVisible,color:this.overlayColor,opacity:this.overlayOpacity,addClass:this.overlayAddClass},contentBox:{padding:this.contentPadding,zIndex:this.zIndex,showBackground:this.contentShowBackground,backgroundColor:this.contentBackgroundColor,backgroundImage:this.contentBackgroundImage,backgroundMode:this.contentBackgroundMode,backgroundPosition:this.contentBackgroundPosition,borderStyle:this.contentBorderStyle,borderRadius:this.contentBorderRadius,borderRadiusType:this.contentBorderRadiusType,borderColor:this.contentBorderColor,borderWidth:this.contentBorderWidth,boxBorderWidth:this.boxBorderWidth,shadowColor:this.contentShadowColor,shadowBlur:this.contentShadowBlur,scrollingEnabled:this.scrollingEnabled,shadowSpread:this.shadowSpread,addClass:this.contentAddClass},contents:this.contents,inline:this.srcElement,iframe:false,position:{right:this.positionRight,top:this.positionTop,bottom:this.positionBottom,left:this.positionLeft},sizingRanges:[{screenFrom:{width:0,height:0},screenTo:{width:300,height:3000},width:'100%',height:this.height,maxWidth:this.maxWidth,maxHeight:this.maxHeight,minWidth:this.minWidth,minHeight:this.minHeight},{screenFrom:{width:300,height:0},screenTo:{width:5000,height:3000},width:this.width,height:this.height,maxWidth:this.maxWidth,maxHeight:this.maxHeight,minWidth:this.minWidth,minHeight:this.minHeight}],shouldOpen:function(){return true;},willOpen:function(){that.addCustomEvent('sgpbWillOpen',eventSendArgs);},didOpen:function(args){if(that.isIE()){var finalArgs=[args,eventSendArgs],finalArgs=finalArgs.reduce(function(r,o){Object.keys(o).forEach(function(k){r[k]=o[k];});return r;},{});}else{var finalArgs=Object.assign(args,eventSendArgs);}
that.addCustomEvent('sgpbDidOpen',finalArgs);},shouldClose:function(){return true;},willClose:function(){that.addCustomEvent('sgpbWillClose',eventSendArgs);},didClose:function(){that.addCustomEvent('sgpbDidClose',eventSendArgs);}};if(this.customShouldOpen){config.shouldOpen=this.customShouldOpen;}
if(this.customShouldClose){config.shouldClose=this.customShouldClose;}
return config;};var obj=new PopupConfig();
function sgAddEvent(element, eventName, fn){
if(element.addEventListener)
element.addEventListener(eventName, fn, false);
else if(element.attachEvent)
element.attachEvent('on' + eventName, fn);
}
window.SGPB_ORDER=0;
function SGPBPopup(){
this.id=null;
this.eventName='';
this.popupData=null;
this.additionalPopupData={};
this.popupConfig={};
this.popupObj=null;
this.onceListener();
this.initialsListeners();
this.countPopupOpen=true;
this.closeButtonDefaultPositions={};
this.closeButtonDefaultPositions[1]={
'left': 9,
'right': 9,
'bottom': 9
};
this.closeButtonDefaultPositions[2]={
'left': 0,
'right': 0,
'top': parseInt('-20'),
'bottom': parseInt('-20')
};
this.closeButtonDefaultPositions[3]={
'right': 4,
'bottom': 4,
'left': 4,
'top': 4
};
this.closeButtonDefaultPositions[4]={
'left': 12,
'right': 12,
'bottom': 9
};
this.closeButtonDefaultPositions[5]={
'left': 8,
'right': 8,
'bottom': 8
};
this.closeButtonDefaultPositions[6]={
'left': parseInt('-18.5'),
'right': parseInt('-18.5'),
'bottom': parseInt('-18.5'),
'top': parseInt('-18.5')
};}
SGPBPopup.htmlCustomButton=function(){
var buttons=jQuery('.sgpb-html-custom-button');
var buttonActionBehaviors=function(button, settings){
button.bind('click', function(){
var behavior=settings['sgpb-custom-button'];
if(behavior==='redirectToURL'){
if(settings['sgpb-custom-button-redirect-new-tab']){
window.open(settings['sgpb-custom-button-redirect-URL']);
}else{
window.location.href=settings['sgpb-custom-button-redirect-URL'];
}}
if(behavior==='hidePopup'){
SGPBPopup.closePopup();
}
if(behavior==='copyToClipBoard'){
var tempInputId=1;
var value=settings['sgpb-custom-button-copy-to-clipboard-text'];
var tempInput=document.createElement("input");
tempInput.id=tempInputId;
tempInput.value=value;
tempInput.style='position: absolute; right: -10000px';
if(!document.getElementById(tempInputId)){
document.body.appendChild(tempInput);
}
tempInput.select();
document.execCommand ("copy");
if(settings['sgpb-copy-to-clipboard-close-popup']){
SGPBPopup.closePopup();
}
if(settings['sgpb-custom-button-copy-to-clipboard-alert']){
alert(settings['sgpb-custom-button-copy-to-clipboard-message']);
}}
});
};
buttons.each(function(){
var settings=jQuery.parseJSON(decodeURIComponent(jQuery(this).attr('data-options')));
buttonActionBehaviors(jQuery(this), settings);
});
};
SGPBPopup.listeners=function (){
var that=this;
sgAddEvent(window, 'sgpbPopupBuilderAdditionalDimensionSettings', function(e){
SGPBPopup.mobileSafariAdditionalSettings(e);
});
sgAddEvent(window, 'sgpbDidOpen', function(e){
if(typeof (Event)==='function'){
var event=new CustomEvent('resize', {
bubbles: true,
cancelable: true
});
}else{
if(SGPBPopup.isIE()){
var event=document.createEvent('Event');
event.initEvent('resize', true, true);
}else{
var event=new CustomEvent('resize', {
bubbles: true,
cancelable: true
});
}}
window.dispatchEvent(event);
SGPBPopup.mobileSafariAdditionalSettings(e);
var args=e.detail;
var popupOptions=args.popupData;
var obj=e.detail.currentObj.sgpbPopupObj;
if(typeof SGPB_ANALYTICS_PARAMS==='undefined'){
if(obj.getCountPopupOpen()){
obj.addToCounter(popupOptions);
}}
if(popupOptions['sgpb-show-popup-same-user']){
obj.setPopupLimitationCookie(popupOptions);
}
SGPBPopup.htmlCustomButton();
});
setInterval(function(){
var openedPopups=window.sgpbOpenedPopup||{};
if(!Object.keys(openedPopups).length){
return false;
}
var params={};
params.popupsIdCollection=window.sgpbOpenedPopup;
var data={
action: 'sgpb_send_to_open_counter',
nonce: SGPB_JS_PARAMS.nonce,
params: params
};
window.sgpbOpenedPopup={};
jQuery.post(SGPB_JS_PARAMS.ajaxUrl, data, function(res){
});
}, 600);
};
SGPBPopup.mobileSafariAdditionalSettings=function(e){
if(typeof e==='undefined'){
var args=SGPBPopup.prototype.getAdditionalPopupData();
if(typeof args==='undefined'){
return false;
}
var popupOptions=args.popupData;
var popupId=parseInt(args.popupId);
}else{
var args=e.detail;
var alreadySavedArgs=SGPBPopup.prototype.getAdditionalPopupData();
if(jQuery.isEmptyObject(alreadySavedArgs)){
SGPBPopup.prototype.setAdditionalPopupData(args);
}
var popupOptions=args.popupData;
var popupId=parseInt(args.popupId);
}
var userAgent=window.navigator.userAgent;
if(userAgent.match(/iPad/i)||userAgent.match(/iPhone/i)){
if(typeof popupOptions['sgpb-popup-dimension-mode']!=='undefined'&&popupOptions['sgpb-popup-dimension-mode']==='responsiveMode'){
var openedPopupWidth=parseInt(window.innerHeight-100);
if(e.detail.popupData['sgpb-type']==='iframe'||e.detail.popupData['sgpb-type']==='video'){
if(jQuery('.sgpb-popup-builder-content-'+popupId +' iframe').length){
jQuery('.sgpb-popup-builder-content-'+popupId).attr('style', 'height:'+openedPopupWidth+'px !important;');
}}
}}
};
SGPBPopup.prototype.setAdditionalPopupData=function(additionalPopupData){
this.additionalPopupData=additionalPopupData;
};
SGPBPopup.prototype.getAdditionalPopupData=function(){
return this.additionalPopupData;
};
SGPBPopup.prototype.setCountPopupOpen=function(countPopupOpen){
this.countPopupOpen=countPopupOpen;
};
SGPBPopup.prototype.getCountPopupOpen=function(){
return this.countPopupOpen;
};
SGPBPopup.playMusic=function(e){
var args=e.detail;
var popupId=parseInt(args.popupId);
var options=SGPBPopup.getPopupOptionsById(popupId);
var soundUrl=options['sgpb-sound-url'];
var soundStatus=options['sgpb-open-sound'];
if(soundStatus&&soundUrl){
var audio=new Audio(soundUrl);
audio.play();
window.SGPB_SOUND[popupId]=audio;
}};
SGPBPopup.floatingButton=function (e){
SGPBPopup.showFloatingButton(e);
jQuery(window).on('sgpbFormSuccess', function (e){
SGPBPopup.hideFloatingButton();
});
};
SGPBPopup.showFloatingButton=function (e){
var popupObj=e||{};
var popupId=0;
var shouldShowFloatingButton=true;
if(e.hasOwnProperty('sgpbPopupObj')){
popupObj=e.detail.currentObj.sgpbPopupObj;
}
if(popupObj instanceof SGPBPopup){
popupId=parseInt(popupObj.id);
shouldShowFloatingButton=popupObj.forceCheckCurrentPopupType(popupObj);
}
if(shouldShowFloatingButton){
if(popupId){
jQuery('.sgpb-floating-button.sg-popup-id-' + popupId).show();
}else{
jQuery('.sgpb-floating-button').show();
}}
};
SGPBPopup.hideFloatingButton=function (popupId){
if(popupId){
jQuery('.sgpb-floating-button.sg-popup-id-' + popupId).fadeOut();
}else{
jQuery('.sgpb-floating-button').fadeOut();
}};
SGPBPopup.prototype.initialsListeners=function(){
var that=this;
sgAddEvent(window, 'sgpbDidOpen', function(e){
jQuery('.sg-popup-close').unbind('click').bind('click',function(){
var currentPopupId=jQuery(this).parents('.sg-popup-builder-content').attr('data-id');
SGPBPopup.closePopupById(currentPopupId);
});
});
sgAddEvent(window, 'sgpbDidClose', function(e){
var args=e.detail;
var popupId=parseInt(args.popupId);
that.htmlIframeFilterForOpen(popupId, 'close');
});
};
SGPBPopup.prototype.onceListener=function(){
var that=this;
sgAddEvent(window, 'sgpbDidOpen', function(e){
document.onkeydown=function(e){
e=e||window.event;
if(e.keyCode===27){ 
var currentPopup=that.getPopupIdForNextEsc();
if(!currentPopup){
return false;
}
var lastPopupId=parseInt(currentPopup['popupId']);
SGPBPopup.closePopupById(lastPopupId);
}};});
sgAddEvent(window, 'sgpbDidClose', function(e){
if(window.sgPopupBuilder.length!==0){
var popups=[].concat(window.sgPopupBuilder).reverse();
for (var i in popups){
var nextIndex=++i;
var nextObj=popups[nextIndex];
if(typeof nextObj==='undefined'){
jQuery('html').removeClass('sgpb-overflow-hidden');
jQuery('body').removeClass('sgpb-overflow-hidden-body');
break;
}
if(nextObj.isOpen===false){
continue;
}
var options=SGPBPopup.getPopupOptionsById(nextObj.popupId);
if(typeof options['sgpb-disable-page-scrolling']==='undefined'){
jQuery('html').removeClass('sgpb-overflow-hidden');
jQuery('body').removeClass('sgpb-overflow-hidden-body');
}else{
jQuery('html').addClass('sgpb-overflow-hidden');
jQuery('body').addClass('sgpb-overflow-hidden-body');
}
break;
}}else{
jQuery('html').addClass('sgpb-overflow-hidden');
jQuery('body').addClass('sgpb-overflow-hidden-body');
}});
};
SGPBPopup.prototype.getPopupIdForNextEsc=function(){
var popups=window.sgPopupBuilder;
var popup=false;
if(!popups.length){
return popup;
}
var searchPopups=[].concat(popups).reverse();
for (var i in searchPopups){
var popupData=searchPopups[i];
if(popupData.isOpen){
var popupId=parseInt(popupData['popupId']);
var popupOptions=SGPBPopup.getPopupOptionsById(popupId);
if(!popupOptions['sgpb-disable-popup-closing']&&popupOptions['sgpb-esc-key']){
popup=popupData;
break;
}}
}
return popup;
};
SGPBPopup.prototype.setPopupId=function(popupId){
this.id=parseInt(popupId);
};
SGPBPopup.prototype.getPopupId=function(){
return this.id;
};
SGPBPopup.prototype.setPopupObj=function(popupObj){
this.popupObj=popupObj;
};
SGPBPopup.prototype.getPopupObj=function(){
return this.popupObj;
};
SGPBPopup.prototype.setPopupData=function(popupData){
if(typeof popupData=='string'){
var popupData=SGPBPopup.JSONParse(popupData);
}
this.popupData=popupData;
};
SGPBPopup.prototype.getPopupData=function(){
return this.popupData;
};
SGPBPopup.prototype.setPopupConfig=function(config){
this.popupConfig=config;
};
SGPBPopup.prototype.getPopupConfig=function(){
return this.popupConfig;
};
SGPBPopup.prototype.setUpPopupConfig=function(){
var popupConfig=new PopupConfig();
this.setPopupConfig(popupConfig);
};
SGPBPopup.createPopupObjById=function(popupId){
var options=SGPBPopup.getPopupOptionsById(popupId);
if(!options){
return false;
}
var popupObj=new SGPBPopup();
popupObj.setPopupId(popupId);
popupObj.setPopupData(options);
return popupObj;
};
SGPBPopup.getPopupOptionsById=function(popupId){
var popupDataDiv=jQuery('#sg-popup-content-wrapper-'+popupId);
if(!popupDataDiv.length){
return false;
}
var options=popupDataDiv.attr('data-options');
return SGPBPopup.JSONParse(options);
};
SGPBPopup.prototype.getCompatibleZiIndex=function(popupZIndex){
if(popupZIndex > 2147483647){
return 2147483627;
}
return popupZIndex;
};
SGPBPopup.prototype.prepareOpen=function(){
var popupId=this.getPopupId();
var popupData=this.getPopupData();
var popupZIndex=this.getCompatibleZiIndex(popupData['sgpb-popup-z-index']);
var popupType=this.popupData['sgpb-type'];
this.setUpPopupConfig();
var that=this;
var popupConfig=this.getPopupConfig();
function decodeEntities(encodedString){
if(typeof encodedString=='undefined'){
return '';
}
var suspiciousStrings=['document.createElement', 'createElement', 'String.fromCharCode', 'fromCharCode'];
for (var i in suspiciousStrings){
if(encodedString.indexOf(suspiciousStrings[i]) > 0){
return '';
}}
var textArea=document.createElement('textarea');
textArea.innerHTML=encodedString;
return textArea.value;
}
popupConfig.customShouldOpen=function(){
var instructions=popupData['sgpb-ShouldOpen'];
instructions=decodeEntities(instructions);
var F=new Function (instructions);
return(F());
};
popupConfig.customShouldClose=function(){
var instructions=popupData['sgpb-ShouldClose'];
instructions=decodeEntities(instructions);
var F=new Function (instructions);
return(F());
};
this.setPopupDimensions();
if(popupData['sgpb-disable-popup-closing']=='on'){
popupData['sgpb-enable-close-button']='';
popupData['sgpb-esc-key']='';
popupData['sgpb-overlay-click']='';
}
popupData['eventName']=this.eventName;
if(SGPBPopup.varToBool(popupData['sgpb-enable-close-button'])){
popupConfig.magicCall('setCloseButtonDelay', parseInt(popupData['sgpb-close-button-delay']));
}
popupConfig.magicCall('setShowButton', SGPBPopup.varToBool(popupData['sgpb-enable-close-button']));
var openAnimationSpeed=parseFloat(popupData['sgpb-open-animation-speed'])*1000;
var closeAnimationSpeed=parseFloat(popupData['sgpb-close-animation-speed'])*1000;
popupConfig.magicCall('setOpenAnimationEffect', popupData['sgpb-open-animation-effect']);
popupConfig.magicCall('setCloseAnimationEffect', popupData['sgpb-close-animation-effect']);
popupConfig.magicCall('setOpenAnimationSpeed', openAnimationSpeed);
popupConfig.magicCall('setCloseAnimationSpeed', closeAnimationSpeed);
popupConfig.magicCall('setOpenAnimationStatus', popupData['sgpb-open-animation']);
popupConfig.magicCall('setCloseAnimationStatus', popupData['sgpb-close-animation']);
popupConfig.magicCall('setContentPadding', popupData['sgpb-content-padding']);
if(typeof SgpbRecentSalesPopupType!='undefined'){
if(popupType==SgpbRecentSalesPopupType){
popupZIndex=2147483647;
popupConfig.magicCall('setCloseAnimationEffect', 'fade');
popupConfig.magicCall('setCloseAnimationSpeed', 1000);
popupConfig.magicCall('setCloseAnimationStatus', 'on');
}}
popupConfig.magicCall('setZIndex', popupZIndex);
popupConfig.magicCall('setCloseButtonWidth', popupData['sgpb-button-image-width']);
popupConfig.magicCall('setCloseButtonHeight', popupData['sgpb-button-image-height']);
popupConfig.magicCall('setPopupId', popupId);
popupConfig.magicCall('setPopupData', popupData);
popupConfig.magicCall('setAllowed', !SGPBPopup.varToBool(popupData['sgpb-disable-popup-closing']));
if(popupData['sgpb-type']==SGPB_POPUP_PARAMS.popupTypeAgeRestriction){
popupConfig.magicCall('setAllowed', false);
}
popupConfig.magicCall('setEscShouldClose', SGPBPopup.varToBool(popupData['sgpb-esc-key']));
popupConfig.magicCall('setOverlayShouldClose', SGPBPopup.varToBool(popupData['sgpb-overlay-click']));
popupConfig.magicCall('setScrollingEnabled', SGPBPopup.varToBool(popupData['sgpb-enable-content-scrolling']));
if(SGPBPopup.varToBool(popupData['sgpb-content-click'])){
this.contentCloseBehavior();
}
sgAddEvent(window, 'sgpbWillOpen', function(e){
if(popupId!=e.detail.popupId||e.detail.popupData['sgpb-content-click']=='undefined'){
return false;
}
that.popupContentClick(e);
});
if(SGPBPopup.varToBool(popupData['sgpb-popup-fixed'])){
this.addFixedPosition();
}
this.themeCreator();
this.themeCustomizations();
popupConfig.magicCall('setContents', document.getElementById('sg-popup-content-wrapper-'+popupId));
popupConfig.magicCall('setPopupType', popupType);
this.setPopupConfig(popupConfig);
this.popupTriggeringListeners();
var allowToOpen=this.checkCurrentPopupType();
if(allowToOpen){
this.open();
}};
SGPBPopup.prototype.popupContentClick=function(e){
var args=e.detail;
var popupId=parseInt(args['popupId']);
jQuery('.sgpb-content-' + popupId).on('click', function(event){
var settings={
popupId: popupId,
eventName: 'sgpbPopupContentclick'
};
jQuery(window).trigger('sgpbPopupContentclick', settings);
});
};
SGPBPopup.prototype.forceCheckCurrentPopupType=function(popupObj){
var allowToOpen=true;
var popupConfig=new PopupConfig();
var className=popupObj.popupData['sgpb-type'];
if(typeof className=='undefined'||className=='undefined'){
return false;
}
if(typeof SGPB_POPUP_PARAMS.conditionalJsClasses!='undefined'&&SGPB_POPUP_PARAMS.conditionalJsClasses.length){
var isAllowConditions=this.forceIsAllowJsConditions(popupObj);
if(!isAllowConditions){
return false;
}}
var popupConfig=new PopupConfig();
var className=this.popupData['sgpb-type'];
className=popupConfig.prefix.toUpperCase() + PopupConfig.firstToUpperCase(className);
if(window.hasOwnProperty(className)){
className=eval(className);
var obj=new className;
if(typeof obj.allowToOpen==='function'){
allowToOpen=obj.allowToOpen(this.id);
if(!allowToOpen){
isAllow=allowToOpen;
}}
}
var allowToOpen=this.checkCurrentPopupType();
if(!allowToOpen){
return false;
}
return allowToOpen;
};
SGPBPopup.prototype.checkCurrentPopupType=function(){
var allowToOpen=true;
var popupConfig=new PopupConfig();
var isPreview=parseInt(this.popupData['sgpb-is-preview']);
if(!isNaN(isPreview)&&isPreview==1){
return allowToOpen;
}
var popupHasLimit=this.isSatistfyForShowingLimitation(this.popupData);
if(!popupHasLimit){
return false;
}
var dontShowPopupCookieName='sgDontShowPopup' + this.popupData['sgpb-post-id'];
var dontShowPopup=SGPopup.getCookie(dontShowPopupCookieName);
if(dontShowPopup!=''){
return false;
}
var className=this.popupData['sgpb-type'];
if(typeof className=='undefined'||className=='undefined'){
return false;
}
if(typeof SGPB_POPUP_PARAMS.conditionalJsClasses!='undefined'&&SGPB_POPUP_PARAMS.conditionalJsClasses.length){
var isAllowConditions=this.isAllowJsConditions();
if(!isAllowConditions){
return false;
}}
className=popupConfig.prefix.toUpperCase() + PopupConfig.firstToUpperCase(className);
if(window.hasOwnProperty(className)){
className=eval(className);
var obj=new className;
if(typeof obj.allowToOpen==='function'){
allowToOpen=obj.allowToOpen(this.id);
}}
return allowToOpen;
};
SGPBPopup.prototype.forceIsAllowJsConditions=function(popupObj){
var conditions=SGPB_POPUP_PARAMS.conditionalJsClasses;
var isAllow=true;
for (var i in conditions){
if(!conditions.hasOwnProperty(i)){
break;
}
try {
var className=eval(conditions[i]);
}
catch (e){
continue;
}
var obj=new className;
if(typeof obj.forceAllowToOpen==='function'){
var popupData=this.getPopupData();
var allowToOpen=obj.forceAllowToOpen(popupObj.id, popupObj);
if(!allowToOpen){
isAllow=allowToOpen;
break;
}}
}
return isAllow;
};
SGPBPopup.prototype.isAllowJsConditions=function(){
var conditions=SGPB_POPUP_PARAMS.conditionalJsClasses;
var isAllow=true;
for (var i in conditions){
if(!conditions.hasOwnProperty(i)){
break;
}
try {
var className=eval(conditions[i]);
}
catch (e){
continue;
}
var obj=new className;
if(typeof obj.allowToOpen==='function'){
var allowToOpen=obj.allowToOpen(this.id, this);
if(!allowToOpen){
isAllow=allowToOpen;
break;
}}
}
return isAllow;
};
SGPBPopup.prototype.setPopupLimitationCookie=function(popupData){
var cookieData=this.getPopupShowLimitationCookie(popupData);
var cookie=cookieData.cookie||{};
var openingCount=cookie.openingCount||0;
var currentUrl=window.location.href;
if(!popupData['sgpb-show-popup-same-user-page-level']){
currentUrl='';
}
cookie.openingCount=openingCount + 1;
cookie.openingPage=currentUrl;
var popupShowingLimitExpiry=parseInt(popupData['sgpb-show-popup-same-user-expiry']);
SGPBPopup.setCookie(cookieData.cookieName, JSON.stringify(cookie), popupShowingLimitExpiry, currentUrl);
};
SGPBPopup.prototype.isSatistfyForShowingLimitation=function(popupData){
var popupLimitation=popupData['sgpb-show-popup-same-user'];
if(!popupLimitation){
return true;
}
var cookieData=this.getPopupShowLimitationCookie(popupData);
if(!cookieData.cookie){
return true;
}
return popupData['sgpb-show-popup-same-user-count'] > cookieData.cookie.openingCount;
};
SGPBPopup.prototype.getPopupShowLimitationCookie=function(popupData){
var savedCookie=this.getPopupShowLimitationCookieDetails(popupData);
var savedCookie=this.filterPopupLimitationCookie(savedCookie);
return savedCookie;
};
SGPBPopup.prototype.filterPopupLimitationCookie=function(cookie){
var result={};
result.cookie='';
if(cookie.isPageLevel){
result.cookieName=cookie.pageLevelCookieName;
if(cookie.pageLevelCookie){
result.cookie=jQuery.parseJSON(cookie.pageLevelCookie);
}
SGPBPopup.deleteCookie(cookie.domainLevelCookieName);
return result;
}
result.cookieName=cookie.domainLevelCookieName;
if(cookie.domainLevelCookie){
result.cookie=jQuery.parseJSON(cookie.domainLevelCookie);
}
var currentUrl=window.location.href;
SGPBPopup.deleteCookie(cookie.pageLevelCookieName, currentUrl);
return result;
};
SGPBPopup.prototype.getPopupShowLimitationCookieDetails=function(popupData){
var result=false;
var currentUrl=window.location.href;
var currentPopupId=popupData['sgpb-post-id'];
var popupLimitationCookieHomePageLevelName='SGPBShowingLimitationHomePage' + currentPopupId;
var popupLimitationCookiePageLevelName='SGPBShowingLimitationPage' + currentPopupId;
var popupLimitationCookieDomainName='SGPBShowingLimitationDomain' + currentPopupId;
var pageLevelCookie=popupData['sgpb-show-popup-same-user-page-level']||false;
if(currentUrl==SGPB_POPUP_PARAMS.homePageUrl){
popupLimitationCookiePageLevelName=popupLimitationCookieHomePageLevelName;
}
var popupLimitationPageLevelCookie=SGPopup.getCookie(popupLimitationCookiePageLevelName);
var popupLimitationDomainCookie=SGPopup.getCookie(popupLimitationCookieDomainName);
result={
'pageLevelCookieName': popupLimitationCookiePageLevelName,
'domainLevelCookieName': popupLimitationCookieDomainName,
'pageLevelCookie': popupLimitationPageLevelCookie,
'domainLevelCookie': popupLimitationDomainCookie,
'isPageLevel': pageLevelCookie
};
return result;
};
SGPBPopup.prototype.themeCreator=function(){
var noPositionSelected=false;
var popupData=this.getPopupData();
var popupId=this.getPopupId();
var popupConfig=this.getPopupConfig();
var forceRtlClass='';
var forceRtl=SGPBPopup.varToBool(popupData['sgpb-force-rtl']);
var popupTheme=popupData['sgpb-popup-themes'];
var popupType=popupData['sgpb-type'];
var closeButtonWidth=popupData['sgpb-button-image-width'];
var closeButtonHeight=popupData['sgpb-button-image-height'];
var contentPadding=parseInt(popupData['sgpb-content-padding']);
var top=parseInt(popupData['sgpb-button-position-top']);
var right=parseInt(popupData['sgpb-button-position-right']);
var bottom=parseInt(popupData['sgpb-button-position-bottom']);
var left=parseInt(popupData['sgpb-button-position-left']);
var contentClass=popupData['sgpb-content-custom-class'];
var popupBorder=SGPBPopup.varToBool(popupData['sgpb-disable-border']);
var closeButtonImage=popupConfig.closeButtonImage;
var themeNumber=1;
var backgroundColor='black';
var borderColor='inherit';
var recentSalesPopup=false;
if(typeof SgpbRecentSalesPopupType!='undefined'){
if(popupType==SgpbRecentSalesPopupType){
recentSalesPopup=true;
popupTheme='sgpb-theme-2';
closeButtonPosition='topRight';
backgroundColor='white';
borderColor='#ececec';
top='-10';
right='-10';
popupConfig.magicCall('setShadowSpread', 1);
popupConfig.magicCall('setContentShadowBlur', 5);
popupConfig.magicCall('setOverlayVisible', false);
popupConfig.magicCall('setContentShadowColor', '#000000b3');
popupConfig.magicCall('setContentBorderRadius', '5px');
}}
var themeIndexNum=popupTheme[popupTheme.length -1];
if(isNaN(top)){
top=this.closeButtonDefaultPositions[themeIndexNum].top;
}
if(isNaN(right)){
right=this.closeButtonDefaultPositions[themeIndexNum].right;
}
if(isNaN(bottom)){
bottom=this.closeButtonDefaultPositions[themeIndexNum].bottom;
}
if(isNaN(left)){
left=this.closeButtonDefaultPositions[themeIndexNum].left;
}
if(forceRtl){
forceRtlClass=' sgpb-popup-content-direction-right';
}
if(popupData['sgpb-type']=='countdown'){
popupConfig.magicCall('setMinWidth', 300);
}
popupConfig.magicCall('setContentPadding', contentPadding);
popupConfig.magicCall('setOverlayAddClass', popupTheme+'-overlay sgpb-popup-overlay-' + popupId);
popupConfig.magicCall('setContentAddClass', 'sgpb-content sgpb-content-'+popupId+' ' + popupTheme+'-content ' + contentClass + forceRtlClass);
if(typeof popupData['sgpb-close-button-position']=='undefined'||popupData['sgpb-close-button-position']==''){
var noPositionSelected=true;
}else{
var closeButtonPosition=popupData['sgpb-close-button-position'];
popupConfig.magicCall('setButtonPosition', closeButtonPosition);
}
if(popupTheme=='sgpb-theme-1'){
themeNumber=1;
popupConfig.magicCall('setShadowSpread', 14);
if(noPositionSelected||closeButtonPosition=='bottomRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}else{
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}}
else if(popupTheme=='sgpb-theme-2'){
themeNumber=2;
popupConfig.magicCall('setButtonInside', false);
popupConfig.magicCall('setContentBorderWidth', 1);
popupConfig.magicCall('setContentBackgroundColor', backgroundColor);
popupConfig.magicCall('setContentBorderColor', borderColor);
popupConfig.magicCall('setOverlayColor', 'white');
var rightPosition='0';
var topPosition='-' + closeButtonHeight + 'px';
if(recentSalesPopup){
rightPosition='-' + (closeButtonWidth / 2) + 'px';
topPosition='-' + (closeButtonHeight / 2) + 'px';
themeNumber=6;
}
if(noPositionSelected||closeButtonPosition=='topRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
}else{
if(closeButtonPosition=='topLeft'){
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
}
else if(closeButtonPosition=='bottomRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}
else if(closeButtonPosition=='bottomLeft'){
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}}
if(popupBorder){
popupConfig.magicCall('setContentBorderWidth', 0);
}}
else if(popupTheme=='sgpb-theme-3'){
themeNumber=3;
popupConfig.magicCall('setContentBorderWidth', 5);
popupConfig.magicCall('setContentBorderRadius', popupData['sgpb-border-radius']);
popupConfig.magicCall('setContentBorderRadiusType', popupData['sgpb-border-radius-type']);
popupConfig.magicCall('setContentBorderColor', popupData['sgpb-border-color']);
var closeButtonPositionPx='4px';
if(popupBorder){
popupConfig.magicCall('setContentBorderWidth', 0);
closeButtonPositionPx='0px';
}
if(noPositionSelected){
popupConfig.magicCall('setCloseButtonWidth', 38);
popupConfig.magicCall('setCloseButtonHeight', 19);
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
}else{
if(closeButtonPosition=='topRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
}
else if(closeButtonPosition=='topLeft'){
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
}
else if(closeButtonPosition=='bottomRight'){
popupConfig.magicCall('setCloseButtonPositionLeft', right+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}
else if(closeButtonPosition=='bottomLeft'){
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}}
}
else if(popupTheme=='sgpb-theme-4'){
themeNumber=4;
popupConfig.magicCall('setButtonImage', popupData['sgpb-button-text']);
popupConfig.magicCall('setCloseButtonType', 'button');
popupConfig.magicCall('setCloseButtonText', popupData['sgpb-button-text']);
popupConfig.magicCall('setContentBorderWidth', 0);
popupConfig.magicCall('setContentBackgroundColor', 'white');
popupConfig.magicCall('setContentBorderColor', 'white');
popupConfig.magicCall('setOverlayColor', 'white');
popupConfig.magicCall('setShadowSpread', 4);
popupConfig.magicCall('setContentShadowBlur', 8);
if(noPositionSelected||closeButtonPosition=='bottomRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}else{
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}}
else if(popupTheme=='sgpb-theme-5'){
themeNumber=5;
popupConfig.magicCall('setBoxBorderWidth', 10);
popupConfig.magicCall('setContentBorderColor', '#4B4B4B');
if(noPositionSelected||closeButtonPosition=='bottomRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}else{
popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
}}
else if(popupTheme=='sgpb-theme-6'){
themeNumber=6;
popupConfig.magicCall('setButtonInside', false);
popupConfig.magicCall('setContentBorderRadius', 7);
popupConfig.magicCall('setContentBorderRadiusType', 'px');
if(noPositionSelected){
popupConfig.magicCall('setCloseButtonWidth', 37);
popupConfig.magicCall('setCloseButtonHeight', 37);
popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
}else{
if(typeof popupData['sgpb-button-position-right']=='undefined'){
right='-' + (closeButtonWidth / 2);
top='-' + (closeButtonHeight / 2);
left='-' + (closeButtonWidth / 2);
bottom='-' + (closeButtonHeight / 2);
}
if(closeButtonPosition=='topRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right + 'px');
popupConfig.magicCall('setCloseButtonPositionTop', top + 'px');
}
else if(closeButtonPosition=='topLeft'){
popupConfig.magicCall('setCloseButtonPositionLeft', left + 'px');
popupConfig.magicCall('setCloseButtonPositionTop', top + 'px');
}
else if(closeButtonPosition=='bottomRight'){
popupConfig.magicCall('setCloseButtonPositionRight', right + 'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom + 'px');
}
else if(closeButtonPosition=='bottomLeft'){
popupConfig.magicCall('setCloseButtonPositionLeft', left + 'px');
popupConfig.magicCall('setCloseButtonPositionBottom', bottom + 'px');
}}
}
popupConfig.magicCall('setPopupTheme', themeNumber);
if(!popupData['sgpb-button-image']){
closeButtonImage=SGPB_POPUP_PARAMS.defaultThemeImages[themeNumber];
if(typeof closeButtonImage!='undefined'){
popupConfig.magicCall('setButtonImage', closeButtonImage);
}}else{
popupConfig.magicCall('setButtonImage', 'data:image/png;base64,'+popupData['sgpb-button-image-data']);
if(popupData['sgpb-button-image-data']==''||popupData['sgpb-button-image-data'].indexOf('http')!=-1){
popupConfig.magicCall('setButtonImage', popupData['sgpb-button-image']);
}}
};
SGPBPopup.prototype.themeCustomizations=function(){
var popupId=this.getPopupId();
var popupData=this.getPopupData();
var popupConfig=this.getPopupConfig();
var contentOpacity=popupData['sgpb-content-opacity'];
var contentBgColor=popupData['sgpb-background-color'];
if(popupData['sgpb-background-image-data']){
var contentBgImage='data:image/png;base64,'+popupData['sgpb-background-image-data'];
}else{
var contentBgImage=popupData['sgpb-background-image'];
}
var showContentBackground=popupData['sgpb-show-background'];
var contentBgImageMode=popupData['sgpb-background-image-mode'];
var overlayColor=popupData['sgpb-overlay-color'];
var popupTheme=popupData['sgpb-popup-themes'];
var popupType=popupData['sgpb-type'];
if(typeof popupData['sgpb-overlay-custom-class']=='undefined'){
popupData['sgpb-overlay-custom-class']='sgpb-popup-overlay';
}
if(typeof popupData['sgpb-popup-themes']=='undefined'){
popupTheme='sgpb-theme-2';
}
if(typeof showContentBackground=='undefined'){
contentBgColor='';
contentBgImage='';
contentBgImageMode='';
}
if(typeof SgpbRecentSalesPopupType!='undefined'){
if(popupType==SgpbRecentSalesPopupType){
showContentBackground='on';
contentBgColor=popupData['sgpb-background-color'];
contentOpacity=popupData['sgpb-content-opacity'];
}}
if(contentOpacity){
popupConfig.magicCall('setContentBackgroundOpacity', contentOpacity);
}
if(contentBgImageMode){
popupConfig.magicCall('setContentBackgroundMode', contentBgImageMode);
}
if(contentBgImage){
popupConfig.magicCall('setContentBackgroundImage', contentBgImage);
}
if(contentBgColor){
contentBgColor=SGPBPopup.hexToRgba(contentBgColor, contentOpacity);
popupConfig.magicCall('setContentBackgroundColor', contentBgColor);
}
if(overlayColor){
popupConfig.magicCall('setOverlayColor', overlayColor);
}
var overlayClasses=popupTheme+'-overlay sgpb-popup-overlay-'+popupId;
if(SGPB_JS_PACKAGES.extensions['advanced-closing']){
if(typeof popupData['sgpb-enable-popup-overlay']!='undefined'&&popupData['sgpb-enable-popup-overlay']=='on'){
popupData['sgpb-enable-popup-overlay']=true;
}
else if(typeof popupData['sgpb-enable-popup-overlay']=='undefined'){
popupData['sgpb-enable-popup-overlay']=false;
}}else{
popupData['sgpb-enable-popup-overlay']=true;
}
popupConfig.magicCall('setOverlayVisible', SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']));
if(typeof SgpbRecentSalesPopupType!='undefined'){
popupConfig.magicCall('setOverlayVisible', false);
}
if(SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay'])){
popupConfig.magicCall('setOverlayAddClass', overlayClasses + ' ' + popupData['sgpb-overlay-custom-class']);
var overlayOpacity=popupData['sgpb-overlay-opacity']||0.8;
popupConfig.magicCall('setOverlayOpacity', overlayOpacity * 100);
}};
SGPBPopup.prototype.formSubmissionDetection=function(args){
if(args.length){
return false;
}
var popupId=args.popupId;
var options=SGPBPopup.getPopupOptionsById(popupId);
if(!options['sgpb-reopen-after-form-submission']){
return false;
}
jQuery('.sgpb-popup-builder-content-' + popupId + ' form').submit(function(){
SGPBPopup.setCookie('SGPBSubmissionReloadPopup', popupId);
});
};
SGPBPopup.prototype.htmlIframeFilterForOpen=function(popupId, popupEventName){
var popupContent=jQuery('.sgpb-content-' + popupId);
if(!popupContent.length){
return false;
}
popupContent.find('iframe').each(function(){
if(popupEventName!='open'){
if(jQuery(this).closest('.fb_iframe_widget').length){
return true;
}
if(typeof jQuery(this).attr('data-attr-src')=='undefined'){
var src=jQuery(this).attr('src');
if(src!=''){
jQuery(this).attr('data-attr-src', src);
jQuery(this).attr('src', '');
}
return true;
}else{
var src=jQuery(this).attr('src');
if(src!=''){
jQuery(this).attr('data-attr-src', src);
jQuery(this).attr('src', '');
}
return true;
}}else{
if(typeof jQuery(this).attr('data-attr-src')=='undefined'){
var src=jQuery(this).attr('src');
if(src!=''){
jQuery(this).attr('data-attr-src', src);
}
return true;
}else{
var src=jQuery(this).attr('data-attr-src');
if(src!=''){
jQuery(this).attr('src', src);
jQuery(this).attr('data-attr-src', src);
}
return true;
}}
});
};
SGPBPopup.prototype.iframeSizesInHtml=function(args){
var popupId=args['popupId'];
var popupOptions=args.popupData;
var popupContent=jQuery('.sgpb-content-' + popupId);
if(!popupContent.length){
return false;
}
popupContent.find('iframe').each(function(){
if(typeof jQuery(this)=='undefined'){
return false;
}
if(popupOptions['sgpb-popup-dimension-mode']=='customMode'){
if(typeof jQuery(this).attr('width')=='undefined'&&typeof popupContent.attr('height')=='undefined'){
jQuery(this).css({'width': popupOptions['sgpb-width'], 'height': popupOptions['sgpb-height']});
}}
});
};
SGPBPopup.prototype.getSearchDataFromContent=function(content){
var pattern=/\[(\[?)(pbvariable)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/gi;
var match;
var collectedData=[];
while (match=pattern.exec(content)){
var currentSearchData=[];
var attributes;
var attributesKeyValue=[];
var parseAttributes=/\s(\w+?)="(.+?)"/g;
currentSearchData['replaceString']=this.htmlDecode(match[0]);
while (attributes=parseAttributes.exec(match[3])){
attributesKeyValue[attributes[1]]=this.htmlDecode(attributes[2]);
}
currentSearchData['searchData']=attributesKeyValue;
collectedData.push(currentSearchData);
}
return collectedData;
};
SGPBPopup.prototype.replaceWithCustomShortcode=function(popupId){
var currentHtmlContent=jQuery('.sgpb-content-'+popupId).html();
var searchData=this.getSearchDataFromContent(currentHtmlContent);
var that=this;
if(!searchData.length){
return false;
}
for (var index in searchData){
var currentSearchData=searchData[index];
var searchAttributes=currentSearchData['searchData'];
if(typeof searchAttributes['selector']=='undefined'||typeof searchAttributes['attribute']=='undefined'){
that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
continue;
}
try {
if(!jQuery(searchAttributes['selector']).length){
that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
continue;
}}
catch (e){
that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
continue;
}
if(searchAttributes['attribute']=='text'){
var replaceName=jQuery(searchAttributes['selector']).text();
}else{
var replaceName=jQuery(searchAttributes['selector']).attr(searchAttributes['attribute']);
}
if(typeof replaceName=='undefined'){
that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
continue;
}
that.replaceShortCode(currentSearchData['replaceString'], replaceName, popupId);
}};
SGPBPopup.prototype.replaceShortCode=function(shortCode, replaceText, popupId){
var popupId=parseInt(popupId);
if(!popupId){
return false;
}
var popupContentWrapper=jQuery('.sgpb-content-' + popupId);
if(!popupContentWrapper.length){
return false;
}
popupContentWrapper.find('div').each(function(){
var currentHtmlContent=jQuery(this).contents();
if(!currentHtmlContent.length){
return false;
}
currentHtmlContent.html(function(i, v){
if(typeof v!='undefined'){
return v.replace(shortCode, replaceText);
}});
});
return true;
};
SGPBPopup.prototype.popupTriggeringListeners=function(){
var that=this;
var popupData=this.getPopupData();
var popupConfig=this.getPopupConfig();
sgAddEvent(window, 'sgpbDidOpen', function(e){
var args=e.detail;
that.iframeSizesInHtml(args);
that.formSubmissionDetection(args);
var popupOptions=args.popupData;
var closeButtonDelay=parseInt(popupOptions['sgpb-close-button-delay']);
if(closeButtonDelay){
that.closeButtonDisplay(popupOptions['sgpb-post-id'], 'show', closeButtonDelay);
}
var disablePageScrolling=popupOptions['sgpb-disable-page-scrolling'];
if(popupOptions['sgpb-overlay-color']){
jQuery('.sgpb-theme-1-overlay').css({'background-image': 'none'});
}
if(SGPBPopup.varToBool(disablePageScrolling)){
jQuery('html').addClass('sgpb-overflow-hidden');
jQuery('body').addClass('sgpb-overflow-hidden-body');
}});
sgAddEvent(window, 'sgpbWillOpen', function(e){
var args=e.detail;
var popupId=parseInt(args['popupId']);
that.htmlIframeFilterForOpen(args.popupId, 'open');
that.replaceWithCustomShortcode(popupId);
that.sgpbDontShowPopup(popupId);
var closeButtonDelay=parseInt(popupData['sgpb-close-button-delay']);
if(closeButtonDelay){
that.closeButtonDisplay(popupData['sgpb-post-id'], 'hide');
}
var settings={
popupId: popupData['sgpb-post-id'],
disabledAnalytics: popupData['sgpb-popup-counting-disabled'],
disabledInGeneral: SGPB_POPUP_PARAMS.disableAnalyticsGeneral
};
jQuery(window).trigger('sgpbDisableAnalytics', settings);
});
sgAddEvent(window, 'sgpbShouldClose', function(e){
});
sgAddEvent(window, 'sgpbWillClose', function(e){
var args=e.detail;
SGPBPopup.offPopup(e.detail.currentObj);
});
};
SGPBPopup.prototype.sgpbDontShowPopup=function(popupId){
var dontShowPopup=jQuery('.sgpb-content-' + popupId).parent().find('[class*="sg-popup-dont-show"]');
if(!dontShowPopup.length){
return false;
}
dontShowPopup.each(function(){
jQuery(this).bind('click', function(e){
e.preventDefault();
var expireTime=SGPB_POPUP_PARAMS.dontShowPopupExpireTime;
var cookieName='sgDontShowPopup' + popupId;
var classNameSearch=jQuery(this).attr('class').match(/sg-popup-dont-show/);
var className=classNameSearch['input'];
var customExpireTime=className.match(/sg-popup-dont-show-(\d+$)/);
if(customExpireTime){
expireTime=parseInt(customExpireTime[1]);
}
SGPBPopup.setCookie(cookieName, expireTime, expireTime);
SGPBPopup.closePopupById(popupId);
});
});
};
SGPBPopup.prototype.addToCounter=function(popupOptions){
if(SGPB_POPUP_PARAMS.isPreview||(typeof popupOptions['sgpb-popup-counting-disabled']!='undefined')){
return false;
}
var that=this;
var openedPopups=window.sgpbOpenedPopup||{};
var popupId=parseInt(popupOptions['sgpb-post-id']);
if(typeof openedPopups[popupId]=='undefined'){
openedPopups[popupId]=1;
}else{
openedPopups[popupId] +=1;
}
window.sgpbOpenedPopup=openedPopups;
};
SGPBPopup.prototype.closeButtonDisplay=function(popupId, display, delay){
if(display=='show'){
setTimeout(function(){
jQuery('.sgpb-content-' + popupId).prev().show();
},
delay * 1000 
);
}
else if(display=='hide'){
jQuery('.sgpb-content-' + popupId).prev().hide();
}};
SGPBPopup.prototype.open=function(args){
var customEvent=this.customEvent;
var config=this.getPopupConfig();
var popupId=this.getPopupId();
var eventName=this.eventName;
if(typeof window.sgPopupBuilder=='undefined'){
window.sgPopupBuilder=[];
}
var popupData=SGPBPopup.getPopupWindowDataById(popupId);
if(!popupData){
window.SGPB_ORDER +=1;
var currentObj={
'eventName': eventName,
'popupId': popupId,
'order': window.SGPB_ORDER,
'isOpen': true,
'sgpbPopupObj': this
};
config.currentObj=currentObj;
var popupConfig=config.combineConfigObj();
var popup=new SGPopup(popupConfig);
currentObj.popup=popup;
window.sgPopupBuilder.push(currentObj);
}else{
popup=popupData['popup'];
popupData['isOpen']=true;
}
if(typeof args!='undefined'&&!args['countPopupOpen']){
this.setCountPopupOpen(false);
}
popup.customEvent=customEvent;
popup.open();
this.setPopupObj(popup);
var options=SGPBPopup.getPopupOptionsById(popupId);
SgpbEventListener.CF7EventListener(popupId, options);
if(typeof options['sgpb-behavior-after-special-events']!='undefined'){
if(options['sgpb-behavior-after-special-events'].length){
options=options['sgpb-behavior-after-special-events'][0][0];
if(options['param']=='contact-form-7'){
SgpbEventListener.processCF7MailSent(popupId, options);
}}
}};
SGPBPopup.varToBool=function(optionName){
var returnValue=optionName ? true:false;
return returnValue;
};
SGPBPopup.hexToRgba=function(hex, opacity){
var c;
if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
c=hex.substring(1).split('');
if(c.length==3){
c=[c[0], c[0], c[1], c[1], c[2], c[2]];
}
c='0x'+c.join('');
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+opacity+')';
}
throw new Error('Bad Hex');
};
SGPBPopup.prototype.contentCopyToClick=function(){
var popupData=this.getPopupData();
var popupId=this.getPopupId();
var tempInputId='content-copy-to-click-'+popupId;
var value=this.htmlDecode(popupData['sgpb-copy-to-clipboard-text']);
var tempInput=document.createElement("input");
tempInput.id=tempInputId;
tempInput.value=value;
tempInput.style='position: absolute; right: -10000px';
if(!document.getElementById(tempInputId)){
document.body.appendChild(tempInput);
}
tempInput.select();
document.execCommand ("copy");
document.body.removeChild(tempInput);
};
SGPBPopup.prototype.htmlDecode=function(value){
return jQuery('<textarea/>').html(value).text();
};
SGPBPopup.prototype.findTargetInsideExceptionsList=function(targetName, exceptionList){
var status=false;
var popupContentMainDiv=document.getElementById('sgpb-popup-dialog-main-div');
while (targetName.parentNode){
targetName=targetName.parentNode;
if(typeof targetName.tagName=='undefined'){
continue;
}
var tagName=targetName.tagName.toLowerCase();
if(targetName===popupContentMainDiv){
break;
}
if(exceptionList.indexOf(tagName)!=-1){
status=true;
break;
}}
return status;
};
SGPBPopup.prototype.contentCloseBehavior=function(){
var that=this;
var popupData=this.getPopupData();
var popupId=this.getPopupId();
var redirectUrl=popupData['sgpb-click-redirect-to-url'];
var contentClickBehavior=popupData['sgpb-content-click-behavior'];
var redirectToNewTab=SGPBPopup.varToBool(popupData['sgpb-redirect-to-new-tab']);
var closePopupAfterCopy=SGPBPopup.varToBool(popupData['sgpb-copy-to-clipboard-close-popup']);
var clipboardAlert=SGPBPopup.varToBool(popupData['sgpb-copy-to-clipboard-alert']);
var separators=['&amp;', '/&/g'];
for (var i in separators){
redirectUrl=redirectUrl.split(separators[i]).join('&');
}
sgAddEvent(window, 'sgpbDidOpen', function(e){
});
sgAddEvent(window, 'sgpbWillOpen', function(e){
if(popupId!=e.detail.popupId||e.detail.popupData['sgpb-content-click']=='undefined'){
return false;
}
if(contentClickBehavior=='redirect'){
jQuery('.sgpb-content-'+popupId).addClass('sgpb-cursor-pointer');
}
jQuery('.sgpb-content-'+e.detail.popupId).on('click', function(event){
var settings={
popupId: popupId,
eventName: 'sgpbPopupContentClick'
};
jQuery(window).trigger('sgpbPopupContentClick', settings);
if(contentClickBehavior=='redirect'){
if(redirectToNewTab){
window.open(redirectUrl);
SGPBPopup.closePopupById(that.getPopupId());
return;
}
window.location=redirectUrl;
SGPBPopup.closePopupById(that.getPopupId());
}
else if(contentClickBehavior=='copy'){
var exceptionList=['input', 'textarea', 'select', 'button', 'a'];
var targetName=event.target.tagName.toLowerCase();
var parentTagName=event.target.parentNode.tagName.toLowerCase();
var parentsIsInExceptionsList=that.findTargetInsideExceptionsList(event.target, exceptionList);
if(exceptionList.indexOf(targetName)==-1&&!parentsIsInExceptionsList){
that.contentCopyToClick();
if(closePopupAfterCopy){
SGPBPopup.closePopupById(that.getPopupId());
}
if(clipboardAlert){
alert(popupData['sgpb-copy-to-clipboard-message'])
}}
}
else if(popupData['sgpb-disable-popup-closing']!='on'){
SGPBPopup.closePopupById(that.getPopupId());
}});
});
sgAddEvent(window, 'sgpbDidClose', function(e){
});
};
SGPBPopup.prototype.addFixedPosition=function(){
var popupData=this.getPopupData();
var popupId=this.getPopupId();
var popupConfig=this.getPopupConfig();
var fixedPosition=popupData['sgpb-popup-fixed-position'];
var positionRight='';
var positionTop='';
var positionBottom='';
var positionLeft='';
if(fixedPosition==1){
positionTop=40;
positionLeft=20;
}
else if(fixedPosition==2){
positionLeft='center';
positionTop=40;
}
else if(fixedPosition==3){
positionTop=40;
positionRight=20;
}
else if(fixedPosition==4){
positionTop='center';
positionLeft=20;
}
else if(fixedPosition==6){
positionTop='center';
positionRight=20;
}
else if(fixedPosition==7){
positionLeft=20;
positionBottom=2;
}
else if(fixedPosition==8){
positionLeft='center';
positionBottom=2;
}
else if(fixedPosition==9){
positionRight=20;
positionBottom=2;
}
if(typeof SgpbRecentSalesPopupType!='undefined'){
if(popupData['sgpb-type']==SgpbRecentSalesPopupType){
if(positionTop!=''){
positionTop=parseInt(positionTop+10);
}
else if(positionBottom!=''){
positionBottom=parseInt(positionBottom+10);
}}
}
popupConfig.magicCall('setPositionTop', positionTop);
popupConfig.magicCall('setPositionRight', positionRight);
popupConfig.magicCall('setPositionBottom', positionBottom);
popupConfig.magicCall('setPositionLeft', positionLeft);
};
SGPBPopup.prototype.setPopupDimensions=function(){
var popupData=this.getPopupData();
var popupConfig=this.getPopupConfig();
var popupId=this.getPopupId();
var dimensionData=popupData['sgpb-popup-dimension-mode'];
var maxWidth=popupData['sgpb-max-width'];
var maxHeight=popupData['sgpb-max-height'];
var minWidth=popupData['sgpb-min-width'];
var minHeight=popupData['sgpb-min-height'];
var contentPadding=popupData['sgpb-content-padding'];
var popupType=popupData['sgpb-type'];
popupConfig.magicCall('setMaxWidth', maxWidth);
popupConfig.magicCall('setMaxHeight', maxHeight);
popupConfig.magicCall('setMinWidth', minWidth);
popupConfig.magicCall('setMinHeight', minHeight);
if(popupType=='image'){
popupConfig.magicCall('setContentBackgroundImage', popupData['sgpb-image-url']);
popupConfig.magicCall('setContentBackgroundMode', 'contain');
if(dimensionData=='customMode'){
popupConfig.magicCall('setContentBackgroundPosition', 'center center');
}}
if(dimensionData=='responsiveMode'){
var dimensionMeasure=popupData['sgpb-responsive-dimension-measure'];
if(popupType=='image'&&dimensionMeasure!='fullScreen'){
popupConfig.magicCall('setContentBackgroundMode', 'fit');
this.setMaxWidthForResponsiveImage();
}
var popupConfig=this.getPopupConfig();
if(dimensionMeasure!='auto'){
popupConfig.magicCall('setWidth', dimensionMeasure+'%');
popupConfig.magicCall('setContentBackgroundPosition', 'center');
}else{
var widthToSet=jQuery('.sgpb-popup-builder-content-'+popupId).width() + (contentPadding*2);
if(isNaN(widthToSet)){
widthToSet='auto';
}else{
popupConfig.magicCall('setContentBackgroundPosition', 'center center');
widthToSet +='px';
}
popupConfig.magicCall('setWidth', widthToSet);
if(dimensionMeasure=='fullScreen'){
popupConfig.magicCall('setHeight', widthToSet);
}}
return popupConfig;
}
var popupWidth=popupData['sgpb-width'];
var popupHeight=popupData['sgpb-height'];
popupConfig.magicCall('setWidth', popupWidth);
popupConfig.magicCall('setHeight', popupHeight);
return popupConfig;
};
SGPBPopup.prototype.setMaxWidthForResponsiveImage=function(){
var popupData=this.getPopupData();
var popupConfig=this.getPopupConfig();
var dimensionMeasure=popupData['sgpb-responsive-dimension-measure'];
if(dimensionMeasure!='auto'){
var maxWidth=popupData['sgpb-max-width'];
if(maxWidth==''){
popupConfig.magicCall('setMaxWidth', dimensionMeasure+'%');
return true;
}
popupConfig.magicCall('setMaxWidth', dimensionMeasure+'%');
if(maxWidth.indexOf('%')!='-1'){
if(parseInt(maxWidth) < dimensionMeasure){
popupConfig.magicCall('setMaxWidth', maxWidth);
}}else{
var responsiveMeasureInPx=(dimensionMeasure*window.innerWidth)/100;
if(maxWidth < responsiveMeasureInPx){
popupConfig.magicCall('setMaxWidth', maxWidth);
}}
}};
SGPBPopup.JSONParse=function(data){
return JSON.parse(atob(data, true));
};
SGPBPopup.b64DecodeUnicode=function(str){
var Base64={
_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
decode:function (input){
var output="";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i=0;
input=input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length){
enc1=this._keyStr.indexOf(input.charAt(i++));
enc2=this._keyStr.indexOf(input.charAt(i++));
enc3=this._keyStr.indexOf(input.charAt(i++));
enc4=this._keyStr.indexOf(input.charAt(i++));
chr1=(enc1 << 2) | (enc2 >> 4);
chr2=((enc2 & 15) << 4) | (enc3 >> 2);
chr3=((enc3 & 3) << 6) | enc4;
output +=String.fromCharCode(chr1);
if(enc3!=64){
output +=String.fromCharCode(chr2);
}
if(enc4!=64){
output +=String.fromCharCode(chr3);
}}
output=Base64._utf8_decode(output);
return output;
},
_utf8_decode:function (utftext){
var string="";
var i=0;
var c=c1=c2=0;
while (i < utftext.length){
c=utftext.charCodeAt(i);
if(c < 128){
string +=String.fromCharCode(c);
i++;
}
else if((c > 191)&&(c < 224)){
c2=utftext.charCodeAt(i+1);
string +=String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i +=2;
}else{
c2=utftext.charCodeAt(i+1);
c3=utftext.charCodeAt(i+2);
string +=String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i +=3;
}}
return string;
}};
return Base64.decode(str);
};
SGPBPopup.unserialize_old=function(data){
data=SGPBPopup.b64DecodeUnicode(data);
var $global=(typeof window!=='undefined' ? window:global);
var utf8Overhead=function(str){
var s=str.length;
for (var i=str.length - 1; i >=0; i--){
var code=str.charCodeAt(i);
if(code > 0x7f&&code <=0x7ff){
s++;
}
else if(code > 0x7ff&&code <=0xffff){
s +=2;
}
if(code >=0xDC00&&code <=0xDFFF){
i--;
}}
return s - 1;
};
var error=function(type, msg, filename, line){
throw new $global[type](msg, filename, line);
};
var readUntil=function(data, offset, stopchr){
var i=2;
var buf=[];
var chr=data.slice(offset, offset + 1);
while (chr!==stopchr){
if((i + offset) > data.length){
error('Error', 'Invalid');
}
buf.push(chr);
chr=data.slice(offset + (i - 1), offset + i);
i +=1;
}
return [buf.length, buf.join('')];
};
var readChrs=function(data, offset, length){
var i, chr, buf;
buf=[];
for (i=0; i < length; i++){
chr=data.slice(offset + (i - 1), offset + i);
buf.push(chr);
length -=utf8Overhead(chr);
}
return [buf.length, buf.join('')];
};
function _unserialize(data, offset){
var dtype;
var dataoffset;
var keyandchrs;
var keys;
var contig;
var length;
var array;
var readdata;
var readData;
var ccount;
var stringlength;
var i;
var key;
var kprops;
var kchrs;
var vprops;
var vchrs;
var value;
var chrs=0;
var typeconvert=function(x){
return x
};
if(!offset){
offset=0
}
dtype=(data.slice(offset, offset + 1)).toLowerCase();
dataoffset=offset + 2;
switch (dtype){
case 'i':
typeconvert=function(x){
return parseInt(x, 10);
};
readData=readUntil(data, dataoffset, ';');
chrs=readData[0];
readdata=readData[1];
dataoffset +=chrs + 1;
break;
case 'b':
typeconvert=function(x){
return parseInt(x, 10)!==0;
};
readData=readUntil(data, dataoffset, ';');
chrs=readData[0];
readdata=readData[1];
dataoffset +=chrs + 1;
break;
case 'd':
typeconvert=function(x){
return parseFloat(x);
};
readData=readUntil(data, dataoffset, ';');
chrs=readData[0];
readdata=readData[1];
dataoffset +=chrs + 1;
break;
case 'n':
readdata=null;
break;
case 's':
ccount=readUntil(data, dataoffset, ':');
chrs=ccount[0];
stringlength=ccount[1];
dataoffset +=chrs + 2;
readData=readChrs(data, dataoffset + 1, parseInt(stringlength, 10));
chrs=readData[0];
readdata=readData[1];
dataoffset +=chrs + 2;
if(chrs!==parseInt(stringlength, 10)&&chrs!==readdata.length){
error('SyntaxError', 'String length mismatch')
}
break;
case 'a':
readdata={};
keyandchrs=readUntil(data, dataoffset, ':');
chrs=keyandchrs[0];
keys=keyandchrs[1];
dataoffset +=chrs + 2;
length=parseInt(keys, 10);
contig=true;
for (i=0; i < length; i++){
kprops=_unserialize(data, dataoffset);
kchrs=kprops[1];
key=kprops[2];
dataoffset +=kchrs;
vprops=_unserialize(data, dataoffset);
vchrs=vprops[1];
value=vprops[2];
dataoffset +=vchrs;
if(key!==i){
contig=false;
}
readdata[key]=value;
}
if(contig){
array=new Array(length);
for (i=0; i < length; i++){
array[i]=readdata[i];
}
readdata=array;
}
dataoffset +=1;
break;
default:
error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
break;
}
return [dtype, dataoffset - offset, typeconvert(readdata)]
}
return _unserialize((data + ''), 0)[2];
};
SGPBPopup.closePopup=function(){
var popupObjs=window.sgPopupBuilder;
var lastPopupObj=this.getLastPopup();
if(typeof lastPopupObj=='undefined'){
return false;
}
var popupId=lastPopupObj.popupId;
SGPBPopup.closePopupById(popupId);
};
SGPBPopup.closePopupById=function(popupId){
var popupObjs=window.sgPopupBuilder;
if(!popupObjs.length){
return;
}
for (var i in popupObjs){
var currentObj=popupObjs[i];
if(currentObj.popupId==popupId){
var popupObj=popupObjs[i]['popup'];
if(popupObj){
popupObj.close(true);
}}
}};
SGPBPopup.getPopupWindowDataById=function(popupId){
var popups=window.sgPopupBuilder;
var popup=false;
if(typeof popups=='undefined'||!popups.length){
return popup;
}
for (var i in popups){
var popupData=popups[i];
if(popupData.popupId==popupId){
popup=popupData;
break;
}}
return popup;
};
SGPBPopup.findPopupObjById=function(popupId){
var popup=false;
var popupData=SGPBPopup.getPopupWindowDataById(popupId);
if(popupData){
popup=popupData['popup'];
}
return popup;
};
SGPBPopup.getLastPopup=function(){
var popups=window.sgPopupBuilder;
var popup=false;
if(!popups.length){
return popup;
}
var searchPopups=[].concat(popups);
for (var i in searchPopups){
var popupData=searchPopups[i];
if(popupData.isOpen){
popup=popupData;
break;
}}
return popup;
};
SGPBPopup.offPopup=function(currentPopup){
var popups=window.sgPopupBuilder;
if(!popups.length){
return false;
}
for (var i in popups){
var popupData=popups[i];
if(popupData.order==currentPopup.order&&popupData.eventName==currentPopup.eventName){
popups[i]['isOpen']=false;
break;
}}
return true;
};
SGPBPopup.capitalizeFirstLetter=function(string){
return string.charAt(0).toUpperCase() + string.slice(1);
};
SGPBPopup.getParamFromUrl=function(param){
var url=window.location.href;
param=param.replace(/[\[\]]/g, "\\$&");
var regex=new RegExp("[?&]" + param + "(=([^&#]*)|&|#|$)"),
results=regex.exec(url);
if(!results){
return null;
}
if(!results[2]){
return '';
}
return decodeURIComponent(results[2].replace(/\+/g, " "));
};
SGPBPopup.setCookie=function(cName, cValue, exDays, cPageLevel){
var sameSite='Lax';
var isPreview=SGPBPopup.getParamFromUrl('preview');
if(isPreview){
return false;
}
var expirationDate=new Date();
var cookiePageLevel='';
var cookieExpirationData=1;
if(!exDays||isNaN(exDays)){
if(!exDays&&exDays===0){
exDays='session';
}else{
exDays=365*50;
}}
if(!Boolean(cPageLevel)){
cookiePageLevel='path=/;';
}
if(exDays=='session'){
cookieExpirationData=0;
}else{
expirationDate.setDate(parseInt(expirationDate.getDate() + parseInt(exDays)));
cookieExpirationData=expirationDate.toUTCString();
}
var expires='expires='+cookieExpirationData;
if(exDays==-1){
expires='';
}
if(!cookieExpirationData){
expires='';
}
if(SGPBPopup.isIE()){
cookiePageLevel='';
}
var value=cValue+((exDays==null) ? ';':'; '+expires+';'+cookiePageLevel+'; SameSite=' + sameSite);
document.cookie=cName + '=' + value;
};
SGPBPopup.isIE=function(){
ua=navigator.userAgent;
var isIe=ua.indexOf('MSIE ') > -1||ua.indexOf('Trident/') > -1;
return isIe;
};
SGPBPopup.getCookie=function(cName){
var name=cName + '=';
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);
}
if(c.indexOf(name)==0){
return c.substring(name.length, c.length);
}}
return '';
};
SGPBPopup.deleteCookie=function(cName, cPath){
if(!cPath){
cPath='path=/;';
}
document.cookie=cName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;' + cPath;
};
function SgpbEventListener(){
this.evenets=null;
this.popupObj={};}
SgpbEventListener.inactivityIdicator=0;
SgpbEventListener.prototype.setEvents=function(events){
this.evenets=events;
};
SgpbEventListener.prototype.getEvents=function(){
return this.evenets;
};
SgpbEventListener.prototype.setPopupObj=function(popupObj){
this.popupObj=popupObj;
};
SgpbEventListener.prototype.getPopupObj=function(){
return this.popupObj;
};
SgpbEventListener.eventsListenerAfterDocumentReady=function(){
window.SGPB_SOUND=[];
sgAddEvent(window, 'sgpbDidOpen', function(e){
const pbsgsoundnotification=document.querySelector("#pbsgsoundnotification");
if(pbsgsoundnotification){
pbsgsoundnotification.addEventListener("click", ()=> {
SGPBPopup.playMusic(e);
pbsgsoundnotification.classList.add("fade");
});
}});
sgAddEvent(window, 'sgpbDidClose', function(e){
var args=e.detail;
var popupId=parseInt(args.popupId);
if(typeof window.SGPB_SOUND[popupId]&&window.SGPB_SOUND[popupId]){
window.SGPB_SOUND[popupId].pause();
delete window.SGPB_SOUND[popupId];
}});
};
SgpbEventListener.init=function(){
SgpbEventListener.eventsListenerAfterDocumentReady();
var popupsData=jQuery('.sg-popup-builder-content');
if(!popupsData){
return '';
}
var that=this;
popupsData.each(function(){
var popupObj=that.popupObjCreator(jQuery(this));
SGPBPopup.floatingButton(popupObj);
});
};
SgpbEventListener.popupObjCreator=function(currentData){
var popupId=currentData.data('id');
var popupData=currentData.data('options');
var events=currentData.attr('data-events');
events=jQuery.parseJSON(events);
SgpbEventListener.reopenAfterFormSubmission(popupData);
var popupObj=new SGPBPopup();
popupObj.setPopupId(popupId);
popupObj.setPopupData(popupData);
for (var i in events){
var obj=new this;
obj.setPopupObj(popupObj);
obj.eventListener(events[i]);
}
return popupObj;
};
SgpbEventListener.prototype.eventListener=function(eventData){
if(eventData==null){
return '';
}
var event='';
if(typeof eventData=='string'){
event=eventData;
}
else if(typeof eventData.param!='undefined'){
event=eventData.param;
}
if(!event){
return false;
}
var popupObj=this.getPopupObj();
var popupData=popupObj.getPopupData();
if(eventData.value==''){
eventData.value=popupData['sgpb-popup-delay'];
}
var eventName=SGPBPopup.capitalizeFirstLetter(event);
eventName='sgpb'+eventName;
popupObj.eventName=eventName;
var allowToOpen=popupObj.forceCheckCurrentPopupType(popupObj);
if(!allowToOpen){
return false;
}
try {
eval('this.'+eventName)(this, eventData);
}
catch (err){
console.log(err)
}};
SgpbEventListener.reopenAfterFormSubmission=function(eventData){
var popupId=SGPBPopup.getCookie('SGPBSubmissionReloadPopup');
popupId=parseInt(popupId);
if(!popupId){
return false;
}
var popupObj=SGPBPopup.createPopupObjById(popupId);
if(!popupObj){
return false;
}
var options=popupObj.getPopupData();
if(!options['sgpb-reopen-after-form-submission']){
return false;
}
popupObj.prepareOpen();
SGPBPopup.deleteCookie('SGPBSubmissionReloadPopup');
};
SgpbEventListener.prototype.sgpbLoad=function(listenerObj, eventData){
var timeout=parseInt(eventData.value);
var popupObj=listenerObj.getPopupObj();
var popupOptions=popupObj.getPopupData();
timeout *=1000;
var timerId,
repetitiveTimeout=null;
popupObj.forceCheckCurrentPopupType(popupObj);
var openOnLoadPopup=function(){
setTimeout(function(){
jQuery(window).trigger('sgpbLoadEvent', popupOptions);
popupObj.prepareOpen();
}, timeout);
};
sgAddEvent(window, 'load', openOnLoadPopup(timeout, popupObj));
sgAddEvent(window, 'sgpbDidOpen', function(e){
var args=e.detail;
clearInterval(repetitiveTimeout);
});
sgAddEvent(window, 'sgpbDidClose', function(e){
var args=e.detail;
var options=popupObj.getPopupData();
if(SGPBPopup.varToBool(eventData['repetitive'])){
var intervalTime=parseInt(eventData['value'])*1000;
repetitiveTimeout=setInterval(function(){
popupObj.prepareOpen();
}, intervalTime);
}});
};
SgpbEventListener.prototype.timerIncrement=function(listenerObj , idleInterval){
var lastActivity=SgpbEventListener.inactivityIdicator;
if(lastActivity==0){
clearInterval(idleInterval);
listenerObj.getPopupObj().prepareOpen();
}
SgpbEventListener.inactivityIdicator=0;
};
SgpbEventListener.prototype.sgpbInsideclick=function(listenerObj, eventData){
sgAddEvent(window, 'sgpbDidOpen', function(e){
var args=e.detail;
var that=listenerObj;
var popupObj=that.getPopupObj();
var popupId=parseInt(popupObj.id);
var targetClick=jQuery('.sgpb-content .sgpb-popup-id-'+popupId);
if(!targetClick.length){
return false;
}
targetClick.each(function(){
jQuery(this).unbind('click').bind('click', function(){
var dontCloseCurrentPopup=jQuery(this).attr('dontCloseCurrentPopup');
if(typeof dontCloseCurrentPopup=='undefined'||dontCloseCurrentPopup!='on'){
SGPBPopup.closePopup();
}
popupObj.prepareOpen();
});
});
});
};
SgpbEventListener.prototype.sgpbClick=function(listenerObj, eventData){
var that=listenerObj;
var popupIds=[];
var popupObj=that.getPopupObj();
var popupOptions=popupObj.getPopupData();
var popupId=parseInt(popupObj.id);
popupIds.push(popupId);
var mapId=listenerObj.filterPopupId(popupId);
popupIds.push(mapId);
if(jQuery.inArray(mapId, popupIds)===-1){
popupIds.push(mapId);
}
for(var key in popupIds){
var popupId=popupIds[key];
if(!popupIds.hasOwnProperty(key)){
return false;
}
var targetClick=jQuery('a[href*="#sg-popup-id-' + popupId + '"], .sg-popup-id-' + popupId + ', .sgpb-popup-id-' + popupId);
if(typeof eventData.operator!='undefined'&&eventData.operator=='clickActionCustomClass'){
targetClick=jQuery('a[href*="#sg-popup-id-' + popupId + '"], .sg-popup-id-' + popupId + ', .sgpb-popup-id-' + popupId+', .'+eventData.value);
}
if(!targetClick.length){
continue;
}
var delay=parseInt(popupOptions['sgpb-popup-delay']) * 1000;
var clickCount=1;
targetClick.each(function(){
if(!jQuery(this).attr('data-popup-id')){
jQuery(this).attr('data-popup-id', popupId);
}
var currentTarget=jQuery(this);
currentTarget.bind('swipe', function(e){
return false;
});
currentTarget.bind('click', function(e){
if(clickCount > 1){
return true;
}
var allowToOpen=popupObj.forceCheckCurrentPopupType(popupObj);
if(!allowToOpen){
return true;
}
++clickCount;
jQuery(window).trigger('sgpbClickEvent', popupOptions);
var popupId=jQuery(this).data('popup-id');
setTimeout(function(){
var popupObj=SGPBPopup.createPopupObjById(popupId);
if(!popupObj){
var mapId=listenerObj.filterPopupId(popupId);
popupObj=SGPBPopup.createPopupObjById(mapId);
}
popupObj.customEvent='Click';
popupObj.prepareOpen();
clickCount=1;
}, delay);
return false;
});
});
}};
SgpbEventListener.prototype.sgpbHover=function(listenerObj, eventData){
var that=listenerObj;
var popupObj=that.getPopupObj();
if(!popupObj){
return false;
}
var popupIds=[];
var popupOptions=popupObj.getPopupData();
var popupId=parseInt(popupObj.id);
popupIds.push(popupId);
var mapId=listenerObj.filterPopupId(popupId);
if(jQuery.inArray(mapId, popupIds)===-1){
popupIds.push(mapId);
}
for(var key in popupIds){
var popupId=popupIds[key];
if(!popupIds.hasOwnProperty(key)){
return false;
}
var hoverSelector=jQuery('.sg-popup-hover-' + popupId + ', .sgpb-popup-id-' + popupId + '[data-popup-event="hover"]');
if(typeof eventData.operator!='undefined'&&eventData.operator=='hoverActionCustomClass'){
hoverSelector=jQuery('.sg-popup-hover-' + popupId + ', .sgpb-popup-id-' + popupId + '[data-popup-event="hover"]'+', .'+eventData.value);
}
if(!hoverSelector){
return false;
}
var hoverCount=1;
var delay=parseInt(popupOptions['sgpb-popup-delay']) * 1000;
hoverSelector.each(function (){
if(!jQuery(this).attr('data-popup-id')){
jQuery(this).attr('data-popup-id', popupId);
}
jQuery(this).bind('mouseenter', function(){
if(hoverCount > 1){
return false;
}
++hoverCount;
var popupId=jQuery(this).data('popup-id');
jQuery(window).trigger('sgpbHoverEvent', popupOptions);
setTimeout(function(){
var popupObj=SGPBPopup.createPopupObjById(popupId);
if(!popupObj){
var mapId=listenerObj.filterPopupId(popupId);
popupObj=SGPBPopup.createPopupObjById(mapId);
}
popupObj.customEvent='Hover';
popupObj.prepareOpen();
hoverCount=1;
}, delay);
});
});
}};
SgpbEventListener.prototype.sgpbConfirm=function(listenerObj, eventData){
var that=listenerObj;
var popupObj=that.getPopupObj();
if(!popupObj){
return false;
}
var popupIds=[];
var popupOptions=popupObj.getPopupData();
var popupId=parseInt(popupObj.id);
popupIds.push(popupId);
var mapId=listenerObj.filterPopupId(popupId);
popupIds.push(mapId);
for(var key in popupIds){
var popupId=popupIds[key];
if(!popupIds.hasOwnProperty(key)){
return false;
}
var confirmSelector=jQuery('.sg-confirm-popup-' + popupId);
if(!confirmSelector){
return false;
}
var confirmCount=1;
confirmSelector.bind('click', function(e){
if(confirmCount > 1){
return false;
}
++confirmCount;
var allowToOpen=popupObj.forceCheckCurrentPopupType(popupObj);
if(!allowToOpen){
return true;
}
jQuery(window).trigger('sgpbConfirmEvent', popupOptions);
var target=jQuery(this).attr('target');
if(typeof target=='undefined'){
target='self';
}
var href=jQuery(this).attr('href');
var delay=parseInt(popupOptions['sgpb-popup-delay']) * 1000;
setTimeout(function(){
if(typeof href!='undefined'){
popupOptions['sgpb-confirm-' + popupId]={'target':target, 'href':href};
popupObj.setPopupData(popupOptions);
}
popupObj.prepareOpen();
confirmCount=1;
}, delay);
return false;
});
sgAddEvent(window, 'sgpbDidClose', function(e){
var args=e.detail;
var popupId=parseInt(args.popupId);
var popupOptions=args.popupData;
if(typeof popupOptions['sgpb-confirm-' + popupId]!='undefined'){
var confirmAgrs=popupOptions['sgpb-confirm-' + popupId];
if(confirmAgrs['target']=='_blank'){
window.open(confirmAgrs['href']);
}else{
window.location.href=confirmAgrs['href'];
}
delete popupOptions['sgpb-confirm-' + popupId];
popupObj.setPopupData(popupOptions);
}});
}};
SgpbEventListener.prototype.sgpbAttronload=function(listenerObj, eventData){
var that=listenerObj;
var popupObj=that.getPopupObj();
var popupId=parseInt(popupObj.id);
popupId=listenerObj.filterPopupId(popupId);
var popupOptions=popupObj.getPopupData();
var delay=parseInt(popupOptions['sgpb-popup-delay']) * 1000;
jQuery(window).trigger('sgpbAttronloadEvent', popupOptions);
setTimeout(function(){
popupObj.prepareOpen();
}, delay);
};
SgpbEventListener.prototype.filterPopupId=function(popupId){
var convertedIds=SGPB_POPUP_PARAMS.convertedIdsReverse;
var popupNewId=popupId;
if(convertedIds[popupId]){
return convertedIds[popupId];
}else{
for(var i in convertedIds){
if(popupId==convertedIds[i]){
popupNewId=parseInt(i);
break;
}}
}
return popupNewId;
};
SgpbEventListener.findCF7InPopup=function(popupId){
return document.querySelector('#sg-popup-content-wrapper-'+popupId+' .wpcf7');
};
SgpbEventListener.CF7EventListener=function(popupId, options){
var wpcf7Elm=SgpbEventListener.findCF7InPopup(popupId);
if(wpcf7Elm){
wpcf7Elm.addEventListener('wpcf7mailsent', function(event){
var settings={
popupId: popupId,
eventName: 'sgpbCF7Success'
};
jQuery(window).trigger('sgpbCF7Success', settings);
});
}};
SgpbEventListener.processCF7MailSent=function(popupId, options){
var wpcf7Elm=SgpbEventListener.findCF7InPopup(popupId);
if(wpcf7Elm){
wpcf7Elm.addEventListener('wpcf7mailsent', function(event){
if(typeof options['operator']=='undefined'){
return;
}
if(options['operator']=='close-popup'){
setTimeout(function(){
SGPBPopup.closePopupById(popupId);
}, parseInt(options['value'])*1000);
}
else if(options['operator']=='redirect-url'){
window.location.href=options['value'];
}
else if(options['operator']=='open-popup'){
SGPBPopup.closePopupById(popupId);
var popupObj=SGPBPopup.createPopupObjById(Object.keys(options['value'])[0]);
popupObj.prepareOpen();
}}, false);
}};
jQuery(document).ready(function(e){
setTimeout(function(){
SgpbEventListener.init();
SGPBPopup.listeners();
}, 1);
});