(function(f){var b,c,j,l,k,i,g,e,h,a;b=document.namespaces;has_canvas=document.createElement("canvas");has_canvas=has_canvas&&has_canvas.getContext;if(!(has_canvas||b)){f.fn.maphilight=function(){return this};return}if(has_canvas){g=function(o,n,m){if(n<=1){o.style.opacity=n;window.setTimeout(g,10,o,n+0.1,10)}};e=function(m){return Math.max(0,Math.min(parseInt(m,16),255))};h=function(m,n){return"rgba("+e(m.substr(0,2))+","+e(m.substr(2,2))+","+e(m.substr(4,2))+","+n+")"};c=function(m){var n=f('<canvas style="width:'+m.width+"px;height:"+m.height+'px;"></canvas>').get(0);n.getContext("2d").clearRect(0,0,n.width,n.height);return n};j=function(p,m,s,o,n){var r,q=p.getContext("2d");q.beginPath();if(m=="rect"){q.rect(s[0],s[1],s[2]-s[0],s[3]-s[1])}else{if(m=="poly"){q.moveTo(s[0],s[1]);for(r=2;r<s.length;r+=2){q.lineTo(s[r],s[r+1])}}else{if(m=="circ"){q.arc(s[0],s[1],s[2],0,Math.PI*2,false)}}}q.closePath();if(o.fill){q.fillStyle=h(o.fillColor,o.fillOpacity);q.fill()}if(o.stroke){q.strokeStyle=h(o.strokeColor,o.strokeOpacity);q.lineWidth=o.strokeWidth;q.stroke()}if(o.fade){g(p,0)}};l=function(m,n){m.getContext("2d").clearRect(0,0,m.width,m.height)}}else{c=function(m){return f('<var style="zoom:1;overflow:hidden;display:block;width:'+m.width+"px;height:"+m.height+'px;"></var>').get(0)};j=function(n,q,r,u,m){var s,t,o,p;s='<v:fill color="#'+u.fillColor+'" opacity="'+(u.fill?u.fillOpacity:0)+'" />';t=(u.stroke?'strokeweight="'+u.strokeWidth+'" stroked="t" strokecolor="#'+u.strokeColor+'"':'stroked="f"');o='<v:stroke opacity="'+u.strokeOpacity+'"/>';if(q=="rect"){p=f('<v:rect name="'+m+'" filled="t" '+t+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+r[0]+"px;top:"+r[1]+"px;width:"+(r[2]-r[0])+"px;height:"+(r[3]-r[1])+'px;"></v:rect>')}else{if(q=="poly"){p=f('<v:shape name="'+m+'" filled="t" '+t+' coordorigin="0,0" coordsize="'+n.width+","+n.height+'" path="m '+r[0]+","+r[1]+" l "+r.join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+n.width+"px;height:"+n.height+'px;"></v:shape>')}else{if(q=="circ"){p=f('<v:oval name="'+m+'" filled="t" '+t+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(r[0]-r[2])+"px;top:"+(r[1]-r[2])+"px;width:"+(r[2]*2)+"px;height:"+(r[2]*2)+'px;"></v:oval>')}}}p.get(0).innerHTML=s+o;f(n).append(p)};l=function(m){f(m).find("[name=highlighted]").remove()}}k=function(n){var m,o=n.getAttribute("coords").split(",");for(m=0;m<o.length;m++){o[m]=parseFloat(o[m])}return[n.getAttribute("shape").toLowerCase().substr(0,4),o]};a=function(m){if(!m.complete){return false}if(typeof m.naturalWidth!="undefined"&&m.naturalWidth==0){return false}return true};i={position:"absolute",left:0,top:0,padding:0,border:0};var d=false;f.fn.maphilight=function(o){o=f.extend({},f.fn.maphilight.defaults,o);if(f.browser.msie&&!d){document.namespaces.add("v","urn:schemas-microsoft-com:vml");var n=document.createStyleSheet();var m=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];f.each(m,function(){n.addRule("v\\:"+this,"behavior: url(#default#VML); antialias:true")});d=true}return this.each(function(){var u,r,x,q,t,v,w,s;u=f(this);if(!a(this)){return window.setTimeout(function(){u.maphilight(o)},200)}x=f.metadata?f.extend({},o,u.metadata()):o;q=f('map[name="'+u.attr("usemap").substr(1)+'"]');if(!(u.is("img")&&u.attr("usemap")&&q.size()>0)){return}if(u.hasClass("maphilighted")){var p=u.parent();u.insertBefore(p);p.remove()}r=f("<div>").css({display:"block",background:"url("+this.src+")",position:"relative",padding:0,width:this.width,height:this.height});u.before(r).css("opacity",0).css(i).remove();if(f.browser.msie){u.css("filter","Alpha(opacity=0)")}r.append(u);t=c(this);f(t).css(i);t.height=this.height;t.width=this.width;w=function(A){var y,z;z=f.metadata?f.extend({},x,f(this).metadata()):x;if(!z.neverOn&&!z.alwaysOn){y=k(this);j(t,y[0],y[1],z,"highlighted")}};if(x.alwaysOn){f(q).find("area[coords]").each(w)}else{if(f.metadata){f(q).find("area[coords]").each(function(){var y,z;z=f.metadata?f.extend({},x,f(this).metadata()):x;if(z.alwaysOn){if(!v){v=c(u.get());f(v).css(i);v.width=u.width();v.height=u.height();u.before(v)}y=k(this);if(f.browser.msie){j(t,y[0],y[1],z,"")}else{j(v,y[0],y[1],z,"")}}})}f(q).find("area[coords]").mouseover(w).mouseout(function(y){l(t)})}u.before(t);u.addClass("maphilighted")})};f.fn.maphilight.defaults={fill:true,fillColor:"00ff00",fillOpacity:0.2,stroke:true,strokeColor:"66CC66",strokeOpacity:1,strokeWidth:1,fade:true,alwaysOn:false}})(jQuery);
