(function(n){function u(t,i,r,u){var f=n(t).attr("data-coords").split(","),e="",o;for(key in f)e+=key%2==0?n(i).width()*(f[key]/100):","+n(i).height()*(f[key]/100)+" ";o=r.find("polygon:eq("+n(t).index()+")");o.attr("points",e).attr("class",function(n,t){return t+" mapify-hover"});u!=""&&o.attr("points",e).attr("class",function(n,t){return t+" "+u})}function f(t,i,r){var u=n(t).attr("data-coords").split(","),f="",e;for(key in u)f+=key%2==0?n(i).width()*(u[key]/100):","+n(i).height()*(u[key]/100)+" ";e=r.find("polygon:eq("+n(t).index()+")");e.attr("points",f).attr("class","active-area");e.attr("points",f).attr("class",function(n,t){return t+" active-area"})}function r(t,i){t.each(function(){var t=n(this).attr("data-coords").split(",");for(key in t)t[key]=key%2==0?n(i).width()*(t[key]/100):n(i).height()*(t[key]/100);n(this).attr("coords",t.toString())})}function s(n){for(var e=n.getAttribute("coords"),u=e.split(","),t,r=maxX=parseInt(u[0],10),i=maxY=parseInt(u[1],10),f=0,o=u.length;f<o;f++)t=parseInt(u[f],10),f%2==0?t<r?r=t:t>maxX&&(maxX=t):t<i?i=t:t>maxY&&(maxY=t);return r=r,maxX=maxX,i=i,maxY=maxY,centerX=parseInt((r+maxX)/2,10),centerY=parseInt((i+maxY)/2,10),{"center top":{0:centerX,1:i},"center bottom":{0:centerX,1:maxY}}}var e={hoverClass:"",popOver:!1},o={hoverClass:"",popOver:{content:function(){return""},delay:.8,margin:"10px",width:"",height:""}},t=!1,i;"ontouchstart"in document.documentElement&&"ontouchmove"in document.documentElement&&"ontouchend"in document.documentElement&&(t=!0);i=/(iPad|iPhone|iPod)/g.test(navigator.userAgent);n.fn.mapify=function(h){var h=n.extend(!0,{},e,h),c,l,a;return h.popOver&&(h=n.extend(!0,{},o,h),h.popOver.margin=parseInt(h.popOver.margin),h.popOver.width=h.popOver.width,c="",l="",isNaN(h.popOver.delay)||(c="all "+h.popOver.delay+"s",l="margin "+h.popOver.delay+"s")),a=this,a.each(function(){var e=this,et=n(e).attr("usemap"),a=n(et).find("area"),p,g,nt,k,ot,v,w,o,b,d,rt,y,tt;if(!n(e).hasClass("mapify")){if(p=!1,h.popOver&&(p=!0),n(e).addClass("mapify"),g=parseInt(n(e).attr("width")),nt=parseInt(n(e).attr("height")),!n(e).attr("width")||!n(e).attr("height"))return alert("The width and height attributes must be specified on your image."),"Not mapified";n(e).wrap(function(){return'<div class="mapify-holder"><\/div>'});k=n(e).parent();n(et).appendTo(k);n(e).before('<img class="mapify-img" src="'+n(e).attr("src")+'" />');ot=n(".mapify-img");n(e).before('<svg class="mapify-areas" width="'+g+'" height="'+nt+'"><\/svg>');n(e).before('<svg class="mapify-svg" width="'+g+'" height="'+nt+'"><\/svg>');v=n(".mapify-svg");w=n(".mapify-areas");a.each(function(){var t,r,u,i;n(this).attr("data-coords-default",n(this).attr("coords"));p&&n(this).removeAttr("alt").attr("data-title",n(this).attr("title")).removeAttr("title");t=n(this).attr("coords").split(",");for(key in t)t[key]=key%2==0?t[key]*100/g:t[key]*100/nt;n(this).attr("data-coords",t.toString());r=document.createElementNS("http://www.w3.org/2000/svg","polygon");r.className="active-area";w.append(r);u=this;f(u,e,w);i=document.createElementNS("http://www.w3.org/2000/svg","polygon");i.className="mapify-polygon";i.setAttribute("fill","none");v.append(i)});n(e).wrap(function(){return'<div class="mapify-imgHolder"><\/div>'}).css("opacity",0);p&&(n(e).after('<div class="mapify-popOver" style=" transition:'+c+'; "><div class="mapify-popOver-content"><\/div><div class="mapify-popOver-arrow" style=" transition:'+l+'; "><\/div><\/div>'),o=n(e).next(".mapify-popOver"),b=o.find(".mapify-popOver-arrow"),o.css({width:h.popOver.width,height:h.popOver.height}));d=!1;n(document).bind("touchend.mapify",function(){d||it(o,v);d=!1}).bind("touchmove.mapify",function(){d=!0});n(e).bind("touchmove.mapify",function(){});a.css({outline:"none"}).bind("touchend.mapify",function(t){n(this).hasClass("mapify-clickable")&&(n(this).trigger("click"),a.removeClass("mapify-clickable"));d=!1;t.stopPropagation()}).bind("click.mapify",function(n){if(n.originalEvent!==undefined&&t)return!1}).bind("touchstart.mapify",function(){a.removeClass("mapify-clickable");v.find("polygon:eq("+n(this).index()+")")[0].classList.contains("mapify-hover")?n(this).addClass("mapify-clickable"):n(this).addClass("mapify-hilightable")}).bind("touchmove.mapify",function(){a.removeClass("mapify-clickable mapify-hilightable")}).bind("mouseenter.mapify focus.mapify touchend.mapify",function(i){var r=this;if(!n(this).hasClass("mapify-hilightable")&&t)return!1;it(o,v);ut(w);p&&ft(o,r);u(r,e,v,h.hoverClass);i.preventDefault()}).bind("mouseout.mapify",function(){it(o,v);ut(w)});i||a.bind("blur.mapify",function(){it(o,v);ut(w)});n(window).bind("resize.mapify",function(){rt&&clearTimeout(rt);rt=setTimeout(function(){var n,t;p&&(o.hasClass("mapify-visible")||o.css({left:0,top:0}));v.find("polygon").attr("points","");r(a,e);n=a[v.find("polygon.mapify-hover").index()];n&&(p&&ft(o,n),u(n,e,v,h.hoverClass));t=a[w.find("polygon").index()];a.each(function(){var n=this;f(n,e,w)})},100)});y=n(e).scrollParent();n(y).is(document)&&(y=n(window));y.addClass("mapify-GPU");y.bind("scroll.mapify",function(){t&&a.removeClass("mapify-clickable mapify-hilightable");p&&(i&&(o.css({top:o.css("top"),left:o.css("left"),transition:"none"}),b.css({marginLeft:b.css("margin-left"),transition:"none"})),clearTimeout(n.data(this,"scrollTimer")),n.data(this,"scrollTimer",setTimeout(function(){var n=a[v.find("polygon.mapify-hover").index()];n&&(ft(o,n),i&&(o.css({top:corners[1],left:corners[0],transition:c}),b.css({marginLeft:popOverArrowCompensation,transition:l})))},100)))});console.log("mapified");function it(n,t){p&&(clearTimeout(tt),tt=setTimeout(function(){n.removeClass("mapify-visible")},300));t.find("polygon").attr("class","mapify-polygon ")}function ut(n){n.find("polygon").attr("class","active-area ")}function ft(t,i){var w=n(i)[0],p=s(w),a=p["center top"],r=t.outerWidth(),u=h.popOver.margin,f,o,v;y.width()-u*2<=r?(r=y.width()-u*2,t.css({maxWidth:r})):k.width()-u*2<=r?(r=k.width()-u*2,t.css({maxWidth:r})):t.css({maxWidth:""});t.css({marginLeft:-(r/2)});f=0;k.width()<y.width()?(o=a[0]-r/2-y.scrollLeft(),o+r>k.width()-u?f=o+r-k.width()+u:o<u&&(f=o-u)):(o=a[0]-r/2-y.scrollLeft(),o+r>y.outerWidth()-u?f=o+r-y.outerWidth()+u:o<u&&(f=o-u));a[1]-t.outerHeight()-u<0?(a=p["center bottom"],t.addClass("mapify-to-bottom")):t.hasClass("mapify-to-bottom")&&t.removeClass("mapify-to-bottom");a[0]-=f;v=f;f>r/2-u*2?v=r/2-u*2:f<-(r/2-u*2)&&(v=-(r/2)+u*2);t.hasClass("mapify-visible")||(t.css({top:a[1],left:a[0],transition:"none"}),b.css({marginLeft:v,transition:"none"}));clearTimeout(tt);tt=setTimeout(function(){var r=h.popOver.content(n(i),e);t.find(".mapify-popOver-content").html(r);t.hasClass("mapify-to-bottom")?(t.css({marginTop:""}),t.hasClass("mapify-bottom")||b.css({marginLeft:f,transition:"none"}),t.addClass("mapify-bottom"),t.removeClass("mapify-to-bottom")):(t.hasClass("mapify-bottom")&&b.css({marginLeft:f,transition:"none"}),t.removeClass("mapify-bottom"),t.css({marginTop:-t.outerHeight()}));setTimeout(function(){t.css({top:a[1],left:a[0],transition:c}).addClass("mapify-visible");b.css({marginLeft:v,transition:l})},10)},100)}}r(a,e);n(e).bind("load.mapify",function(){r(a,e)})}),"mapified"};n.fn.scrollParent=function(){var t=this.css("position"),r=t==="absolute",i=this.parents().filter(function(){var t=n(this);return r&&t.css("position")==="static"?!1:/(auto|scroll)/.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return t==="fixed"||!i.length?n(this[0].ownerDocument||document):i}})(jQuery);$("img[usemap]").mapify({popOver:{content:function(n){return"<h2 class='map-area-title'>"+n.attr("data-title")+"<\/h2><p class='map-area-description'>"+n.attr("data-factory")+"<\/p>"},fill:!0,delay:.7,margin:"15px",padding:"30px",width:"240px"}})