!function($){$.fn.bgPhotoFrame=function(setting){function userAgent(){var e,t=navigator.userAgent;return e=t.indexOf("iPhone")>-1||t.indexOf("iPad")>-1||t.indexOf("iPod")>-1?"ios":t.indexOf("Android")>-1?"android":"pc"}function removeUnit(e){return parseInt(e.replace(/([a-z]+)/,""))}function resizeImages(_num,animation,force,callback){var windowWidth=$(window).width(),windowHeight=$(window).height(),windowRatio=windowWidth/windowHeight,_li=element.find("li").eq(_num),_img,arrow;if(force?arrow=!0:"none"!=_li.css("display")&&(arrow=!0),arrow&&_num in imgInfo){_img=_li.find("img");var imgRatio=imgInfo[_num].ratio,baseWidth=imgInfo[_num].width,baseHeight=imgInfo[_num].height,imgWidth,imgHeight,marginTop,marginLeft;_img.stop(!0,!1),"background"==currentMode?windowRatio>imgRatio?(imgWidth=windowWidth,imgHeight=parseInt(baseHeight*(imgWidth/baseWidth)),marginTop=-(imgHeight-windowHeight)/2,marginLeft=0):(imgHeight=windowHeight,imgWidth=parseInt(baseWidth*(imgHeight/baseHeight)),marginTop=0,marginLeft=-(imgWidth-windowWidth)/2):"photoframe"==currentMode&&(windowRatio>=imgRatio?(imgHeight=windowHeight,imgWidth=parseInt(baseWidth*(imgHeight/baseHeight)),marginLeft=(windowWidth-imgWidth)/2,marginTop=0):(imgWidth=windowWidth,imgHeight=parseInt(baseHeight*(imgWidth/baseWidth)),marginLeft=0,marginTop=(windowHeight-imgHeight)/2)),imgWidth=parseInt(imgWidth),imgHeight=parseInt(imgHeight),marginTop=parseInt(marginTop),marginLeft=parseInt(marginLeft),animation?_img.animate({width:imgWidth+"px",height:imgHeight+"px",marginTop:marginTop+"px",marginLeft:marginLeft+"px"},photoAnimeTime,easing,function(){callback&&eval(callback+"()")}):(_img.width(imgWidth),_img.height(imgHeight),_img.css({marginTop:marginTop+"px",marginLeft:marginLeft+"px"}))}}function stopResizeImages(){for(var e=0;e"),maskElement=$("#images-mask"),maskElement.css({background:"rgba("+setting.maskColor+","+setting.maskColor+","+setting.maskColor+","+setting.maskOpacity+")"})}function resizeMask(){maskElement.css({width:$(window).width()+"px",height:$(window).height()+"px"})}function photoFrameMode(){currentMode="photoframe",hideContents()}function backgroundMode(){currentMode="background",modeChangeAnimation(mode)}function showContents(){$(setting.contents).fadeIn(contentFadeTime,function(){contentsAnimationEnd()})}function hideContents(){$(setting.contents).fadeOut(contentFadeTime,function(){contentsAnimationEnd()})}function stopContentsAnimation(){$(setting.contents).stop(!1,!0)}function contentsAnimationEnd(){"photoframe"==currentMode?modeChangeAnimation():"background"==currentMode&&command("modeChangeEnd")}function modeChangeAnimation(e){element.find("li").eq(current).find("img");resizeImages(current,!0,!0,"EndModeChangeAnimation")}function EndModeChangeAnimation(){"photoframe"==currentMode||"background"==currentMode&&showContents(),changeToggleBtnIcon(),command("modeChangeEnd")}function stopModeChangeAnimation(){stopContentsAnimation()}function initToggle(){controls.append(toggleButtonSrc),toggleButton=$("#"+toggleBtnId),"pc"==device?toggleButton.click(function(){return command("modeChange"),!1}):toggleButton.bind("touchstart",function(e){command("modeChange"),e.preventDefault()})}function changeToggleBtnIcon(){$("#"+toggleBtnId).find("span").removeClass(iconClassPhotoFrame),$("#"+toggleBtnId).find("span").removeClass(iconClassBlog),"background"==currentMode?($("#"+toggleBtnId).find("span.glyphicon").addClass(iconClassPhotoFrame),$("#"+toggleBtnId).find("span.screen-reader-text").html("Swich to Photoframe Mode")):"photoframe"==currentMode&&($("#"+toggleBtnId).find("span.glyphicon").addClass(iconClassBlog),$("#"+toggleBtnId).find("span.screen-reader-text").html("Swich to Background Mode"))}function initNav(){element.find("li").length&&(controls.append('Change the Previous Image'),controls.append('Change the Next Image'),"pc"==device?$("."+navPrefix).click(function(){return navClick($(this)),!1}):$("."+navPrefix).bind("touchstart",function(e){navClick($(this)),e.preventDefault()}),$(window).resize(function(){resizeNav()}),nav=$("."+navPrefix))}function navClick(e){if(btnEnable&&nav.hasClass("active")){var e=e.attr("id").replace(navPrefix+"-","");command("imgChange",e)}}function showNav(){nav.stop(!1,!0),nav.fadeIn(fadeTime,function(){nav.addClass("active")}),navPosition()}function hideNav(){nav.removeClass("active"),nav.stop(!1,!0),nav.fadeOut()}function stopNav(){}function resizeNav(){navPosition()}function navPosition(){var e=($(window).height()-nav.width())/2;$("#"+navPrefix+"-prev, #"+navPrefix+"-next").css({top:e+"px"})}function initThumbs(){controls.append('Open Image Thumbnails List'),thumbBtn=$("#"+thumbBtnClass),controls.append('
    '),thumbPage=$("#"+thumbPageClass+" ul");for(var e=0;e'+t+"";thumbPage.append(n)}"pc"==device?thumbBtn.click(function(){return toggleThumbBtn(),!1}):thumbBtn.bind("touchstart",function(e){toggleThumbBtn(),e.preventDefault()}),$("#"+thumbPageClass).bind("click",function(){return closeThumbs(),!1})}function attachThumbImage(e,t){var n=thumbPage.find("li").eq(e).find("a"),i=new Image;i.src=t,imgWidth=imgInfo[e].width,imgHeight=imgInfo[e].height,imgRatio=imgInfo[e].ratio,thumbSize=thumbPage.find("li").width();var a,r,o=document.createElement("canvas"),s=o.getContext("2d"),m=0,d=0;imgRatio>1?(r=thumbSize,a=thumbSize*imgRatio,m=(thumbSize-thumbSize*imgRatio)/2):(a=thumbSize,r=imgHeight*(thumbSize/a),d=(thumbSize-thumbSize/imgRatio)/2),s.drawImage(i,m,d,a,r),n.append(o),n.click(function(){return ThumbClick(n),!1})}function resizeThumbs(){var e=$(window).width(),t=($(window).height(),.02*$(window).width());$("#"+thumbPageClass+"-inner").css({width:e+"px",padding:t+"px "+t+"px"});var n=thumbPage.find("li").width(),i=removeUnit(thumbPage.find("li").css("margin")),a=($("#"+thumbPageClass+" ul").width()-(n+2*i)*parseInt($("#"+thumbPageClass+" ul").width()/(2*i+n)))/2;$("#"+thumbPageClass+" ul").css({marginLeft:a+"px"})}function showThumbBtn(){thumbBtn.stop(!1,!0),thumbBtn.fadeIn(fadeTime)}function hideThumbBtn(){thumbBtn.stop(!1,!0),thumbBtn.fadeOut(fadeTime)}function toggleThumbBtn(){thumbBtn.toggleClass("active"),toggleThumbs()}function toggleThumbs(){thumbAnimationStop(),thumbBtn.hasClass("active")?openThumbs():closeThumbs()}function thumbAnimationStop(){$("#"+thumbPageClass).stop(!1,!0)}function openThumbs(){$("#"+thumbPageClass).show(),$("#"+thumbPageClass).animate({width:"100%",height:"100%"},thumbTime,easing)}function closeThumbs(){$("#"+thumbPageClass).animate({width:"0%",height:"0%"},thumbTime,easing,function(){$("#"+thumbPageClass).hide()}),thumbBtn.removeClass("active")}function ThumbClick(e){var t=e.attr("href").replace("#","");command("imgChange",t),closeThumbs()}function initTimer(){if(setting.autoChange&&element.find("li").length){var e='Disable Auto Change Images';controls.append(e),timerBtn=$("#"+timerBtnId),setting.autoChange&&element.find("li").length&&timerBtn.addClass("on"),"pc"==device?timerBtn.click(function(){return toggleTimer(),!1}):timerBtn.bind("touchend",function(e){toggleTimer(),e.preventDefault()})}}function toggleTimer(){timerBtn.toggleClass("on"),timerBtn.hasClass("on")?timerOn():timerOff()}function timerOn(){timerBtn.addClass("on"),timer.setTimer(),$("#"+timerBtnId).find("span.screen-reader-text").html("Disable Auto Change Images")}function timerOff(){timerBtn.removeClass("on"),timer.disableTimer(),$("#"+timerBtnId).find("span.screen-reader-text").html("Enable Auto Change Images")}function enableTimer(){timerArr.push(setTimeout(function(){timerChange()},setting.autoTimer))}function timerChange(){command("timerChange")}function showTimer(){timerBtn.stop(!1,!0),timerBtn.fadeIn(),timerBtn.addClass("active")}function hideTimer(){timerBtn.removeClass("active"),timerBtn.stop(!1,!0),timerBtn.fadeOut()}function setImageSize(e){var t=element.find("img").eq(e),n=(t.attr("src"),getImageTrueSize(t));n.ratio=n.width/n.height,imgInfo[e].width=n.width,imgInfo[e].height=n.height,imgInfo[e].ratio=n.ratio,imgInfo[e].loaded=!0,checkLoadComplete(e)}function getImageTrueSize(e){var t=[];if(e.prop("naturalWidth"))t.width=e.prop("naturalWidth"),t.height=e.prop("naturalHeight");else{var n=new Image;n.src=e.attr("src"),t.width=n.width,t.height=n.height}return t}function checkLoadComplete(e){var t=!0;if(0==e)LoadFirstImageComplete();else for(var n=0;nt;t++){var n=element.find("li").eq(t);n.stop(!1,!0)}}function transitionFadeEnd(){command("transitionEnd")}function swipeLoop(e,t){var n=easing,i=swipeSpeed;removeUnit(wrapper.css("marginLeft"));i=setSpeed(e,t),setSwipePosition(e,t),setSwipeImage(e,t),wrapper.animate({marginLeft:0},i,n,function(){swipeEnd(e,t)}),swipeAnmation=!0}function setSwipePosition(e,t){var n=0,i=removeUnit(wrapper.css("marginLeft"));"current"==t?n=removeUnit(wrapper.css("marginLeft")):"next"==t?n=$(window).width()+i:"prev"==t&&(n=-$(window).width()+i),wrapper.css({marginLeft:n+"px"})}function setSwipeImage(e,t){var n=element.find("li").eq(e);command("setSwipeImage",e),n.css({display:"block",marginLeft:0}),element.find("li:not(:eq("+e+"))").css({display:"none"})}function setSpeed(e,t){var n=0,i=1,a=removeUnit(wrapper.css("marginLeft"));return n=a>=0?($(window).width()-a)*i:($(window).width()+a)*i}function swipeEnd(e,t){swipeLoopStop(),command("swipeEnd")}function swipeLoopStop(){wrapper.stop(!0,!1),swipeAnmation=!1}function swipeDown(e){"photoframe"==currentMode&&(swipeLoopStop(),swipeActive=!0,swipeDistance=0,swipeSpeed=0,setSwipePosition(current,"current"),setSwipeImage(current,"current"),swipeActiveStart=e,swipeSpeedStart=e,swipeStartMargin=removeUnit(wrapper.css("marginLeft")),swipeSpeedTimer.push(setInterval(function(){setSwipeSpeed()},swipeSpeedTimerSpan)),command("swipeDown"))}function setSwipeSpeed(){swipeSpeed=swipeSpeedStart-swipeSpeedCurrent,swipeSpeedStart=swipeSpeedCurrent}function swipeMove(e){if(swipeActive){swipeLoopStop(),swipeDistance=e-swipeActiveStart,swipeSpeedCurrent=e;var t=swipeStartMargin+swipeDistance;wrapper.css({marginLeft:t+"px"})}}function swipeUp(e){if(swipeActive){swipeLoopStop();for(var t=0;tswipeSpeedLimit||-swipeSpeedLimit>swipeSpeed?n=swipeSpeed>0?"next":"prev":(i>$(window).width()/2||i<-$(window).width()/2)&&(n=0>i?"next":"prev"),n&&command("imgChange",n),command("swipeUp"),swipeDistance=0}swipeActive=!1}function initDammy(){element.after('
      '),dammyElement=$(".bg-photo-frame-dammy"),dammyElement.css({margin:"0px",padding:"0px",position:"absolute",display:"block",width:"100%"})}function dammyShow(e,t,n){command("setDammy",e);var i,a=element.find("li").eq(e).find("img"),r=a.width(),o=a.height(),s=a.css("marginTop");removeUnit(wrapper.css("marginLeft"));"left"==n?i=-$(window).width()*(t+1)+($(window).width()-r)/2:"right"==n&&(i=$(window).width()*(t+1)+($(window).width()-r)/2);var m=a.attr("src"),d=a.attr("alt"),c=$("
    • ");c.find("img").attr("src",m),c.find("img").attr("alt",d),c.addClass("bg-photo-frame-dammy-list").addClass("bg-photo-frame-dammy-"+n),c.css({width:"100%",position:"absolute",listStyle:"none"}),c.find("img").css({width:r+"px",height:o+"px",marginTop:s,marginLeft:i+"px"}),dammyElement.append(c)}var defaluts={suffle:!1,width:"100%",height:"auto",minHeight:"none",maxHeight:"none",autoChange:!0,autoTimer:4e3,interfaceTimer:!0,fadeSpeed:1e3,shuffle:!1,gradationColor:"0,0,0",callbackBefore:null,callbackAfter:null,callbackChange:null,photoFrame:!1,stopWhenClicked:!0,contents:"",maskColor:"light",maskOpacity:.7,controls:""};if(setting=$.extend(defaluts,setting),this.length){var element=this,wrapper,controls,parent=element.parent(),num=element.find("li").length,imgInfo=[],current=0,previous=0,timer=[],device=userAgent(),loaded=!1,breakPoint=782,btnEnable=!0,clicked=!1,prefix="bg-photo-frame",easing="easeOutCubic",fadeTime=1e3;if(setting.callbackBefore&&window[setting.callbackBefore].apply(),element.find("li").length){if(element.wrap("
      "),wrapper=$("#bg-photo-frame-images-wrapper"),""!=setting.controls?controls=$(setting.controls):($("body").prepend("
      "),controls=$("#bg-photo-frame-controls")),element.css({margin:"0px",padding:"0px"}),wrapper.css({opacity:"1.0"}),"auto"!=setting.height&&element.css({height:setting.height+"px"}),element.find("li").css({position:"absolute",listStyle:"none",display:"none",overflow:"hidden"}),element.find("img").css({maxWidth:"none"}),"100%"==setting.width?(element.find("li").css({width:"100%"}),element.find("img").css({width:"100%"})):"auto"!=setting.width&&element.find("img").css({width:setting.width+"px"}),setting.shuffle){var shuffleElement=element.html().split("");shuffleElement.splice(shuffleElement.length-1);for(var i=shuffleElement.length-1;i>=0;i--){var r=Math.floor(i*Math.random()),tmp=shuffleElement[i];shuffleElement[i]=shuffleElement[r],shuffleElement[r]=tmp}element.empty();for(var i=0;iSwich to Photoframe Mode',toggleButton;setting.photoFrame&&initToggle();var nav,prev,next,navClicked=!1,navPrefix=prefix+"-nav";setting.photoFrame&&initNav();var thumbPage,thumbBtn,thumbPrefix=prefix+"-thumb",thumbPageClass=thumbPrefix+"-thumbs",thumbBtnClass=thumbPrefix+"-btn",thumbTime=500;setting.photoFrame&&(initThumbs(),$(window).resize(function(){resizeThumbs()}),resizeThumbs());var timer=[],timerArr=[],timerBtn,timerPrefix=prefix+"-timer",timerBtnId=timerPrefix+"-btn";initTimer(),timer.setTimer=function(e,t){timer.disableTimer(),setting.autoChange&&timerBtn.hasClass("on")&&element.find("li").length&&enableTimer()},timer.disableTimer=function(){for(var e=0;en;n++){var i=element.find("li").eq(n);i.stop(!0,!1),e==n?(i.css({marginLeft:0}),e!=current&&("none"==i.css("display")?i.fadeIn(setting.fadeSpeed,function(){transitionFadeEnd()}):i.fadeTo(setting.fadeSpeed,1,function(){transitionFadeEnd()}),resizeImages(n))):i.fadeOut(setting.fadeSpeed)}transitionFadeEnd()};var swipe=[],swipeSpeed=2e3,swipeAnmation=!1,currentSwipeNum=0,nextSwipeNum=0,swipeSpeedLimit=5,swipeSpeedTimerSpan=100;swipe.transitionSwipe=function(e,t){swipeAnmation||(currentSwipeNum=parseInt(current)),swipeLoopStop(),swipeLoop(e,t)};var swipeActive,swipeActiveStart,swipeActiveCurrent,swipeStartMargin,swipeDistance,swipeSpeed,swipeSpeedStart,swipeSpeedCurrent,swipeSpeedTimer=[];"pc"==device?(maskElement.mousedown(function(e){swipeDown(e.pageX)}),$(window).mousemove(function(e){swipeMove(e.pageX)}),$(window).mouseup(function(e){swipeUp(e.pageX)})):(maskElement.bind("touchstart",function(){swipeDown(event.changedTouches[0].pageX)}),$(window).bind("touchmove",function(){swipeMove(event.changedTouches[0].pageX)}),$(window).bind("touchend",function(){swipeUp(event.changedTouches[0].pageX)}));var dammy=[],dammyElement;dammy.setDammy=function(e,t){dammyElement.find("li").remove();var n,i;n=-$(window).width(),i=$(window).width();var a=removeUnit(wrapper.css("marginLeft"));e=parseInt(e);var r,o=1,s=1;if(a>0?o=Math.floor((a+$(window).width())/$(window).width())+1:0>a&&(s=Math.floor(-(a-$(window).width())/$(window).width())+1),r=e,"next"==t||"current"==t)for(var m=0;o>m;m++){var d;d=0==r?element.find("li").length-1:r-1,dammyShow(d,m,"left"),r=d}if("prev"==t||"current"==t){r=e;for(var m=0;s>m;m++){var c;c=r==element.find("li").length-1?0:r+1,dammyShow(c,m,"right"),r=c}}dammyElement.css("display","block")},dammy.removeDammy=function(){dammyElement.find("li").remove()},initDammy()}}}}(jQuery),jQuery.easing.jswing=jQuery.easing.swing,jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,t,n,i,a){return jQuery.easing[jQuery.easing.def](e,t,n,i,a)},easeInQuad:function(e,t,n,i,a){return i*(t/=a)*t+n},easeOutQuad:function(e,t,n,i,a){return-i*(t/=a)*(t-2)+n},easeInOutQuad:function(e,t,n,i,a){return(t/=a/2)<1?i/2*t*t+n:-i/2*(--t*(t-2)-1)+n},easeInCubic:function(e,t,n,i,a){return i*(t/=a)*t*t+n},easeOutCubic:function(e,t,n,i,a){return i*((t=t/a-1)*t*t+1)+n},easeInOutCubic:function(e,t,n,i,a){return(t/=a/2)<1?i/2*t*t*t+n:i/2*((t-=2)*t*t+2)+n},easeInQuart:function(e,t,n,i,a){return i*(t/=a)*t*t*t+n},easeOutQuart:function(e,t,n,i,a){return-i*((t=t/a-1)*t*t*t-1)+n},easeInOutQuart:function(e,t,n,i,a){return(t/=a/2)<1?i/2*t*t*t*t+n:-i/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(e,t,n,i,a){return i*(t/=a)*t*t*t*t+n},easeOutQuint:function(e,t,n,i,a){return i*((t=t/a-1)*t*t*t*t+1)+n},easeInOutQuint:function(e,t,n,i,a){return(t/=a/2)<1?i/2*t*t*t*t*t+n:i/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(e,t,n,i,a){return-i*Math.cos(t/a*(Math.PI/2))+i+n},easeOutSine:function(e,t,n,i,a){return i*Math.sin(t/a*(Math.PI/2))+n},easeInOutSine:function(e,t,n,i,a){return-i/2*(Math.cos(Math.PI*t/a)-1)+n},easeInExpo:function(e,t,n,i,a){return 0==t?n:i*Math.pow(2,10*(t/a-1))+n},easeOutExpo:function(e,t,n,i,a){return t==a?n+i:i*(-Math.pow(2,-10*t/a)+1)+n},easeInOutExpo:function(e,t,n,i,a){return 0==t?n:t==a?n+i:(t/=a/2)<1?i/2*Math.pow(2,10*(t-1))+n:i/2*(-Math.pow(2,-10*--t)+2)+n},easeInCirc:function(e,t,n,i,a){return-i*(Math.sqrt(1-(t/=a)*t)-1)+n},easeOutCirc:function(e,t,n,i,a){return i*Math.sqrt(1-(t=t/a-1)*t)+n},easeInOutCirc:function(e,t,n,i,a){return(t/=a/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+n:i/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(e,t,n,i,a){var r=1.70158,o=0,s=i;if(0==t)return n;if(1==(t/=a))return n+i;if(o||(o=.3*a),st?-.5*(s*Math.pow(2,10*(t-=1))*Math.sin((t*a-r)*(2*Math.PI)/o))+n:s*Math.pow(2,-10*(t-=1))*Math.sin((t*a-r)*(2*Math.PI)/o)*.5+i+n},easeInBack:function(e,t,n,i,a,r){return void 0==r&&(r=1.70158),i*(t/=a)*t*((r+1)*t-r)+n},easeOutBack:function(e,t,n,i,a,r){return void 0==r&&(r=1.70158),i*((t=t/a-1)*t*((r+1)*t+r)+1)+n},easeInOutBack:function(e,t,n,i,a,r){return void 0==r&&(r=1.70158),(t/=a/2)<1?i/2*(t*t*(((r*=1.525)+1)*t-r))+n:i/2*((t-=2)*t*(((r*=1.525)+1)*t+r)+2)+n},easeInBounce:function(e,t,n,i,a){return i-jQuery.easing.easeOutBounce(e,a-t,0,i,a)+n},easeOutBounce:function(e,t,n,i,a){return(t/=a)<1/2.75?i*(7.5625*t*t)+n:2/2.75>t?i*(7.5625*(t-=1.5/2.75)*t+.75)+n:2.5/2.75>t?i*(7.5625*(t-=2.25/2.75)*t+.9375)+n:i*(7.5625*(t-=2.625/2.75)*t+.984375)+n},easeInOutBounce:function(e,t,n,i,a){return a/2>t?.5*jQuery.easing.easeInBounce(e,2*t,0,i,a)+n:.5*jQuery.easing.easeOutBounce(e,2*t-a,0,i,a)+.5*i+n}});