// Modernizr v1.7  www.modernizr.com
window.Modernizr=function(a,b,c){function G(){e.input=function(a){for(var b=0,c=a.length;b<c;b++)t[a[b]]=!!(a[b]in l);return t}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)l.setAttribute("type",f=a[d]),e=l.type!=="text",e&&(l.value=m,l.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&l.style.WebkitAppearance!==c?(g.appendChild(l),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(l,null).WebkitAppearance!=="textfield"&&l.offsetHeight!==0,g.removeChild(l)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=l.checkValidity&&l.checkValidity()===!1:/^color$/.test(f)?(g.appendChild(l),g.offsetWidth,e=l.value!=m,g.removeChild(l)):e=l.value!=m)),s[a[d]]=!!e;return s}("search tel url email datetime date month week time datetime-local number range color".split(" "))}function F(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+p.join(c+" ")+c).split(" ");return!!E(d,b)}function E(a,b){for(var d in a)if(k[a[d]]!==c&&(!b||b(a[d],j)))return!0}function D(a,b){return(""+a).indexOf(b)!==-1}function C(a,b){return typeof a===b}function B(a,b){return A(o.join(a+";")+(b||""))}function A(a){k.cssText=a}var d="1.7",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l=b.createElement("input"),m=":)",n=Object.prototype.toString,o=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),p="Webkit Moz O ms Khtml".split(" "),q={svg:"http://www.w3.org/2000/svg"},r={},s={},t={},u=[],v,w=function(a){var c=b.createElement("style"),d=b.createElement("div"),e;c.textContent=a+"{#modernizr{height:3px}}",h.appendChild(c),d.id="modernizr",g.appendChild(d),e=d.offsetHeight===3,c.parentNode.removeChild(c),d.parentNode.removeChild(d);return!!e},x=function(){function d(d,e){e=e||b.createElement(a[d]||"div");var f=(d="on"+d)in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=C(e[d],"function"),C(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),y=({}).hasOwnProperty,z;C(y,c)||C(y.call,c)?z=function(a,b){return b in a&&C(a.constructor.prototype[b],c)}:z=function(a,b){return y.call(a,b)},r.flexbox=function(){function c(a,b,c,d){a.style.cssText=o.join(b+":"+c+";")+(d||"")}function a(a,b,c,d){b+=":",a.style.cssText=(b+o.join(c+";"+b)).slice(0,-b.length)+(d||"")}var d=b.createElement("div"),e=b.createElement("div");a(d,"display","box","width:42px;padding:0;"),c(e,"box-flex","1","width:10px;"),d.appendChild(e),g.appendChild(d);var f=e.offsetWidth===42;d.removeChild(e),g.removeChild(d);return f},r.canvas=function(){var a=b.createElement("canvas");return a.getContext&&a.getContext("2d")},r.canvastext=function(){return e.canvas&&C(b.createElement("canvas").getContext("2d").fillText,"function")},r.webgl=function(){return!!a.WebGLRenderingContext},r.touch=function(){return"ontouchstart"in a||w("@media ("+o.join("touch-enabled),(")+"modernizr)")},r.geolocation=function(){return!!navigator.geolocation},r.postmessage=function(){return!!a.postMessage},r.websqldatabase=function(){var b=!!a.openDatabase;return b},r.indexedDB=function(){for(var b=-1,c=p.length;++b<c;){var d=p[b].toLowerCase();if(a[d+"_indexedDB"]||a[d+"IndexedDB"])return!0}return!1},r.hashchange=function(){return x("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},r.history=function(){return !!(a.history&&history.pushState)},r.draganddrop=function(){return x("dragstart")&&x("drop")},r.websockets=function(){return"WebSocket"in a},r.rgba=function(){A("background-color:rgba(150,255,150,.5)");return D(k.backgroundColor,"rgba")},r.hsla=function(){A("background-color:hsla(120,40%,100%,.5)");return D(k.backgroundColor,"rgba")||D(k.backgroundColor,"hsla")},r.multiplebgs=function(){A("background:url(//:),url(//:),red url(//:)");return(new RegExp("(url\\s*\\(.*?){3}")).test(k.background)},r.backgroundsize=function(){return F("backgroundSize")},r.borderimage=function(){return F("borderImage")},r.borderradius=function(){return F("borderRadius","",function(a){return D(a,"orderRadius")})},r.boxshadow=function(){return F("boxShadow")},r.textshadow=function(){return b.createElement("div").style.textShadow===""},r.opacity=function(){B("opacity:.55");return/^0.55$/.test(k.opacity)},r.cssanimations=function(){return F("animationName")},r.csscolumns=function(){return F("columnCount")},r.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";A((a+o.join(b+a)+o.join(c+a)).slice(0,-a.length));return D(k.backgroundImage,"gradient")},r.cssreflections=function(){return F("boxReflect")},r.csstransforms=function(){return!!E(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])},r.csstransforms3d=function(){var a=!!E(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);a&&"webkitPerspective"in g.style&&(a=w("@media ("+o.join("transform-3d),(")+"modernizr)"));return a},r.csstransitions=function(){return F("transitionProperty")},r.fontface=function(){var a,c,d=h||g,e=b.createElement("style"),f=b.implementation||{hasFeature:function(){return!1}};e.type="text/css",d.insertBefore(e,d.firstChild),a=e.sheet||e.styleSheet;var i=f.hasFeature("CSS2","")?function(b){if(!a||!b)return!1;var c=!1;try{a.insertRule(b,0),c=/src/i.test(a.cssRules[0].cssText),a.deleteRule(a.cssRules.length-1)}catch(d){}return c}:function(b){if(!a||!b)return!1;a.cssText=b;return a.cssText.length!==0&&/src/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(b.split(" ")[0])===0};c=i('@font-face { font-family: "font"; src: url(data:,); }'),d.removeChild(e);return c},r.video=function(){var a=b.createElement("video"),c=!!a.canPlayType;if(c){c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"');var d='video/mp4; codecs="avc1.42E01E';c.h264=a.canPlayType(d+'"')||a.canPlayType(d+', mp4a.40.2"'),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return c},r.audio=function(){var a=b.createElement("audio"),c=!!a.canPlayType;c&&(c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"'),c.mp3=a.canPlayType("audio/mpeg;"),c.wav=a.canPlayType('audio/wav; codecs="1"'),c.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;"));return c},r.localstorage=function(){try{return!!localStorage.getItem}catch(a){return!1}},r.sessionstorage=function(){try{return!!sessionStorage.getItem}catch(a){return!1}},r.webWorkers=function(){return!!a.Worker},r.applicationcache=function(){return!!a.applicationCache},r.svg=function(){return!!b.createElementNS&&!!b.createElementNS(q.svg,"svg").createSVGRect},r.inlinesvg=function(){var a=b.createElement("div");a.innerHTML="<svg/>";return(a.firstChild&&a.firstChild.namespaceURI)==q.svg},r.smil=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"animate")))},r.svgclippaths=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"clipPath")))};for(var H in r)z(r,H)&&(v=H.toLowerCase(),e[v]=r[H](),u.push((e[v]?"":"no-")+v));e.input||G(),e.crosswindowmessaging=e.postmessage,e.historymanagement=e.history,e.addTest=function(a,b){a=a.toLowerCase();if(!e[a]){b=!!b(),g.className+=" "+(b?"":"no-")+a,e[a]=b;return e}},A(""),j=l=null,f&&a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function p(a,b){var c=-1,d=a.length,e,f=[];while(++c<d)e=a[c],(b=e.media||b)!="screen"&&f.push(p(e.imports,b),e.cssText);return f.join("")}function o(a){var b=-1;while(++b<e)a.createElement(d[b])}var c="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",d=c.split("|"),e=d.length,f=new RegExp("(^|\\s)("+c+")","gi"),g=new RegExp("<(/*)("+c+")","gi"),h=new RegExp("(^|[^\\n]*?\\s)("+c+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),i=b.createDocumentFragment(),j=b.documentElement,k=j.firstChild,l=b.createElement("body"),m=b.createElement("style"),n;o(b),o(i),k.insertBefore(m,k.firstChild),m.media="print",a.attachEvent("onbeforeprint",function(){var a=-1,c=p(b.styleSheets,"all"),k=[],o;n=n||b.body;while((o=h.exec(c))!=null)k.push((o[1]+o[2]+o[3]).replace(f,"$1.iepp_$2")+o[4]);m.styleSheet.cssText=k.join("\n");while(++a<e){var q=b.getElementsByTagName(d[a]),r=q.length,s=-1;while(++s<r)q[s].className.indexOf("iepp_")<0&&(q[s].className+=" iepp_"+d[a])}i.appendChild(n),j.appendChild(l),l.className=n.className,l.innerHTML=n.innerHTML.replace(g,"<$1font")}),a.attachEvent("onafterprint",function(){l.innerHTML="",j.removeChild(l),j.appendChild(n),m.styleSheet.cssText=""})}(a,b),e._enableHTML5=f,e._version=d,g.className=g.className.replace(/\bno-js\b/,"")+" js "+u.join(" ");return e}(this,this.document);
/*
 * Raphael 1.5.2 - JavaScript Vector Library
 *
 * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
 * Licensed under the MIT (http://raphaeljs.com/license.html) license.
 */
(function(){function a(){if(a.is(arguments[0],G)){var b=arguments[0],d=bV[m](a,b.splice(0,3+a.is(b[0],E))),e=d.set();for(var g=0,h=b[w];g<h;g++){var i=b[g]||{};c[f](i.type)&&e[L](d[i.type]().attr(i))}return e}return bV[m](a,arguments)}a.version="1.5.2";var b=/[, ]+/,c={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},d=/\{(\d+)\}/g,e="prototype",f="hasOwnProperty",g=document,h=window,i={was:Object[e][f].call(h,"Raphael"),is:h.Raphael},j=function(){this.customAttributes={}},k,l="appendChild",m="apply",n="concat",o="createTouch"in g,p="",q=" ",r=String,s="split",t="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[s](q),u={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},v="join",w="length",x=r[e].toLowerCase,y=Math,z=y.max,A=y.min,B=y.abs,C=y.pow,D=y.PI,E="number",F="string",G="array",H="toString",I="fill",J=Object[e][H],K={},L="push",M=/^url\(['"]?([^\)]+?)['"]?\)$/i,N=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,O={"NaN":1,Infinity:1,"-Infinity":1},P=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,Q=y.round,R="setAttribute",S=parseFloat,T=parseInt,U=" progid:DXImageTransform.Microsoft",V=r[e].toUpperCase,W={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:"10px \"Arial\"","font-family":"\"Arial\"","font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},X={along:"along",blur:E,"clip-rect":"csv",cx:E,cy:E,fill:"colour","fill-opacity":E,"font-size":E,height:E,opacity:E,path:"path",r:E,rotation:"csv",rx:E,ry:E,scale:"csv",stroke:"colour","stroke-opacity":E,"stroke-width":E,translation:"csv",width:E,x:E,y:E},Y="replace",Z=/^(from|to|\d+%?)$/,$=/\s*,\s*/,_={hs:1,rg:1},ba=/,?([achlmqrstvxz]),?/gi,bb=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,bc=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,bd=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,be=function(a,b){return a.key-b.key};a.type=h.SVGAngle||g.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML";if(a.type=="VML"){var bf=g.createElement("div"),bg;bf.innerHTML="<v:shape adj=\"1\"/>";bg=bf.firstChild;bg.style.behavior="url(#default#VML)";if(!(bg&&typeof bg.adj=="object"))return a.type=null;bf=null}a.svg=!(a.vml=a.type=="VML");j[e]=a[e];k=j[e];a._id=0;a._oid=0;a.fn={};a.is=function(a,b){b=x.call(b);if(b=="finite")return!O[f](+a);return b=="null"&&a===null||b==typeof a||b=="object"&&a===Object(a)||b=="array"&&Array.isArray&&Array.isArray(a)||J.call(a).slice(8,-1).toLowerCase()==b};a.angle=function(b,c,d,e,f,g){{if(f==null){var h=b-d,i=c-e;if(!h&&!i)return 0;return((h<0)*180+y.atan(-i/-h)*180/D+360)%360}return a.angle(b,c,f,g)-a.angle(d,e,f,g)}};a.rad=function(a){return a%360*D/180};a.deg=function(a){return a*180/D%360};a.snapTo=function(b,c,d){d=a.is(d,"finite")?d:10;if(a.is(b,G)){var e=b.length;while(e--)if(B(b[e]-c)<=d)return b[e]}else{b=+b;var f=c%b;if(f<d)return c-f;if(f>b-d)return c-f+b}return c};function bh(){var a=[],b=0;for(;b<32;b++)a[b]=(~(~(y.random()*16)))[H](16);a[12]=4;a[16]=(a[16]&3|8)[H](16);return"r-"+a[v]("")}a.setWindow=function(a){h=a;g=h.document};var bi=function(b){if(a.vml){var c=/^\s+|\s+$/g,d;try{var e=new ActiveXObject("htmlfile");e.write("<body>");e.close();d=e.body}catch(a){d=createPopup().document.body}var f=d.createTextRange();bi=bm(function(a){try{d.style.color=r(a)[Y](c,p);var b=f.queryCommandValue("ForeColor");b=(b&255)<<16|b&65280|(b&16711680)>>>16;return"#"+("000000"+b[H](16)).slice(-6)}catch(a){return"none"}})}else{var h=g.createElement("i");h.title="Raphaël Colour Picker";h.style.display="none";g.body[l](h);bi=bm(function(a){h.style.color=a;return g.defaultView.getComputedStyle(h,p).getPropertyValue("color")})}return bi(b)},bj=function(){return"hsb("+[this.h,this.s,this.b]+")"},bk=function(){return"hsl("+[this.h,this.s,this.l]+")"},bl=function(){return this.hex};a.hsb2rgb=function(b,c,d,e){if(a.is(b,"object")&&"h"in b&&"s"in b&&"b"in b){d=b.b;c=b.s;b=b.h;e=b.o}return a.hsl2rgb(b,c,d/2,e)};a.hsl2rgb=function(b,c,d,e){if(a.is(b,"object")&&"h"in b&&"s"in b&&"l"in b){d=b.l;c=b.s;b=b.h}if(b>1||c>1||d>1){b/=360;c/=100;d/=100}var f={},g=["r","g","b"],h,i,j,k,l,m;if(c){d<0.5?h=d*(1+c):h=d+c-d*c;i=2*d-h;for(var n=0;n<3;n++){j=b+1/3*-(n-1);j<0&&j++;j>1&&j--;j*6<1?f[g[n]]=i+(h-i)*6*j:j*2<1?f[g[n]]=h:j*3<2?f[g[n]]=i+(h-i)*(2/3-j)*6:f[g[n]]=i}}else f={r:d,g:d,b:d};f.r*=255;f.g*=255;f.b*=255;f.hex="#"+(16777216|f.b|f.g<<8|f.r<<16).toString(16).slice(1);a.is(e,"finite")&&(f.opacity=e);f.toString=bl;return f};a.rgb2hsb=function(b,c,d){if(c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b){d=b.b;c=b.g;b=b.r}if(c==null&&a.is(b,F)){var e=a.getRGB(b);b=e.r;c=e.g;d=e.b}if(b>1||c>1||d>1){b/=255;c/=255;d/=255}var f=z(b,c,d),g=A(b,c,d),h,i,j=f;{if(g==f)return{h:0,s:0,b:f,toString:bj};var k=f-g;i=k/f;b==f?h=(c-d)/k:c==f?h=2+(d-b)/k:h=4+(b-c)/k;h/=6;h<0&&h++;h>1&&h--}return{h:h,s:i,b:j,toString:bj}};a.rgb2hsl=function(b,c,d){if(c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b){d=b.b;c=b.g;b=b.r}if(c==null&&a.is(b,F)){var e=a.getRGB(b);b=e.r;c=e.g;d=e.b}if(b>1||c>1||d>1){b/=255;c/=255;d/=255}var f=z(b,c,d),g=A(b,c,d),h,i,j=(f+g)/2,k;if(g==f)k={h:0,s:0,l:j};else{var l=f-g;i=j<0.5?l/(f+g):l/(2-f-g);b==f?h=(c-d)/l:c==f?h=2+(d-b)/l:h=4+(b-c)/l;h/=6;h<0&&h++;h>1&&h--;k={h:h,s:i,l:j}}k.toString=bk;return k};a._path2string=function(){return this.join(",")[Y](ba,"$1")};function bm(a,b,c){function d(){var g=Array[e].slice.call(arguments,0),h=g[v]("►"),i=d.cache=d.cache||{},j=d.count=d.count||[];if(i[f](h))return c?c(i[h]):i[h];j[w]>=1000&&delete i[j.shift()];j[L](h);i[h]=a[m](b,g);return c?c(i[h]):i[h]}return d}a.getRGB=bm(function(b){if(!b||!(!((b=r(b)).indexOf("-")+1)))return{r:-1,g:-1,b:-1,hex:"none",error:1};if(b=="none")return{r:-1,g:-1,b:-1,hex:"none"};!(_[f](b.toLowerCase().substring(0,2))||b.charAt()=="#")&&(b=bi(b));var c,d,e,g,h,i,j,k=b.match(N);if(k){if(k[2]){g=T(k[2].substring(5),16);e=T(k[2].substring(3,5),16);d=T(k[2].substring(1,3),16)}if(k[3]){g=T((i=k[3].charAt(3))+i,16);e=T((i=k[3].charAt(2))+i,16);d=T((i=k[3].charAt(1))+i,16)}if(k[4]){j=k[4][s]($);d=S(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=S(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=S(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);k[1].toLowerCase().slice(0,4)=="rgba"&&(h=S(j[3]));j[3]&&j[3].slice(-1)=="%"&&(h/=100)}if(k[5]){j=k[5][s]($);d=S(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=S(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=S(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360);k[1].toLowerCase().slice(0,4)=="hsba"&&(h=S(j[3]));j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsb2rgb(d,e,g,h)}if(k[6]){j=k[6][s]($);d=S(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=S(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=S(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360);k[1].toLowerCase().slice(0,4)=="hsla"&&(h=S(j[3]));j[3]&&j[3].slice(-1)=="%"&&(h/=100);return a.hsl2rgb(d,e,g,h)}k={r:d,g:e,b:g};k.hex="#"+(16777216|g|e<<8|d<<16).toString(16).slice(1);a.is(h,"finite")&&(k.opacity=h);return k}return{r:-1,g:-1,b:-1,hex:"none",error:1}},a);a.getColor=function(a){var b=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||0.75},c=this.hsb2rgb(b.h,b.s,b.b);b.h+=0.075;if(b.h>1){b.h=0;b.s-=0.2;b.s<=0&&(this.getColor.start={h:0,s:1,b:b.b})}return c.hex};a.getColor.reset=function(){delete this.start};a.parsePathString=bm(function(b){if(!b)return null;var c={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},d=[];a.is(b,G)&&a.is(b[0],G)&&(d=bo(b));d[w]||r(b)[Y](bb,function(a,b,e){var f=[],g=x.call(b);e[Y](bc,function(a,b){b&&f[L](+b)});if(g=="m"&&f[w]>2){d[L]([b][n](f.splice(0,2)));g="l";b=b=="m"?"l":"L"}while(f[w]>=c[g]){d[L]([b][n](f.splice(0,c[g])));if(!c[g])break}});d[H]=a._path2string;return d});a.findDotsAtSegment=function(a,b,c,d,e,f,g,h,i){var j=1-i,k=C(j,3)*a+C(j,2)*3*i*c+j*3*i*i*e+C(i,3)*g,l=C(j,3)*b+C(j,2)*3*i*d+j*3*i*i*f+C(i,3)*h,m=a+2*i*(c-a)+i*i*(e-2*c+a),n=b+2*i*(d-b)+i*i*(f-2*d+b),o=c+2*i*(e-c)+i*i*(g-2*e+c),p=d+2*i*(f-d)+i*i*(h-2*f+d),q=(1-i)*a+i*c,r=(1-i)*b+i*d,s=(1-i)*e+i*g,t=(1-i)*f+i*h,u=90-y.atan((m-o)/(n-p))*180/D;(m>o||n<p)&&(u+=180);return{x:k,y:l,m:{x:m,y:n},n:{x:o,y:p},start:{x:q,y:r},end:{x:s,y:t},alpha:u}};var bn=bm(function(a){if(!a)return{x:0,y:0,width:0,height:0};a=bw(a);var b=0,c=0,d=[],e=[],f;for(var g=0,h=a[w];g<h;g++){f=a[g];if(f[0]=="M"){b=f[1];c=f[2];d[L](b);e[L](c)}else{var i=bv(b,c,f[1],f[2],f[3],f[4],f[5],f[6]);d=d[n](i.min.x,i.max.x);e=e[n](i.min.y,i.max.y);b=f[5];c=f[6]}}var j=A[m](0,d),k=A[m](0,e);return{x:j,y:k,width:z[m](0,d)-j,height:z[m](0,e)-k}}),bo=function(b){var c=[];if(!a.is(b,G)||!a.is(b&&b[0],G))b=a.parsePathString(b);for(var d=0,e=b[w];d<e;d++){c[d]=[];for(var f=0,g=b[d][w];f<g;f++)c[d][f]=b[d][f]}c[H]=a._path2string;return c},bp=bm(function(b){if(!a.is(b,G)||!a.is(b&&b[0],G))b=a.parsePathString(b);var c=[],d=0,e=0,f=0,g=0,h=0;if(b[0][0]=="M"){d=b[0][1];e=b[0][2];f=d;g=e;h++;c[L](["M",d,e])}for(var i=h,j=b[w];i<j;i++){var k=c[i]=[],l=b[i];if(l[0]!=x.call(l[0])){k[0]=x.call(l[0]);switch(k[0]){case"a":k[1]=l[1];k[2]=l[2];k[3]=l[3];k[4]=l[4];k[5]=l[5];k[6]=+(l[6]-d).toFixed(3);k[7]=+(l[7]-e).toFixed(3);break;case"v":k[1]=+(l[1]-e).toFixed(3);break;case"m":f=l[1];g=l[2];default:for(var m=1,n=l[w];m<n;m++)k[m]=+(l[m]-(m%2?d:e)).toFixed(3)}}else{k=c[i]=[];if(l[0]=="m"){f=l[1]+d;g=l[2]+e}for(var o=0,p=l[w];o<p;o++)c[i][o]=l[o]}var q=c[i][w];switch(c[i][0]){case"z":d=f;e=g;break;case"h":d+=+c[i][q-1];break;case"v":e+=+c[i][q-1];break;default:d+=+c[i][q-2];e+=+c[i][q-1]}}c[H]=a._path2string;return c},0,bo),bq=bm(function(b){if(!a.is(b,G)||!a.is(b&&b[0],G))b=a.parsePathString(b);var c=[],d=0,e=0,f=0,g=0,h=0;if(b[0][0]=="M"){d=+b[0][1];e=+b[0][2];f=d;g=e;h++;c[0]=["M",d,e]}for(var i=h,j=b[w];i<j;i++){var k=c[i]=[],l=b[i];if(l[0]!=V.call(l[0])){k[0]=V.call(l[0]);switch(k[0]){case"A":k[1]=l[1];k[2]=l[2];k[3]=l[3];k[4]=l[4];k[5]=l[5];k[6]=+(l[6]+d);k[7]=+(l[7]+e);break;case"V":k[1]=+l[1]+e;break;case"H":k[1]=+l[1]+d;break;case"M":f=+l[1]+d;g=+l[2]+e;default:for(var m=1,n=l[w];m<n;m++)k[m]=+l[m]+(m%2?d:e)}}else for(var o=0,p=l[w];o<p;o++)c[i][o]=l[o];switch(k[0]){case"Z":d=f;e=g;break;case"H":d=k[1];break;case"V":e=k[1];break;case"M":f=c[i][c[i][w]-2];g=c[i][c[i][w]-1];default:d=c[i][c[i][w]-2];e=c[i][c[i][w]-1]}}c[H]=a._path2string;return c},null,bo),br=function(a,b,c,d){return[a,b,c,d,c,d]},bs=function(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]},bt=function(a,b,c,d,e,f,g,h,i,j){var k=D*120/180,l=D/180*(+e||0),m=[],o,p=bm(function(a,b,c){var d=a*y.cos(c)-b*y.sin(c),e=a*y.sin(c)+b*y.cos(c);return{x:d,y:e}});if(j){G=j[0];H=j[1];E=j[2];F=j[3]}else{o=p(a,b,-l);a=o.x;b=o.y;o=p(h,i,-l);h=o.x;i=o.y;var q=y.cos(D/180*e),r=y.sin(D/180*e),t=(a-h)/2,u=(b-i)/2,x=t*t/(c*c)+u*u/(d*d);if(x>1){x=y.sqrt(x);c=x*c;d=x*d}var z=c*c,A=d*d,C=(f==g?-1:1)*y.sqrt(B((z*A-z*u*u-A*t*t)/(z*u*u+A*t*t))),E=C*c*u/d+(a+h)/2,F=C*-d*t/c+(b+i)/2,G=y.asin(((b-F)/d).toFixed(9)),H=y.asin(((i-F)/d).toFixed(9));G=a<E?D-G:G;H=h<E?D-H:H;G<0&&(G=D*2+G);H<0&&(H=D*2+H);g&&G>H&&(G=G-D*2);!g&&H>G&&(H=H-D*2)}var I=H-G;if(B(I)>k){var J=H,K=h,L=i;H=G+k*(g&&H>G?1:-1);h=E+c*y.cos(H);i=F+d*y.sin(H);m=bt(h,i,c,d,e,0,g,K,L,[H,J,E,F])}I=H-G;var M=y.cos(G),N=y.sin(G),O=y.cos(H),P=y.sin(H),Q=y.tan(I/4),R=4/3*c*Q,S=4/3*d*Q,T=[a,b],U=[a+R*N,b-S*M],V=[h+R*P,i-S*O],W=[h,i];U[0]=2*T[0]-U[0];U[1]=2*T[1]-U[1];{if(j)return[U,V,W][n](m);m=[U,V,W][n](m)[v]()[s](",");var X=[];for(var Y=0,Z=m[w];Y<Z;Y++)X[Y]=Y%2?p(m[Y-1],m[Y],l).y:p(m[Y],m[Y+1],l).x;return X}},bu=function(a,b,c,d,e,f,g,h,i){var j=1-i;return{x:C(j,3)*a+C(j,2)*3*i*c+j*3*i*i*e+C(i,3)*g,y:C(j,3)*b+C(j,2)*3*i*d+j*3*i*i*f+C(i,3)*h}},bv=bm(function(a,b,c,d,e,f,g,h){var i=e-2*c+a-(g-2*e+c),j=2*(c-a)-2*(e-c),k=a-c,l=(-j+y.sqrt(j*j-4*i*k))/2/i,n=(-j-y.sqrt(j*j-4*i*k))/2/i,o=[b,h],p=[a,g],q;B(l)>"1e12"&&(l=0.5);B(n)>"1e12"&&(n=0.5);if(l>0&&l<1){q=bu(a,b,c,d,e,f,g,h,l);p[L](q.x);o[L](q.y)}if(n>0&&n<1){q=bu(a,b,c,d,e,f,g,h,n);p[L](q.x);o[L](q.y)}i=f-2*d+b-(h-2*f+d);j=2*(d-b)-2*(f-d);k=b-d;l=(-j+y.sqrt(j*j-4*i*k))/2/i;n=(-j-y.sqrt(j*j-4*i*k))/2/i;B(l)>"1e12"&&(l=0.5);B(n)>"1e12"&&(n=0.5);if(l>0&&l<1){q=bu(a,b,c,d,e,f,g,h,l);p[L](q.x);o[L](q.y)}if(n>0&&n<1){q=bu(a,b,c,d,e,f,g,h,n);p[L](q.x);o[L](q.y)}return{min:{x:A[m](0,p),y:A[m](0,o)},max:{x:z[m](0,p),y:z[m](0,o)}}}),bw=bm(function(a,b){var c=bq(a),d=b&&bq(b),e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},f={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},g=function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null);switch(a[0]){case"M":b.X=a[1];b.Y=a[2];break;case"A":a=["C"][n](bt[m](0,[b.x,b.y][n](a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x));d=b.y+(b.y-(b.by||b.y));a=["C",c,d][n](a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x));b.qy=b.y+(b.y-(b.qy||b.y));a=["C"][n](bs(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1];b.qy=a[2];a=["C"][n](bs(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"][n](br(b.x,b.y,a[1],a[2]));break;case"H":a=["C"][n](br(b.x,b.y,a[1],b.y));break;case"V":a=["C"][n](br(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"][n](br(b.x,b.y,b.X,b.Y));break}return a},h=function(a,b){if(a[b][w]>7){a[b].shift();var e=a[b];while(e[w])a.splice(b++,0,["C"][n](e.splice(0,6)));a.splice(b,1);k=z(c[w],d&&d[w]||0)}},i=function(a,b,e,f,g){if(a&&b&&a[g][0]=="M"&&b[g][0]!="M"){b.splice(g,0,["M",f.x,f.y]);e.bx=0;e.by=0;e.x=a[g][1];e.y=a[g][2];k=z(c[w],d&&d[w]||0)}};for(var j=0,k=z(c[w],d&&d[w]||0);j<k;j++){c[j]=g(c[j],e);h(c,j);d&&(d[j]=g(d[j],f));d&&h(d,j);i(c,d,e,f,j);i(d,c,f,e,j);var l=c[j],o=d&&d[j],p=l[w],q=d&&o[w];e.x=l[p-2];e.y=l[p-1];e.bx=S(l[p-4])||e.x;e.by=S(l[p-3])||e.y;f.bx=d&&(S(o[q-4])||f.x);f.by=d&&(S(o[q-3])||f.y);f.x=d&&o[q-2];f.y=d&&o[q-1]}return d?[c,d]:c},null,bo),bx=bm(function(b){var c=[];for(var d=0,e=b[w];d<e;d++){var f={},g=b[d].match(/^([^:]*):?([\d\.]*)/);f.color=a.getRGB(g[1]);if(f.color.error)return null;f.color=f.color.hex;g[2]&&(f.offset=g[2]+"%");c[L](f)}for(d=1,e=c[w]-1;d<e;d++){if(!c[d].offset){var h=S(c[d-1].offset||0),i=0;for(var j=d+1;j<e;j++){if(c[j].offset){i=c[j].offset;break}}if(!i){i=100;j=e}i=S(i);var k=(i-h)/(j-d+1);for(;d<j;d++){h+=k;c[d].offset=h+"%"}}}return c}),by=function(b,c,d,e){var f;if(a.is(b,F)||a.is(b,"object")){f=a.is(b,F)?g.getElementById(b):b;if(f.tagName)return c==null?{container:f,width:f.style.pixelWidth||f.offsetWidth,height:f.style.pixelHeight||f.offsetHeight}:{container:f,width:c,height:d}}else return{container:1,x:b,y:c,width:d,height:e}},bz=function(a,b){var c=this;for(var d in b){if(b[f](d)&&!(d in a))switch(typeof b[d]){case"function":(function(b){a[d]=a===c?b:function(){return b[m](c,arguments)}})(b[d]);break;case"object":a[d]=a[d]||{};bz.call(this,a[d],b[d]);break;default:a[d]=b[d];break}}},bA=function(a,b){a==b.top&&(b.top=a.prev);a==b.bottom&&(b.bottom=a.next);a.next&&(a.next.prev=a.prev);a.prev&&(a.prev.next=a.next)},bB=function(a,b){if(b.top===a)return;bA(a,b);a.next=null;a.prev=b.top;b.top.next=a;b.top=a},bC=function(a,b){if(b.bottom===a)return;bA(a,b);a.next=b.bottom;a.prev=null;b.bottom.prev=a;b.bottom=a},bD=function(a,b,c){bA(a,c);b==c.top&&(c.top=a);b.next&&(b.next.prev=a);a.next=b.next;a.prev=b;b.next=a},bE=function(a,b,c){bA(a,c);b==c.bottom&&(c.bottom=a);b.prev&&(b.prev.next=a);a.prev=b.prev;b.prev=a;a.next=b},bF=function(a){return function(){throw new Error("Raphaël: you are calling to method “"+a+"” of removed object")}};a.pathToRelative=bp;if(a.svg){k.svgns="http://www.w3.org/2000/svg";k.xlink="http://www.w3.org/1999/xlink";Q=function(a){return+a+(~(~a)===a)*0.5};var bG=function(a,b){if(b)for(var c in b)b[f](c)&&a[R](c,r(b[c]));else{a=g.createElementNS(k.svgns,a);a.style.webkitTapHighlightColor="rgba(0,0,0,0)";return a}};a[H]=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var bH=function(a,b){var c=bG("path");b.canvas&&b.canvas[l](c);var d=new bN(c,b);d.type="path";bK(d,{fill:"none",stroke:"#000",path:a});return d},bI=function(a,b,c){var d="linear",e=0.5,f=0.5,h=a.style;b=r(b)[Y](bd,function(a,b,c){d="radial";if(b&&c){e=S(b);f=S(c);var g=(f>0.5)*2-1;C(e-0.5,2)+C(f-0.5,2)>0.25&&(f=y.sqrt(0.25-C(e-0.5,2))*g+0.5)&&f!=0.5&&(f=f.toFixed(5)-0.00001*g)}return p});b=b[s](/\s*\-\s*/);if(d=="linear"){var i=b.shift();i=-S(i);if(isNaN(i))return null;var j=[0,0,y.cos(i*D/180),y.sin(i*D/180)],k=1/(z(B(j[2]),B(j[3]))||1);j[2]*=k;j[3]*=k;if(j[2]<0){j[0]=-j[2];j[2]=0}if(j[3]<0){j[1]=-j[3];j[3]=0}}var m=bx(b);if(!m)return null;var n=a.getAttribute(I);n=n.match(/^url\(#(.*)\)$/);n&&c.defs.removeChild(g.getElementById(n[1]));var o=bG(d+"Gradient");o.id=bh();bG(o,d=="radial"?{fx:e,fy:f}:{x1:j[0],y1:j[1],x2:j[2],y2:j[3]});c.defs[l](o);for(var q=0,t=m[w];q<t;q++){var u=bG("stop");bG(u,{offset:m[q].offset?m[q].offset:q?"100%":"0%","stop-color":m[q].color||"#fff"});o[l](u)}bG(a,{fill:"url(#"+o.id+")",opacity:1,"fill-opacity":1});h.fill=p;h.opacity=1;h.fillOpacity=1;return 1},bJ=function(b){var c=b.getBBox();bG(b.pattern,{patternTransform:a.format("translate({0},{1})",c.x,c.y)})},bK=function(c,d){var e={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},h=c.node,i=c.attrs,j=c.rotate(),k=function(a,b){b=e[x.call(b)];if(b){var c=a.attrs["stroke-width"]||"1",f=({round:c,square:c,butt:0})[a.attrs["stroke-linecap"]||d["stroke-linecap"]]||0,g=[],i=b[w];while(i--)g[i]=b[i]*c+(i%2?1:-1)*f;bG(h,{"stroke-dasharray":g[v](",")})}};d[f]("rotation")&&(j=d.rotation);var m=r(j)[s](b);if(m.length-1){m[1]=+m[1];m[2]=+m[2]}else m=null;S(j)&&c.rotate(0,true);for(var n in d){if(d[f](n)){if(!W[f](n))continue;var o=d[n];i[n]=o;switch(n){case"blur":c.blur(o);break;case"rotation":c.rotate(o,true);break;case"href":case"title":case"target":var t=h.parentNode;if(x.call(t.tagName)!="a"){var u=bG("a");t.insertBefore(u,h);u[l](h);t=u}n=="target"&&o=="blank"?t.setAttributeNS(c.paper.xlink,"show","new"):t.setAttributeNS(c.paper.xlink,n,o);break;case"cursor":h.style.cursor=o;break;case"clip-rect":var y=r(o)[s](b);if(y[w]==4){c.clip&&c.clip.parentNode.parentNode.removeChild(c.clip.parentNode);var z=bG("clipPath"),A=bG("rect");z.id=bh();bG(A,{x:y[0],y:y[1],width:y[2],height:y[3]});z[l](A);c.paper.defs[l](z);bG(h,{"clip-path":"url(#"+z.id+")"});c.clip=A}if(!o){var B=g.getElementById(h.getAttribute("clip-path")[Y](/(^url\(#|\)$)/g,p));B&&B.parentNode.removeChild(B);bG(h,{"clip-path":p});delete c.clip}break;case"path":c.type=="path"&&bG(h,{d:o?i.path=bq(o):"M0,0"});break;case"width":h[R](n,o);if(i.fx){n="x";o=i.x}else break;case"x":i.fx&&(o=-i.x-(i.width||0));case"rx":if(n=="rx"&&c.type=="rect")break;case"cx":m&&(n=="x"||n=="cx")&&(m[1]+=o-i[n]);h[R](n,o);c.pattern&&bJ(c);break;case"height":h[R](n,o);if(i.fy){n="y";o=i.y}else break;case"y":i.fy&&(o=-i.y-(i.height||0));case"ry":if(n=="ry"&&c.type=="rect")break;case"cy":m&&(n=="y"||n=="cy")&&(m[2]+=o-i[n]);h[R](n,o);c.pattern&&bJ(c);break;case"r":c.type=="rect"?bG(h,{rx:o,ry:o}):h[R](n,o);break;case"src":c.type=="image"&&h.setAttributeNS(c.paper.xlink,"href",o);break;case"stroke-width":h.style.strokeWidth=o;h[R](n,o);i["stroke-dasharray"]&&k(c,i["stroke-dasharray"]);break;case"stroke-dasharray":k(c,o);break;case"translation":var C=r(o)[s](b);C[0]=+C[0]||0;C[1]=+C[1]||0;if(m){m[1]+=C[0];m[2]+=C[1]}cz.call(c,C[0],C[1]);break;case"scale":C=r(o)[s](b);c.scale(+C[0]||1,+C[1]||+C[0]||1,isNaN(S(C[2]))?null:+C[2],isNaN(S(C[3]))?null:+C[3]);break;case I:var D=r(o).match(M);if(D){z=bG("pattern");var E=bG("image");z.id=bh();bG(z,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1});bG(E,{x:0,y:0});E.setAttributeNS(c.paper.xlink,"href",D[1]);z[l](E);var F=g.createElement("img");F.style.cssText="position:absolute;left:-9999em;top-9999em";F.onload=function(){bG(z,{width:this.offsetWidth,height:this.offsetHeight});bG(E,{width:this.offsetWidth,height:this.offsetHeight});g.body.removeChild(this);c.paper.safari()};g.body[l](F);F.src=D[1];c.paper.defs[l](z);h.style.fill="url(#"+z.id+")";bG(h,{fill:"url(#"+z.id+")"});c.pattern=z;c.pattern&&bJ(c);break}var G=a.getRGB(o);if(G.error)if((({circle:1,ellipse:1})[f](c.type)||r(o).charAt()!="r")&&bI(h,o,c.paper)){i.gradient=o;i.fill="none";break}else{delete d.gradient;delete i.gradient;!a.is(i.opacity,"undefined")&&a.is(d.opacity,"undefined")&&bG(h,{opacity:i.opacity});!a.is(i["fill-opacity"],"undefined")&&a.is(d["fill-opacity"],"undefined")&&bG(h,{"fill-opacity":i["fill-opacity"]})}G[f]("opacity")&&bG(h,{"fill-opacity":G.opacity>1?G.opacity/100:G.opacity});case"stroke":G=a.getRGB(o);h[R](n,G.hex);n=="stroke"&&G[f]("opacity")&&bG(h,{"stroke-opacity":G.opacity>1?G.opacity/100:G.opacity});break;case"gradient":(({circle:1,ellipse:1})[f](c.type)||r(o).charAt()!="r")&&bI(h,o,c.paper);break;case"opacity":i.gradient&&!i[f]("stroke-opacity")&&bG(h,{"stroke-opacity":o>1?o/100:o});case"fill-opacity":if(i.gradient){var H=g.getElementById(h.getAttribute(I)[Y](/^url\(#|\)$/g,p));if(H){var J=H.getElementsByTagName("stop");J[J[w]-1][R]("stop-opacity",o)}break}default:n=="font-size"&&(o=T(o,10)+"px");var K=n[Y](/(\-.)/g,function(a){return V.call(a.substring(1))});h.style[K]=o;h[R](n,o);break}}}bM(c,d);m?c.rotate(m.join(q)):S(j)&&c.rotate(j,true)},bL=1.2,bM=function(b,c){if(b.type!="text"||!(c[f]("text")||c[f]("font")||c[f]("font-size")||c[f]("x")||c[f]("y")))return;var d=b.attrs,e=b.node,h=e.firstChild?T(g.defaultView.getComputedStyle(e.firstChild,p).getPropertyValue("font-size"),10):10;if(c[f]("text")){d.text=c.text;while(e.firstChild)e.removeChild(e.firstChild);var i=r(c.text)[s]("\n");for(var j=0,k=i[w];j<k;j++)if(i[j]){var m=bG("tspan");j&&bG(m,{dy:h*bL,x:d.x});m[l](g.createTextNode(i[j]));e[l](m)}}else{i=e.getElementsByTagName("tspan");for(j=0,k=i[w];j<k;j++)j&&bG(i[j],{dy:h*bL,x:d.x})}bG(e,{y:d.y});var n=b.getBBox(),o=d.y-(n.y+n.height/2);o&&a.is(o,"finite")&&bG(e,{y:d.y+o})},bN=function(b,c){var d=0,e=0;this[0]=b;this.id=a._oid++;this.node=b;b.raphael=this;this.paper=c;this.attrs=this.attrs||{};this.transformations=[];this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1};!c.bottom&&(c.bottom=this);this.prev=c.top;c.top&&(c.top.next=this);c.top=this;this.next=null},bO=bN[e];bN[e].rotate=function(c,d,e){if(this.removed)return this;if(c==null){if(this._.rt.cx)return[this._.rt.deg,this._.rt.cx,this._.rt.cy][v](q);return this._.rt.deg}var f=this.getBBox();c=r(c)[s](b);if(c[w]-1){d=S(c[1]);e=S(c[2])}c=S(c[0]);d!=null&&d!==false?this._.rt.deg=c:this._.rt.deg+=c;e==null&&(d=null);this._.rt.cx=d;this._.rt.cy=e;d=d==null?f.x+f.width/2:d;e=e==null?f.y+f.height/2:e;if(this._.rt.deg){this.transformations[0]=a.format("rotate({0} {1} {2})",this._.rt.deg,d,e);this.clip&&bG(this.clip,{transform:a.format("rotate({0} {1} {2})",-this._.rt.deg,d,e)})}else{this.transformations[0]=p;this.clip&&bG(this.clip,{transform:p})}bG(this.node,{transform:this.transformations[v](q)});return this};bN[e].hide=function(){!this.removed&&(this.node.style.display="none");return this};bN[e].show=function(){!this.removed&&(this.node.style.display="");return this};bN[e].remove=function(){if(this.removed)return;bA(this,this.paper);this.node.parentNode.removeChild(this.node);for(var a in this)delete this[a];this.removed=true};bN[e].getBBox=function(){if(this.removed)return this;if(this.type=="path")return bn(this.attrs.path);if(this.node.style.display=="none"){this.show();var a=true}var b={};try{b=this.node.getBBox()}catch(a){}finally{b=b||{}}if(this.type=="text"){b={x:b.x,y:Infinity,width:0,height:0};for(var c=0,d=this.node.getNumberOfChars();c<d;c++){var e=this.node.getExtentOfChar(c);e.y<b.y&&(b.y=e.y);e.y+e.height-b.y>b.height&&(b.height=e.y+e.height-b.y);e.x+e.width-b.x>b.width&&(b.width=e.x+e.width-b.x)}}a&&this.hide();return b};bN[e].attr=function(b,c){if(this.removed)return this;if(b==null){var d={};for(var e in this.attrs)this.attrs[f](e)&&(d[e]=this.attrs[e]);this._.rt.deg&&(d.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(d.scale=this.scale());d.gradient&&d.fill=="none"&&(d.fill=d.gradient)&&delete d.gradient;return d}if(c==null&&a.is(b,F)){if(b=="translation")return cz.call(this);if(b=="rotation")return this.rotate();if(b=="scale")return this.scale();if(b==I&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[b]}if(c==null&&a.is(b,G)){var g={};for(var h=0,i=b.length;h<i;h++)g[b[h]]=this.attr(b[h]);return g}if(c!=null){var j={};j[b]=c}else b!=null&&a.is(b,"object")&&(j=b);for(var k in this.paper.customAttributes)if(this.paper.customAttributes[f](k)&&j[f](k)&&a.is(this.paper.customAttributes[k],"function")){var l=this.paper.customAttributes[k].apply(this,[][n](j[k]));this.attrs[k]=j[k];for(var m in l)l[f](m)&&(j[m]=l[m])}bK(this,j);return this};bN[e].toFront=function(){if(this.removed)return this;this.node.parentNode[l](this.node);var a=this.paper;a.top!=this&&bB(this,a);return this};bN[e].toBack=function(){if(this.removed)return this;if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);bC(this,this.paper);var a=this.paper}return this};bN[e].insertAfter=function(a){if(this.removed)return this;var b=a.node||a[a.length-1].node;b.nextSibling?b.parentNode.insertBefore(this.node,b.nextSibling):b.parentNode[l](this.node);bD(this,a,this.paper);return this};bN[e].insertBefore=function(a){if(this.removed)return this;var b=a.node||a[0].node;b.parentNode.insertBefore(this.node,b);bE(this,a,this.paper);return this};bN[e].blur=function(a){var b=this;if(+a!==0){var c=bG("filter"),d=bG("feGaussianBlur");b.attrs.blur=a;c.id=bh();bG(d,{stdDeviation:+a||1.5});c.appendChild(d);b.paper.defs.appendChild(c);b._blur=c;bG(b.node,{filter:"url(#"+c.id+")"})}else{if(b._blur){b._blur.parentNode.removeChild(b._blur);delete b._blur;delete b.attrs.blur}b.node.removeAttribute("filter")}};var bP=function(a,b,c,d){var e=bG("circle");a.canvas&&a.canvas[l](e);var f=new bN(e,a);f.attrs={cx:b,cy:c,r:d,fill:"none",stroke:"#000"};f.type="circle";bG(e,f.attrs);return f},bQ=function(a,b,c,d,e,f){var g=bG("rect");a.canvas&&a.canvas[l](g);var h=new bN(g,a);h.attrs={x:b,y:c,width:d,height:e,r:f||0,rx:f||0,ry:f||0,fill:"none",stroke:"#000"};h.type="rect";bG(g,h.attrs);return h},bR=function(a,b,c,d,e){var f=bG("ellipse");a.canvas&&a.canvas[l](f);var g=new bN(f,a);g.attrs={cx:b,cy:c,rx:d,ry:e,fill:"none",stroke:"#000"};g.type="ellipse";bG(f,g.attrs);return g},bS=function(a,b,c,d,e,f){var g=bG("image");bG(g,{x:c,y:d,width:e,height:f,preserveAspectRatio:"none"});g.setAttributeNS(a.xlink,"href",b);a.canvas&&a.canvas[l](g);var h=new bN(g,a);h.attrs={x:c,y:d,width:e,height:f,src:b};h.type="image";return h},bT=function(a,b,c,d){var e=bG("text");bG(e,{x:b,y:c,"text-anchor":"middle"});a.canvas&&a.canvas[l](e);var f=new bN(e,a);f.attrs={x:b,y:c,"text-anchor":"middle",text:d,font:W.font,stroke:"none",fill:"#000"};f.type="text";bK(f,f.attrs);return f},bU=function(a,b){this.width=a||this.width;this.height=b||this.height;this.canvas[R]("width",this.width);this.canvas[R]("height",this.height);return this},bV=function(){var b=by[m](0,arguments),c=b&&b.container,d=b.x,e=b.y,f=b.width,h=b.height;if(!c)throw new Error("SVG container not found.");var i=bG("svg");d=d||0;e=e||0;f=f||512;h=h||342;bG(i,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:f,height:h});if(c==1){i.style.cssText="position:absolute;left:"+d+"px;top:"+e+"px";g.body[l](i)}else c.firstChild?c.insertBefore(i,c.firstChild):c[l](i);c=new j;c.width=f;c.height=h;c.canvas=i;bz.call(c,c,a.fn);c.clear();return c};k.clear=function(){var a=this.canvas;while(a.firstChild)a.removeChild(a.firstChild);this.bottom=this.top=null;(this.desc=bG("desc"))[l](g.createTextNode("Created with Raphaël"));a[l](this.desc);a[l](this.defs=bG("defs"))};k.remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=bF(a)}}if(a.vml){var bW={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},bX=/([clmz]),?([^clmz]*)/gi,bY=/ progid:\S+Blur\([^\)]+\)/g,bZ=/-?[^,\s-]+/g,b$=1000+q+1000,b_=10,ca={path:1,rect:1},cb=function(a){var b=/[ahqstv]/ig,c=bq;r(a).match(b)&&(c=bw);b=/[clmz]/g;if(c==bq&&!r(a).match(b)){var d=r(a)[Y](bX,function(a,b,c){var d=[],e=x.call(b)=="m",f=bW[b];c[Y](bZ,function(a){if(e&&d[w]==2){f+=d+bW[b=="m"?"l":"L"];d=[]}d[L](Q(a*b_))});return f+d});return d}var e=c(a),f,g;d=[];for(var h=0,i=e[w];h<i;h++){f=e[h];g=x.call(e[h][0]);g=="z"&&(g="x");for(var j=1,k=f[w];j<k;j++)g+=Q(f[j]*b_)+(j!=k-1?",":p);d[L](g)}return d[v](q)};a[H]=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version};bH=function(a,b){var c=cd("group");c.style.cssText="position:absolute;left:0;top:0;width:"+b.width+"px;height:"+b.height+"px";c.coordsize=b.coordsize;c.coordorigin=b.coordorigin;var d=cd("shape"),e=d.style;e.width=b.width+"px";e.height=b.height+"px";d.coordsize=b$;d.coordorigin=b.coordorigin;c[l](d);var f=new bN(d,c,b),g={fill:"none",stroke:"#000"};a&&(g.path=a);f.type="path";f.path=[];f.Path=p;bK(f,g);b.canvas[l](c);return f};bK=function(c,d){c.attrs=c.attrs||{};var e=c.node,h=c.attrs,i=e.style,j,k=(d.x!=h.x||d.y!=h.y||d.width!=h.width||d.height!=h.height||d.r!=h.r)&&c.type=="rect",m=c;for(var n in d)d[f](n)&&(h[n]=d[n]);if(k){h.path=cc(h.x,h.y,h.width,h.height,h.r);c.X=h.x;c.Y=h.y;c.W=h.width;c.H=h.height}d.href&&(e.href=d.href);d.title&&(e.title=d.title);d.target&&(e.target=d.target);d.cursor&&(i.cursor=d.cursor);"blur"in d&&c.blur(d.blur);if(d.path&&c.type=="path"||k)e.path=cb(h.path);d.rotation!=null&&c.rotate(d.rotation,true);if(d.translation){j=r(d.translation)[s](b);cz.call(c,j[0],j[1]);if(c._.rt.cx!=null){c._.rt.cx+=+j[0];c._.rt.cy+=+j[1];c.setBox(c.attrs,j[0],j[1])}}if(d.scale){j=r(d.scale)[s](b);c.scale(+j[0]||1,+j[1]||+j[0]||1,+j[2]||null,+j[3]||null)}if("clip-rect"in d){var o=r(d["clip-rect"])[s](b);if(o[w]==4){o[2]=+o[2]+ +o[0];o[3]=+o[3]+ +o[1];var q=e.clipRect||g.createElement("div"),t=q.style,u=e.parentNode;t.clip=a.format("rect({1}px {2}px {3}px {0}px)",o);if(!e.clipRect){t.position="absolute";t.top=0;t.left=0;t.width=c.paper.width+"px";t.height=c.paper.height+"px";u.parentNode.insertBefore(q,u);q[l](u);e.clipRect=q}}d["clip-rect"]||e.clipRect&&(e.clipRect.style.clip=p)}c.type=="image"&&d.src&&(e.src=d.src);if(c.type=="image"&&d.opacity){e.filterOpacity=U+".Alpha(opacity="+d.opacity*100+")";i.filter=(e.filterMatrix||p)+(e.filterOpacity||p)}d.font&&(i.font=d.font);d["font-family"]&&(i.fontFamily="\""+d["font-family"][s](",")[0][Y](/^['"]+|['"]+$/g,p)+"\"");d["font-size"]&&(i.fontSize=d["font-size"]);d["font-weight"]&&(i.fontWeight=d["font-weight"]);d["font-style"]&&(i.fontStyle=d["font-style"]);if(d.opacity!=null||d["stroke-width"]!=null||d.fill!=null||d.stroke!=null||d["stroke-width"]!=null||d["stroke-opacity"]!=null||d["fill-opacity"]!=null||d["stroke-dasharray"]!=null||d["stroke-miterlimit"]!=null||d["stroke-linejoin"]!=null||d["stroke-linecap"]!=null){e=c.shape||e;var v=e.getElementsByTagName(I)&&e.getElementsByTagName(I)[0],x=false;!v&&(x=v=cd(I));if("fill-opacity"in d||"opacity"in d){var y=((+h["fill-opacity"]+1||2)-1)*((+h.opacity+1||2)-1)*((+a.getRGB(d.fill).o+1||2)-1);y=A(z(y,0),1);v.opacity=y}d.fill&&(v.on=true);if(v.on==null||d.fill=="none")v.on=false;if(v.on&&d.fill){var B=d.fill.match(M);if(B){v.src=B[1];v.type="tile"}else{v.color=a.getRGB(d.fill).hex;v.src=p;v.type="solid";if(a.getRGB(d.fill).error&&(m.type in{circle:1,ellipse:1}||r(d.fill).charAt()!="r")&&bI(m,d.fill)){h.fill="none";h.gradient=d.fill}}}x&&e[l](v);var C=e.getElementsByTagName("stroke")&&e.getElementsByTagName("stroke")[0],D=false;!C&&(D=C=cd("stroke"));if(d.stroke&&d.stroke!="none"||d["stroke-width"]||d["stroke-opacity"]!=null||d["stroke-dasharray"]||d["stroke-miterlimit"]||d["stroke-linejoin"]||d["stroke-linecap"])C.on=true;(d.stroke=="none"||C.on==null||d.stroke==0||d["stroke-width"]==0)&&(C.on=false);var E=a.getRGB(d.stroke);C.on&&d.stroke&&(C.color=E.hex);y=((+h["stroke-opacity"]+1||2)-1)*((+h.opacity+1||2)-1)*((+E.o+1||2)-1);var F=(S(d["stroke-width"])||1)*0.75;y=A(z(y,0),1);d["stroke-width"]==null&&(F=h["stroke-width"]);d["stroke-width"]&&(C.weight=F);F&&F<1&&(y*=F)&&(C.weight=1);C.opacity=y;d["stroke-linejoin"]&&(C.joinstyle=d["stroke-linejoin"]||"miter");C.miterlimit=d["stroke-miterlimit"]||8;d["stroke-linecap"]&&(C.endcap=d["stroke-linecap"]=="butt"?"flat":d["stroke-linecap"]=="square"?"square":"round");if(d["stroke-dasharray"]){var G={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};C.dashstyle=G[f](d["stroke-dasharray"])?G[d["stroke-dasharray"]]:p}D&&e[l](C)}if(m.type=="text"){i=m.paper.span.style;h.font&&(i.font=h.font);h["font-family"]&&(i.fontFamily=h["font-family"]);h["font-size"]&&(i.fontSize=h["font-size"]);h["font-weight"]&&(i.fontWeight=h["font-weight"]);h["font-style"]&&(i.fontStyle=h["font-style"]);m.node.string&&(m.paper.span.innerHTML=r(m.node.string)[Y](/</g,"&#60;")[Y](/&/g,"&#38;")[Y](/\n/g,"<br>"));m.W=h.w=m.paper.span.offsetWidth;m.H=h.h=m.paper.span.offsetHeight;m.X=h.x;m.Y=h.y+Q(m.H/2);switch(h["text-anchor"]){case"start":m.node.style["v-text-align"]="left";m.bbx=Q(m.W/2);break;case"end":m.node.style["v-text-align"]="right";m.bbx=-Q(m.W/2);break;default:m.node.style["v-text-align"]="center";break}}};bI=function(a,b){a.attrs=a.attrs||{};var c=a.attrs,d,e="linear",f=".5 .5";a.attrs.gradient=b;b=r(b)[Y](bd,function(a,b,c){e="radial";if(b&&c){b=S(b);c=S(c);C(b-0.5,2)+C(c-0.5,2)>0.25&&(c=y.sqrt(0.25-C(b-0.5,2))*((c>0.5)*2-1)+0.5);f=b+q+c}return p});b=b[s](/\s*\-\s*/);if(e=="linear"){var g=b.shift();g=-S(g);if(isNaN(g))return null}var h=bx(b);if(!h)return null;a=a.shape||a.node;d=a.getElementsByTagName(I)[0]||cd(I);!d.parentNode&&a.appendChild(d);if(h[w]){d.on=true;d.method="none";d.color=h[0].color;d.color2=h[h[w]-1].color;var i=[];for(var j=0,k=h[w];j<k;j++)h[j].offset&&i[L](h[j].offset+q+h[j].color);d.colors&&(d.colors.value=i[w]?i[v]():"0% "+d.color);if(e=="radial"){d.type="gradientradial";d.focus="100%";d.focussize=f;d.focusposition=f}else{d.type="gradient";d.angle=(270-g)%360}}return 1};bN=function(b,c,d){var e=0,f=0,g=0,h=1;this[0]=b;this.id=a._oid++;this.node=b;b.raphael=this;this.X=0;this.Y=0;this.attrs={};this.Group=c;this.paper=d;this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};!d.bottom&&(d.bottom=this);this.prev=d.top;d.top&&(d.top.next=this);d.top=this;this.next=null};bO=bN[e];bO.rotate=function(a,c,d){if(this.removed)return this;if(a==null){if(this._.rt.cx)return[this._.rt.deg,this._.rt.cx,this._.rt.cy][v](q);return this._.rt.deg}a=r(a)[s](b);if(a[w]-1){c=S(a[1]);d=S(a[2])}a=S(a[0]);c!=null?this._.rt.deg=a:this._.rt.deg+=a;d==null&&(c=null);this._.rt.cx=c;this._.rt.cy=d;this.setBox(this.attrs,c,d);this.Group.style.rotation=this._.rt.deg;return this};bO.setBox=function(a,b,c){if(this.removed)return this;var d=this.Group.style,e=this.shape&&this.shape.style||this.node.style;a=a||{};for(var g in a)a[f](g)&&(this.attrs[g]=a[g]);b=b||this._.rt.cx;c=c||this._.rt.cy;var h=this.attrs,i,j,k,l;switch(this.type){case"circle":i=h.cx-h.r;j=h.cy-h.r;k=l=h.r*2;break;case"ellipse":i=h.cx-h.rx;j=h.cy-h.ry;k=h.rx*2;l=h.ry*2;break;case"image":i=+h.x;j=+h.y;k=h.width||0;l=h.height||0;break;case"text":this.textpath.v=["m",Q(h.x),", ",Q(h.y-2),"l",Q(h.x)+1,", ",Q(h.y-2)][v](p);i=h.x-Q(this.W/2);j=h.y-this.H/2;k=this.W;l=this.H;break;case"rect":case"path":if(this.attrs.path){var m=bn(this.attrs.path);i=m.x;j=m.y;k=m.width;l=m.height}else{i=0;j=0;k=this.paper.width;l=this.paper.height}break;default:i=0;j=0;k=this.paper.width;l=this.paper.height;break}b=b==null?i+k/2:b;c=c==null?j+l/2:c;var n=b-this.paper.width/2,o=c-this.paper.height/2,q;d.left!=(q=n+"px")&&(d.left=q);d.top!=(q=o+"px")&&(d.top=q);this.X=ca[f](this.type)?-n:i;this.Y=ca[f](this.type)?-o:j;this.W=k;this.H=l;if(ca[f](this.type)){e.left!=(q=-n*b_+"px")&&(e.left=q);e.top!=(q=-o*b_+"px")&&(e.top=q)}else if(this.type=="text"){e.left!=(q=-n+"px")&&(e.left=q);e.top!=(q=-o+"px")&&(e.top=q)}else{d.width!=(q=this.paper.width+"px")&&(d.width=q);d.height!=(q=this.paper.height+"px")&&(d.height=q);e.left!=(q=i-n+"px")&&(e.left=q);e.top!=(q=j-o+"px")&&(e.top=q);e.width!=(q=k+"px")&&(e.width=q);e.height!=(q=l+"px")&&(e.height=q)}};bO.hide=function(){!this.removed&&(this.Group.style.display="none");return this};bO.show=function(){!this.removed&&(this.Group.style.display="block");return this};bO.getBBox=function(){if(this.removed)return this;if(ca[f](this.type))return bn(this.attrs.path);return{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}};bO.remove=function(){if(this.removed)return;bA(this,this.paper);this.node.parentNode.removeChild(this.node);this.Group.parentNode.removeChild(this.Group);this.shape&&this.shape.parentNode.removeChild(this.shape);for(var a in this)delete this[a];this.removed=true};bO.attr=function(b,c){if(this.removed)return this;if(b==null){var d={};for(var e in this.attrs)this.attrs[f](e)&&(d[e]=this.attrs[e]);this._.rt.deg&&(d.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(d.scale=this.scale());d.gradient&&d.fill=="none"&&(d.fill=d.gradient)&&delete d.gradient;return d}if(c==null&&a.is(b,"string")){if(b=="translation")return cz.call(this);if(b=="rotation")return this.rotate();if(b=="scale")return this.scale();if(b==I&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[b]}if(this.attrs&&c==null&&a.is(b,G)){var g,h={};for(e=0,g=b[w];e<g;e++)h[b[e]]=this.attr(b[e]);return h}var i;if(c!=null){i={};i[b]=c}c==null&&a.is(b,"object")&&(i=b);if(i){for(var j in this.paper.customAttributes)if(this.paper.customAttributes[f](j)&&i[f](j)&&a.is(this.paper.customAttributes[j],"function")){var k=this.paper.customAttributes[j].apply(this,[][n](i[j]));this.attrs[j]=i[j];for(var l in k)k[f](l)&&(i[l]=k[l])}i.text&&this.type=="text"&&(this.node.string=i.text);bK(this,i);i.gradient&&(({circle:1,ellipse:1})[f](this.type)||r(i.gradient).charAt()!="r")&&bI(this,i.gradient);(!ca[f](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this};bO.toFront=function(){!this.removed&&this.Group.parentNode[l](this.Group);this.paper.top!=this&&bB(this,this.paper);return this};bO.toBack=function(){if(this.removed)return this;if(this.Group.parentNode.firstChild!=this.Group){this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild);bC(this,this.paper)}return this};bO.insertAfter=function(a){if(this.removed)return this;a.constructor==cC&&(a=a[a.length-1]);a.Group.nextSibling?a.Group.parentNode.insertBefore(this.Group,a.Group.nextSibling):a.Group.parentNode[l](this.Group);bD(this,a,this.paper);return this};bO.insertBefore=function(a){if(this.removed)return this;a.constructor==cC&&(a=a[0]);a.Group.parentNode.insertBefore(this.Group,a.Group);bE(this,a,this.paper);return this};bO.blur=function(b){var c=this.node.runtimeStyle,d=c.filter;d=d.replace(bY,p);if(+b!==0){this.attrs.blur=b;c.filter=d+q+U+".Blur(pixelradius="+(+b||1.5)+")";c.margin=a.format("-{0}px 0 0 -{0}px",Q(+b||1.5))}else{c.filter=d;c.margin=0;delete this.attrs.blur}};bP=function(a,b,c,d){var e=cd("group"),f=cd("oval"),g=f.style;e.style.cssText="position:absolute;left:0;top:0;width:"+a.width+"px;height:"+a.height+"px";e.coordsize=b$;e.coordorigin=a.coordorigin;e[l](f);var h=new bN(f,e,a);h.type="circle";bK(h,{stroke:"#000",fill:"none"});h.attrs.cx=b;h.attrs.cy=c;h.attrs.r=d;h.setBox({x:b-d,y:c-d,width:d*2,height:d*2});a.canvas[l](e);return h};function cc(b,c,d,e,f){return f?a.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",b+f,c,d-f*2,f,-f,e-f*2,f*2-d,f*2-e):a.format("M{0},{1}l{2},0,0,{3},{4},0z",b,c,d,e,-d)}bQ=function(a,b,c,d,e,f){var g=cc(b,c,d,e,f),h=a.path(g),i=h.attrs;h.X=i.x=b;h.Y=i.y=c;h.W=i.width=d;h.H=i.height=e;i.r=f;i.path=g;h.type="rect";return h};bR=function(a,b,c,d,e){var f=cd("group"),g=cd("oval"),h=g.style;f.style.cssText="position:absolute;left:0;top:0;width:"+a.width+"px;height:"+a.height+"px";f.coordsize=b$;f.coordorigin=a.coordorigin;f[l](g);var i=new bN(g,f,a);i.type="ellipse";bK(i,{stroke:"#000"});i.attrs.cx=b;i.attrs.cy=c;i.attrs.rx=d;i.attrs.ry=e;i.setBox({x:b-d,y:c-e,width:d*2,height:e*2});a.canvas[l](f);return i};bS=function(a,b,c,d,e,f){var g=cd("group"),h=cd("image");g.style.cssText="position:absolute;left:0;top:0;width:"+a.width+"px;height:"+a.height+"px";g.coordsize=b$;g.coordorigin=a.coordorigin;h.src=b;g[l](h);var i=new bN(h,g,a);i.type="image";i.attrs.src=b;i.attrs.x=c;i.attrs.y=d;i.attrs.w=e;i.attrs.h=f;i.setBox({x:c,y:d,width:e,height:f});a.canvas[l](g);return i};bT=function(b,c,d,e){var f=cd("group"),g=cd("shape"),h=g.style,i=cd("path"),j=i.style,k=cd("textpath");f.style.cssText="position:absolute;left:0;top:0;width:"+b.width+"px;height:"+b.height+"px";f.coordsize=b$;f.coordorigin=b.coordorigin;i.v=a.format("m{0},{1}l{2},{1}",Q(c*10),Q(d*10),Q(c*10)+1);i.textpathok=true;h.width=b.width;h.height=b.height;k.string=r(e);k.on=true;g[l](k);g[l](i);f[l](g);var m=new bN(k,f,b);m.shape=g;m.textpath=i;m.type="text";m.attrs.text=e;m.attrs.x=c;m.attrs.y=d;m.attrs.w=1;m.attrs.h=1;bK(m,{font:W.font,stroke:"none",fill:"#000"});m.setBox();b.canvas[l](f);return m};bU=function(a,b){var c=this.canvas.style;a==+a&&(a+="px");b==+b&&(b+="px");c.width=a;c.height=b;c.clip="rect(0 "+a+" "+b+" 0)";return this};var cd;g.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!g.namespaces.rvml&&g.namespaces.add("rvml","urn:schemas-microsoft-com:vml");cd=function(a){return g.createElement("<rvml:"+a+" class=\"rvml\">")}}catch(a){cd=function(a){return g.createElement("<"+a+" xmlns=\"urn:schemas-microsoft.com:vml\" class=\"rvml\">")}}bV=function(){var b=by[m](0,arguments),c=b.container,d=b.height,e,f=b.width,h=b.x,i=b.y;if(!c)throw new Error("VML container not found.");var k=new j,n=k.canvas=g.createElement("div"),o=n.style;h=h||0;i=i||0;f=f||512;d=d||342;f==+f&&(f+="px");d==+d&&(d+="px");k.width=1000;k.height=1000;k.coordsize=b_*1000+q+b_*1000;k.coordorigin="0 0";k.span=g.createElement("span");k.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";n[l](k.span);o.cssText=a.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",f,d);if(c==1){g.body[l](n);o.left=h+"px";o.top=i+"px";o.position="absolute"}else c.firstChild?c.insertBefore(n,c.firstChild):c[l](n);bz.call(k,k,a.fn);return k};k.clear=function(){this.canvas.innerHTML=p;this.span=g.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[l](this.span);this.bottom=this.top=null};k.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=bF(a);return true}}var ce=navigator.userAgent.match(/Version\\x2f(.*?)\s/);navigator.vendor=="Apple Computer, Inc."&&(ce&&ce[1]<4||navigator.platform.slice(0,2)=="iP")?k.safari=function(){var a=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});h.setTimeout(function(){a.remove()})}:k.safari=function(){};var cf=function(){this.returnValue=false},cg=function(){return this.originalEvent.preventDefault()},ch=function(){this.cancelBubble=true},ci=function(){return this.originalEvent.stopPropagation()},cj=(function(){{if(g.addEventListener)return function(a,b,c,d){var e=o&&u[b]?u[b]:b,g=function(e){if(o&&u[f](b))for(var g=0,h=e.targetTouches&&e.targetTouches.length;g<h;g++){if(e.targetTouches[g].target==a){var i=e;e=e.targetTouches[g];e.originalEvent=i;e.preventDefault=cg;e.stopPropagation=ci;break}}return c.call(d,e)};a.addEventListener(e,g,false);return function(){a.removeEventListener(e,g,false);return true}};if(g.attachEvent)return function(a,b,c,d){var e=function(a){a=a||h.event;a.preventDefault=a.preventDefault||cf;a.stopPropagation=a.stopPropagation||ch;return c.call(d,a)};a.attachEvent("on"+b,e);var f=function(){a.detachEvent("on"+b,e);return true};return f}}})(),ck=[],cl=function(a){var b=a.clientX,c=a.clientY,d=g.documentElement.scrollTop||g.body.scrollTop,e=g.documentElement.scrollLeft||g.body.scrollLeft,f,h=ck.length;while(h--){f=ck[h];if(o){var i=a.touches.length,j;while(i--){j=a.touches[i];if(j.identifier==f.el._drag.id){b=j.clientX;c=j.clientY;(a.originalEvent?a.originalEvent:a).preventDefault();break}}}else a.preventDefault();b+=e;c+=d;f.move&&f.move.call(f.move_scope||f.el,b-f.el._drag.x,c-f.el._drag.y,b,c,a)}},cm=function(b){a.unmousemove(cl).unmouseup(cm);var c=ck.length,d;while(c--){d=ck[c];d.el._drag={};d.end&&d.end.call(d.end_scope||d.start_scope||d.move_scope||d.el,b)}ck=[]};for(var cn=t[w];cn--;)(function(b){a[b]=bN[e][b]=function(c,d){if(a.is(c,"function")){this.events=this.events||[];this.events.push({name:b,f:c,unbind:cj(this.shape||this.node||g,b,c,d||this)})}return this};a["un"+b]=bN[e]["un"+b]=function(a){var c=this.events,d=c[w];while(d--)if(c[d].name==b&&c[d].f==a){c[d].unbind();c.splice(d,1);!c.length&&delete this.events;return this}return this}})(t[cn]);bO.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)};bO.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};bO.drag=function(b,c,d,e,f,h){this._drag={};this.mousedown(function(i){(i.originalEvent||i).preventDefault();var j=g.documentElement.scrollTop||g.body.scrollTop,k=g.documentElement.scrollLeft||g.body.scrollLeft;this._drag.x=i.clientX+k;this._drag.y=i.clientY+j;this._drag.id=i.identifier;c&&c.call(f||e||this,i.clientX+k,i.clientY+j,i);!ck.length&&a.mousemove(cl).mouseup(cm);ck.push({el:this,move:b,end:d,move_scope:e,start_scope:f,end_scope:h})});return this};bO.undrag=function(b,c,d){var e=ck.length;while(e--)ck[e].el==this&&(ck[e].move==b&&ck[e].end==d)&&ck.splice(e++,1);!ck.length&&a.unmousemove(cl).unmouseup(cm)};k.circle=function(a,b,c){return bP(this,a||0,b||0,c||0)};k.rect=function(a,b,c,d,e){return bQ(this,a||0,b||0,c||0,d||0,e||0)};k.ellipse=function(a,b,c,d){return bR(this,a||0,b||0,c||0,d||0)};k.path=function(b){b&&!a.is(b,F)&&!a.is(b[0],G)&&(b+=p);return bH(a.format[m](a,arguments),this)};k.image=function(a,b,c,d,e){return bS(this,a||"about:blank",b||0,c||0,d||0,e||0)};k.text=function(a,b,c){return bT(this,a||0,b||0,r(c))};k.set=function(a){arguments[w]>1&&(a=Array[e].splice.call(arguments,0,arguments[w]));return new cC(a)};k.setSize=bU;k.top=k.bottom=null;k.raphael=a;function co(){return this.x+q+this.y}bO.resetScale=function(){if(this.removed)return this;this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};bO.scale=function(a,b,c,d){if(this.removed)return this;if(a==null&&b==null)return{x:this._.sx,y:this._.sy,toString:co};b=b||a;!(+b)&&(b=a);var e,f,g,h,i=this.attrs;if(a!=0){var j=this.getBBox(),k=j.x+j.width/2,l=j.y+j.height/2,m=B(a/this._.sx),o=B(b/this._.sy);c=+c||c==0?c:k;d=+d||d==0?d:l;var r=this._.sx>0,s=this._.sy>0,t=~(~(a/B(a))),u=~(~(b/B(b))),x=m*t,y=o*u,z=this.node.style,A=c+B(k-c)*x*(k>c==r?1:-1),C=d+B(l-d)*y*(l>d==s?1:-1),D=a*t>b*u?o:m;switch(this.type){case"rect":case"image":var E=i.width*m,F=i.height*o;this.attr({height:F,r:i.r*D,width:E,x:A-E/2,y:C-F/2});break;case"circle":case"ellipse":this.attr({rx:i.rx*m,ry:i.ry*o,r:i.r*D,cx:A,cy:C});break;case"text":this.attr({x:A,y:C});break;case"path":var G=bp(i.path),H=true,I=r?x:m,J=s?y:o;for(var K=0,L=G[w];K<L;K++){var M=G[K],N=V.call(M[0]);{if(N=="M"&&H)continue;H=false}if(N=="A"){M[G[K][w]-2]*=I;M[G[K][w]-1]*=J;M[1]*=m;M[2]*=o;M[5]=+(t+u?!(!(+M[5])):!(+M[5]))}else if(N=="H")for(var O=1,P=M[w];O<P;O++)M[O]*=I;else if(N=="V")for(O=1,P=M[w];O<P;O++)M[O]*=J;else for(O=1,P=M[w];O<P;O++)M[O]*=O%2?I:J}var Q=bn(G);e=A-Q.x-Q.width/2;f=C-Q.y-Q.height/2;G[0][1]+=e;G[0][2]+=f;this.attr({path:G});break}if(this.type in{text:1,image:1}&&(t!=1||u!=1))if(this.transformations){this.transformations[2]="scale("[n](t,",",u,")");this.node[R]("transform",this.transformations[v](q));e=t==-1?-i.x-(E||0):i.x;f=u==-1?-i.y-(F||0):i.y;this.attr({x:e,y:f});i.fx=t-1;i.fy=u-1}else{this.node.filterMatrix=U+".Matrix(M11="[n](t,", M12=0, M21=0, M22=",u,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')");z.filter=(this.node.filterMatrix||p)+(this.node.filterOpacity||p)}else if(this.transformations){this.transformations[2]=p;this.node[R]("transform",this.transformations[v](q));i.fx=0;i.fy=0}else{this.node.filterMatrix=p;z.filter=(this.node.filterMatrix||p)+(this.node.filterOpacity||p)}i.scale=[a,b,c,d][v](q);this._.sx=a;this._.sy=b}return this};bO.clone=function(){if(this.removed)return null;var a=this.attr();delete a.scale;delete a.translation;return this.paper[this.type]().attr(a)};var cp={},cq=function(b,c,d,e,f,g,h,i,j){var k=0,l=100,m=[b,c,d,e,f,g,h,i].join(),n=cp[m],o,p;!n&&(cp[m]=n={data:[]});n.timer&&clearTimeout(n.timer);n.timer=setTimeout(function(){delete cp[m]},2000);if(j!=null){var q=cq(b,c,d,e,f,g,h,i);l=~(~q)*10}for(var r=0;r<l+1;r++){if(n.data[j]>r)p=n.data[r*l];else{p=a.findDotsAtSegment(b,c,d,e,f,g,h,i,r/l);n.data[r]=p}r&&(k+=C(C(o.x-p.x,2)+C(o.y-p.y,2),0.5));if(j!=null&&k>=j)return p;o=p}if(j==null)return k},cr=function(b,c){return function(d,e,f){d=bw(d);var g,h,i,j,k="",l={},m,n=0;for(var o=0,p=d.length;o<p;o++){i=d[o];if(i[0]=="M"){g=+i[1];h=+i[2]}else{j=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6]);if(n+j>e){if(c&&!l.start){m=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);k+=["C",m.start.x,m.start.y,m.m.x,m.m.y,m.x,m.y];if(f)return k;l.start=k;k=["M",m.x,m.y+"C",m.n.x,m.n.y,m.end.x,m.end.y,i[5],i[6]][v]();n+=j;g=+i[5];h=+i[6];continue}if(!b&&!c){m=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);return{x:m.x,y:m.y,alpha:m.alpha}}}n+=j;g=+i[5];h=+i[6]}k+=i}l.end=k;m=b?n:c?l:a.findDotsAtSegment(g,h,i[1],i[2],i[3],i[4],i[5],i[6],1);m.alpha&&(m={x:m.x,y:m.y,alpha:m.alpha});return m}},cs=cr(1),ct=cr(),cu=cr(0,1);bO.getTotalLength=function(){if(this.type!="path")return;if(this.node.getTotalLength)return this.node.getTotalLength();return cs(this.attrs.path)};bO.getPointAtLength=function(a){if(this.type!="path")return;return ct(this.attrs.path,a)};bO.getSubpath=function(a,b){if(this.type!="path")return;if(B(this.getTotalLength()-b)<"1e-6")return cu(this.attrs.path,a).end;var c=cu(this.attrs.path,b,1);return a?cu(c,a).end:c};a.easing_formulas={linear:function(a){return a},"<":function(a){return C(a,3)},">":function(a){return C(a-1,3)+1},"<>":function(a){a=a*2;if(a<1)return C(a,3)/2;a-=2;return(C(a,3)+2)/2},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){a=a-1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==0||a==1)return a;var b=0.3,c=b/4;return C(2,-10*a)*y.sin((a-c)*(2*D)/b)+1},bounce:function(a){var b=7.5625,c=2.75,d;if(a<1/c)d=b*a*a;else if(a<2/c){a-=1.5/c;d=b*a*a+0.75}else if(a<2.5/c){a-=2.25/c;d=b*a*a+0.9375}else{a-=2.625/c;d=b*a*a+0.984375}return d}};var cv=[],cw=function(){var b=+(new Date);for(var c=0;c<cv[w];c++){var d=cv[c];if(d.stop||d.el.removed)continue;var e=b-d.start,g=d.ms,h=d.easing,i=d.from,j=d.diff,k=d.to,l=d.t,m=d.el,n={},o;if(e<g){var r=h(e/g);for(var s in i)if(i[f](s)){switch(X[s]){case"along":o=r*g*j[s];k.back&&(o=k.len-o);var t=ct(k[s],o);m.translate(j.sx-j.x||0,j.sy-j.y||0);j.x=t.x;j.y=t.y;m.translate(t.x-j.sx,t.y-j.sy);k.rot&&m.rotate(j.r+t.alpha,t.x,t.y);break;case E:o=+i[s]+r*g*j[s];break;case"colour":o="rgb("+[cy(Q(i[s].r+r*g*j[s].r)),cy(Q(i[s].g+r*g*j[s].g)),cy(Q(i[s].b+r*g*j[s].b))][v](",")+")";break;case"path":o=[];for(var u=0,x=i[s][w];u<x;u++){o[u]=[i[s][u][0]];for(var y=1,z=i[s][u][w];y<z;y++)o[u][y]=+i[s][u][y]+r*g*j[s][u][y];o[u]=o[u][v](q)}o=o[v](q);break;case"csv":switch(s){case"translation":var A=r*g*j[s][0]-l.x,B=r*g*j[s][1]-l.y;l.x+=A;l.y+=B;o=A+q+B;break;case"rotation":o=+i[s][0]+r*g*j[s][0];i[s][1]&&(o+=","+i[s][1]+","+i[s][2]);break;case"scale":o=[+i[s][0]+r*g*j[s][0],+i[s][1]+r*g*j[s][1],2 in k[s]?k[s][2]:p,3 in k[s]?k[s][3]:p][v](q);break;case"clip-rect":o=[];u=4;while(u--)o[u]=+i[s][u]+r*g*j[s][u];break}break;default:var C=[].concat(i[s]);o=[];u=m.paper.customAttributes[s].length;while(u--)o[u]=+C[u]+r*g*j[s][u];break}n[s]=o}m.attr(n);m._run&&m._run.call(m)}else{if(k.along){t=ct(k.along,k.len*!k.back);m.translate(j.sx-(j.x||0)+t.x-j.sx,j.sy-(j.y||0)+t.y-j.sy);k.rot&&m.rotate(j.r+t.alpha,t.x,t.y)}(l.x||l.y)&&m.translate(-l.x,-l.y);k.scale&&(k.scale+=p);m.attr(k);cv.splice(c--,1)}}a.svg&&m&&m.paper&&m.paper.safari();cv[w]&&setTimeout(cw)},cx=function(b,c,d,e,f){var g=d-e;c.timeouts.push(setTimeout(function(){a.is(f,"function")&&f.call(c);c.animate(b,g,b.easing)},e))},cy=function(a){return z(A(a,255),0)},cz=function(a,b){if(a==null)return{x:this._.tx,y:this._.ty,toString:co};this._.tx+=+a;this._.ty+=+b;switch(this.type){case"circle":case"ellipse":this.attr({cx:+a+this.attrs.cx,cy:+b+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+a+this.attrs.x,y:+b+this.attrs.y});break;case"path":var c=bp(this.attrs.path);c[0][1]+=+a;c[0][2]+=+b;this.attr({path:c});break}return this};bO.animateWith=function(a,b,c,d,e){for(var f=0,g=cv.length;f<g;f++)cv[f].el.id==a.id&&(b.start=cv[f].start);return this.animate(b,c,d,e)};bO.animateAlong=cA();bO.animateAlongBack=cA(1);function cA(b){return function(c,d,e,f){var g={back:b};a.is(e,"function")?f=e:g.rot=e;c&&c.constructor==bN&&(c=c.attrs.path);c&&(g.along=c);return this.animate(g,d,f)}}function cB(a,b,c,d,e,f){var g=3*b,h=3*(d-b)-g,i=1-g-h,j=3*c,k=3*(e-c)-j,l=1-j-k;function m(a){return((i*a+h)*a+g)*a}function n(a,b){var c=o(a,b);return((l*c+k)*c+j)*c}function o(a,b){var c,d,e,f,j,k;for(e=a,k=0;k<8;k++){f=m(e)-a;if(B(f)<b)return e;j=(3*i*e+2*h)*e+g;if(B(j)<0.000001)break;e=e-f/j}c=0;d=1;e=a;if(e<c)return c;if(e>d)return d;while(c<d){f=m(e);if(B(f-a)<b)return e;a>f?c=e:d=e;e=(d-c)/2+c}return e}return n(a,1/(200*f))}bO.onAnimation=function(a){this._run=a||0;return this};bO.animate=function(c,d,e,g){var h=this;h.timeouts=h.timeouts||[];if(a.is(e,"function")||!e)g=e||null;if(h.removed){g&&g.call(h);return h}var i={},j={},k=false,l={};for(var m in c)if(c[f](m)){if(X[f](m)||h.paper.customAttributes[f](m)){k=true;i[m]=h.attr(m);i[m]==null&&(i[m]=W[m]);j[m]=c[m];switch(X[m]){case"along":var n=cs(c[m]),o=ct(c[m],n*!(!c.back)),p=h.getBBox();l[m]=n/d;l.tx=p.x;l.ty=p.y;l.sx=o.x;l.sy=o.y;j.rot=c.rot;j.back=c.back;j.len=n;c.rot&&(l.r=S(h.rotate())||0);break;case E:l[m]=(j[m]-i[m])/d;break;case"colour":i[m]=a.getRGB(i[m]);var q=a.getRGB(j[m]);l[m]={r:(q.r-i[m].r)/d,g:(q.g-i[m].g)/d,b:(q.b-i[m].b)/d};break;case"path":var t=bw(i[m],j[m]);i[m]=t[0];var u=t[1];l[m]=[];for(var v=0,x=i[m][w];v<x;v++){l[m][v]=[0];for(var y=1,z=i[m][v][w];y<z;y++)l[m][v][y]=(u[v][y]-i[m][v][y])/d}break;case"csv":var A=r(c[m])[s](b),B=r(i[m])[s](b);switch(m){case"translation":i[m]=[0,0];l[m]=[A[0]/d,A[1]/d];break;case"rotation":i[m]=B[1]==A[1]&&B[2]==A[2]?B:[0,A[1],A[2]];l[m]=[(A[0]-i[m][0])/d,0,0];break;case"scale":c[m]=A;i[m]=r(i[m])[s](b);l[m]=[(A[0]-i[m][0])/d,(A[1]-i[m][1])/d,0,0];break;case"clip-rect":i[m]=r(i[m])[s](b);l[m]=[];v=4;while(v--)l[m][v]=(A[v]-i[m][v])/d;break}j[m]=A;break;default:A=[].concat(c[m]);B=[].concat(i[m]);l[m]=[];v=h.paper.customAttributes[m][w];while(v--)l[m][v]=((A[v]||0)-(B[v]||0))/d;break}}}if(k){var G=a.easing_formulas[e];if(!G){G=r(e).match(P);if(G&&G[w]==5){var H=G;G=function(a){return cB(a,+H[1],+H[2],+H[3],+H[4],d)}}else G=function(a){return a}}cv.push({start:c.start||+(new Date),ms:d,easing:G,from:i,diff:l,to:j,el:h,t:{x:0,y:0}});a.is(g,"function")&&(h._ac=setTimeout(function(){g.call(h)},d));cv[w]==1&&setTimeout(cw)}else{var C=[],D;for(var F in c)if(c[f](F)&&Z.test(F)){m={value:c[F]};F=="from"&&(F=0);F=="to"&&(F=100);m.key=T(F,10);C.push(m)}C.sort(be);C[0].key&&C.unshift({key:0,value:h.attrs});for(v=0,x=C[w];v<x;v++)cx(C[v].value,h,d/100*C[v].key,d/100*(C[v-1]&&C[v-1].key||0),C[v-1]&&C[v-1].value.callback);D=C[C[w]-1].value.callback;D&&h.timeouts.push(setTimeout(function(){D.call(h)},d))}return this};bO.stop=function(){for(var a=0;a<cv.length;a++)cv[a].el.id==this.id&&cv.splice(a--,1);for(a=0,ii=this.timeouts&&this.timeouts.length;a<ii;a++)clearTimeout(this.timeouts[a]);this.timeouts=[];clearTimeout(this._ac);delete this._ac;return this};bO.translate=function(a,b){return this.attr({translation:a+" "+b})};bO[H]=function(){return"Raphaël’s object"};a.ae=cv;var cC=function(a){this.items=[];this[w]=0;this.type="set";if(a)for(var b=0,c=a[w];b<c;b++){if(a[b]&&(a[b].constructor==bN||a[b].constructor==cC)){this[this.items[w]]=this.items[this.items[w]]=a[b];this[w]++}}};cC[e][L]=function(){var a,b;for(var c=0,d=arguments[w];c<d;c++){a=arguments[c];if(a&&(a.constructor==bN||a.constructor==cC)){b=this.items[w];this[b]=this.items[b]=a;this[w]++}}return this};cC[e].pop=function(){delete this[this[w]--];return this.items.pop()};for(var cD in bO)bO[f](cD)&&(cC[e][cD]=(function(a){return function(){for(var b=0,c=this.items[w];b<c;b++)this.items[b][a][m](this.items[b],arguments);return this}})(cD));cC[e].attr=function(b,c){if(b&&a.is(b,G)&&a.is(b[0],"object"))for(var d=0,e=b[w];d<e;d++)this.items[d].attr(b[d]);else for(var f=0,g=this.items[w];f<g;f++)this.items[f].attr(b,c);return this};cC[e].animate=function(b,c,d,e){(a.is(d,"function")||!d)&&(e=d||null);var f=this.items[w],g=f,h,i=this,j;e&&(j=function(){!(--f)&&e.call(i)});d=a.is(d,F)?d:j;h=this.items[--g].animate(b,c,d,j);while(g--)this.items[g]&&!this.items[g].removed&&this.items[g].animateWith(h,b,c,d,j);return this};cC[e].insertAfter=function(a){var b=this.items[w];while(b--)this.items[b].insertAfter(a);return this};cC[e].getBBox=function(){var a=[],b=[],c=[],d=[];for(var e=this.items[w];e--;){var f=this.items[e].getBBox();a[L](f.x);b[L](f.y);c[L](f.x+f.width);d[L](f.y+f.height)}a=A[m](0,a);b=A[m](0,b);return{x:a,y:b,width:z[m](0,c)-a,height:z[m](0,d)-b}};cC[e].clone=function(a){a=new cC;for(var b=0,c=this.items[w];b<c;b++)a[L](this.items[b].clone());return a};a.registerFont=function(a){if(!a.face)return a;this.fonts=this.fonts||{};var b={w:a.w,face:{},glyphs:{}},c=a.face["font-family"];for(var d in a.face)a.face[f](d)&&(b.face[d]=a.face[d]);this.fonts[c]?this.fonts[c][L](b):this.fonts[c]=[b];if(!a.svg){b.face["units-per-em"]=T(a.face["units-per-em"],10);for(var e in a.glyphs)if(a.glyphs[f](e)){var g=a.glyphs[e];b.glyphs[e]={w:g.w,k:{},d:g.d&&"M"+g.d[Y](/[mlcxtrv]/g,function(a){return({l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"})[a]||"M"})+"z"};if(g.k)for(var h in g.k)g[f](h)&&(b.glyphs[e].k[h]=g.k[h])}}return a};k.getFont=function(b,c,d,e){e=e||"normal";d=d||"normal";c=+c||({normal:400,bold:700,lighter:300,bolder:800})[c]||400;if(!a.fonts)return;var g=a.fonts[b];if(!g){var h=new RegExp("(^|\\s)"+b[Y](/[^\w\d\s+!~.:_-]/g,p)+"(\\s|$)","i");for(var i in a.fonts)if(a.fonts[f](i)){if(h.test(i)){g=a.fonts[i];break}}}var j;if(g)for(var k=0,l=g[w];k<l;k++){j=g[k];if(j.face["font-weight"]==c&&(j.face["font-style"]==d||!j.face["font-style"])&&j.face["font-stretch"]==e)break}return j};k.print=function(c,d,e,f,g,h,i){h=h||"middle";i=z(A(i||0,1),-1);var j=this.set(),k=r(e)[s](p),l=0,m=p,n;a.is(f,e)&&(f=this.getFont(f));if(f){n=(g||16)/f.face["units-per-em"];var o=f.face.bbox.split(b),q=+o[0],t=+o[1]+(h=="baseline"?o[3]-o[1]+ +f.face.descent:(o[3]-o[1])/2);for(var u=0,v=k[w];u<v;u++){var x=u&&f.glyphs[k[u-1]]||{},y=f.glyphs[k[u]];l+=u?(x.w||f.w)+(x.k&&x.k[k[u]]||0)+f.w*i:0;y&&y.d&&j[L](this.path(y.d).attr({fill:"#000",stroke:"none",translation:[l,0]}))}j.scale(n,n,q,t).translate(c-q,d-t)}return j};a.format=function(b,c){var e=a.is(c,G)?[0][n](c):arguments;b&&a.is(b,F)&&e[w]-1&&(b=b[Y](d,function(a,b){return e[++b]==null?p:e[b]}));return b||p};a.ninja=function(){i.was?h.Raphael=i.is:delete Raphael;return a};a.el=bO;a.st=cC[e];i.was?h.Raphael=a:Raphael=a})();
/*!
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version: 2.9995 (09-AUG-2011)
 * Dual licensed under the MIT and GPL licenses.
 * http://jquery.malsup.com/license.html
 * Requires: jQuery v1.3.2 or later
 */
;(function($) {

var ver = '2.9995';

// if $.support is not defined (pre jQuery 1.3) add what I need
if ($.support == undefined) {
	$.support = {
		opacity: !($.browser.msie)
	};
}

function debug(s) {
	$.fn.cycle.debug && log(s);
}		
function log() {
	window.console && console.log && console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
}
$.expr[':'].paused = function(el) {
	return el.cyclePause;
}


// the options arg can be...
//   a number  - indicates an immediate transition should occur to the given slide index
//   a string  - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
//   an object - properties to control the slideshow
//
// the arg2 arg can be...
//   the name of an fx (only used in conjunction with a numeric value for 'options')
//   the value true (only used in first arg == 'resume') and indicates
//	 that the resume should occur immediately (not wait for next timeout)

$.fn.cycle = function(options, arg2) {
	var o = { s: this.selector, c: this.context };

	// in 1.3+ we can fix mistakes with the ready state
	if (this.length === 0 && options != 'stop') {
		if (!$.isReady && o.s) {
			log('DOM not ready, queuing slideshow');
			$(function() {
				$(o.s,o.c).cycle(options,arg2);
			});
			return this;
		}
		// is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
		log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
		return this;
	}

	// iterate the matched nodeset
	return this.each(function() {
		var opts = handleArguments(this, options, arg2);
		if (opts === false)
			return;

		opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
		
		// stop existing slideshow for this container (if there is one)
		if (this.cycleTimeout)
			clearTimeout(this.cycleTimeout);
		this.cycleTimeout = this.cyclePause = 0;

		var $cont = $(this);
		var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
		var els = $slides.get();

		var opts2 = buildOptions($cont, $slides, els, opts, o);
		if (opts2 === false)
			return;

		if (els.length < 2) {
			log('terminating; too few slides: ' + els.length);
			return;
		}

		var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards);

		// if it's an auto slideshow, kick it off
		if (startTime) {
			startTime += (opts2.delay || 0);
			if (startTime < 10)
				startTime = 10;
			debug('first timeout: ' + startTime);
			this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards)}, startTime);
		}
	});
};

function triggerPause(cont, byHover, onPager) {
	var opts = $(cont).data('cycle.opts');
	var paused = !!cont.cyclePause;
	if (paused && opts.paused)
		opts.paused(cont, opts, byHover, onPager);
	else if (!paused && opts.resumed)
		opts.resumed(cont, opts, byHover, onPager);
}

// process the args that were passed to the plugin fn
function handleArguments(cont, options, arg2) {
	if (cont.cycleStop == undefined)
		cont.cycleStop = 0;
	if (options === undefined || options === null)
		options = {};
	if (options.constructor == String) {
		switch(options) {
		case 'destroy':
		case 'stop':
			var opts = $(cont).data('cycle.opts');
			if (!opts)
				return false;
			cont.cycleStop++; // callbacks look for change
			if (cont.cycleTimeout)
				clearTimeout(cont.cycleTimeout);
			cont.cycleTimeout = 0;
			opts.elements && $(opts.elements).stop();
			$(cont).removeData('cycle.opts');
			if (options == 'destroy')
				destroy(opts);
			return false;
		case 'toggle':
			cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1;
			checkInstantResume(cont.cyclePause, arg2, cont);
			triggerPause(cont);
			return false;
		case 'pause':
			cont.cyclePause = 1;
			triggerPause(cont);
			return false;
		case 'resume':
			cont.cyclePause = 0;
			checkInstantResume(false, arg2, cont);
			triggerPause(cont);
			return false;
		case 'prev':
		case 'next':
			var opts = $(cont).data('cycle.opts');
			if (!opts) {
				log('options not found, "prev/next" ignored');
				return false;
			}
			$.fn.cycle[options](opts);
			return false;
		default:
			options = { fx: options };
		};
		return options;
	}
	else if (options.constructor == Number) {
		// go to the requested slide
		var num = options;
		options = $(cont).data('cycle.opts');
		if (!options) {
			log('options not found, can not advance slide');
			return false;
		}
		if (num < 0 || num >= options.elements.length) {
			log('invalid slide index: ' + num);
			return false;
		}
		options.nextSlide = num;
		if (cont.cycleTimeout) {
			clearTimeout(cont.cycleTimeout);
			cont.cycleTimeout = 0;
		}
		if (typeof arg2 == 'string')
			options.oneTimeFx = arg2;
		go(options.elements, options, 1, num >= options.currSlide);
		return false;
	}
	return options;
	
	function checkInstantResume(isPaused, arg2, cont) {
		if (!isPaused && arg2 === true) { // resume now!
			var options = $(cont).data('cycle.opts');
			if (!options) {
				log('options not found, can not resume');
				return false;
			}
			if (cont.cycleTimeout) {
				clearTimeout(cont.cycleTimeout);
				cont.cycleTimeout = 0;
			}
			go(options.elements, options, 1, !options.backwards);
		}
	}
};

function removeFilter(el, opts) {
	if (!$.support.opacity && opts.cleartype && el.style.filter) {
		try { el.style.removeAttribute('filter'); }
		catch(smother) {} // handle old opera versions
	}
};

// unbind event handlers
function destroy(opts) {
	if (opts.next)
		$(opts.next).unbind(opts.prevNextEvent);
	if (opts.prev)
		$(opts.prev).unbind(opts.prevNextEvent);
	
	if (opts.pager || opts.pagerAnchorBuilder)
		$.each(opts.pagerAnchors || [], function() {
			this.unbind().remove();
		});
	opts.pagerAnchors = null;
	if (opts.destroy) // callback
		opts.destroy(opts);
};

// one-time initialization
function buildOptions($cont, $slides, els, options, o) {
	// support metadata plugin (v1.0 and v2.0)
	var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
	var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
	if (meta)
		opts = $.extend(opts, meta);
	if (opts.autostop)
		opts.countdown = opts.autostopCount || els.length;

	var cont = $cont[0];
	$cont.data('cycle.opts', opts);
	opts.$cont = $cont;
	opts.stopCount = cont.cycleStop;
	opts.elements = els;
	opts.before = opts.before ? [opts.before] : [];
	opts.after = opts.after ? [opts.after] : [];

	// push some after callbacks
	if (!$.support.opacity && opts.cleartype)
		opts.after.push(function() { removeFilter(this, opts); });
	if (opts.continuous)
		opts.after.push(function() { go(els,opts,0,!opts.backwards); });

	saveOriginalOpts(opts);

	// clearType corrections
	if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
		clearTypeFix($slides);

	// container requires non-static position so that slides can be position within
	if ($cont.css('position') == 'static')
		$cont.css('position', 'relative');
	if (opts.width)
		$cont.width(opts.width);
	if (opts.height && opts.height != 'auto')
		$cont.height(opts.height);

	if (opts.startingSlide)
		opts.startingSlide = parseInt(opts.startingSlide,10);
	else if (opts.backwards)
		opts.startingSlide = els.length - 1;

	// if random, mix up the slide array
	if (opts.random) {
		opts.randomMap = [];
		for (var i = 0; i < els.length; i++)
			opts.randomMap.push(i);
		opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
		opts.randomIndex = 1;
		opts.startingSlide = opts.randomMap[1];
	}
	else if (opts.startingSlide >= els.length)
		opts.startingSlide = 0; // catch bogus input
	opts.currSlide = opts.startingSlide || 0;
	var first = opts.startingSlide;

	// set position and zIndex on all the slides
	$slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
		var z;
		if (opts.backwards)
			z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
		else
			z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
		$(this).css('z-index', z)
	});

	// make sure first slide is visible
	$(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
	removeFilter(els[first], opts);

	// stretch slides
	if (opts.fit) {
		if (!opts.aspect) {
	        if (opts.width)
	            $slides.width(opts.width);
	        if (opts.height && opts.height != 'auto')
	            $slides.height(opts.height);
		} else {
			$slides.each(function(){
				var $slide = $(this);
				var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
				if( opts.width && $slide.width() != opts.width ) {
					$slide.width( opts.width );
					$slide.height( opts.width / ratio );
				}

				if( opts.height && $slide.height() < opts.height ) {
					$slide.height( opts.height );
					$slide.width( opts.height * ratio );
				}
			});
		}
	}

	if (opts.center && ((!opts.fit) || opts.aspect)) {
		$slides.each(function(){
			var $slide = $(this);
			$slide.css({
				"margin-left": opts.width ?
					((opts.width - $slide.width()) / 2) + "px" :
					0,
				"margin-top": opts.height ?
					((opts.height - $slide.height()) / 2) + "px" :
					0
			});
		});
	}

	if (opts.center && !opts.fit && !opts.slideResize) {
	  	$slides.each(function(){
	    	var $slide = $(this);
	    	$slide.css({
	      		"margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0,
	      		"margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0
	    	});
	  	});
	}
		
	// stretch container
	var reshape = opts.containerResize && !$cont.innerHeight();
	if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
		var maxw = 0, maxh = 0;
		for(var j=0; j < els.length; j++) {
			var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
			if (!w) w = e.offsetWidth || e.width || $e.attr('width');
			if (!h) h = e.offsetHeight || e.height || $e.attr('height');
			maxw = w > maxw ? w : maxw;
			maxh = h > maxh ? h : maxh;
		}
		if (maxw > 0 && maxh > 0)
			$cont.css({width:maxw+'px',height:maxh+'px'});
	}

	var pauseFlag = false;  // https://github.com/malsup/cycle/issues/44
	if (opts.pause)
		$cont.hover(
			function(){
				pauseFlag = true;
				this.cyclePause++;
				triggerPause(cont, true);
			},
			function(){
				pauseFlag && this.cyclePause--;
				triggerPause(cont, true);
			}
		);

	if (supportMultiTransitions(opts) === false)
		return false;

	// apparently a lot of people use image slideshows without height/width attributes on the images.
	// Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
	var requeue = false;
	options.requeueAttempts = options.requeueAttempts || 0;
	$slides.each(function() {
		// try to get height/width of each slide
		var $el = $(this);
		this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
		this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);

		if ( $el.is('img') ) {
			// sigh..  sniffing, hacking, shrugging...  this crappy hack tries to account for what browsers do when
			// an image is being downloaded and the markup did not include sizing info (height/width attributes);
			// there seems to be some "default" sizes used in this situation
			var loadingIE	= ($.browser.msie  && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
			var loadingFF	= ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete);
			var loadingOp	= ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete);
			var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);
			// don't requeue for images that are still loading but have a valid size
			if (loadingIE || loadingFF || loadingOp || loadingOther) {
				if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
					log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
					setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout);
					requeue = true;
					return false; // break each loop
				}
				else {
					log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
				}
			}
		}
		return true;
	});

	if (requeue)
		return false;

	opts.cssBefore = opts.cssBefore || {};
	opts.cssAfter = opts.cssAfter || {};
	opts.cssFirst = opts.cssFirst || {};
	opts.animIn = opts.animIn || {};
	opts.animOut = opts.animOut || {};

	$slides.not(':eq('+first+')').css(opts.cssBefore);
	$($slides[first]).css(opts.cssFirst);

	if (opts.timeout) {
		opts.timeout = parseInt(opts.timeout,10);
		// ensure that timeout and speed settings are sane
		if (opts.speed.constructor == String)
			opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10);
		if (!opts.sync)
			opts.speed = opts.speed / 2;
		
		var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
		while((opts.timeout - opts.speed) < buffer) // sanitize timeout
			opts.timeout += opts.speed;
	}
	if (opts.easing)
		opts.easeIn = opts.easeOut = opts.easing;
	if (!opts.speedIn)
		opts.speedIn = opts.speed;
	if (!opts.speedOut)
		opts.speedOut = opts.speed;

	opts.slideCount = els.length;
	opts.currSlide = opts.lastSlide = first;
	if (opts.random) {
		if (++opts.randomIndex == els.length)
			opts.randomIndex = 0;
		opts.nextSlide = opts.randomMap[opts.randomIndex];
	}
	else if (opts.backwards)
		opts.nextSlide = opts.startingSlide == 0 ? (els.length-1) : opts.startingSlide-1;
	else
		opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;

	// run transition init fn
	if (!opts.multiFx) {
		var init = $.fn.cycle.transitions[opts.fx];
		if ($.isFunction(init))
			init($cont, $slides, opts);
		else if (opts.fx != 'custom' && !opts.multiFx) {
			log('unknown transition: ' + opts.fx,'; slideshow terminating');
			return false;
		}
	}

	// fire artificial events
	var e0 = $slides[first];
	if (!opts.skipInitializationCallbacks) {
		if (opts.before.length)
			opts.before[0].apply(e0, [e0, e0, opts, true]);
		if (opts.after.length)
			opts.after[0].apply(e0, [e0, e0, opts, true]);
	}
	if (opts.next)
		$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1)});
	if (opts.prev)
		$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0)});
	if (opts.pager || opts.pagerAnchorBuilder)
		buildPager(els,opts);

	exposeAddSlide(opts, els);

	return opts;
};

// save off original opts so we can restore after clearing state
function saveOriginalOpts(opts) {
	opts.original = { before: [], after: [] };
	opts.original.cssBefore = $.extend({}, opts.cssBefore);
	opts.original.cssAfter  = $.extend({}, opts.cssAfter);
	opts.original.animIn	= $.extend({}, opts.animIn);
	opts.original.animOut   = $.extend({}, opts.animOut);
	$.each(opts.before, function() { opts.original.before.push(this); });
	$.each(opts.after,  function() { opts.original.after.push(this); });
};

function supportMultiTransitions(opts) {
	var i, tx, txs = $.fn.cycle.transitions;
	// look for multiple effects
	if (opts.fx.indexOf(',') > 0) {
		opts.multiFx = true;
		opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
		// discard any bogus effect names
		for (i=0; i < opts.fxs.length; i++) {
			var fx = opts.fxs[i];
			tx = txs[fx];
			if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
				log('discarding unknown transition: ',fx);
				opts.fxs.splice(i,1);
				i--;
			}
		}
		// if we have an empty list then we threw everything away!
		if (!opts.fxs.length) {
			log('No valid transitions named; slideshow terminating.');
			return false;
		}
	}
	else if (opts.fx == 'all') {  // auto-gen the list of transitions
		opts.multiFx = true;
		opts.fxs = [];
		for (p in txs) {
			tx = txs[p];
			if (txs.hasOwnProperty(p) && $.isFunction(tx))
				opts.fxs.push(p);
		}
	}
	if (opts.multiFx && opts.randomizeEffects) {
		// munge the fxs array to make effect selection random
		var r1 = Math.floor(Math.random() * 20) + 30;
		for (i = 0; i < r1; i++) {
			var r2 = Math.floor(Math.random() * opts.fxs.length);
			opts.fxs.push(opts.fxs.splice(r2,1)[0]);
		}
		debug('randomized fx sequence: ',opts.fxs);
	}
	return true;
};

// provide a mechanism for adding slides after the slideshow has started
function exposeAddSlide(opts, els) {
	opts.addSlide = function(newSlide, prepend) {
		var $s = $(newSlide), s = $s[0];
		if (!opts.autostopCount)
			opts.countdown++;
		els[prepend?'unshift':'push'](s);
		if (opts.els)
			opts.els[prepend?'unshift':'push'](s); // shuffle needs this
		opts.slideCount = els.length;

		$s.css('position','absolute');
		$s[prepend?'prependTo':'appendTo'](opts.$cont);

		if (prepend) {
			opts.currSlide++;
			opts.nextSlide++;
		}

		if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
			clearTypeFix($s);

		if (opts.fit && opts.width)
			$s.width(opts.width);
		if (opts.fit && opts.height && opts.height != 'auto')
			$s.height(opts.height);
		s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
		s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();

		$s.css(opts.cssBefore);

		if (opts.pager || opts.pagerAnchorBuilder)
			$.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);

		if ($.isFunction(opts.onAddSlide))
			opts.onAddSlide($s);
		else
			$s.hide(); // default behavior
	};
}

// reset internal state; we do this on every pass in order to support multiple effects
$.fn.cycle.resetState = function(opts, fx) {
	fx = fx || opts.fx;
	opts.before = []; opts.after = [];
	opts.cssBefore = $.extend({}, opts.original.cssBefore);
	opts.cssAfter  = $.extend({}, opts.original.cssAfter);
	opts.animIn	= $.extend({}, opts.original.animIn);
	opts.animOut   = $.extend({}, opts.original.animOut);
	opts.fxFn = null;
	$.each(opts.original.before, function() { opts.before.push(this); });
	$.each(opts.original.after,  function() { opts.after.push(this); });

	// re-init
	var init = $.fn.cycle.transitions[fx];
	if ($.isFunction(init))
		init(opts.$cont, $(opts.elements), opts);
};

// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
function go(els, opts, manual, fwd) {
	// opts.busy is true if we're in the middle of an animation
	if (manual && opts.busy && opts.manualTrump) {
		// let manual transitions requests trump active ones
		debug('manualTrump in go(), stopping active transition');
		$(els).stop(true,true);
		opts.busy = 0;
	}
	// don't begin another timeout-based transition if there is one active
	if (opts.busy) {
		debug('transition active, ignoring new tx request');
		return;
	}

	var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];

	// stop cycling if we have an outstanding stop request
	if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
		return;

	// check to see if we should stop cycling based on autostop options
	if (!manual && !p.cyclePause && !opts.bounce &&
		((opts.autostop && (--opts.countdown <= 0)) ||
		(opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
		if (opts.end)
			opts.end(opts);
		return;
	}

	// if slideshow is paused, only transition on a manual trigger
	var changed = false;
	if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
		changed = true;
		var fx = opts.fx;
		// keep trying to get the slide size if we don't have it yet
		curr.cycleH = curr.cycleH || $(curr).height();
		curr.cycleW = curr.cycleW || $(curr).width();
		next.cycleH = next.cycleH || $(next).height();
		next.cycleW = next.cycleW || $(next).width();

		// support multiple transition types
		if (opts.multiFx) {
			if (fwd && (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length))
				opts.lastFx = 0;
			else if (!fwd && (opts.lastFx == undefined || --opts.lastFx < 0))
				opts.lastFx = opts.fxs.length - 1;
			fx = opts.fxs[opts.lastFx];
		}

		// one-time fx overrides apply to:  $('div').cycle(3,'zoom');
		if (opts.oneTimeFx) {
			fx = opts.oneTimeFx;
			opts.oneTimeFx = null;
		}

		$.fn.cycle.resetState(opts, fx);

		// run the before callbacks
		if (opts.before.length)
			$.each(opts.before, function(i,o) {
				if (p.cycleStop != opts.stopCount) return;
				o.apply(next, [curr, next, opts, fwd]);
			});

		// stage the after callacks
		var after = function() {
			opts.busy = 0;
			$.each(opts.after, function(i,o) {
				if (p.cycleStop != opts.stopCount) return;
				o.apply(next, [curr, next, opts, fwd]);
			});
		};

		debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);
		
		// get ready to perform the transition
		opts.busy = 1;
		if (opts.fxFn) // fx function provided?
			opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
		else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
			$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
		else
			$.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
	}

	if (changed || opts.nextSlide == opts.currSlide) {
		// calculate the next slide
		opts.lastSlide = opts.currSlide;
		if (opts.random) {
			opts.currSlide = opts.nextSlide;
			if (++opts.randomIndex == els.length)
				opts.randomIndex = 0;
			opts.nextSlide = opts.randomMap[opts.randomIndex];
			if (opts.nextSlide == opts.currSlide)
				opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
		}
		else if (opts.backwards) {
			var roll = (opts.nextSlide - 1) < 0;
			if (roll && opts.bounce) {
				opts.backwards = !opts.backwards;
				opts.nextSlide = 1;
				opts.currSlide = 0;
			}
			else {
				opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1;
				opts.currSlide = roll ? 0 : opts.nextSlide+1;
			}
		}
		else { // sequence
			var roll = (opts.nextSlide + 1) == els.length;
			if (roll && opts.bounce) {
				opts.backwards = !opts.backwards;
				opts.nextSlide = els.length-2;
				opts.currSlide = els.length-1;
			}
			else {
				opts.nextSlide = roll ? 0 : opts.nextSlide+1;
				opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
			}
		}
	}
	if (changed && opts.pager)
		opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
	
	// stage the next transition
	var ms = 0;
	if (opts.timeout && !opts.continuous)
		ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
	else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
		ms = 10;
	if (ms > 0)
		p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards) }, ms);
};

// invoked after transition
$.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
   $(pager).each(function() {
       $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
   });
};

// calculate timeout value for current transition
function getTimeout(curr, next, opts, fwd) {
	if (opts.timeoutFn) {
		// call user provided calc fn
		var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
		while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
			t += opts.speed;
		debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
		if (t !== false)
			return t;
	}
	return opts.timeout;
};

// expose next/prev function, caller must pass in state
$.fn.cycle.next = function(opts) { advance(opts,1); };
$.fn.cycle.prev = function(opts) { advance(opts,0);};

// advance slide forward or back
function advance(opts, moveForward) {
	var val = moveForward ? 1 : -1;
	var els = opts.elements;
	var p = opts.$cont[0], timeout = p.cycleTimeout;
	if (timeout) {
		clearTimeout(timeout);
		p.cycleTimeout = 0;
	}
	if (opts.random && val < 0) {
		// move back to the previously display slide
		opts.randomIndex--;
		if (--opts.randomIndex == -2)
			opts.randomIndex = els.length-2;
		else if (opts.randomIndex == -1)
			opts.randomIndex = els.length-1;
		opts.nextSlide = opts.randomMap[opts.randomIndex];
	}
	else if (opts.random) {
		opts.nextSlide = opts.randomMap[opts.randomIndex];
	}
	else {
		opts.nextSlide = opts.currSlide + val;
		if (opts.nextSlide < 0) {
			if (opts.nowrap) return false;
			opts.nextSlide = els.length - 1;
		}
		else if (opts.nextSlide >= els.length) {
			if (opts.nowrap) return false;
			opts.nextSlide = 0;
		}
	}

	var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
	if ($.isFunction(cb))
		cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
	go(els, opts, 1, moveForward);
	return false;
};

function buildPager(els, opts) {
	var $p = $(opts.pager);
	$.each(els, function(i,o) {
		$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
	});
	opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
};

$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
	var a;
	if ($.isFunction(opts.pagerAnchorBuilder)) {
		a = opts.pagerAnchorBuilder(i,el);
		debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
	}
	else
		a = '<a href="#">'+(i+1)+'</a>';
		
	if (!a)
		return;
	var $a = $(a);
	// don't reparent if anchor is in the dom
	if ($a.parents('body').length === 0) {
		var arr = [];
		if ($p.length > 1) {
			$p.each(function() {
				var $clone = $a.clone(true);
				$(this).append($clone);
				arr.push($clone[0]);
			});
			$a = $(arr);
		}
		else {
			$a.appendTo($p);
		}
	}

	opts.pagerAnchors =  opts.pagerAnchors || [];
	opts.pagerAnchors.push($a);
	
	var pagerFn = function(e) {
		e.preventDefault();
		opts.nextSlide = i;
		var p = opts.$cont[0], timeout = p.cycleTimeout;
		if (timeout) {
			clearTimeout(timeout);
			p.cycleTimeout = 0;
		}
		var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
		if ($.isFunction(cb))
			cb(opts.nextSlide, els[opts.nextSlide]);
		go(els,opts,1,opts.currSlide < i); // trigger the trans
//		return false; // <== allow bubble
	}
	
	if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) {
		$a.hover(pagerFn, function(){/* no-op */} );
	}
	else {
		$a.bind(opts.pagerEvent, pagerFn);
	}
	
	if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
		$a.bind('click.cycle', function(){return false;}); // suppress click
	
	var cont = opts.$cont[0];
	var pauseFlag = false; // https://github.com/malsup/cycle/issues/44
	if (opts.pauseOnPagerHover) {
		$a.hover(
			function() { 
				pauseFlag = true;
				cont.cyclePause++; 
				triggerPause(cont,true,true);
			}, function() { 
				pauseFlag && cont.cyclePause--; 
				triggerPause(cont,true,true);
			} 
		);
	}
};

// helper fn to calculate the number of slides between the current and the next
$.fn.cycle.hopsFromLast = function(opts, fwd) {
	var hops, l = opts.lastSlide, c = opts.currSlide;
	if (fwd)
		hops = c > l ? c - l : opts.slideCount - l;
	else
		hops = c < l ? l - c : l + opts.slideCount - c;
	return hops;
};

// fix clearType problems in ie6 by setting an explicit bg color
// (otherwise text slides look horrible during a fade transition)
function clearTypeFix($slides) {
	debug('applying clearType background-color hack');
	function hex(s) {
		s = parseInt(s,10).toString(16);
		return s.length < 2 ? '0'+s : s;
	};
	function getBg(e) {
		for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
			var v = $.css(e,'background-color');
			if (v && v.indexOf('rgb') >= 0 ) {
				var rgb = v.match(/\d+/g);
				return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
			}
			if (v && v != 'transparent')
				return v;
		}
		return '#ffffff';
	};
	$slides.each(function() { $(this).css('background-color', getBg(this)); });
};

// reset common props before the next transition
$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
	$(opts.elements).not(curr).hide();
	if (typeof opts.cssBefore.opacity == 'undefined')
		opts.cssBefore.opacity = 1;
	opts.cssBefore.display = 'block';
	if (opts.slideResize && w !== false && next.cycleW > 0)
		opts.cssBefore.width = next.cycleW;
	if (opts.slideResize && h !== false && next.cycleH > 0)
		opts.cssBefore.height = next.cycleH;
	opts.cssAfter = opts.cssAfter || {};
	opts.cssAfter.display = 'none';
	$(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
	$(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
};

// the actual fn for effecting a transition
$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
	var $l = $(curr), $n = $(next);
	var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
	$n.css(opts.cssBefore);
	if (speedOverride) {
		if (typeof speedOverride == 'number')
			speedIn = speedOut = speedOverride;
		else
			speedIn = speedOut = 1;
		easeIn = easeOut = null;
	}
	var fn = function() {
		$n.animate(opts.animIn, speedIn, easeIn, function() {
			cb();
		});
	};
	$l.animate(opts.animOut, speedOut, easeOut, function() {
		$l.css(opts.cssAfter);
		if (!opts.sync) 
			fn();
	});
	if (opts.sync) fn();
};

// transition definitions - only fade is defined here, transition pack defines the rest
$.fn.cycle.transitions = {
	fade: function($cont, $slides, opts) {
		$slides.not(':eq('+opts.currSlide+')').css('opacity',0);
		opts.before.push(function(curr,next,opts) {
			$.fn.cycle.commonReset(curr,next,opts);
			opts.cssBefore.opacity = 0;
		});
		opts.animIn	   = { opacity: 1 };
		opts.animOut   = { opacity: 0 };
		opts.cssBefore = { top: 0, left: 0 };
	}
};

$.fn.cycle.ver = function() { return ver; };

// override these globally if you like (they are all optional)
$.fn.cycle.defaults = {
	activePagerClass: 'activeSlide', // class name used for the active pager link
	after:		   null,  // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag)
	allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling
	animIn:		   null,  // properties that define how the slide animates in
	animOut:	   null,  // properties that define how the slide animates out
	aspect:		   false,  // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option)
	autostop:	   0,	  // true to end slideshow after X transitions (where X == slide count)
	autostopCount: 0,	  // number of transitions (optionally used with autostop to define X)
	backwards:     false, // true to start slideshow at last slide and move backwards through the stack
	before:		   null,  // transition callback (scope set to element to be shown):	 function(currSlideElement, nextSlideElement, options, forwardFlag)
	center: 	   null,  // set to true to have cycle add top/left margin to each slide (use with width and height options)
	cleartype:	   !$.support.opacity,  // true if clearType corrections should be applied (for IE)
	cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
	containerResize: 1,	  // resize container to fit largest slide
	continuous:	   0,	  // true to start next transition immediately after current one completes
	cssAfter:	   null,  // properties that defined the state of the slide after transitioning out
	cssBefore:	   null,  // properties that define the initial state of the slide before transitioning in
	delay:		   0,	  // additional delay (in ms) for first transition (hint: can be negative)
	easeIn:		   null,  // easing for "in" transition
	easeOut:	   null,  // easing for "out" transition
	easing:		   null,  // easing method for both in and out transitions
	end:		   null,  // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
	fastOnEvent:   0,	  // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
	fit:		   0,	  // force slides to fit container
	fx:			  'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle')
	fxFn:		   null,  // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
	height:		  'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well)
	manualTrump:   true,  // causes manual transition to stop an active transition instead of being ignored
	metaAttr:     'cycle',// data- attribute that holds the option data for the slideshow
	next:		   null,  // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide
	nowrap:		   0,	  // true to prevent slideshow from wrapping
	onPagerEvent:  null,  // callback fn for pager events: function(zeroBasedSlideIndex, slideElement)
	onPrevNextEvent: null,// callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)
	pager:		   null,  // element, jQuery object, or jQuery selector string for the element to use as pager container
	pagerAnchorBuilder: null, // callback fn for building anchor links:  function(index, DOMelement)
	pagerEvent:	  'click.cycle', // name of event which drives the pager navigation
	pause:		   0,	  // true to enable "pause on hover"
	pauseOnPagerHover: 0, // true to pause when hovering over pager link
	prev:		   null,  // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide
	prevNextEvent:'click.cycle',// event which drives the manual transition to the previous or next slide
	random:		   0,	  // true for random, false for sequence (not applicable to shuffle fx)
	randomizeEffects: 1,  // valid when multiple effects are used; true to make the effect sequence random
	requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
	requeueTimeout: 250,  // ms delay for requeue
	rev:		   0,	  // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle)
	shuffle:	   null,  // coords for shuffle animation, ex: { top:15, left: 200 }
	skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition
	slideExpr:	   null,  // expression for selecting slides (if something other than all children is required)
	slideResize:   1,     // force slide width/height to fixed size before every transition
	speed:		   1000,  // speed of the transition (any valid fx speed value)
	speedIn:	   null,  // speed of the 'in' transition
	speedOut:	   null,  // speed of the 'out' transition
	startingSlide: 0,	  // zero-based index of the first slide to be displayed
	sync:		   1,	  // true if in/out transitions should occur simultaneously
	timeout:	   4000,  // milliseconds between slide transitions (0 to disable auto advance)
	timeoutFn:     null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
	updateActivePagerLink: null, // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
	width:         null   // container width (if the 'fit' option is true, the slides will be set to this width as well)
};

})(jQuery);


/*!
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version:	 2.73
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function($) {

//
// These functions define slide initialization and properties for the named
// transitions. To save file size feel free to remove any of these that you
// don't need.
//
$.fn.cycle.transitions.none = function($cont, $slides, opts) {
	opts.fxFn = function(curr,next,opts,after){
		$(next).show();
		$(curr).hide();
		after();
	};
};

// not a cross-fade, fadeout only fades out the top slide
$.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
	$slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 });
	opts.before.push(function(curr,next,opts,w,h,rev) {
		$(curr).css('zIndex',opts.slideCount + (!rev === true ? 1 : 0));
		$(next).css('zIndex',opts.slideCount + (!rev === true ? 0 : 1));
	});
	opts.animIn.opacity = 1;
	opts.animOut.opacity = 0;
	opts.cssBefore.opacity = 1;
	opts.cssBefore.display = 'block';
	opts.cssAfter.zIndex = 0;
};

// scrollUp/Down/Left/Right
$.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
	$cont.css('overflow','hidden');
	opts.before.push($.fn.cycle.commonReset);
	var h = $cont.height();
	opts.cssBefore.top = h;
	opts.cssBefore.left = 0;
	opts.cssFirst.top = 0;
	opts.animIn.top = 0;
	opts.animOut.top = -h;
};
$.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
	$cont.css('overflow','hidden');
	opts.before.push($.fn.cycle.commonReset);
	var h = $cont.height();
	opts.cssFirst.top = 0;
	opts.cssBefore.top = -h;
	opts.cssBefore.left = 0;
	opts.animIn.top = 0;
	opts.animOut.top = h;
};
$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
	$cont.css('overflow','hidden');
	opts.before.push($.fn.cycle.commonReset);
	var w = $cont.width();
	opts.cssFirst.left = 0;
	opts.cssBefore.left = w;
	opts.cssBefore.top = 0;
	opts.animIn.left = 0;
	opts.animOut.left = 0-w;
};
$.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
	$cont.css('overflow','hidden');
	opts.before.push($.fn.cycle.commonReset);
	var w = $cont.width();
	opts.cssFirst.left = 0;
	opts.cssBefore.left = -w;
	opts.cssBefore.top = 0;
	opts.animIn.left = 0;
	opts.animOut.left = w;
};
$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
	$cont.css('overflow','hidden').width();
	opts.before.push(function(curr, next, opts, fwd) {
		if (opts.rev)
			fwd = !fwd;
		$.fn.cycle.commonReset(curr,next,opts);
		opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
		opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
	});
	opts.cssFirst.left = 0;
	opts.cssBefore.top = 0;
	opts.animIn.left = 0;
	opts.animOut.top = 0;
};
$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
	$cont.css('overflow','hidden');
	opts.before.push(function(curr, next, opts, fwd) {
		if (opts.rev)
			fwd = !fwd;
		$.fn.cycle.commonReset(curr,next,opts);
		opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
		opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
	});
	opts.cssFirst.top = 0;
	opts.cssBefore.left = 0;
	opts.animIn.top = 0;
	opts.animOut.left = 0;
};

// slideX/slideY
$.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$(opts.elements).not(curr).hide();
		$.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.animIn.width = next.cycleW;
	});
	opts.cssBefore.left = 0;
	opts.cssBefore.top = 0;
	opts.cssBefore.width = 0;
	opts.animIn.width = 'show';
	opts.animOut.width = 0;
};
$.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$(opts.elements).not(curr).hide();
		$.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.animIn.height = next.cycleH;
	});
	opts.cssBefore.left = 0;
	opts.cssBefore.top = 0;
	opts.cssBefore.height = 0;
	opts.animIn.height = 'show';
	opts.animOut.height = 0;
};

// shuffle
$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
	var i, w = $cont.css('overflow', 'visible').width();
	$slides.css({left: 0, top: 0});
	opts.before.push(function(curr,next,opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,true,true);
	});
	// only adjust speed once!
	if (!opts.speedAdjusted) {
		opts.speed = opts.speed / 2; // shuffle has 2 transitions
		opts.speedAdjusted = true;
	}
	opts.random = 0;
	opts.shuffle = opts.shuffle || {left:-w, top:15};
	opts.els = [];
	for (i=0; i < $slides.length; i++)
		opts.els.push($slides[i]);

	for (i=0; i < opts.currSlide; i++)
		opts.els.push(opts.els.shift());

	// custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
	opts.fxFn = function(curr, next, opts, cb, fwd) {
		if (opts.rev)
			fwd = !fwd;
		var $el = fwd ? $(curr) : $(next);
		$(next).css(opts.cssBefore);
		var count = opts.slideCount;
		$el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
			var hops = $.fn.cycle.hopsFromLast(opts, fwd);
			for (var k=0; k < hops; k++)
				fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
			if (fwd) {
				for (var i=0, len=opts.els.length; i < len; i++)
					$(opts.els[i]).css('z-index', len-i+count);
			}
			else {
				var z = $(curr).css('z-index');
				$el.css('z-index', parseInt(z,10)+1+count);
			}
			$el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
				$(fwd ? this : curr).hide();
				if (cb) cb();
			});
		});
	};
	$.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
};

// turnUp/Down/Left/Right
$.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.cssBefore.top = next.cycleH;
		opts.animIn.height = next.cycleH;
		opts.animOut.width = next.cycleW;
	});
	opts.cssFirst.top = 0;
	opts.cssBefore.left = 0;
	opts.cssBefore.height = 0;
	opts.animIn.top = 0;
	opts.animOut.height = 0;
};
$.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.animIn.height = next.cycleH;
		opts.animOut.top   = curr.cycleH;
	});
	opts.cssFirst.top = 0;
	opts.cssBefore.left = 0;
	opts.cssBefore.top = 0;
	opts.cssBefore.height = 0;
	opts.animOut.height = 0;
};
$.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.cssBefore.left = next.cycleW;
		opts.animIn.width = next.cycleW;
	});
	opts.cssBefore.top = 0;
	opts.cssBefore.width = 0;
	opts.animIn.left = 0;
	opts.animOut.width = 0;
};
$.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.animIn.width = next.cycleW;
		opts.animOut.left = curr.cycleW;
	});
	$.extend(opts.cssBefore, { top: 0, left: 0, width: 0 });
	opts.animIn.left = 0;
	opts.animOut.width = 0;
};

// zoom
$.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,false,false,true);
		opts.cssBefore.top = next.cycleH/2;
		opts.cssBefore.left = next.cycleW/2;
		$.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
		$.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 });
	});
	opts.cssFirst.top = 0;
	opts.cssFirst.left = 0;
	opts.cssBefore.width = 0;
	opts.cssBefore.height = 0;
};

// fadeZoom
$.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,false,false);
		opts.cssBefore.left = next.cycleW/2;
		opts.cssBefore.top = next.cycleH/2;
		$.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
	});
	opts.cssBefore.width = 0;
	opts.cssBefore.height = 0;
	opts.animOut.opacity = 0;
};

// blindX
$.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
	var w = $cont.css('overflow','hidden').width();
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts);
		opts.animIn.width = next.cycleW;
		opts.animOut.left   = curr.cycleW;
	});
	opts.cssBefore.left = w;
	opts.cssBefore.top = 0;
	opts.animIn.left = 0;
	opts.animOut.left = w;
};
// blindY
$.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
	var h = $cont.css('overflow','hidden').height();
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts);
		opts.animIn.height = next.cycleH;
		opts.animOut.top   = curr.cycleH;
	});
	opts.cssBefore.top = h;
	opts.cssBefore.left = 0;
	opts.animIn.top = 0;
	opts.animOut.top = h;
};
// blindZ
$.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
	var h = $cont.css('overflow','hidden').height();
	var w = $cont.width();
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts);
		opts.animIn.height = next.cycleH;
		opts.animOut.top   = curr.cycleH;
	});
	opts.cssBefore.top = h;
	opts.cssBefore.left = w;
	opts.animIn.top = 0;
	opts.animIn.left = 0;
	opts.animOut.top = h;
	opts.animOut.left = w;
};

// growX - grow horizontally from centered 0 width
$.fn.cycle.transitions.growX = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,false,true);
		opts.cssBefore.left = this.cycleW/2;
		opts.animIn.left = 0;
		opts.animIn.width = this.cycleW;
		opts.animOut.left = 0;
	});
	opts.cssBefore.top = 0;
	opts.cssBefore.width = 0;
};
// growY - grow vertically from centered 0 height
$.fn.cycle.transitions.growY = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,false);
		opts.cssBefore.top = this.cycleH/2;
		opts.animIn.top = 0;
		opts.animIn.height = this.cycleH;
		opts.animOut.top = 0;
	});
	opts.cssBefore.height = 0;
	opts.cssBefore.left = 0;
};

// curtainX - squeeze in both edges horizontally
$.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,false,true,true);
		opts.cssBefore.left = next.cycleW/2;
		opts.animIn.left = 0;
		opts.animIn.width = this.cycleW;
		opts.animOut.left = curr.cycleW/2;
		opts.animOut.width = 0;
	});
	opts.cssBefore.top = 0;
	opts.cssBefore.width = 0;
};
// curtainY - squeeze in both edges vertically
$.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,false,true);
		opts.cssBefore.top = next.cycleH/2;
		opts.animIn.top = 0;
		opts.animIn.height = next.cycleH;
		opts.animOut.top = curr.cycleH/2;
		opts.animOut.height = 0;
	});
	opts.cssBefore.height = 0;
	opts.cssBefore.left = 0;
};

// cover - curr slide covered by next slide
$.fn.cycle.transitions.cover = function($cont, $slides, opts) {
	var d = opts.direction || 'left';
	var w = $cont.css('overflow','hidden').width();
	var h = $cont.height();
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts);
		if (d == 'right')
			opts.cssBefore.left = -w;
		else if (d == 'up')
			opts.cssBefore.top = h;
		else if (d == 'down')
			opts.cssBefore.top = -h;
		else
			opts.cssBefore.left = w;
	});
	opts.animIn.left = 0;
	opts.animIn.top = 0;
	opts.cssBefore.top = 0;
	opts.cssBefore.left = 0;
};

// uncover - curr slide moves off next slide
$.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
	var d = opts.direction || 'left';
	var w = $cont.css('overflow','hidden').width();
	var h = $cont.height();
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,true,true);
		if (d == 'right')
			opts.animOut.left = w;
		else if (d == 'up')
			opts.animOut.top = -h;
		else if (d == 'down')
			opts.animOut.top = h;
		else
			opts.animOut.left = -w;
	});
	opts.animIn.left = 0;
	opts.animIn.top = 0;
	opts.cssBefore.top = 0;
	opts.cssBefore.left = 0;
};

// toss - move top slide and fade away
$.fn.cycle.transitions.toss = function($cont, $slides, opts) {
	var w = $cont.css('overflow','visible').width();
	var h = $cont.height();
	opts.before.push(function(curr, next, opts) {
		$.fn.cycle.commonReset(curr,next,opts,true,true,true);
		// provide default toss settings if animOut not provided
		if (!opts.animOut.left && !opts.animOut.top)
			$.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
		else
			opts.animOut.opacity = 0;
	});
	opts.cssBefore.left = 0;
	opts.cssBefore.top = 0;
	opts.animIn.left = 0;
};

// wipe - clip animation
$.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
	var w = $cont.css('overflow','hidden').width();
	var h = $cont.height();
	opts.cssBefore = opts.cssBefore || {};
	var clip;
	if (opts.clip) {
		if (/l2r/.test(opts.clip))
			clip = 'rect(0px 0px '+h+'px 0px)';
		else if (/r2l/.test(opts.clip))
			clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
		else if (/t2b/.test(opts.clip))
			clip = 'rect(0px '+w+'px 0px 0px)';
		else if (/b2t/.test(opts.clip))
			clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
		else if (/zoom/.test(opts.clip)) {
			var top = parseInt(h/2,10);
			var left = parseInt(w/2,10);
			clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
		}
	}

	opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';

	var d = opts.cssBefore.clip.match(/(\d+)/g);
	var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10);

	opts.before.push(function(curr, next, opts) {
		if (curr == next) return;
		var $curr = $(curr), $next = $(next);
		$.fn.cycle.commonReset(curr,next,opts,true,true,false);
		opts.cssAfter.display = 'block';

		var step = 1, count = parseInt((opts.speedIn / 13),10) - 1;
		(function f() {
			var tt = t ? t - parseInt(step * (t/count),10) : 0;
			var ll = l ? l - parseInt(step * (l/count),10) : 0;
			var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h;
			var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w;
			$next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
			(step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none');
		})();
	});
	$.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
	opts.animIn	   = { left: 0 };
	opts.animOut   = { left: 0 };
};

})(jQuery);
;
/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 *
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 *
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function($) {
	var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,

		selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],

		ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,

		loadingTimer, loadingFrame = 1,

		titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),

		isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

		/*
		 * Private methods 
		 */

		_abort = function() {
			loading.hide();

			imgPreloader.onerror = imgPreloader.onload = null;

			if (ajaxLoader) {
				ajaxLoader.abort();
			}

			tmp.empty();
		},

		_error = function() {
			if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
				loading.hide();
				busy = false;
				return;
			}

			selectedOpts.titleShow = false;

			selectedOpts.width = 'auto';
			selectedOpts.height = 'auto';

			tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );

			_process_inline();
		},

		_start = function() {
			var obj = selectedArray[ selectedIndex ],
				href, 
				type, 
				title,
				str,
				emb,
				ret;

			_abort();

			selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

			ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);

			if (ret === false) {
				busy = false;
				return;
			} else if (typeof ret == 'object') {
				selectedOpts = $.extend(selectedOpts, ret);
			}

			title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';

			if (obj.nodeName && !selectedOpts.orig) {
				selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
			}

			if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
				title = selectedOpts.orig.attr('alt');
			}

			href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;

			if ((/^(?:javascript)/i).test(href) || href == '#') {
				href = null;
			}

			if (selectedOpts.type) {
				type = selectedOpts.type;

				if (!href) {
					href = selectedOpts.content;
				}

			} else if (selectedOpts.content) {
				type = 'html';

			} else if (href) {
				if (href.match(imgRegExp)) {
					type = 'image';

				} else if (href.match(swfRegExp)) {
					type = 'swf';

				} else if ($(obj).hasClass("iframe")) {
					type = 'iframe';

				} else if (href.indexOf("#") === 0) {
					type = 'inline';

				} else {
					type = 'ajax';
				}
			}

			if (!type) {
				_error();
				return;
			}

			if (type == 'inline') {
				obj	= href.substr(href.indexOf("#"));
				type = $(obj).length > 0 ? 'inline' : 'ajax';
			}

			selectedOpts.type = type;
			selectedOpts.href = href;
			selectedOpts.title = title;

			if (selectedOpts.autoDimensions) {
				if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
					selectedOpts.width = 'auto';
					selectedOpts.height = 'auto';
				} else {
					selectedOpts.autoDimensions = false;	
				}
			}

			if (selectedOpts.modal) {
				selectedOpts.overlayShow = true;
				selectedOpts.hideOnOverlayClick = false;
				selectedOpts.hideOnContentClick = false;
				selectedOpts.enableEscapeButton = false;
				selectedOpts.showCloseButton = false;
			}

			selectedOpts.padding = parseInt(selectedOpts.padding, 10);
			selectedOpts.margin = parseInt(selectedOpts.margin, 10);

			tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));

			$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
				$(this).replaceWith(content.children());				
			});

			switch (type) {
				case 'html' :
					tmp.html( selectedOpts.content );
					_process_inline();
				break;

				case 'inline' :
					if ( $(obj).parent().is('#fancybox-content') === true) {
						busy = false;
						return;
					}

					$('<div class="fancybox-inline-tmp" />')
						.hide()
						.insertBefore( $(obj) )
						.bind('fancybox-cleanup', function() {
							$(this).replaceWith(content.children());
						}).bind('fancybox-cancel', function() {
							$(this).replaceWith(tmp.children());
						});

					$(obj).appendTo(tmp);

					_process_inline();
				break;

				case 'image':
					busy = false;

					$.fancybox.showActivity();

					imgPreloader = new Image();

					imgPreloader.onerror = function() {
						_error();
					};

					imgPreloader.onload = function() {
						busy = true;

						imgPreloader.onerror = imgPreloader.onload = null;

						_process_image();
					};

					imgPreloader.src = href;
				break;

				case 'swf':
					selectedOpts.scrolling = 'no';

					str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
					emb = '';

					$.each(selectedOpts.swf, function(name, val) {
						str += '<param name="' + name + '" value="' + val + '"></param>';
						emb += ' ' + name + '="' + val + '"';
					});

					str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

					tmp.html(str);

					_process_inline();
				break;

				case 'ajax':
					busy = false;

					$.fancybox.showActivity();

					selectedOpts.ajax.win = selectedOpts.ajax.success;

					ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
						url	: href,
						data : selectedOpts.ajax.data || {},
						error : function(XMLHttpRequest, textStatus, errorThrown) {
							if ( XMLHttpRequest.status > 0 ) {
								_error();
							}
						},
						success : function(data, textStatus, XMLHttpRequest) {
							var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
							if (o.status == 200) {
								if ( typeof selectedOpts.ajax.win == 'function' ) {
									ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);

									if (ret === false) {
										loading.hide();
										return;
									} else if (typeof ret == 'string' || typeof ret == 'object') {
										data = ret;
									}
								}

								tmp.html( data );
								_process_inline();
							}
						}
					}));

				break;

				case 'iframe':
					_show();
				break;
			}
		},

		_process_inline = function() {
			var
				w = selectedOpts.width,
				h = selectedOpts.height;

			if (w.toString().indexOf('%') > -1) {
				w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';

			} else {
				w = w == 'auto' ? 'auto' : w + 'px';	
			}

			if (h.toString().indexOf('%') > -1) {
				h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';

			} else {
				h = h == 'auto' ? 'auto' : h + 'px';	
			}

			tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');

			selectedOpts.width = tmp.width();
			selectedOpts.height = tmp.height();

			_show();
		},

		_process_image = function() {
			selectedOpts.width = imgPreloader.width;
			selectedOpts.height = imgPreloader.height;

			$("<img />").attr({
				'id' : 'fancybox-img',
				'src' : imgPreloader.src,
				'alt' : selectedOpts.title
			}).appendTo( tmp );

			_show();
		},

		_show = function() {
			var pos, equal;

			loading.hide();

			if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
				$.event.trigger('fancybox-cancel');

				busy = false;
				return;
			}

			busy = true;

			$(content.add( overlay )).unbind();

			$(window).unbind("resize.fb scroll.fb");
			$(document).unbind('keydown.fb');

			if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
				wrap.css('height', wrap.height());
			}

			currentArray = selectedArray;
			currentIndex = selectedIndex;
			currentOpts = selectedOpts;

			if (currentOpts.overlayShow) {
				overlay.css({
					'background-color' : currentOpts.overlayColor,
					'opacity' : currentOpts.overlayOpacity,
					'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
					'height' : $(document).height()
				});

				if (!overlay.is(':visible')) {
					if (isIE6) {
						$('select:not(#fancybox-tmp select)').filter(function() {
							return this.style.visibility !== 'hidden';
						}).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
							this.style.visibility = 'inherit';
						});
					}

					overlay.show();
				}
			} else {
				overlay.hide();
			}

			final_pos = _get_zoom_to();

			_process_title();

			if (wrap.is(":visible")) {
				$( close.add( nav_left ).add( nav_right ) ).hide();

				pos = wrap.position(),

				start_pos = {
					top	 : pos.top,
					left : pos.left,
					width : wrap.width(),
					height : wrap.height()
				};

				equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);

				content.fadeTo(currentOpts.changeFade, 0.3, function() {
					var finish_resizing = function() {
						content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
					};

					$.event.trigger('fancybox-change');

					content
						.empty()
						.removeAttr('filter')
						.css({
							'border-width' : currentOpts.padding,
							'width'	: final_pos.width - currentOpts.padding * 2,
							'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
						});

					if (equal) {
						finish_resizing();

					} else {
						fx.prop = 0;

						$(fx).animate({prop: 1}, {
							 duration : currentOpts.changeSpeed,
							 easing : currentOpts.easingChange,
							 step : _draw,
							 complete : finish_resizing
						});
					}
				});

				return;
			}

			wrap.removeAttr("style");

			content.css('border-width', currentOpts.padding);

			if (currentOpts.transitionIn == 'elastic') {
				start_pos = _get_zoom_from();

				content.html( tmp.contents() );

				wrap.show();

				if (currentOpts.opacity) {
					final_pos.opacity = 0;
				}

				fx.prop = 0;

				$(fx).animate({prop: 1}, {
					 duration : currentOpts.speedIn,
					 easing : currentOpts.easingIn,
					 step : _draw,
					 complete : _finish
				});

				return;
			}

			if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {	
				title.show();	
			}

			content
				.css({
					'width' : final_pos.width - currentOpts.padding * 2,
					'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
				})
				.html( tmp.contents() );

			wrap
				.css(final_pos)
				.fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
		},

		_format_title = function(title) {
			if (title && title.length) {
				if (currentOpts.titlePosition == 'float') {
					return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
				}

				return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
			}

			return false;
		},

		_process_title = function() {
			titleStr = currentOpts.title || '';
			titleHeight = 0;

			title
				.empty()
				.removeAttr('style')
				.removeClass();

			if (currentOpts.titleShow === false) {
				title.hide();
				return;
			}

			titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);

			if (!titleStr || titleStr === '') {
				title.hide();
				return;
			}

			title
				.addClass('fancybox-title-' + currentOpts.titlePosition)
				.html( titleStr )
				.appendTo( 'body' )
				.show();

			switch (currentOpts.titlePosition) {
				case 'inside':
					title
						.css({
							'width' : final_pos.width - (currentOpts.padding * 2),
							'marginLeft' : currentOpts.padding,
							'marginRight' : currentOpts.padding
						});

					titleHeight = title.outerHeight(true);

					title.appendTo( outer );

					final_pos.height += titleHeight;
				break;

				case 'over':
					title
						.css({
							'marginLeft' : currentOpts.padding,
							'width'	: final_pos.width - (currentOpts.padding * 2),
							'bottom' : currentOpts.padding
						})
						.appendTo( outer );
				break;

				case 'float':
					title
						.css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
						.appendTo( wrap );
				break;

				default:
					title
						.css({
							'width' : final_pos.width - (currentOpts.padding * 2),
							'paddingLeft' : currentOpts.padding,
							'paddingRight' : currentOpts.padding
						})
						.appendTo( wrap );
				break;
			}

			title.hide();
		},

		_set_navigation = function() {
			if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
				$(document).bind('keydown.fb', function(e) {
					if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
						e.preventDefault();
						$.fancybox.close();

					} else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
						e.preventDefault();
						$.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
					}
				});
			}

			if (!currentOpts.showNavArrows) { 
				nav_left.hide();
				nav_right.hide();
				return;
			}

			if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
				nav_left.show();
			}

			if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
				nav_right.show();
			}
		},

		_finish = function () {
			if (!$.support.opacity) {
				content.get(0).style.removeAttribute('filter');
				wrap.get(0).style.removeAttribute('filter');
			}

			if (selectedOpts.autoDimensions) {
				content.css('height', 'auto');
			}

			wrap.css('height', 'auto');

			if (titleStr && titleStr.length) {
				title.show();
			}

			if (currentOpts.showCloseButton) {
				close.show();
			}

			_set_navigation();
	
			if (currentOpts.hideOnContentClick)	{
				content.bind('click', $.fancybox.close);
			}

			if (currentOpts.hideOnOverlayClick)	{
				overlay.bind('click', $.fancybox.close);
			}

			$(window).bind("resize.fb", $.fancybox.resize);

			if (currentOpts.centerOnScroll) {
				$(window).bind("scroll.fb", $.fancybox.center);
			}

			if (currentOpts.type == 'iframe') {
				$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
			}

			wrap.show();

			busy = false;

			$.fancybox.center();

			currentOpts.onComplete(currentArray, currentIndex, currentOpts);

			_preload_images();
		},

		_preload_images = function() {
			var href, 
				objNext;

			if ((currentArray.length -1) > currentIndex) {
				href = currentArray[ currentIndex + 1 ].href;

				if (typeof href !== 'undefined' && href.match(imgRegExp)) {
					objNext = new Image();
					objNext.src = href;
				}
			}

			if (currentIndex > 0) {
				href = currentArray[ currentIndex - 1 ].href;

				if (typeof href !== 'undefined' && href.match(imgRegExp)) {
					objNext = new Image();
					objNext.src = href;
				}
			}
		},

		_draw = function(pos) {
			var dim = {
				width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
				height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),

				top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
				left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
			};

			if (typeof final_pos.opacity !== 'undefined') {
				dim.opacity = pos < 0.5 ? 0.5 : pos;
			}

			wrap.css(dim);

			content.css({
				'width' : dim.width - currentOpts.padding * 2,
				'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
			});
		},

		_get_viewport = function() {
			return [
				$(window).width() - (currentOpts.margin * 2),
				$(window).height() - (currentOpts.margin * 2),
				$(document).scrollLeft() + currentOpts.margin,
				$(document).scrollTop() + currentOpts.margin
			];
		},

		_get_zoom_to = function () {
			var view = _get_viewport(),
				to = {},
				resize = currentOpts.autoScale,
				double_padding = currentOpts.padding * 2,
				ratio;

			if (currentOpts.width.toString().indexOf('%') > -1) {
				to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
			} else {
				to.width = currentOpts.width + double_padding;
			}

			if (currentOpts.height.toString().indexOf('%') > -1) {
				to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
			} else {
				to.height = currentOpts.height + double_padding;
			}

			if (resize && (to.width > view[0] || to.height > view[1])) {
				if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
					ratio = (currentOpts.width ) / (currentOpts.height );

					if ((to.width ) > view[0]) {
						to.width = view[0];
						to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
					}

					if ((to.height) > view[1]) {
						to.height = view[1];
						to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
					}

				} else {
					to.width = Math.min(to.width, view[0]);
					to.height = Math.min(to.height, view[1]);
				}
			}

			to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
			to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);

			return to;
		},

		_get_obj_pos = function(obj) {
			var pos = obj.offset();

			pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
			pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;

			pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
			pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;

			pos.width = obj.width();
			pos.height = obj.height();

			return pos;
		},

		_get_zoom_from = function() {
			var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
				from = {},
				pos,
				view;

			if (orig && orig.length) {
				pos = _get_obj_pos(orig);

				from = {
					width : pos.width + (currentOpts.padding * 2),
					height : pos.height + (currentOpts.padding * 2),
					top	: pos.top - currentOpts.padding - 20,
					left : pos.left - currentOpts.padding - 20
				};

			} else {
				view = _get_viewport();

				from = {
					width : currentOpts.padding * 2,
					height : currentOpts.padding * 2,
					top	: parseInt(view[3] + view[1] * 0.5, 10),
					left : parseInt(view[2] + view[0] * 0.5, 10)
				};
			}

			return from;
		},

		_animate_loading = function() {
			if (!loading.is(':visible')){
				clearInterval(loadingTimer);
				return;
			}

			$('div', loading).css('top', (loadingFrame * -40) + 'px');

			loadingFrame = (loadingFrame + 1) % 12;
		};

	/*
	 * Public methods 
	 */

	$.fn.fancybox = function(options) {
		if (!$(this).length) {
			return this;
		}

		$(this)
			.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
			.unbind('click.fb')
			.bind('click.fb', function(e) {
				e.preventDefault();

				if (busy) {
					return;
				}

				busy = true;

				$(this).blur();

				selectedArray = [];
				selectedIndex = 0;

				var rel = $(this).attr('rel') || '';

				if (!rel || rel == '' || rel === 'nofollow') {
					selectedArray.push(this);

				} else {
					selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
					selectedIndex = selectedArray.index( this );
				}

				_start();

				return;
			});

		return this;
	};

	$.fancybox = function(obj) {
		var opts;

		if (busy) {
			return;
		}

		busy = true;
		opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};

		selectedArray = [];
		selectedIndex = parseInt(opts.index, 10) || 0;

		if ($.isArray(obj)) {
			for (var i = 0, j = obj.length; i < j; i++) {
				if (typeof obj[i] == 'object') {
					$(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
				} else {
					obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
				}
			}

			selectedArray = jQuery.merge(selectedArray, obj);

		} else {
			if (typeof obj == 'object') {
				$(obj).data('fancybox', $.extend({}, opts, obj));
			} else {
				obj = $({}).data('fancybox', $.extend({content : obj}, opts));
			}

			selectedArray.push(obj);
		}

		if (selectedIndex > selectedArray.length || selectedIndex < 0) {
			selectedIndex = 0;
		}

		_start();
	};

	$.fancybox.showActivity = function() {
		clearInterval(loadingTimer);

		loading.show();
		loadingTimer = setInterval(_animate_loading, 66);
	};

	$.fancybox.hideActivity = function() {
		loading.hide();
	};

	$.fancybox.next = function() {
		return $.fancybox.pos( currentIndex + 1);
	};

	$.fancybox.prev = function() {
		return $.fancybox.pos( currentIndex - 1);
	};

	$.fancybox.pos = function(pos) {
		if (busy) {
			return;
		}

		pos = parseInt(pos);

		selectedArray = currentArray;

		if (pos > -1 && pos < currentArray.length) {
			selectedIndex = pos;
			_start();

		} else if (currentOpts.cyclic && currentArray.length > 1) {
			selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
			_start();
		}

		return;
	};

	$.fancybox.cancel = function() {
		if (busy) {
			return;
		}

		busy = true;

		$.event.trigger('fancybox-cancel');

		_abort();

		selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);

		busy = false;
	};

	// Note: within an iframe use - parent.$.fancybox.close();
	$.fancybox.close = function() {
		if (busy || wrap.is(':hidden')) {
			return;
		}

		busy = true;

		if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
			busy = false;
			return;
		}

		_abort();

		$(close.add( nav_left ).add( nav_right )).hide();

		$(content.add( overlay )).unbind();

		$(window).unbind("resize.fb scroll.fb");
		$(document).unbind('keydown.fb');

		content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');

		if (currentOpts.titlePosition !== 'inside') {
			title.empty();
		}

		wrap.stop();

		function _cleanup() {
			overlay.fadeOut('fast');

			title.empty().hide();
			wrap.hide();

			$.event.trigger('fancybox-cleanup');

			content.empty();

			currentOpts.onClosed(currentArray, currentIndex, currentOpts);

			currentArray = selectedOpts	= [];
			currentIndex = selectedIndex = 0;
			currentOpts = selectedOpts	= {};

			busy = false;
		}

		if (currentOpts.transitionOut == 'elastic') {
			start_pos = _get_zoom_from();

			var pos = wrap.position();

			final_pos = {
				top	 : pos.top ,
				left : pos.left,
				width :	wrap.width(),
				height : wrap.height()
			};

			if (currentOpts.opacity) {
				final_pos.opacity = 1;
			}

			title.empty().hide();

			fx.prop = 1;

			$(fx).animate({ prop: 0 }, {
				 duration : currentOpts.speedOut,
				 easing : currentOpts.easingOut,
				 step : _draw,
				 complete : _cleanup
			});

		} else {
			wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
		}
	};

	$.fancybox.resize = function() {
		if (overlay.is(':visible')) {
			overlay.css('height', $(document).height());
		}

		$.fancybox.center(true);
	};

	$.fancybox.center = function() {
		var view, align;

		if (busy) {
			return;	
		}

		align = arguments[0] === true ? 1 : 0;
		view = _get_viewport();

		if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
			return;	
		}

		wrap
			.stop()
			.animate({
				'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
				'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
			}, typeof arguments[0] == 'number' ? arguments[0] : 200);
	};

	$.fancybox.init = function() {
		if ($("#fancybox-wrap").length) {
			return;
		}

		$('body').append(
			tmp	= $('<div id="fancybox-tmp"></div>'),
			loading	= $('<div id="fancybox-loading"><div></div></div>'),
			overlay	= $('<div id="fancybox-overlay"></div>'),
			wrap = $('<div id="fancybox-wrap"></div>')
		);

		outer = $('<div id="fancybox-outer"></div>')
			.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
			.appendTo( wrap );

		outer.append(
			content = $('<div id="fancybox-content"></div>'),
			close = $('<a id="fancybox-close"></a>'),
			title = $('<div id="fancybox-title"></div>'),

			nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
			nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
		);

		close.click($.fancybox.close);
		loading.click($.fancybox.cancel);

		nav_left.click(function(e) {
			e.preventDefault();
			$.fancybox.prev();
		});

		nav_right.click(function(e) {
			e.preventDefault();
			$.fancybox.next();
		});

		if ($.fn.mousewheel) {
			wrap.bind('mousewheel.fb', function(e, delta) {
				if (busy) {
					e.preventDefault();

				} else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
					e.preventDefault();
					$.fancybox[ delta > 0 ? 'prev' : 'next']();
				}
			});
		}

		if (!$.support.opacity) {
			wrap.addClass('fancybox-ie');
		}

		if (isIE6) {
			loading.addClass('fancybox-ie6');
			wrap.addClass('fancybox-ie6');

			$('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
		}
	};

	$.fn.fancybox.defaults = {
		padding : 10,
		margin : 40,
		opacity : false,
		modal : false,
		cyclic : false,
		scrolling : 'auto',	// 'auto', 'yes' or 'no'

		width : 560,
		height : 340,

		autoScale : true,
		autoDimensions : true,
		centerOnScroll : false,

		ajax : {},
		swf : { wmode: 'transparent' },

		hideOnOverlayClick : true,
		hideOnContentClick : false,

		overlayShow : true,
		overlayOpacity : 0.7,
		overlayColor : '#777',

		titleShow : true,
		titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
		titleFormat : null,
		titleFromAlt : false,

		transitionIn : 'fade', // 'elastic', 'fade' or 'none'
		transitionOut : 'fade', // 'elastic', 'fade' or 'none'

		speedIn : 300,
		speedOut : 300,

		changeSpeed : 300,
		changeFade : 'fast',

		easingIn : 'swing',
		easingOut : 'swing',

		showCloseButton	 : true,
		showNavArrows : true,
		enableEscapeButton : true,
		enableKeyboardNav : true,

		onStart : function(){},
		onCancel : function(){},
		onComplete : function(){},
		onCleanup : function(){},
		onClosed : function(){},
		onError : function(){}
	};

	$(document).ready(function() {
		$.fancybox.init();
	});

})(jQuery);;
(function($){
  $(function(){
    
    //Hide Readspeaker on mouse over of the add this element
    $('img[src="http://s9.addthis.com/button1-share.gif"]').mouseover(function(){
      $('#xp1').css('visibility', 'hidden');
    });

    //show Readspeaker on mouse out.
    $('img[src="http://s9.addthis.com/button1-share.gif"]').mouseout(function(){
      $('#xp1').css('visibility', 'visible');
    });
    
    
    $(document).ready(function(){
      
      //The type attribute is in the $head array but for some reason this attribute it is not rendered. 
      jQuery('link[rel="alternate"]').attr('type', 'application/rss+xml');

      //measure and adjust neighbored home single columns
      $("div.container.two-col.teaser-article").each(function(){
        //check if there is left AND right col
        var $cols = $(this).find("section.col");
        if ($cols && $cols.length == 2) {
          var leftCol = $cols.first();
          var rightCol = $cols.last();
          var $leftArticles = $(leftCol).find("article");
          var $rightArticles = $(rightCol).find("article");
          //if we have articles in both columns
          if ($leftArticles && $rightArticles) {
            var leftLen   = $leftArticles.length;
            var rightLen  = $rightArticles.length;
            var len       = Math.min(leftLen, rightLen);
            //adjust as long as we have an article left and an article right
            for (var i=0; i<len; ++i) {
              var $leftArticle = $($leftArticles[i]);
              var $rightArticle = $($rightArticles[i]);
              var leftHeight = $leftArticle.height();
              var rightHeight = $rightArticle.height();
              var targetHeight = Math.max(leftHeight, rightHeight);
              $leftArticle.height(targetHeight);
              $rightArticle.height(targetHeight);
            }
          }
        }
      });

      $("ul.article-galerie").cycle({
        fx: "fade",
        timeout:0,
        next: "#showroom-next",
        prev: "#showroom-prev"
      });

      $.gemeindeFlyout();
      $.gemeindeMap();

  		// Aufklapp-Mechanismus Gemeinde Container
  		$('#township-container-toggle').click(function(e) {
  		  e.preventDefault();
        e.stopPropagation();
  			$('.hidden-container').toggle('normal');
  			$(this).toggleClass('link-plus');
  			$(this).toggleClass('link-minus');
  			$(this).text($(this).text() == Drupal.t('Weitere Informationen anzeigen') ? Drupal.t('Ausblenden') : Drupal.t('Weitere Informationen anzeigen'));
  		});

  		// Aufklapp-Mechanismus Gemeinde Messages
  		$('#message-toggle').click(function(e) {
  		  e.preventDefault();
        e.stopPropagation();
  			$('.hidden-box').toggle('normal');
  			$(this).toggleClass('link-plus');
  			$(this).toggleClass('link-minus');
  			$(this).text($(this).text() == Drupal.t('Alle anzeigen') ? Drupal.t('Ausblenden') : Drupal.t('Alle anzeigen'));
  		});

  		//Aufklapp Mechanismus Artikel Liveticker
      $(".liveticker .liveticker-klapp .toggle").click(function(e) {
        e.preventDefault();
        e.stopPropagation();
        $('.liveticker-article .hidden-container').toggle('normal');
        $(this)
          .toggleClass('link-plus')
          .toggleClass('link-minus')
          .parent()
            .toggleClass('matchzeitung-klapp-zu');
        $(this).text($(this).text() == Drupal.t('Alle anzeigen') ? Drupal.t('Ausblenden') : Drupal.t('Alle anzeigen'));
      });
    
      //Aufklapp Mechanismus Matchzeitung
      $(".match-paper .liveticker-klapp .toggle").click(function(e) {
        e.preventDefault();
        e.stopPropagation();
        
        var src_id = $(this).attr("id");
        var $hidden_container;
        if(src_id) {
          var idArr  = src_id.split("_");
          var target_id = "hidden_" + idArr[idArr.length-1];
          $hidden_container = $("#" + target_id);
        } else {
          $hidden_container = $('.liveticker-article .hidden-container');
        }
        
        $hidden_container.toggle('normal');
        $(this)
          .toggleClass('link-plus')
          .toggleClass('link-minus')
          .parent()
            .toggleClass('matchzeitung-klapp-zu');
        $(this).text($(this).text() == Drupal.t('Matchzeitungen anzeigen') ? Drupal.t('Matchzeitungen verbergen') : Drupal.t('Matchzeitungen anzeigen'));
      });

  		//Breaking News Ticker
  		$('.breaking-news .ticker').each(function(){
  		  var speed           = 30;
  		  
  		  var containerWidth  = $(".breaking-news .newstext").width();
  		  var $innerSpan      = $(this).find("span");
  		  
  		  var textWidth       = $innerSpan.width();
  		  var duration        = ((containerWidth + textWidth) / speed) * 1000;
  		  $(this).css("left", containerWidth);
  		  scrollTicker($(this), textWidth, duration, containerWidth);
  		});
		
  		function scrollTicker(element, textWidth, duration, containerWidth) {
  		  //[todo] maybe add time update function 
  		  $(element).animate({left: -textWidth}, duration, "linear", function(){$(element).css("left", containerWidth); scrollTicker(element, textWidth, duration, containerWidth);});
  		}
		
		
		
  		/** 
  		 * News Slider Home 
  		*/
  		$(".main-articles-list .col a").mouseover(function(e) {
  		  e.preventDefault();
  		  e.stopPropagation();
  		  var pathArr = $(this).attr("href").split("#");
  		  var pos     = pathArr[pathArr.length-1];
  		  
  		  newsSliderScrollTo(pos);
  		});
		
  		$(".main-articles").hover(
  		    function(){
  		      stopNewsSlider();
  		    },
  		    function(){
  		      startNewsSlider();
  		    }
  		);
		
  		function newsSliderScrollTo(pos) {
  		  var containerWidth = $(".main-articles-content-outer").width();
  		  var targetLeft     = -(containerWidth * pos);
  		  
  		  $links = $(".main-articles-list .col a");
  		  $links.each(function(){
            $(this).removeClass('active');
        });
  		  $($links.get(pos)).addClass("active");
  		  $(".main-articles-content-inner").animate({left:targetLeft}, 300);
  		}
		
		
  		function newsSliderGetNextIndex() {
  		  var numTotal = $(".main-articles-list .col a").length;
  		  var current  = -1;
  		  var count    = 0;
  		  $(".main-articles-list .col a").each(function(){
  		    if ($(this).hasClass("active")) {
  		      current = count;
  		    }
  		    if (current == -1) {
  		      count++;
  		    }
  		  });
  		  
  		  return ((count == numTotal-1) ? 0 : (count+1));
  		}
		
		
  		var newsSliderInterval = -1;
  		startNewsSlider();  
  		function startNewsSlider() {
  		  newsSliderInterval = setInterval(slideToNextIndex, 6000);
  		}
		
  		function stopNewsSlider() {
  		  clearInterval(newsSliderInterval);
  		}
		
  		function slideToNextIndex() {
  		  newsSliderScrollTo(newsSliderGetNextIndex());
  		  //console.log(newsSliderGetNextIndex());
  		}
	
		
    });
    
    
    $.gemeindeFlyout = function(_options) {
  		// Configuration options.
  		var _options = jQuery.extend({
  			triggerSelector: 'a.gemeinde',
  			flyoutId: '#meine-gemeinde-flyout',
  			closeButtonId: '#meine-gemeinde-flyout-close',
  			mainNavId: '#mainnav',
  			distanceFromTop: 198,
  			distanceFromBottom: 57
  		}, _options);

  		// Which menu item was active before we opened the flyout?
  		var activeNavigationItem = $(_options.mainNavId + ' > ul > li.active');
  
  		// State of flyout
  		var showingFlyout = false;
  		var openedLastByBottom = false;
  		var openedLastByTop = false;
  
  		// Flyout
  		var $flyout = $(_options.flyoutId);
  
  		// Setting nav item active.
  		function setActive($navItem) {
  			$navItem.addClass('active');
  			$navItem.children('a').addClass('active');
  		};

  		// Setting nav item inactive.
  		function setInactive($navItem) {
  			$navItem.removeClass('active');
  			$navItem.children('a').removeClass('active');
  		};

  		// Toggles the flyout.
  		function toggleFlyout($clickedLink, show) {
  			var topLinkClicked = $clickedLink.hasClass('top');
  			var bottomLinkClicked = $clickedLink.hasClass('bottom');
         $('#meine-gemeinde-flyout').css('border-top','1px solid #B9B9B9');
         
  			// Show Flyout
  			if(show) {
  				if(bottomLinkClicked) {
  					// Show border on top
  					$flyout.removeClass('region-top');
  					// Add some shadow to bottom link
  					$clickedLink.addClass('flyout-shadow-bottom');
  					// Add correct background image
  					//$clickedLink.find('span').css('background-position-y', '-120px');
  					//$clickedLink.css('background-position-y', '-120px');
  					openedLastByBottom = true;
  					openedLastByTop = false;
  				}
  				else if (topLinkClicked) {
  				  $('#meine-gemeinde-flyout').css('border-top','0px');
  					openedLastByTop = true;
  					openedLastByBottom = false;
  				}
  				showingFlyout = true;
  
  				setActive($clickedLink.parent());
  				setInactive(activeNavigationItem);
  
  				$flyout.slideDown('fast');
  			}

  			// Hide Flyout.
  			else {
  				$flyout.slideUp('fast', function() {
  					// Reset background image (in any case) at end of animation
  					//$(_options.triggerSelector).find('span').css('background-position-y', '0');
  					//$(_options.triggerSelector).css('background-position-y', '0');
  				});
  
  				setInactive($(_options.triggerSelector).parent());
  				setActive(activeNavigationItem);
  
  				showingFlyout = false;
  
  				if(bottomLinkClicked) {
  					// Remove border on top
  					$flyout.addClass('region-top');
  					// Remove shadow from link
  					$clickedLink.removeClass('flyout-shadow-bottom');
  					openedLastByBottom = false;
  				}
  				else if (topLinkClicked) {
  					openedLastByTop = false;
  				}
  
  			}
  		}

  		// Clicking on 'meine gemeinde'.
  		$(_options.triggerSelector).click(function(event) {
  		  
  			event.preventDefault();

  			var $clickedLink = $(this);
  			var topLinkClicked = $clickedLink.hasClass('top');
  			var bottomLinkClicked = $clickedLink.hasClass('bottom');
  
  			// Check if user clicked on top or bottom button and adjust flyout position accordingly.
  			if(bottomLinkClicked) {
  				$flyout.css('top', '');
  				$flyout.css('bottom', _options.distanceFromBottom);
  
  				// Restore z-index of lower button to default.
  				$(_options.triggerSelector + '.bottom').css('z-index', $flyout.css('z-index')+5);
  			}
  			else if (topLinkClicked) {
  				$flyout.css('bottom', '');
  				$flyout.css('top', _options.distanceFromTop);
  
  				// Reduce z-index of lower button if opened from top
  				$(_options.triggerSelector + '.bottom').css('z-index', $flyout.css('z-index')-5);
  			}
  
  			// Special case: Flyout is open, but user clicks on different button,
  			// In all posibility he wants to open it, not close it.
  			if((showingFlyout && bottomLinkClicked && openedLastByTop) || (showingFlyout && topLinkClicked && openedLastByBottom)) {
  				toggleFlyout($clickedLink, true);
  			}
  
  			// Show flyout.
  			else if(!showingFlyout) {
  				toggleFlyout($clickedLink, true);
  			}
  			// Hide flyout.
  			else {
  				toggleFlyout($clickedLink, false);
  			}
  		});

  		// Clicking on close button on flyout.
  		$(_options.closeButtonId).click(function(event) {
  			event.preventDefault();
  			toggleFlyout($(this), false);
  		});
  	};

  	$.gemeindeMap = function(_options) {
  
  		// Configuration options.
  		var _options = jQuery.extend({
  			canvasId: 'township-map',
  			canvasWidth: 627,
  			canvasHeight: 559,
  			toolTipSelector: '#township-tooltip',
  			pathStrokeColor: '#fff',
  			pathStrockWidth: 0.6,
  			pathStrokeLinejoin: "round",
  			townshipBg: '#B2B3B6',
  			townshipJuraBg: '#C7C8CA',
  			townshipHoverBg: '#E2001A'
  		}, _options);
  
  
  		//function doTranslateAnimation(path, x, y) {
  		//	var temp = path.clone();
  		//	temp.translate(x,y);
  		//	path.animate({path: temp.attr('path')}, 100);
  		//	temp.remove();
  		//}
  
  		//check if the canvastarget is present (JdJ doesen't have this)
  		if ($("#" + _options.canvasId).length) {
  		
    		// Create Raphael canvas.
    		var canvas = Raphael(document.getElementById(_options.canvasId), _options.canvasWidth, _options.canvasHeight);
    
    		// Default path attributes for townships.
    		var townshipAttr = {
    			fill: _options.townshipBg,
    			stroke: _options.pathStrokeColor,
    			"stroke-width": _options.pathStrockWidth,
    			"stroke-linejoin": _options.pathStrokeLinejoin
    		};
    
    		// Lakes have no fill.
    		var lakeAttr = {
    			fill: 'none',
    			stroke: _options.pathStrokeColor,
    			"stroke-width": _options.pathStrockWidth,
    			"stroke-linejoin": _options.pathStrokeLinejoin
    		};
    
    		// Township in Jura have another bgColor.
    		var townshipJuraAttr = {
    			fill: _options.townshipJuraBg,
    			stroke: _options.pathStrokeColor,
    			"stroke-width": _options.pathStrockWidth,
    			"stroke-linejoin": _options.pathStrokeLinejoin
    		};
    
    		var $tooltip = $(_options.toolTipSelector); // jQuery object of the tooltip
    		var mouseOverTownship = false; // Is the mous currently over a township?
    		var mapping = new Array(); // Storing connection of raphael objects to our township path objects
    
    
    		if (typeof townshipPaths != 'undefined') {
      		for (var townshipObjName in townshipPaths) {
    
      			var township = townshipPaths[townshipObjName]; // Paths object
    
      			// Draw the path
      			var raphaelObj = canvas.path(township.path);
    
      			// Mapping raphael object to our path object
      			mapping[raphaelObj.id] = township;
    
      			var $township = $(raphaelObj.node); // jQuery object of dom node.
    
      			$township.css('cursor', 'pointer');
    
      			// Lake path
      			if(townshipObjName == 'lake') {
      				raphaelObj.attr(lakeAttr);
      			}
    
      			// Township paths
      			else {
    
      				if(township.jura) {
      					raphaelObj.attr(townshipJuraAttr);
      				}
      				else {
      					raphaelObj.attr(townshipAttr);
      				}
    
      				// Clicking on a township
      				raphaelObj.click(function() {
    
      					// Show loading indicator
      					$('#' + _options.canvasId + '> svg').fadeOut();
      					$('#' + _options.canvasId).addClass('loading');
    
      					// Go to content
      					window.location = $('a.nid'+ mapping[this.id].nid).attr('href');
      				});
    
      				// Create hover effect
      				raphaelObj.hover(function() {
    
      					$tooltip.html(mapping[this.id].name);
    
      					this.animate({fill: _options.townshipHoverBg}, 300);
      					//doTranslateAnimation(this, 0, -8);
    
      					// Show tooltip.
      					$tooltip.stop(true, true).fadeIn();
    
      					mouseOverTownship = true;
    
      				}, function(){
    
      					var originalBgColor = _options.townshipBg;
    
      					if(mapping[this.id].jura) {
      						originalBgColor = _options.townshipJuraBg;
      					}
    
      					this.animate({fill: originalBgColor}, 300);
      					//doTranslateAnimation(this, 0, 8);
    
      					// Hide tooltip.
      					$tooltip.stop(true, true).fadeOut();
    
      					mouseOverTownship = false;
      				});
      			}
      		}
    		}
    		// Move tooltip with mouse
    		$(document).mousemove(function(e){
    			if (mouseOverTownship){
    				var canvasPosition = $('#' + _options.canvasId).offset();
    				$tooltip.css("left", e.clientX-canvasPosition.left-$tooltip.width()/2+$(window).scrollLeft())
    				.css("top", e.clientY-canvasPosition.top+$(window).scrollTop()-40);
    			}
    		});
  	  }
  	};

  });
})(jQuery);
;
(function ($) {

Drupal.behaviors.galleryAjaxPager =  {
	attach: function(context, settings){
		$('ul.pager li').click( 
			function() {
/*				var parents = $(this).parentsUntil('.node-media-gallery');
        var node = parents.last().parent();
        var id = node.attr('id');
				var url = $(this).children('a').attr("href") + " #" + id;
				$(this).attr("background-color","blue");
				$('#'+id).fadeOut(800);
				$('#'+id).parent().load(url, 
					function(response) {
						Drupal.attachBehaviors(response);
					}
				);
				$('#'+id).fadeIn(800);
				return false;*/
			}
		);
	}
};

}(jQuery));
;
(function($){
  var boxPositions;
  
  $(document).ready(function(){
    initBoxes();
  });
  
  $("#sidebar .box .clickbox.next").live("click", function(e){
    e.preventDefault();
    e.stopPropagation();
    
    var target_id = $(this).parent().find('div.box-content.clickbox').attr("id");
    if (boxPositions[target_id].position < boxPositions[target_id].max) {
      boxPositions[target_id].position++;
    } else {
      boxPositions[target_id].position = 0;
    }
    slideBox(target_id);
    //console.log(boxPositions[target_id]);
  });
  
  $("#sidebar .box .clickbox.back").live("click", function(e){
    e.preventDefault();
    e.stopPropagation();
    
    var target_id = $(this).parent().find('div.box-content.clickbox').attr("id");
    if (boxPositions[target_id].position > 0) {
      boxPositions[target_id].position--;
    } else {
      boxPositions[target_id].position = boxPositions[target_id].max;
    }
    slideBox(target_id);
    //console.log(boxPositions[target_id]);
  });
  
  function initBoxes() {
    boxPositions = [];
    $("div.box-content.clickbox").each(function() {
      var id = $(this).attr("id");
      boxPositions[id]                  = [];
      boxPositions[id]['id']            = id;
      boxPositions[id]['position']      = 0;
      boxPositions[id]['max']           = $(this).find("article.clickbox").length - 1;
      boxPositions[id]['container']     = $(this).find(".box-inner");
      boxPositions[id]['scrollWidth']   = $(this).width() + parseInt($(this).css("padding-left").replace("px", "")) + parseInt($(this).css("padding-right").replace("px", ""));
//      console.log($(this).css("border"));
    });
    //console.log(boxPositions);
  }
  
  function slideBox(id) {
    var targetLeft = -(boxPositions[id]['position'] * boxPositions[id]['scrollWidth']);
    $(boxPositions[id]['container']).animate({left:targetLeft}, 300);
  }
  
  
})(jQuery);;
/**  
 *  Script lazy loader 0.5 - Modified By Web2ajaX
 *  Copyright (c) 2008 Bob Matsuoka
 *
 *  This program is free software; you can redistribute it and/or 
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  Lazyloader updated for a jQuery implementation and appendChild in context
 *  not only in document.body
 *  Add script remove on callback to clean space.
 *
 */
(function($) { 
var LazyLoader = {}; //namespace
LazyLoader.timer = {};  // contains timers for scripts
LazyLoader.scripts = [];  // contains called script references
LazyLoader.load = function(url, context, callback) {
        // handle object or path
        var classname = null;
        var properties = null;
        try {
        
            // make sure we only load once
            // note that we loaded already
            LazyLoader.scripts.push(url);
            var script = document.createElement("script");
            script.src = url;
            script.type = "text/javascript";
            context.get(0).appendChild(script);  // add script tag to head element
            
            // was a callback requested
            if (callback) {    
                // test for onreadystatechange to trigger callback
                script.onreadystatechange = function () {
                    if (script.readyState == 'loaded' || script.readyState == 'complete') {
                        callback();
                        $(script).remove() ;
                    }
                }                            
                // test for onload to trigger callback
                script.onload = function () {
                    callback();
                    $(script).remove() ;
                    return;
                }
                // safari doesn't support either onload or readystate, create a timer
                // only way to do this in safari
				try {
					if (($.browser.webkit && !navigator.userAgent.match(/Version\/3/)) || $.browser.opera) { // sniff
						LazyLoader.timer[url] = setInterval(function() {
							if (/loaded|complete/.test(document.readyState)) {
								clearInterval(LazyLoader.timer[url]);
								callback(); // call the callback handler
							}
						}, 10);
					}
				} catch(e) { }
            }
        } catch (e) {
            alert(e);
        }
} ;


/**
 *  Display an xray overlay to show Ad loading progression
 */
 
var xrayAd = {

	div: null,
	viewport: null,
	thresold: 200,
	elements: [],
	adBlockCount:0,
	w: 160,
	h: 200,
	
	// -- Init XrayAd Div
	init: function() {
		this.div = $('#xrayAd') ;
		if ( ! this.div ) {
			this.div = $('<div>', {
				id: 'xrayAd',
				css: {
					position: 'fixed',
					top: 10,
					left: 10,
					width: this.w,
					height: this.h,
					zIndex: 10000,
					background: 'rgba(0,0,0, 0.5)'
				}
			}) ;
			this.div.appendTo($('body')) ;
		}
	},
	
	// -- Update viewport div
	viewportUpdate: function() {
		
		// Create div if not exists
		if ( ! this.viewport ) {
			this.viewport = $('<div>', {
				id: 'xrayAdViewport',
				css: {
					position: 'absolute',
					width: this.w,
					height: 10,
					zIndex: 10001,
					background: 'rgba(255,255,255, 0.3)'
				}
			}) ;
			this.viewport.appendTo(this.div);
		}
		
		// Create div if not exists
		if ( ! this.viewThresoldTop ) {
			this.viewThresoldTop = $('<div>', {
				id: 'xrayAdThresold',
				css: {
					position: 'absolute',
					width: this.w,
					height: 1,
					zIndex: 10002,
					background: 'rgba(255,0,0, 0.5)'
				}
			}) ;
			this.viewThresoldTop.appendTo(this.div);
			this.viewThresoldBottom = this.viewThresoldTop.clone().appendTo(this.div);
		}
		
		// Update div size and position
		this.bodyHeight = $(document).height() ;
		this.bodyWidth = $(window).width() ;
		var vH = ($(window).height()/this.bodyHeight)*xrayAd.h,
			vT = ($(window).scrollTop()/this.bodyHeight)*xrayAd.h ;
		this.viewport.css({ height: vH , top: vT }) ;
		
		// Update thresold size and position
		this.viewThresoldTop.css({
			top: (($(window).scrollTop()-xrayAd.thresold)/this.bodyHeight)*xrayAd.h
		}) ;
		this.viewThresoldBottom.css({
			top: (($(window).scrollTop()+xrayAd.thresold)/this.bodyHeight)*xrayAd.h + vH - 1
		}) ;
		
		// Refresh Ad blocks
		if ( this.div && this.div.length ) {
			var blocks = this.div.find('.xrayAdBlock') ;
			
			$.each(blocks, function(key, val) {
				
				// Get block id 
				var xrayBlock = $(this) ;
				var adBlock = $(xrayAd.elements[key]) ;
				
				if ( xrayBlock.length && adBlock.length ) {
					// Get offset and size of the page ad
					var size = {} ;
					size.off = adBlock.offset() ;
					if ( size.off ) {
						size.top = (size.off.top/xrayAd.bodyHeight)*xrayAd.h ;
						size.left = (size.off.left/xrayAd.bodyWidth)*xrayAd.w ;
						size.w = (Math.max(adBlock.width(), 10)/xrayAd.bodyWidth)*xrayAd.w ;
						size.h = (Math.max(adBlock.height(), 10)/xrayAd.bodyHeight)*xrayAd.h ;
						
						// Get ad load status
						var bgColor = '#FF0071' ;
						bgColor = ( adBlock.data('loading') == 'true' ? 'orange' : bgColor ) ;
						bgColor = ( adBlock.data('loaded') == 'true' ? '#00FF00' : bgColor ) ;
						
						// Update xray Block
						xrayBlock.css({
							top:size.top,
							left:size.left,
							width:size.w,
							height: size.h,
							borderColor: bgColor
						}) ;
					}
				}
				
			}) ;
		}
	},
	
	// -- Load elemnts to xray
	load: function(el, thresold) {
		
		// Init thresold
		this.thresold = thresold || 0 ;
		
		// Init Overlay Div
		this.init() ;
		
		// Draw each elements on div
		var adBlock = $('<div>', {
			'class': 'xrayAdBlock', 
			'css': {
				position: 'absolute',
				background: '#ffffff',
				border: '1px solid #FF0071',
				top: 0, left: 0, width: 0, height: 0,
				zIndex: 10003
			}
		});
		
		// Init elements
		$.each(el, function() {
		
			// Create adBlock
			adBlock.clone().attr('xrayblock', 'xrayAdBlock_'+ (xrayAd.adBlockCount++)).appendTo(xrayAd.div) ;
			
			// Bind load and complete
			$(this).bind('onCompleteXray',function() {
				xrayAd.viewportUpdate();
			}) ;
			$(this).bind('onLoadXray',function() {
				xrayAd.viewportUpdate();
			}) ;
	
			// Push src
			xrayAd.elements.push(this);
		}) ;
		
		
		// Init viewport Div
		xrayAd.viewportUpdate() ;
		
		// Bind scroll
		$(window).bind("scroll", function(event) {
			xrayAd.viewportUpdate() ;        
		});
	}


} ;


/* •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
   ••  Project: jQuery LazyLoad For Advertisement                   ••
   ••  Author:  delarueguillaume@gmail.com                          ••
   ••  WebSite : http://www.web2ajax.fr/                            ••
   ••  Date:    2010                                                ••
   ••  Version: 1.4 (24 sept 2010)  : Add synchronous method to js  •• 
   ••  Version: 1.3 (20 sept 2010)  : OpenX Compatibility		    ••   
   ••  Version: 1.2 (30 march 2010) : Hight Imporvements of code    ••   
   ••  Version: 1.1 (25 march 2010) : Improve IE compatibility      ••
   ••  Version: 1.0 (24 march 2010)                                 ••
   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••   
   
    Defer Advertisement loading and load only if the ad is in the visible part of
    the page like lazyLoad for pictures.
    -> Highly improve general page load
    -> Improve cpu load of visitor in case of displaying flash banners (only displayed if necessary)
    –> Compatibility with AdSense and many other advertisers
    -> Cross Browser suupprt (IE5.5+, Firefox, Opera, Chrome, Safari)
    
    A big thanks to Mika Tuupola for the Lazy load part
    -> http://www.appelsiini.net/projects/lazyload 
    
    Another big thanks to Thomas Aylott and his MooTools based document.write replacement
    -> http://SubtleGradient.com/
    
*/



	$.lazyLoadAdRunning = false ;
	$.lazyLoadAdTimers = [] ;
	
    $.fn.lazyLoadAd = function(options) {
        var settings = {
            threshold    : 0,
            failurelimit : 1,
            forceLoad	 : false,
            event        : "scroll",
            viewport	 : window,
            placeholder	 : false,		// Can specify a picture to replace media while loading
            onLoad		 : false,
            onComplete	 : false,
            timeout		 : 1500,
            debug		 : false,
            xray		 : false
        };
                
        if(options) {
            $.extend(settings, options);
        }
        
        /* Write logs if possible in console */
        function _debug() {
        	if ( typeof console != 'undefined' && settings.debug ) {	
        		var args = [] ;
        		for ( var i = 0 ; i < arguments.length ; i++ ) args.push(arguments[i]) ;
        		try { console.log('LazyLoadAD |', args) ; } catch(e) {} ;
        	}
        }
        
        /* If xray display requested */
        if ( settings.xray && ( typeof xrayAd == 'object' ) ) {
        	xrayAd.load(this, settings.threshold) ;
        }

        /* Fire one scroll event per scroll. Not one scroll event per image. */
        var elements = this;
        $(settings.viewport).bind("checkLazyLoadAd", function() {
        	var counter = 0;
        	elements.each(function() {                	
        		if ( $.lazyLoadAdRunning ) {
        			if ( $.lazyLoadAdTimers['runTimeOut'] ) clearTimeout( $.lazyLoadAdTimers['runTimeOut'] ) ;
        			 $.lazyLoadAdTimers['runTimeOut'] = setTimeout(function() {
        				$(settings.viewport).trigger("checkLazyLoadAd") ; 
        			}, 300) ;
        			return false ;
        		} else if ( settings.forceLoad == true ) {
        			$(this).trigger("load");
        		} else if (!$.belowthefold(this, settings) && !$.abovethetop(this, settings)) {
        	        $(this).trigger("load");
        	    } else {
        	        if (counter++ > settings.failurelimit) {
        	            return false;
        	        }
        	    }
        	});
        	/* Remove element from array so it is not looped next time. */
        	var temp = $.grep(elements, function(element) {
        	    return ! (($(element).data('loaded') == 'true') ? true : false) ;
        	});
        	elements = $(temp);
        }) ; 
        
        if ("scroll" == settings.event) {
            $(settings.viewport).bind("scroll", function(event) {
            	if ( elements.length == 0 ) return false;
               	$(settings.viewport).trigger("checkLazyLoadAd") ;                
            });
        }
        
        
        // -- Bind each element
        this.each(function(_index, _value) {
        
            var self = $(this);
            
            /* Save original only if it is not defined in HTML. */
            if (undefined == self.attr("original")) {
                self.attr("original", self.attr("src"));     
            }
            
            /* Test if element is loaded */
            self.isLoaded = function() { return ((self.data('loaded') == 'true') ? true : false)  ; } ;
            
            /* Trigger Debug Display */
            self.bind("debug", function(e, status) {
            
            	status = status || 'start' ;
            	
            	// -- Trigger xRay if possible
            	if ( settings.xray ) { 
            		if ( status == 'start') self.trigger('onLoadXray') ; 
            		else if ( status == 'error' ) self.trigger('onErrorXray') ; 
            		else if ( status == 'complete' ) self.trigger('onCompleteXray') ;   
            	}
            	
            	// -- Change border color of ad frame
	            if ( settings.debug ) {
	            	if ( status == 'start') self.css({border: '3px solid orange'}) ;
	            	else if ( status == 'error' ) self.css({border: '3px solid red'}) ;
	            	else if ( status == 'complete' ) self.css({border: '3px solid green'}) ;     
            	}
            	
            });
            
            /* On ad Load successful */
            self.one('onComplete', function() {
            	
            	_debug('---> lazyLoadComplete') ;
            	
            	// -- Remove original attr
            	$(self).removeAttr("original") ;
            	
            	// -- Set as loaded
            	$.lazyLoadAdRunning = false ;
            	self.data('loaded', 'true') ;
            	
            	// -- Mark debug
            	self.trigger('debug', 'complete') ;
            	
            	if ( typeof settings.onComplete == 'function') {
            		try { settings.onComplete() } catch(e) {} ;
            	}
            }) ;
            
            
            /* Launch the makina !! */
            self.stack = [] ;
            self.makinaBlock = false ;
            self.bind('makina_go', function() {
            
            	if ( self.makinaBlock ) return false ;
            	
            	if ( self.stack.length > 0 ) {
            		var el = self.stack.shift() ;
					
					var wrapAd = self.find('.wrapAd') ;
					if ( ! wrapAd.length ) {
						wrapAd = $('<div class="wrapAd"></div>').clone() ;
						wrapAd.appendTo(self) ;
					}
					
					var wrap = $('<div>').clone().appendTo(wrapAd) ;
					
            		if ( typeof el == 'string' ) {
            			wrap.replaceWith(el);
            		} else if ( typeof el == 'object' ) {
            			if ( el.is('script') ) {
            			
            				// -- Load JS and block makina until script is loaded
            				if ( el.attr('src') ) {
	            				_debug('JS to load !! --> ' +  el.attr('src') ) ;
	            				//self.makinaBlock = true ;
	            				LazyLoader.load(el.attr('src'), self, function(){
	            				    self.makinaBlock = false ;
	            				    _debug('JS to load !! ++> ' +  el.attr('src') ) ;
	            				    self.trigger('makina_go') ;
	            				});
            				}
            				
            				// -- Write JS code in wrapper
            				else {
            					wrap.replaceWith(el);
            				}
            			} else {
            				wrap.replaceWith(el);
            			}	
            		}
            		
            		self.trigger('makina_go') ;
            	} else {
            		if ( $.lazyLoadAdTimers.loadJS ) clearTimeout($.lazyLoadAdTimers.loadJS) ;
            		$.lazyLoadAdTimers.loadJS = setTimeout(function() {
            			self.trigger('onComplete') ;	
            		}, settings.timeout) ;
            	}
            
            }) ;
            
            /* Write directly in DOM : tag is html valid */
            self.bind('docWrite_direct', function(e, html) {
            	var el = $(html) ;
            	_debug('Fragment Direct Write : ', el, el.length) ;
            	$.each(el, function() { self.stack.push($(this)) ; }) ;
            	self.trigger('makina_go') ;
            }) ;
            
            /* Write directly in DOM : tag is html valid */
            self.bind('docWrite_delayed', function(e, html) {
            	_debug('Fragment Delayed Write : ', html) ;
            	
            	self.numWrappers-- ;
            	_debug("Fragment append : ", self.numWrappers, html);						
            	self.docHtmlCurrent += html;
            	if ( self.numWrappers == 0 ) {
            		html = self.docHtmlCurrent ;
            		self.docHtmlCurrent = '' ;
            		setTimeout(function() {
            			self.stack.push(html) ;
            			self.docHtmlCurrent = ''; 
            			self.trigger('makina_go') ;
            		}, 0);
            	}
            }) ;
            
            
            
            /* Overload the default document.write */
            self.numWrappers = 0 ;
            self.docHtmlCurrent = '' ;
            self.bind('docWrite_overload', function() {

            	// -- Overload default document.write function
            	document._writeOriginal = document.write;
            	document.write = document.writeln = function(){
            		
            		var args = arguments, id = null ;
            		var html=''; for(var i=0;i<args.length;i++) html+=args[i] ;
 
            		// -- Check if html to write is valid
            		var testHTML = '',
            			directWrite = false ;
            			
            		try { 
            			testHTML = $(html) ; 
            			directWrite = ( ( testHTML.is('div') || testHTML.is('script') ) ? true : false ) ;
            		} catch(e) { } ;
            		
            		self.history[self.fragmentId] = self.history[self.fragmentId] || {} ;
            		if ( self.history[self.fragmentId][html] == undefined ) {
            			self.history[self.fragmentId][html] = true ;
            			if ( directWrite ) {
            				self.trigger('docWrite_direct', html) ;
            			} else {
            				self.numWrappers++ ;
            				setTimeout(function() {
	            				self.trigger('docWrite_delayed', html) ;
	            			}, 0) ;
            				
            			}
            		} 
            	};
            }) ;
            
            
            /* Eval Script into <code> tags */
            self.bind('evalCode', function() {
	            var scripts = [],
	            	script,
	            	regexp = /<code[^>]*>([\s\S]*?)<\/code>/gi;
	            	
	            while ((script = regexp.exec(self.html()))) {
	            	var _s = script[1] ;
	            	_s = _s.replace('<!--//<![CDATA[', '').replace('//]]>-->','').replace('<!--', '').replace('//-->', '') ;
	            	_s = _s.replace(/\&gt\;/g,'>').replace(/\&lt\;/g,'<') ;
	            	scripts.push($.trim(_s));
	            }
	            
	            // -- Eval param code before calling ad script					
	            try {
	            	scripts = ( scripts.length ? scripts.join('\n') : '' ) ;
	            	_debug('Script to eval : ', scripts) ;
	            	if ( scripts != '' ) eval(scripts); 
	            } catch(e) { } ;    
            });
            
            
            /* Load a JS and wait for callback */
            self.bind('loadJS', function(e, js2load) {
            	
            	var callback = null, script = null ;
            	if ( js2load.src ) {
            		callback = js2load.callback || null ;
            		js2load = js2load.src ;
            	}
            	
            	// Add an anticache 
            	if ( js2load.indexOf('?') == -1 ) {
            		js2load += '?_='+ (new Date().getTime()) ;
            	} else {
            		js2load += '&_='+ (new Date().getTime()) ;
            	}
            	
            	_debug('loadJS :: ', js2load) ;

				// Request JS
            	LazyLoader.load(js2load, self, function(){
            	    _debug('loadJS COMPLETE :: ' + js2load) ;
            	    if ( callback ) {
            	    	callback() ;
            	    }else {
            	    	$.lazyLoadAdTimers.loadJS = setTimeout(function() {
            	    		self.trigger('onComplete') ;	
            	    	}, settings.timeout) ;
            	    }
            	});
            	
            }) ;
            
            
            /* When appear is triggered load ad. */
            self.one("load", function() {
            	
            	// Detect if element is already loaded
                if (! self.isLoaded() ) {
                
                	// Lock other adverts load
                	$.lazyLoadAdRunning = true ;
                	
                	// Have to load the current ad...
                	self.data('loading', 'true') ;
                	self.trigger('debug', 'start') ;
                	
                	// Get original source to load
                	var srcOriginal = $(self).attr("original") ;
                	
                	// Set fragmentId
                	self.history = {} ;
                	
                	// -- Call script and let's dance
                	_debug('------------------------------  Lazy Load Ad CALL ----') ;
                	_debug('Context : ', self ) ;	
                	
                	// Bind document.write overload
                	self.trigger('docWrite_overload') ;
                	
                	// Eval code
                	self.trigger('evalCode') ;
                	
                	// Eval attached script
                	if ( srcOriginal ) {
                		self.trigger('loadJS', srcOriginal) ;
                	}
                	
                };
            });
            
            

            /* When wanted event is triggered load ad */
            /* by triggering appear.                              */
            if ("scroll" != settings.event) {
                self.bind(settings.event, function(event) {
                    if (!self.isLoaded()) {
                        self.trigger("load");
                    }
                });
            }
        });
        
        /* Force initial check if images should appear. */
        $(settings.viewport).trigger('checkLazyLoadAd');
        
        return this;

    };

    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */
    
    $.belowthefold = function(element, settings) {
        if (settings.viewport === undefined || settings.viewport === window) {
            var fold = $(window).height() + $(window).scrollTop();
        } else {
            var fold = $(settings.viewport).offset().top + $(settings.viewport).height();
        }
        return fold <= $(element).offset().top - settings.threshold;
    };
        
    $.abovethetop = function(element, settings) {
        if (settings.viewport === undefined || settings.viewport === window) {
            var fold = $(window).scrollTop();
        } else {
            var fold = $(settings.viewport).offset().top;
        }
        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };
    
})(jQuery);;
(function($){

  //this scripts inject the ads into the dom after the page has finished loading
  $(document).ready(function(){
    $(".lazy-ad").lazyLoadAd({
      threshold    : 1000,
      timeout      : 0
    });

  });

  
})(jQuery);
;
var rs = {
    settings: {
        usePopupButton: true,
        usePopupPlayer: true,
        useReadspeakerIcon: false,
        usePost: false,
        wordColor: "#FF0000",
        sentColor: "#666666",
        textColor: "#FFFFFF",
        defaultspeed: 100,
        appserverhost: "app.readspeaker.com",
        flashParams: "&time_format=ms&tips=0&rvolume=0&rcontrol=mini&rloading=0&c1=0x3B3B3B&c2=0x3B3B3B&c3=0xFFFFFF&c4=0xE2001A&c5=0x3B3B3B&c6=0x777777&c7=0xE2001A&c9=0xFFFFFF&c10=0x3B3B3B&c11=0x3B3B3B&c13=0xE2001A&c14=0xFFFFFF&c15=0x3B3B3B&c16=0xFFFFFF&c17=0xFFFFFF&c20=0x3B3B3B&c21=0x3B3B3B",
        flashLink: document.location.protocol + "//media.readspeaker.com/flash/readspeaker20.swf",
        allowScriptAccess: null,
        protocol: document.location.protocol || "http:",
        rsent: "rsent",
        defaultsync: "wordsent",
        version: "1.01-embhl",
	height: '25',
	popupHeight: '20',
	popupWidth: '60',
	width: '200',
        reloadPage: false
    },
    phrases: {
        closeplayer: "Player schlie&szlig;en",
        fast: "Hoch",
        hide: "Ausblenden",
        highlightingoptions: "Highlighting optionen",
        listentoselectedtext: "Markierten text vorlesen",
        medium: "Mittel",
        nohighlighting: "Kein highlighting",
        nosound: "Kein Ton?",
        pause: "Pause",
        playerwidth: "250",
        play: "Play",
        popupbutton: "Popup-Taste",
        sentonly: "Nur Satz",
        settings: "Einstellungen",
        show: "Anzeigen",
        slow: "Langsam",
        speechenabled: "Sprachwiedergabe durch <a href='http://www.readspeaker.com/de' target='_blank'>ReadSpeaker</a>",
        speed: "Geschwindigkeit",
        stop: "Stop",
        volume: "Volume",
        wordonly: "Nur Wort",
        wordsent: "Wort und Satz"
    },
    thesync: "none",
    thespeed: 100,
    state: "NO_ACTION",
    defaultsurvive: 360000000,
    bmindex: 1,
    sentbmindex: 0,
    seltexttimes: 0,
    seltextcleanuptimes: 0,
    startofsentence: 1,
    inc: 0,
    start: null,
    stop: null,
    newhtml: "",
    startOffset: null,
    endOffset: null,
    selectedString: "",
    selhtml: "",
    selectedWordsRange: [],
    firstrun: 1,
    selectedRange: null,
    globalcount: null,
    oldwordhl_FF: [],
    oldwordhlclass_FF: [],
    oldsenthl_FF: [],
    oldsenthlclass_FF: [],
    oldwordhlrange_IE: [],
    oldwordhlbackcol_IE: [],
    oldwordhlforecol_IE: [],
    oldwordhl_IE: [],
    oldwordhlclass_IE: [],
    oldsenthlrange_IE: [],
    oldsenthlbackcol_IE: [],
    oldsenthlforecol_IE: [],
    oldsenthl_IE: [],
    oldsenthlclass_IE: [],
    oldbodyclass: null,
    exludednodes: ["table", "tr", "select", "option", "textarea", "ul", "ol", "dl", "thead", "tbody", "tfoot", "colgroup", "script", "map", "optgroup"],
    data: {
        restorehtml: [],
        readid: [],
        current: {
            restorehtml: null,
            readid: null,
            playerid: null
        },
        previous: {
            playerid: null,
            sync: null
        }
    },
    convertSpeed: function(a) {
        switch (a) {
        case "slow":
            return rs.settings.defaultspeed - 25;
        case "medium":
            return rs.settings.defaultspeed;
        case "fast":
            return rs.settings.defaultspeed + 25;
        default:
            return rs.settings.defaultspeed
        }
    },
    issuePOST: function(a, c) {
        rs.globalcount++;
        if (!document.getElementById("postiframe1") || !document.getElementById("postiframe2") || !document.getElementById("postiframe3")) {
            var g = null;
            if (document.selection) {
                g = document.createElement('<iframe name="postiframe' + rs.globalcount + '">')
            } else {
                g = document.createElement("iframe");
                g.name = "postiframe" + rs.globalcount
            }
            g.setAttribute("id", "postiframe" + rs.globalcount);
            g.setAttribute("style", "display: none; position: absolute;");
            g.style.display = "none";
            var d = document.getElementsByTagName("body");
            var n = null;
            if (d.length > 0) {
                var n = d.item(0)
            }
            if (n) {
                n.appendChild(g)
            } else {
                return
            }
        }
        a = a + "&output=audiolink";
        var f = document.createElement("form");
        f.target = "postiframe" + rs.globalcount;
        f.method = "post";
        var m = a.split("?");
        var l = Math.random();
        f.action = rs.settings.protocol + "//" + rs.settings.appserverhost + "/enterprise/iframeproxy.php?rsent=" + rs.settings.rsent + "&randid=" + l;
        var k = m[1].split("&");
        var h;
        for (h = 0; h < k.length; h++) {
            var e = k[h].split("=");
            var o = document.createElement("input");
            o.setAttribute("name", unescape(e[0]));
            o.setAttribute("value", unescape(e[1]));
            f.appendChild(o)
        }
        var o = document.createElement("input");
        if (rs.state == "PLAYING_NO_SELECTION" && rs.settings.usePost) {
            o.setAttribute("name", "html_base64")
        } else {
            o.setAttribute("name", "selectedhtml_base64")
        }
        o.setAttribute("value", rs.base64.encode(c));
        f.appendChild(o);
        document.body.appendChild(f);
        f.submit();
        document.body.removeChild(f);
        return rs.settings.protocol + "//" + rs.settings.appserverhost + "/enterprise/iframeproxy.php?rsent=" + rs.settings.rsent + "&listen=1&randid=" + l
    },
    removeiFrames: function() {
        if (document.getElementById("postiframe1")) {
            document.body.removeChild(document.getElementById("postiframe1"))
        }
        if (document.getElementById("postiframe2")) {
            document.body.removeChild(document.getElementById("postiframe2"))
        }
        if (document.getElementById("postiframe3")) {
            document.body.removeChild(document.getElementById("postiframe3"))
        }
    },
    readpage: function(b, c) {
        rs.globalcount = 0;
        rs.getreadids();
        if (rs.popup.time) {
            clearTimeout(rs.popup.time);
            rs.popup.setVisibility()
        }
        if (rs.settings.allowScriptAccess === null) {
            if (rs.settings.flashLink.indexOf("media.readspeaker.com") == -1) {
                rs.settings.allowScriptAccess = "sameDomain"
            } else {
                rs.settings.allowScriptAccess = "always"
            }
        }
        if ((navigator.userAgent.toLowerCase().indexOf("iphone") > -1 || navigator.userAgent.toLowerCase().indexOf("ipad") > -1 || navigator.userAgent.toLowerCase().indexOf("ipod") > -1) && navigator.vendor.toLowerCase().indexOf("apple") > -1) {
            rs.html5.inUse = true
        }
        rs.thespeed = rs.convertSpeed(rs.loadSettings("ReadSpeakerHLspeed"));
        if (rs.state.indexOf("USER_SELECTION") == -1) {
            rs.data.previous.sync = rs.thesync
        }
        rs.thesync = rs.loadSettings("ReadSpeakerHL");
        if (rs.thesync === null || rs.thesync === "") {
            rs.thesync = rs.settings.defaultsync
        }
        var d = b.match(/readid=[^&]+/gi);
        rs.data.current.readid = d[0].replace("readid=", "");
        rs.data.current.playerid = c;
        if (rs.data.previous.playerid !== null) {
            var e = null;
            e = document.getElementById(rs.data.previous.playerid);
            if (e) {
                e.innerHTML = "";
                e.style.display = "none"
            }
        }
        rs.data.previous.playerid = rs.data.current.playerid;
        if (rs.state == "USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_NO_SELECTION" || rs.state == "SETTINGS_CHANGED_PLAYING_USER_SELECTION") {
            rs.cleanup();
            if (rs.state != "SETTINGS_CHANGED_PLAYING_USER_SELECTION") {
                rs.selhtml = rs.selectRange()
            }
            if (document.selection) {
                document.execCommand("Unselect")
            }
            rs.state = "PLAYING_USER_SELECTION"
        } else {
            rs.state = "PLAYING_NO_SELECTION";
            if (rs.data.previous.sync != "none" || rs.thesync != "none") {
                rs.cleanup()
            }
            if (rs.settings.usePost) {
                if (rs.data.current.readid !== null) {
                    var a = document.getElementById(rs.data.current.readid);
                    if (a !== null) {
                        rs.data.current.restorehtml = a.innerHTML
                    }
                }
            }
        }
        if (rs.html5.inUse) {
            rs.html5.player(b)
        } else {
            if (rs.data.current.playerid == "rs_popup_player") {
                rs.popup.player(b)
            } else {
                rs.player(b)
            }
        }
        rs.selectedString = ""
    },
    player: function(b) {
        if (rs.state != "PLAYING_NO_SELECTION") {
            var d = encodeURIComponent(rs.issuePOST(b + "&audioformat=flv&sync=user&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version + "&syncalignuser=" + rs.thesync, rs.selhtml));
            var c = rs.issuePOST(b + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version, rs.selhtml)
        } else {
            if (rs.settings.usePost) {
                var d = encodeURIComponent(rs.issuePOST(b + "&audioformat=flv&sync=" + rs.thesync + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version, "<div id='" + rs.data.current.readid + "'>" + rs.data.current.restorehtml + "</div>"));
                var c = rs.issuePOST(b + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version, "<div id='" + rs.data.current.readid + "'>" + rs.data.current.restorehtml + "</div>")
            } else {
                var d = encodeURIComponent(b + "&audioformat=flv&sync=" + rs.thesync + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version);
                var c = b + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version
            }
        }
        var e = "<div id='rs_playerarea'>";
        e += "<div style='margin-bottom: 2px; width: 100%; height: 20px;'><span style='position: absolute; top: 0px; left: 0px;'><object type='application/x-shockwave-flash' data='" + rs.settings.flashLink + "?flv=" + d + rs.settings.flashParams + "&text_play=" + rs.phrases.play + "&text_pause=" + rs.phrases.pause + "&text_stop=" + rs.phrases.stop + "&text_vol=" + rs.phrases.volume + "' style='height:20px; width:250px;'>";
        e += "<param name='movie' value='" + rs.settings.flashLink + "?flv=" + d + rs.settings.flashParams + "&text_play=" + rs.phrases.play + "&text_pause=" + rs.phrases.pause + "&text_stop=" + rs.phrases.stop + "&text_vol=" + rs.phrases.volume + "'>";
        e += "<param name='quality' value='high'><param name='autostart' value='true'>";
        e += "<param name='allowScriptAccess' value='" + rs.settings.allowScriptAccess + "'><param name='bgcolor' value='#323232'>";
        e += "<param name='loop' value='false'></object></span>";
        e += "<span style='position: absolute; top: 4px; right: 4px;'><a style='border-style: none;' href='JavaScript:void(0);' onclick='rs.closepage(\"" + rs.data.current.playerid + "\");return false'><img id='closebr' src='" + rs.settings.protocol + "//media.readspeaker.com/images/enterprise/default/close.png' alt='" + rs.phrases.closeplayer + "' title='" + rs.phrases.closeplayer + "'></a></span></div>";
        e += "<div id='bottomlinks'><a href='JavaScript:void(0);' class='rs_settings' onclick='rs.showcontrols(\"" + b + '","' + rs.data.current.playerid + "\");return false'>" + rs.phrases.settings + "</a> | <a id='rsSaveBtn' href='" + c + "' target='rs' onclick='rs.removeiFrames(); return true;'>" + rs.phrases.nosound + "</a> | " + rs.phrases.speechenabled + "</div>";
        e += "<div id='controls'></div>";
        e += "</div>";
        var a = document.getElementById(rs.data.current.playerid);
        if (a) {
            a.innerHTML = e;
            a.style.display = "block"
        }
    },
    getreadids: function() {
        if (rs.data.readid.length === 0) {
            var f = document.getElementsByTagName("A");
            for (var e = 0; e < f.length; e++) {
                if (f[e].getAttribute("href") && f[e].getAttribute("href").indexOf(rs.settings.appserverhost + "/cgi-bin/" + rs.settings.rsent) != -1 && f[e].id != "rsSaveBtn") {
                    var c = f[e].getAttribute("href").match(/readid=[^&]+/gi);
                    if (c) {
                        var a = c[0].replace("readid=", "");
                        rs.data.readid.push(a)
                    }
                }
            }
            if (rs.data.readid.length > 0) {
                var d = null;
                for (var b = 0; b < rs.data.readid.length; b++) {
                    d = document.getElementById(rs.data.readid[b]);
                    if (d) {
                        rs.data.restorehtml.push(d.innerHTML)
                    }
                }
            }
        }
    },
    closepage: function(b) {
        if (rs.html5.inUse) {
            rs.html5.controls.stop()
        }
        var a = document.getElementById(b);
        if (a) {
            a.innerHTML = "";
            a.style.display = "none"
        }
        rs.state = "CLOSE";
        var c = document.getElementById(rs.data.current.readid);
        if (c && c.className.toLowerCase().indexOf("rs_reload") > -1 || rs.settings.reloadPage) {
            setTimeout("location.reload(true);", 500)
        } else {
            setTimeout("rs.cleanup();rs.data.current.restorehtml=null;", 500);
            if (document.getElementById("rs_selimg")) {
                document.body.removeChild(document.getElementById("rs_selimg"))
            }
            if (document.getElementById("rs_popup_player")) {
                document.body.removeChild(document.getElementById("rs_popup_player"))
            }
        }
    },
    rshlexit: function() {
        setTimeout("rs.cleanup();", 500)
    },
    saveSettings: function(name, content, lifetime) {
        lifetime = parseInt(eval(lifetime));
        if (lifetime + "" == "NaN") {
            tmpdate = ""
        } else {
            var thedate = new Date();
            thedate.setTime(thedate.getTime() + lifetime);
            thedate = thedate.toGMTString();
            tmpdate = "; expires=" + thedate
        }
        document.cookie = name + "=" + escape(content) + tmpdate
    },
    loadSettings: function(a) {
        ckarr = document.cookie;
        cks = ckarr.split("; ");
        for (i = 0; i < cks.length; i++) {
            cknameval = cks[i].split("=");
            for (j = 0; j < cknameval.length; j++) {
                if (cknameval[j] == a) {
                    return unescape(cknameval[j + 1])
                }
            }
        }
        return ""
    },
    setstyle: function(b) {
        if (b.indexOf("icon") > -1) {
            rs.saveSettings("ReadSpeakerHLicon", b, rs.defaultsurvive)
        } else {
            if (b == "slow" || b == "medium" || b == "fast") {
                rs.saveSettings("ReadSpeakerHLspeed", b, rs.defaultsurvive)
            } else {
                rs.saveSettings("ReadSpeakerHL", b, rs.defaultsurvive)
            }
        }
        var a = document.getElementById("controls");
        if (a !== null) {
            a.innerHTML = ""
        }
    },
    showcontrols: function(b, c) {
        var a = document.getElementById("controls");
        if (a !== null && a.innerHTML != "") {
            a.innerHTML = "";
            a.style.display = "none";
            return false
        }
        var e = rs.loadSettings("ReadSpeakerHL");
        var f = rs.loadSettings("ReadSpeakerHLicon");
        var d = rs.loadSettings("ReadSpeakerHLspeed");
        if (e == "") {
            e = rs.settings.defaultsync
        }
        if (f == "") {
            if (rs.settings.usePopupButton) {
                f = "iconon"
            } else {
                f = "iconoff"
            }
        }
        if (d == "") {
            d = "medium"
        }
        thestring = "<div id='rspopup'><fieldset class='rs_block'><legend>" + rs.phrases.highlightingoptions + "</legend><ul>";
        thestring += "<li class=";
        if (e == "wordsent") {
            thestring += "'rs_active'"
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","wordsent");return false;\'>' + rs.phrases.wordsent + "</a></li>";
        thestring += "<li class=";
        if (e == "sent") {
            thestring += "'rs_active'"
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","sent");return false;\'>' + rs.phrases.sentonly + "</a></li>";
        thestring += "<li class=";
        if (e == "word") {
            thestring += "rs_active"
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","word");return false;\'>' + rs.phrases.wordonly + "</a></li>";
        thestring += "<li class=";
        if (e == "none") {
            thestring += "rs_active"
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","none");return false;\'>' + rs.phrases.nohighlighting + "</a></li>";
        thestring += "</ul></fieldset><fieldset class='rs_block'><legend>" + rs.phrases.popupbutton + "</legend><ul>";
        thestring += "<li class=";
        if (f == "iconon") {
            thestring += "rs_active "
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.settings.usePopupButton=true;rs.changeSettings(\"" + b + '","' + c + '","iconon");return false;\'>' + rs.phrases.show + "</a></li>";
        thestring += "<li class=";
        if (f == "iconoff") {
            thestring += "rs_active "
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.settings.usePopupButton=false;rs.changeSettings(\"" + b + '","' + c + '","iconoff");return false;\'>' + rs.phrases.hide + "</a></li>";
        thestring += "</ul></fieldset><fieldset class='rs_block'><legend>" + rs.phrases.speed + "</legend><ul>";
        thestring += "<li class=";
        if (d == "slow") {
            thestring += "rs_active "
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","slow");return false;\'>' + rs.phrases.slow + "</a></li>";
        thestring += "<li class=";
        if (d == "medium") {
            thestring += "rs_active "
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","medium");return false;\'>' + rs.phrases.medium + "</a></li>";
        thestring += "<li class=";
        if (d == "fast") {
            thestring += "rs_active "
        }
        thestring += "><a href='JavaScript:void(0);' onclick='rs.changeSettings(\"" + b + '","' + c + '","fast");return false;\'>' + rs.phrases.fast + "</a></li>";
        thestring += "</ul></fieldset></div><div style='clear: both;'></div>";
        var a = document.getElementById("controls");
        if (a !== null) {
            a.style.display = "block";
            a.innerHTML = thestring
        }
    },
    changeSettings: function(a, b, c) {
        if (rs.html5.inUse) {
            rs.html5.stop()
        }
        if (rs.state == "PLAYING_NO_SELECTION") {
            rs.state = "SETTINGS_CHANGED_PLAYING_NO_SELECTION"
        } else {
            rs.state = "SETTINGS_CHANGED_PLAYING_USER_SELECTION"
        }
        rs.setstyle(c);
        rs.readpage(a, b)
    },
    copyselected: function(a) {
        rs.popup.mouseRel(a);
        setTimeout("rs.getSelectedHTML()", 50);
        return true
    },
    getSelectedHTML: function() {
        rs.selectedString = '';
        var b = undefined;
        var a = undefined;
        if (window.getSelection) {
            a = window.getSelection();
            if (!a.isCollapsed) {
                if (a.getRangeAt) {
                    b = a.getRangeAt(0)
                } else {
                    b = document.createRange();
                    b.setStart(a.anchorNode, a.anchorOffset);
                    b.setEnd(a.focusNode, a.focusOffset)
                }
                if (b) {
                    DOM = b.cloneContents();
                    object = document.createElement("div");
                    object.appendChild(DOM.cloneNode(true));
                    rs.selectedString = object.innerHTML
                } else {
                    rs.selectedString = a
                }
            }
        } else {
            if (document.selection) {
                a = document.selection;
                b = a.createRange();
                if (b && b.htmlText && b.text && b.text.length > 0) {
                    rs.selectedString = b.htmlText
                } else {
                    if (b && b.text) {
                        rs.selectedString = b.text
                    }
                }
            } else {
                if (document.getSelection) {
                    rs.selectedString = document.getSelection()
                }
            }
        }
        rs.popup.button();
        if (rs.selectedString.length > 0 && rs.state == "NO_ACTION") {
            rs.state = "USER_SELECTION"
        } else {
            if (rs.selectedString.length > 0 && rs.state == "PLAYING_USER_SELECTION") {
                rs.state = "USER_SELECTION_WHILE_PLAYING_USER_SELECTION"
            } else {
                if (rs.selectedString.length > 0 && rs.state == "PLAYING_NO_SELECTION") {
                    rs.state = "USER_SELECTION_WHILE_PLAYING_NO_SELECTION"
                }
            }
        }
    },
    cleanup: function() {
        if (document.selection) {
            if (rs.state == "USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_NO_SELECTION") {
                if (rs.oldwordhl_IE.length > 0) {
                    for (var c = 0; c < rs.oldwordhl_IE.length; c++) {
                        rs.oldwordhl_IE[c].className = rs.oldwordhlclass_IE[c]
                    }
                    rs.oldwordhlclass_IE = [];
                    rs.oldwordhl_IE = []
                }
                if (rs.oldsenthl_IE.length > 0) {
                    for (var c = 0; c < rs.oldsenthl_IE.length; c++) {
                        rs.oldsenthl_IE[c].className = rs.oldsenthlclass_IE[c]
                    }
                    rs.oldsenthl_IE = [];
                    rs.oldsenthlclass_IE = []
                }
            }
            if (rs.oldwordhlrange_IE.length > 0) {
                for (var c = 0; c < rs.oldwordhlrange_IE.length; c++) {
                    if (rs.oldwordhlbackcol_IE[c] && rs.oldwordhlforecol_IE) {
                        rs.oldwordhlrange_IE[c].execCommand("backcolor", 0, rs.oldwordhlbackcol_IE[c]);
                        if (rs.oldwordhlforecol_IE[c] !== null) {
                            rs.oldwordhlrange_IE[c].execCommand("forecolor", 0, rs.oldwordhlforecol_IE[c])
                        }
                    }
                }
                rs.oldwordhlrange_IE = [];
                rs.oldwordhlbackcol_IE = [];
                rs.oldwordhlforecol_IE = []
            }
            if (rs.oldsenthlrange_IE.length > 0) {
                for (var c = 0; c < rs.oldsenthlrange_IE.length; c++) {
                    if (rs.oldsenthlbackcol_IE[c] && rs.oldsenthlforecol_IE) {
                        rs.oldsenthlrange_IE[c].execCommand("backcolor", 0, rs.oldsenthlbackcol_IE[c]);
                        if (rs.oldsenthlforecol_IE[c] !== null) {
                            rs.oldsenthlrange_IE[c].execCommand("forecolor", 0, rs.oldsenthlforecol_IE[c])
                        }
                    }
                }
                rs.oldsenthlrange_IE = [];
                rs.oldsenthlbackcol_IE = [];
                rs.oldsenthlforecol_IE = []
            }
            if (rs.state != "SETTINGS_CHANGED_PLAYING_USER_SELECTION" && rs.state != "PLAYING_USER_SELECTION") {
                rs.selectedWordsRange = []
            }
        } else {
            if (rs.state == "USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_NO_SELECTION") {
                var d = document.getElementsByTagName("RS:SPAN");
                for (c = d.length - 1; c > -1; c--) {
                    d[c].className = d[c].className.replace("sync_sent_highlighted", "");
                    d[c].className = d[c].className.replace("sync_word_highlighted", "")
                }
                var d = document.getElementsByTagName("RSI:SPAN");
                for (c = d.length - 1; c > -1; c--) {
                    d[c].className = d[c].className.replace("sync_sent_highlighted", "");
                    d[c].className = d[c].className.replace("sync_word_highlighted", "")
                }
            }
            if (rs.state == "PLAYING_USER_SELECTION" || rs.state == "SETTINGS_CHANGED_PLAYING_USER_SELECTION") {
                if (rs.oldwordhl_FF.length > 0) {
                    for (var c = 0; c < rs.oldwordhl_FF.length; c++) {
                        rs.oldwordhl_FF[c].className = rs.oldwordhlclass_FF[c]
                    }
                    rs.oldwordhlclass_FF = [];
                    rs.oldwordhl_FF = []
                }
                if (rs.oldsenthl_FF.length > 0) {
                    for (var c = 0; c < rs.oldsenthl_FF.length; c++) {
                        rs.oldsenthl_FF[c].className = rs.oldsenthlclass_FF[c]
                    }
                    rs.oldsenthl_FF = [];
                    rs.oldsenthlclass_FF = []
                }
            }
            if (rs.state == "CLOSE" || rs.state == "PLAYING_NO_SELECTION") {
                rs.cleanUpSpans()
            }
        }
        if (rs.state == "CLOSE" || rs.state == "PLAYING_NO_SELECTION" && rs.data.restorehtml != null && rs.data.readid != null) {
            var b = null;
            for (var a = 0; a < rs.data.readid.length; a++) {
                b = document.getElementById(rs.data.readid[a]);
                if (b && rs.data.restorehtml[a] !== null) {
                    b.innerHTML = rs.data.restorehtml[a]
                }
            }
        }
        if (rs.html5.inUse && rs.oldbodyclass) {
            document.body.className = rs.html5.oldbodyclass
        }
        if (rs.state == "CLOSE") {
            rs.state = "NO_ACTION";
            rs.data.restorehtml = [];
            rs.data.readid = []
        }
    },
    rshlsetContent: function(a) {
        rs.newhtml += a
    },
    rshlsetId: function(a) {
        rs.data.current.readid = a
    },
    rshlinit: function() {
        if (rs.state == "PLAYING_USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_USER_SELECTION") {
            rs.firstrun = 1;
            if (document.selection) {
                document.selection.empty()
            } else {
                rs.identifyElementsReplacementNode(document.body)
            }
            rs.newhtml = ""
        } else {
            if (rs.thesync != "none") {
                var a = null;
                if (rs.data.current.readid !== null) {
                    a = document.getElementById(rs.data.current.readid)
                }
                if (a !== null) {
                    a.innerHTML = rs.newhtml;
                    rs.newhtml = ""
                }
            } else {
                rs.newhtml = ""
            }
        }
        rs.removeiFrames()
    },
    rshlsync: function(d, f) {
        var a = false;
        if ((d & 2) == 0) {
            if ((d & 1) != 0) {
                a = true
            } else {
                a = false
            }
        }
        if (rs.state == "PLAYING_USER_SELECTION" || rs.state == "USER_SELECTION_WHILE_PLAYING_USER_SELECTION") {
            if (document.selection) {
                var e;
                e = rs.selectedWordsRange[f];
                if (rs.firstrun == 1) {
                    rs.firstrun = 0;
                    if (rs.oldsenthlrange_IE && rs.oldsenthlrange_IE.length > 0) {
                        for (var c = 0; c < rs.oldsenthlrange_IE.length; c++) {
                            if (rs.oldsenthlbackcol_IE[c] && rs.oldsenthlforecol_IE) {
                                rs.oldsenthlrange_IE[c].execCommand("backcolor", 0, rs.oldsenthlbackcol_IE[c]);
                                if (rs.oldsenthlforecol_IE[c] !== null) {
                                    rs.oldsenthlrange_IE[c].execCommand("forecolor", 0, rs.oldsenthlforecol_IE[c])
                                }
                            }
                        }
                        rs.oldsenthlrange_IE = [];
                        rs.oldsenthlbackcol_IE = [];
                        rs.oldsenthlforecol_IE = []
                    }
                    if (rs.selectedWordsRange && rs.selectedWordsRange.length > 0 && rs.thesync == "wordsent") {
                        for (var c = 0; c < rs.selectedWordsRange.length; c++) {
                            if (rs.selectedWordsRange[c]) {
                                rs.oldsenthlrange_IE.push(rs.selectedWordsRange[c]);
                                rs.oldsenthlbackcol_IE.push(rs.selectedWordsRange[c].queryCommandValue("backcolor"));
                                rs.oldsenthlforecol_IE.push(rs.selectedWordsRange[c].queryCommandValue("forecolor"));
                                if (rs.selectedWordsRange[c].text != "") {
                                    rs.selectedWordsRange[c].execCommand("backcolor", 0, rs.settings.sentColor);
                                    rs.selectedWordsRange[c].execCommand("forecolor", 0, rs.settings.textColor)
                                }
                            }
                        }
                    }
                }
                if (rs.thesync == "wordsent" || rs.thesync == "sent" || rs.thesync == "word" || rs.thesync == "") {
                    if (!a && rs.oldwordhlrange_IE.length > 0) {
                        for (var c = 0; c < rs.oldwordhlrange_IE.length; c++) {
                            if (rs.thesync == "word" || rs.thesync == "sent") {
                                rs.oldwordhlrange_IE[c].execCommand("backcolor", 0, rs.oldwordhlbackcol_IE[c])
                            } else {
                                rs.oldwordhlrange_IE[c].execCommand("backcolor", 0, rs.settings.sentColor)
                            }
                            rs.oldwordhlrange_IE[c].execCommand("forecolor", 0, rs.oldwordhlforecol_IE[c])
                        }
                        rs.oldwordhlrange_IE = [];
                        rs.oldwordhlbackcol_IE = [];
                        rs.oldwordhlforecol_IE = []
                    }
                    rs.oldwordhlbackcol_IE.push(e.queryCommandValue("backcolor"));
                    rs.oldwordhlforecol_IE.push(e.queryCommandValue("forecolor"));
                    rs.oldwordhlrange_IE.push(e);
                    if (rs.thesync == "sent") {
                        e.execCommand("backcolor", 0, rs.settings.sentColor)
                    } else {
                        e.execCommand("backcolor", 0, rs.settings.wordColor)
                    }
                    e.execCommand("forecolor", 0, rs.settings.textColor)
                }
            } else {
                var e;
                e = rs.selectedWordsRange["sync" + (f)];
                if (e.className.replace("word", "") != e.className) {
                    if (rs.oldwordhl_FF && rs.oldwordhl_FF.length > 0 && rs.oldwordhlclass_FF && rs.oldwordhlclass_FF.length > 0 && !a) {
                        for (var c = 0; c < rs.oldwordhl_FF.length; c++) {
                            rs.oldwordhl_FF[c].className = rs.oldwordhlclass_FF[c]
                        }
                        rs.oldwordhlclass_FF = [];
                        rs.oldwordhl_FF = []
                    }
                    if (rs.thesync == "wordsent" || rs.thesync == "sent" || rs.thesync == "word" || rs.thesync == "") {
                        rs.oldwordhlclass_FF.push(e.className);
                        rs.oldwordhl_FF.push(e);
                        if (rs.thesync == "sent") {
                            e.className = "sync_sent_highlighted"
                        } else {
                            e.className = "sync_word_highlighted"
                        }
                    }
                }
                if (rs.firstrun == 1) {
                    rs.firstrun = 0;
                    if (rs.oldsenthl_FF.length > 0) {
                        for (var c = 0; c < rs.oldsenthl_FF.length; c++) {
                            rs.oldsenthl_FF[c].className = rs.oldsenthlclass_FF[c]
                        }
                        rs.oldsenthl_FF = [];
                        rs.oldsenthlclass_FF = []
                    }
                    if (rs.thesync != "none" && rs.thesync != "word" && rs.thesync != "sent") {
                        var b = rs.returnClassArraySubstring("ffsent" + rs.seltexttimes + " ");
                        for (var c = 0; c < b.length; c++) {
                            rs.oldsenthl_FF[c] = b[c];
                            rs.oldsenthlclass_FF[c] = rs.oldsenthl_FF[c].className;
                            b[c].className = "sync_sent_highlighted"
                        }
                    }
                }
            }
        } else {
            if (document.selection) {
                var e;
                e = document.getElementById("sync" + (f));
                if (e && e.className.replace("word", "") != e.className) {
                    if (!a && rs.oldwordhl_IE.length > 0) {
                        for (var c = 0; c < rs.oldwordhl_IE.length; c++) {
                            rs.oldwordhl_IE[c].className = rs.oldwordhlclass_IE[c]
                        }
                        rs.oldwordhl_IE = [];
                        rs.oldwordhlclass_IE = []
                    }
                    rs.oldwordhlclass_IE.push(e.className);
                    rs.oldwordhl_IE.push(e);
                    e.className = "sync_word_highlighted"
                } else {
                    if (e && e.className.replace("sent", "") != e.className) {
                        if (!a && rs.oldsenthl_IE.length > 0) {
                            for (var c = 0; c < rs.oldsenthl_IE.length; c++) {
                                rs.oldsenthl_IE[c].className = rs.oldsenthlclass_IE[c]
                            }
                            rs.oldsenthl_IE = [];
                            rs.oldsenthlclass_IE = []
                        }
                        rs.oldsenthlclass_IE.push(e.className);
                        rs.oldsenthl_IE.push(e);
                        e.className = "sync_sent_highlighted"
                    }
                }
            } else {
                var e;
                e = document.getElementById("sync" + (f));
                if (e && e.className.replace("word", "") != e.className) {
                    if (!a && rs.oldwordhl_FF.length > 0) {
                        for (var c = 0; c < rs.oldwordhl_FF.length; c++) {
                            rs.oldwordhl_FF[c].className = rs.oldwordhlclass_FF[c]
                        }
                        rs.oldwordhl_FF = [];
                        rs.oldwordhlclass_FF = []
                    }
                    rs.oldwordhlclass_FF.push(e.className);
                    rs.oldwordhl_FF.push(e);
                    e.className = "sync_word_highlighted"
                } else {
                    if (e && e.className.replace("sent", "") != e.className) {
                        if (!a && rs.oldsenthl_FF.length > 0) {
                            for (var c = 0; c < rs.oldsenthl_FF.length; c++) {
                                rs.oldsenthl_FF[c].className = rs.oldsenthlclass_FF[c]
                            }
                            rs.oldsenthl_FF = [];
                            rs.oldsenthlclass_FF = []
                        }
                        rs.oldsenthlclass_FF.push(e.className);
                        rs.oldsenthl_FF.push(e);
                        e.className = "sync_sent_highlighted"
                    }
                }
            }
        }
    },
    selectRange: function() {
        rs.seltexttimes++;
        if (document.selection) {
            rs.selectedRange = document.selection.createRange().duplicate();
            return rs.selectRangeIE(rs.selectedRange, -1)
        } else {
            var a = "";
            var b = window.getSelection().getRangeAt(0);
            rs.start = b.startContainer;
            rs.stop = b.endContainer;
            rs.startOffset = rs.modifyOffsetStartOfWord(rs.start, b.startOffset);
            rs.endOffset = rs.modifyOffsetEndOfWord(rs.stop, b.endOffset);
            rs.bmindex++;
            rs.sentbmindex = rs.bmindex;
            rs.bmindex++;
            rs.startofsentence = 1;
            a = rs.rangeMarkupGecko(b.commonAncestorContainer);
            window.getSelection().removeAllRanges();
            return (a)
        }
    },
    selectRangeIE: function(m) {
        var o = m.duplicate();
        m.moveStart("word", -1);
        m.moveStart("word", 1);
        if (!o.isEqual(m)) {
            m.moveStart("word", -1)
        }
        o = m.duplicate();
        m.moveEnd("word", 1);
        m.moveEnd("word", -1);
        if (!o.isEqual(m)) {
            m.moveEnd("word", 1)
        }
        var l = m.duplicate();
        var p = 0;
        var s = "";
        var v = 1;
        var k = m.parentElement();
        var t = 0;
        l.collapse();
        var a = l.duplicate();
        a.collapse(false);
        var g = 0;
        while (m.inRange(l) && m.compareEndPoints("EndToEnd", l) != 0) {
            g++;
            p++;
            if (p > 10000) {
                break
            }
            l.collapse(false);
            l.expand("word", 1);
            var h = "";
            var b = "";
            var r = l.duplicate();
            r.collapse(false);
            a.collapse(false);
            if (a.compareEndPoints("StartToStart", r) == 0 && a.compareEndPoints("EndToEnd", r) == 0 && r.htmlText == a.htmlText) {
                t++;
                if (t < 2) {
                    l.move("character", 1)
                } else {
                    if (t < 4) {
                        l.move("character", 2)
                    } else {
                        if (t < 6) {
                            l.move("word", 1)
                        } else {
                            if (t < 8) {
                                l.move("word", 2)
                            } else {
                                if (t < 10) {
                                    l.move("sentence", 1)
                                } else {
                                    if (t < 12) {
                                        l.move("sentence", 2)
                                    } else {
                                        break
                                    }
                                }
                            }
                        }
                    }
                }
                l.collapse(false)
            } else {
                t = 0;
                if (g == -1) {
                    return l
                }
                rs.selectedWordsRange[g] = l.duplicate();
                var q = l.text;
                var f = l.htmlText;
                l.collapse(false);
                var e;
                if (v) {
                    lastPos = l.duplicate();
                    e = rs.iterateParentTree(lastPos.parentElement(), document.body, k, 0)
                } else {
                    e = rs.iterateParentTree(l.parentElement(), lastPos.parentElement(), k, 0)
                }
                var c = rs.iterateParentTree(lastPos.parentElement(), l.parentElement(), k, 0);
                var u = l.parentElement();
                for (var n = 0; n < e && n < 20; n++) {
                    if (!u.className.match("sync_")) {
                        h = u.outerHTML.match("<[^>]*>")[0] + h
                    }
                    u = u.parentElement
                }
                var u = lastPos.parentElement();
                for (var n = 0; n < c && n < 20; n++) {
                    if (!u.className.match("sync_")) {
                        b += "</" + u.tagName + ">"
                    }
                    u = u.parentElement
                }
                if (e != 0 || c != 0) {
                    lastPos = l.duplicate()
                }
                if (v) {
                    s += h;
                    v = 0
                } else {
                    s += b + h
                }
                if (f.replace("sync_sent_highlighted", "") != "") {
                    s += "<rs:span class='sync_user' id='sync" + g + "'>" + q + "</rs:span>"
                }
                a = l.duplicate()
            }
        }
        s += "<!-- f -->";
        var c = rs.iterateParentTree(lastPos.parentElement(), document.body, k, 0);
        var u = lastPos.parentElement();
        for (var n = 0; n < c; n++) {
            if (!u.className.match("sync_")) {
                s += "</" + u.tagName + ">"
            }
            u = u.parentElement
        }
        l.collapse();
        return (s)
    },
    iterateParentTree: function(b, d, f, a) {
        var e = d;
        while (e !== null) {
            if (b == f) {
                return a
            } else {
                if (b == e) {
                    return a
                }
            }
            e = e.parentElement
        }
        a++;
        return rs.iterateParentTree(b.parentElement, d, f, a)
    },
    rangeMarkupGecko: function(d) {
        rs.firstrun = 1;
        var f = "";
        var c = rs.inc;
        if (d.nodeType == 3) {
            f += rs.markup(d)
        } else {
            var b;
            var a = "";
            if (d.hasChildNodes()) {
                for (b = 0; b < d.childNodes.length; b++) {
                    var g = d.childNodes.item(b);
                    if (g == rs.start) {
                        rs.inc = 1
                    }
                    if (d == rs.start && b == rs.startOffset) {
                        rs.inc = 1
                    }
                    if (g.nodeType != 8) {
                        a += rs.rangeMarkupGecko(g)
                    }
                    if (d == rs.stop && b == rs.endOffset) {
                        rs.inc = 0;
                        break
                    }
                    if (g == rs.stop) {
                        rs.inc = 0;
                        break
                    }
                }
            }
            if ((c || rs.inc) && (!d.className || (d.className.replace("sync") == d.className && d.id.replace("sync") == d.id))) {
                var e = document.createElement("div");
                e.appendChild(d.cloneNode(true));
                tempdivtag = e.innerHTML.match("<[^>]*>");
                if (tempdivtag !== null && tempdivtag.length > 0) {
                    f += tempdivtag[0];
                    f += a;
                    f += "</" + d.nodeName + ">"
                } else {
                    f += a
                }
            } else {
                f += a
            }
            if (d.hasChildNodes()) {
                for (b = 0; b < d.childNodes.length; b++) {
                    if (d == rs.stop && b == rs.endOffset) {
                        rs.inc = 0;
                        break
                    }
                    if (g == rs.stop) {
                        rs.inc = 0;
                        break
                    }
                }
            }
        }
        return f.replace(/rsi:span/g, "rs:span")
    },
    markup: function(e) {
        var b = true;
        var g = "";
        var c;
        var f = "";
        var h = "";
        var a = e.nodeValue;
        if ((e == rs.start && rs.startOffset != -1) && (e == rs.stop && rs.endOffset != -1)) {
            f = e.nodeValue.substring(0, rs.startOffset);
            a = e.nodeValue.substring(rs.startOffset, rs.endOffset);
            h = e.nodeValue.substring(rs.endOffset);
            rs.inc = 1
        } else {
            if (e == rs.start && rs.startOffset != -1) {
                f = e.nodeValue.substring(0, rs.startOffset);
                a = e.nodeValue.substring(rs.startOffset);
                rs.inc = 1
            } else {
                if (e == rs.stop && rs.endOffset != -1) {
                    a = e.nodeValue.substring(0, rs.endOffset);
                    h = e.nodeValue.substring(rs.endOffset);
                    rs.inc = 1
                }
            }
        }
        if (!rs.inc) {
            return ""
        }
        for (var c = 0; c < rs.exludednodes.length; c++) {
            if (e.parentNode && e.parentNode.nodeName.toLowerCase() == rs.exludednodes[c]) {
                b = false;
                g = rs.htmlencode(a);
                break
            }
        }
        if (b) {
            g = rs.markupSentences(rs.htmlencode(a), null)
        }
        if (e == rs.stop && rs.endOffset != -1) {
            rs.inc = 0
        }
        if (b && e.parentNode !== null && a != "") {
            var d = rs.createreplacementnode(f + g + h, getComputedStyle(e.parentNode, null));
            e.parentNode.insertBefore(d, e);
            e.parentNode.removeChild(e)
        }
        return g
    },
    markupSentences: function(c) {
        var a = rs.splitString(c, new Array(", ", ". ", "! ", "? ", decodeURIComponent("%e3%80%81"), decodeURIComponent("%e3%80%82")));
        if (!a) {
            return ""
        }
        var d = "";
        var e = [];
        for (var b = 0; b < a.length; b++) {
            d += "<rsi:span class=' ffsent" + rs.seltexttimes + " cj" + rs.seltexttimes + "' ";
            d += "id='sync" + (rs.sentbmindex) + "'";
            rs.startofsentence = 0;
            d += ">";
            d += rs.markupWords(a[b]);
            d += "</rsi:span>"
        }
        return d
    },
    markupWords: function(c) {
        var d = rs.splitString(c, " ");
        if (!d) {
            return ""
        }
        var b = "";
        var e = [];
        for (var a = 0; a < d.length; a++) {
            b += "<rsi:span class='sync_user word ck" + rs.seltexttimes + "'";
            b += " id='sync" + (rs.bmindex++) + "'";
            b += ">";
            b += (d[a]);
            b += "</rsi:span>"
        }
        return b
    },
    trim: function(a) {
        return a.replace(/^\s+|\s+$/g, "")
    },
    htmlencode: function(b) {
        var c = document.createElement("div");
        var a = document.createTextNode(b);
        c.appendChild(a);
        return c.innerHTML
    },
    identifyElementsReplacementNode: function(b) {
        if (b.tagName && b.tagName == "RSI:SPAN" && b.id) {
            rs.selectedWordsRange[b.id] = b
        }
        if (b.hasChildNodes()) {
            for (var a = 0; a < b.childNodes.length; a++) {
                var c = b.childNodes.item(a);
                rs.identifyElementsReplacementNode(c)
            }
        }
    },
    createreplacementnode: function(c, a) {
        var b = document.createElement("rsi:span");
        b.innerHTML = c;
        b.setAttribute("class", "synctemp cl" + rs.seltexttimes);
        return b
    },
    modifyOffsetStartOfWord: function(b, d) {
        var c = new Array(" ", ", ", ". ", "! ", "? ", decodeURIComponent("%e3%80%81"), decodeURIComponent("%e3%80%82"));
        while (b.nodeValue && d != 0) {
            for (var a = 0; a < c.length; a++) {
                breakstr = c[a];
                if (b.nodeValue.substring(d - 1).indexOf(breakstr) == 0) {
                    return d
                }
            }
            d--
        }
        return d
    },
    modifyOffsetEndOfWord: function(b, d) {
        var c = new Array(" ", ", ", ". ", "! ", "? ", decodeURIComponent("%e3%80%81"), decodeURIComponent("%e3%80%82"));
        while (b.nodeValue && d != b.nodeValue.length) {
            for (var a = 0; a < c.length; a++) {
                breakstr = c[a];
                if (b.nodeValue.substring(d - 1).indexOf(breakstr) == 0) {
                    return d
                }
            }
            d++
        }
        return d
    },
    returnClassArraySubstring: function(b) {
        var c = document.getElementsByTagName("*");
        var d = 0;
        var a = [];
        for (i = 0; i < c.length; i++) {
            if (c[i].className.replace(b, "") != c[i].className) {
                a[d] = c[i];
                d++
            }
        }
        return a
    },
    cleanUpSpans: function() {
        var b = document.getElementsByTagName("RSI:SPAN");
        var a;
        for (i = b.length - 1; i > -1; i--) {
            a = document.createDocumentFragment();
            for (j = 0; j < b[i].childNodes.length; j++) {
                a.appendChild(b[i].childNodes[j].cloneNode(true))
            }
            b[i].parentNode.replaceChild(a, b[i])
        }
    },
    splitString: function(h, c) {
        var m = new Array("");
        var e = 0;
        for (var f = 0; f < h.length; f++) {
            for (var d = 0; d < c.length; d++) {
                var g = c[d];
                var a = true;
                for (var b = 0; b < g.length; b++) {
                    if (h.length - (f + b) < 0 || g[g.length - b - 1] != h[f - b - 1]) {
                        a = false;
                        break
                    }
                }
                if (a) {
                    e++;
                    m[e] = ""
                }
            }
            m[e] += h[f]
        }
        return m
    },
    popup: {
        buttonExists: null,
        mouse_y_startpos: null,
        mouse_x_pos: null,
        mouse_y_pos: null,
        player_x_pos: null,
        player_y_pos: null,
        time: null,
        viewportwidth: null,
        viewportheight: null,
        button: function() {
            if (rs.popup.mouse_x_pos && rs.popup.mouse_y_pos && rs.selectedString.length > 0) {
                if (!document.getElementById("rs_selimg")) {
                    var h = null;
                    var o = document.getElementsByTagName("A");
                    var b = [];
                    for (var f = 0; f < o.length; f++) {
                        b[f] = o[f]
                    }
                    for (var e = 0; e < b.length; e++) {
                        if (b[e].getAttribute("href") && b[e].getAttribute("href").indexOf(rs.settings.appserverhost + "/cgi-bin/" + rs.settings.rsent) != -1 && b[e].id != "rsSaveBtn") {
                            rs.popup.buttonExists = true;
                            if (!rs.usersicon && b[e].getElementsByTagName("img").length > 0) {
                                h = b[e].getElementsByTagName("img")[0].src
                            }
                            for (var g = 0; g < b[e].attributes.length; g++) {
                                if (b[e].attributes[g].nodeName.toLowerCase() == "href") {
                                    var a = b[e].attributes[g].nodeValue
                                } else {
                                    if (b[e].attributes[g].nodeName.toLowerCase() == "onclick") {
                                        var n = b[e].attributes[g].nodeValue
                                    }
                                }
                            }
                            break
                        }
                    }
                    if (rs.popup.buttonExists) {
                        var l = document.createElement("img");
                        if (rs.settings.useReadspeakerIcon || !h) {
                            h = rs.settings.protocol + "//media.readspeaker.com/images/buttons/listen_icons/icon_16px.gif"
                        }
                        l.setAttribute("src", h);
                        l.style.border = "none";
                        l.setAttribute("alt", rs.phrases.listentoselectedtext);
                        l.setAttribute("title", rs.phrases.listentoselectedtext);
                        var m = document.createElement("a");
                        m.setAttribute("id", "rs_selimg");
                        m.setAttribute("href", a);
                        if (rs.settings.usePopupPlayer) {
                            n = "readpage(this.href,'rs_popup_player'); return false;"
                        }
                        if (n == "") {
                            n = "readpage(this.href,'xp1'); return false;"
                        }
                        m.setAttribute("onclick", "clearTimeout(rs.popup.time);rs.popup.setVisibility();" + n);
                        m.setAttribute("onmouseover", "clearTimeout(rs.popup.time);");
                        m.setAttribute("onmouseout", "rs.popup.hideIcon();");
                        m.onclick = new Function("clearTimeout(rs.popup.time);rs.popup.setVisibility();" + n);
                        m.onmouseover = new Function("clearTimeout(rs.popup.time);");
                        m.onmouseout = new Function("rs.popup.hideIcon();");
                        m.appendChild(l);
                        var c = document.createDocumentFragment();
                        c.appendChild(m);
                        document.body.appendChild(c)
                    }
                }
                if (rs.popup.buttonExists) {
                    var p = document.getElementById("rs_selimg");
                    p.style.top = rs.popup.mouse_y_pos + "px";
                    p.style.left = rs.popup.mouse_x_pos + "px";
                    rs.popup.player_y_pos = rs.popup.mouse_y_pos + "px";
                    rs.popup.player_x_pos = rs.popup.mouse_x_pos + "px";
                    var d = rs.loadSettings("ReadSpeakerHLicon");
                    if (d == "") {
                        if (rs.settings.usePopupButton) {
                            d = "iconon"
                        } else {
                            d = "iconoff"
                        }
                    }
                    if (d == "iconoff") {
                        p.style.display = "none"
                    } else {
                        p.style.display = "inline"
                    }
                    rs.popup.hideIcon()
                }
            }
        },
        player: function(b) {
            var f = encodeURIComponent(rs.issuePOST(b + "&audioformat=flv&sync=user&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version + "&syncalignuser=" + rs.thesync, rs.selhtml));
            var d = rs.issuePOST(b + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version, rs.selhtml);
            var e = document.getElementById(rs.data.current.playerid);
            if (!e) {
                var h = document.createElement("div");
                h.setAttribute("id", "rs_popup_player");
                var c = document.createDocumentFragment();
                c.appendChild(h);
                document.body.appendChild(c);
                e = document.getElementById(rs.data.current.playerid)
            }
            e.style.top = rs.popup.player_y_pos;
            e.style.left = rs.popup.player_x_pos;
            var g = "<div style='height: 15px;'><span style='position: absolute; top: 0px; left: 0px;'><object type='application/x-shockwave-flash' data='" + rs.settings.flashLink + "?flv=" + f + rs.settings.flashParams + "&rplayer=mini&text_play=" + rs.phrases.play + "&text_pause=" + rs.phrases.pause + "&text_stop=" + rs.phrases.stop + "&text_vol=" + rs.phrases.volume + "' style='height:20px; width:60px;'>";
            g += "<param name='movie' value='" + rs.settings.flashLink + "?flv=" + f + rs.settings.flashParams + "&rplayer=mini&text_play=" + rs.phrases.play + "&text_pause=" + rs.phrases.pause + "&text_stop=" + rs.phrases.stop + "&text_vol=" + rs.phrases.volume + "'>";
            g += "<param name='quality' value='high'><param name='autostart' value='true'>";
            g += "<param name='allowScriptAccess' value='" + rs.settings.allowScriptAccess + "'><param name='bgcolor' value='#323232'>";
            g += "<param name='loop' value='false'><a id='rsSaveBtn' href='" + d + "' target='rs'>" + rs.phrases.nosound + "</a></object></span>";
            g += "<span style='position: absolute; top: 4px; right: 4px;'><a href='JavaScript:void(0);' onclick='rs.closepage(\"" + rs.data.current.playerid + "\");return false'><img style='border-style: none !important; margin: 0px !important;' src='" + rs.settings.protocol + "//media.readspeaker.com/images/enterprise/default/close.png' title='" + rs.phrases.closeplayer + "' alt='" + rs.phrases.closeplayer + "'></a></span></div>";
            g += "<span id='rs_popup_link' style='position: absolute; top: 4px; right: 21px;'><a href='JavaScript:void(0);' onclick='rs.showcontrols(\"" + b + '","' + rs.data.current.playerid + "\");return false'><img style='width: 13px; height: 13px; border-style: none !important;' src='" + rs.settings.protocol + "//media.readspeaker.com/images/enterprise/default/wrench.png' alt='" + rs.phrases.settings + "' title='" + rs.phrases.settings + "'></a></span>";
            g += "<div id='controls'></div>";
            var a = document.getElementById(rs.data.current.playerid);
            if (a) {
                a.innerHTML = g;
                a.style.display = "block"
            }
        },
        hideIcon: function() {
            if (rs.popup.time) {
                clearTimeout(rs.popup.time)
            }
            rs.popup.time = setTimeout("rs.popup.setVisibility()", 2500)
        },
        setVisibility: function() {
            if (document.getElementById("rs_selimg")) {
                document.getElementById("rs_selimg").style.display = "none"
            }
        },
        mousePress: function(a) {
            if (!a) {
                var a = window.event
            }
            a.cancelBubble = true;
            if (a.stopPropagation) {
                a.stopPropagation()
            }
            if (a.pageX || a.pageY) {
                rs.popup.mouse_y_startpos = a.pageY
            } else {
                if (a.clientX || a.clientY) {
                    rs.popup.mouse_y_startpos = a.clientY + document.body.scrollTop + document.documentElement.scrollTop
                }
            }
            return true
        },
        mouseRel: function(a) {
            if (!a) {
                var a = window.event
            }
            a.cancelBubble = true;
            if (a.stopPropagation) {
                a.stopPropagation()
            }
            var b = null;
            var c = null;
            rs.popup.getViewportSize();
            if (a.pageX || a.pageY) {
                b = a.pageY;
                c = a.pageX
            } else {
                if (a.clientX || a.clientY) {
                    b = a.clientY + document.body.scrollTop + document.documentElement.scrollTop;
                    c = a.clientX + document.body.scrollLeft + document.documentElement.scrollLeft
                }
            }
            if (b > rs.popup.mouse_y_startpos) {
                if ((b + 20) > (rs.popup.viewportheight - 30)) {
                    rs.popup.mouse_y_pos = b - 40
                } else {
                    rs.popup.mouse_y_pos = b + 20
                }
            } else {
                if ((b - 40) < 10) {
                    rs.popup.mouse_y_pos = b + 20
                } else {
                    rs.popup.mouse_y_pos = b - 40
                }
            }
            if (c < 5) {
                rs.popup.mouse_x_pos = c + 30
            } else {
                if (c > rs.popup.viewportwidth - 80) {
                    rs.popup.mouse_x_pos = c - 80
                } else {
                    rs.popup.mouse_x_pos = c + 15
                }
            }
            return true
        },
        getViewportSize: function() {
            if (typeof window.innerWidth != "undefined") {
                rs.popup.viewportwidth = window.innerWidth + document.body.scrollLeft + document.documentElement.scrollLeft;
                rs.popup.viewportheight = window.innerHeight + document.body.scrollTop + document.documentElement.scrollTop
            } else {
                if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
                    rs.popup.viewportwidth = document.documentElement.clientWidth + document.body.scrollLeft + document.documentElement.scrollLeft;
                    rs.popup.viewportheight = document.documentElement.clientHeight + document.body.scrollTop + document.documentElement.scrollTop
                } else {
                    rs.popup.viewportwidth = document.getElementsByTagName("body")[0].clientWidth + document.body.scrollLeft + document.documentElement.scrollLeft;
                    rs.popup.viewportheight = document.getElementsByTagName("body")[0].clientHeight + document.body.scrollTop + document.documentElement.scrollTop
                }
            }
        }
    },
    base64: {
        encode: function(f) {
            newdata = encodeURIComponent(f);
            var g = 0;
            var e = 0;
            var b = [];
            for (; g < newdata.length; g++) {
                if (newdata.charCodeAt(g) != "%".charCodeAt(0)) {
                    b[e] = newdata.charCodeAt(g)
                } else {
                    b[e] = parseInt("0x" + newdata.charAt(g + 1) + "" + newdata.charAt(g + 2));
                    g = g + 2
                }
                e++
            }
            var l = b.length;
            var c = 4 * parseInt((l + 2) / 3);
            var h = new String();
            var k = parseInt(l / 3);
            var a;
            var d = l - 3 * k;
            g = 0;
            for (; g < 3 * k; g += 3) {
                a = rs.base64.chars(b[g] >> 2);
                h += a;
                a = rs.base64.chars(((b[g] & 3) << 4) | (b[g + 1] >> 4));
                h += a;
                a = rs.base64.chars(((b[g + 1] & 15) << 2) | (b[g + 2] >> 6));
                h += a;
                a = rs.base64.chars(b[g + 2] & 63);
                h += a
            }
            if (d == 1) {
                h += rs.base64.chars(b[g] >> 2);
                h += rs.base64.chars((b[g] & 3) << 4);
                h += "=";
                h += "="
            }
            if (d == 2) {
                h += rs.base64.chars(b[g] >> 2);
                h += rs.base64.chars(((b[g] & 3) << 4) | (b[g + 1] >> 4));
                h += rs.base64.chars((b[g + 1] & 15) << 2);
                h += "="
            }
            return h
        },
        decode: function(f) {
            var h = "";
            var d = "";
            var g = 0;
            var c = 0;
            var e = "";
            var b = f.length;
            while (g < b) {
                if (rs.base64.value(f[g]) != -1) {
                    e = f.substring(g, g + 4);
                    c = 0;
                    for (i = 0; i < 4; i++) {
                        if (e[i] == "=") {
                            c++
                        }
                    }
                    for (i = 0; i < 3 - c; i++) {
                        if (i == 0) {
                            d = (rs.base64.value(e[0]) << 2) | ((rs.base64.value(e[1]) & 48) >> 4)
                        } else {
                            if (i == 1) {
                                d = ((rs.base64.value(e[1]) & 15) << 4) | ((rs.base64.value(e[2]) & 60) >> 2)
                            } else {
                                if (i == 2) {
                                    d = ((rs.base64.value(e[2]) & 3) << 6) | rs.base64.value(e[3])
                                }
                            }
                        }
                        var a = d.toString(16);
                        if (a.length == 1) {
                            a = "0" + a
                        }
                        h += "%" + a
                    }
                    g += 4
                } else {
                    g++
                }
            }
            return decodeURIComponent(h)
        },
        value: function(a) {
            var b = a.charCodeAt(0);
            if (b >= "A".charCodeAt(0) && b <= "Z".charCodeAt(0)) {
                return b - "A".charCodeAt(0)
            } else {
                if (b >= "a".charCodeAt(0) && b <= "z".charCodeAt(0)) {
                    return b - "a".charCodeAt(0) + 26
                } else {
                    if (b >= "0".charCodeAt(0) && b <= "9".charCodeAt(0)) {
                        return b - "0".charCodeAt(0) + 52
                    } else {
                        if (b == "+".charCodeAt(0)) {
                            return 62
                        } else {
                            if (b == "/".charCodeAt(0)) {
                                return 63
                            } else {
                                return - 1
                            }
                        }
                    }
                }
            }
        },
        chars: function(a) {
            if (a < 26) {
                return String.fromCharCode(a + "A".charCodeAt(0))
            } else {
                if (a < 52) {
                    return String.fromCharCode(a + "a".charCodeAt(0) - 26)
                } else {
                    if (a < 62) {
                        return String.fromCharCode(a + "0".charCodeAt(0) - 52)
                    } else {
                        if (a == 62) {
                            return "+"
                        } else {
                            if (a == 63) {
                                return "/"
                            } else {
                                return String.fromCharCode(0)
                            }
                        }
                    }
                }
            }
        }
    },
    html5: {
        STATE_BEGIN: 0,
        STATE_USER_START_NOT_READY: 1,
        STATE_USER_START_PLAYING: 2,
        state: 0,
        inUse: false,
        audioelement: null,
        lastcurrenttime: -1,
        currentsyncindex: 0,
        oldbodyclass: null,
        lastevent: null,
        lastlastevent: null,
        lastlastlastevent: null,
        synclist: new Array(),
        synclistindex: 0,
        url: null,
        iframeurl: null,
        player: function(b) {
            var d = Math.random();
            if (rs.settings.usePost) {
                rs.html5.url = rs.issuePOST(b + "&requestgrouptype=html5iframe&sync=" + rs.thesync + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version + "&audioformat=mp3&requestgroup=" + d, "<div id='" + rs.data.current.readid + "'>" + rs.data.current.restorehtml + "</div>");
                rs.html5.iframeurl = rs.issuePOST(b + "&requestgrouptype=html5iframe&sync=" + rs.thesync + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version + "&audioformat=html5iframe&requestgroupid=" + d, "<div id='" + rs.data.current.readid + "'>" + rs.data.current.restorehtml + "</div>");
                var c = rs.issuePOST(b + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version, "<div id='" + rs.data.current.readid + "'>" + rs.data.current.restorehtml + "</div>")
            } else {
                rs.html5.url = b + "&requestgrouptype=html5iframe&sync=" + rs.thesync + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version + "&audioformat=mp3&requestgroup=" + d;
                rs.html5.iframeurl = b + "&requestgrouptype=html5iframe&sync=" + rs.thesync + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version + "&audioformat=html5iframe&requestgroupid=" + d;
                var c = b + "&speed=" + rs.thespeed + "&rsjs_ver=" + rs.settings.version
            }
            rs.html5.oldbodyclass = document.body.className;
            document.body.className += " rs_iphone";
            var e = "<div id='rs_playerarea' style='width:250px; height: 25px;'><div style='margin-bottom: 2px; width: 100%; height: 25px;'>";
            e += "<div style='position: absolute; top: 4px; left: 4px;'><a id='rs_playbtn' href='JavaScript:void(0);'><img id='rs_playimg' style='border-style: none !important; margin: 0px !important; padding:0px !important;' src='http://media.readspeaker.com/images/enterprise/default/play2.png' title='" + rs.phrases.play + "' alt='" + rs.phrases.play + "'></a></div>";
            e += "<div style='position: absolute; top: 4px; left: 21px;'><a id='rs_pausebtn' href='JavaScript:void(0);'><img id='rs_pauseimg' style='border-style: none !important; margin: 0px !important; padding:0px !important;' src='http://media.readspeaker.com/images/enterprise/default/pause.png' title='" + rs.phrases.pause + "' alt='" + rs.phrases.pause + "'></a></div>";
            e += "<div style='position: absolute; top: 4px; left: 38px;'><a id='rs_stopbtn' href='JavaScript:void(0);'><img id='rs_stopimg' style='border-style: none !important; margin: 0px !important; padding:0px !important;' src='http://media.readspeaker.com/images/enterprise/default/stop.png' title='" + rs.phrases.stop + "' alt='" + rs.phrases.stop + "'></a></div>";
            e += "<div id='timeline'><div id='duration'></div><span id='durationtxt'></span></div>";
            e += "<div style='position: absolute; top: 2px; left: 231px;'><a href='http://www.readspeaker.com'><img style='border-style: none !important; margin: 0px !important; padding:0px !important;' src='http://media.readspeaker.com/images/buttons/listen_icons/icon_16px.gif' title='Go to the ReadSpeaker website' alt='Go to the ReadSpeaker website' /></a></div>";
            e += "<span style='position: absolute; top: 4px; right: 4px;'><a style='border-style: none;' href='JavaScript:void(0);' onclick='rs.html5.stop();rs.closepage(\"" + rs.data.current.playerid + "\");return false'><img style='border-style: none !important; margin: 0px !important;' id='closebr' src='http://media.readspeaker.com/images/enterprise/default/close.png' alt='" + rs.phrases.closeplayer + "' title='" + rs.phrases.closeplayer + "'></a></span></div>";
            e += "<div id='bottomlinks'><a href='JavaScript:void(0);' class='rs_settings' onclick='rs.showcontrols(\"" + b + '","' + rs.data.current.playerid + "\");return false'>" + rs.phrases.settings + "</a> | <a id='rsSaveBtn' href='" + c + "' target='rs'>" + rs.phrases.nosound + "</a> | " + rs.phrases.speechenabled + "</div>";
            e += "<div id='controls'></div>";
            e += "</div>";
            var a = document.getElementById(rs.data.current.playerid);
            if (a) {
                a.innerHTML = e;
                a.style.display = "block"
            }
            rs.html5.start()
        },
        start: function() {
            rs.html5.stop();
            var a = null;
            rs.html5.audioelement = new Audio(rs.html5.url);
            rs.html5.audioelement.setAttribute("controls", "controls");
            rs.html5.audioelement.loop = false;
            rs.html5.audioelement.play();
            rs.html5.audioelement.addEventListener("ended", rs.html5.controls.stop, false);
            rs.html5.audioelement.addEventListener("timeupdate", rs.html5.controls.timer, false);
            var d = document.getElementById("rs_playbtn");
            d.addEventListener("click", rs.html5.controls.play, false);
            var c = document.getElementById("rs_pausebtn");
            c.addEventListener("click", rs.html5.controls.pause, false);
            var b = document.getElementById("rs_stopbtn");
            b.addEventListener("click", rs.html5.controls.stop, false);
            if (rs.thesync != "none") {
                if (!document.getElementById("synciframe")) {
                    a = document.createElement("iframe");
                    a.setAttribute("id", "synciframe")
                } else {
                    a = document.getElementById("synciframe")
                }
                a.src = rs.html5.iframeurl;
                a.type = "text/javascript";
                a.height = 0;
                a.width = 0;
                a.style.display = "none";
                document.body.appendChild(a);
                rs.html5.refresh()
            } else {
                rs.html5.state = rs.html5.STATE_USER_START_PLAYING
            }
        },
        controls: {
            play: function() {
                if (rs.html5.audioelement) {
                    rs.html5.audioelement.play()
                } else {
                    rs.html5.start(rs.html5.url)
                }
                if (document.getElementById("rs_playimg")) {
                    document.getElementById("rs_playimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/play2.png")
                }
                if (document.getElementById("rs_pauseimg")) {
                    document.getElementById("rs_pauseimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/pause.png")
                }
                if (document.getElementById("rs_stopimg")) {
                    document.getElementById("rs_stopimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/stop.png")
                }
            },
            pause: function() {
                setTimeout("rs.html5.audioelement.pause()", 200);
                if (document.getElementById("rs_pauseimg")) {
                    document.getElementById("rs_pauseimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/pause2.png")
                }
                if (document.getElementById("rs_playimg")) {
                    document.getElementById("rs_playimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/play.png")
                }
            },
            stop: function() {
                if (rs.html5.audioelement) {
                    rs.html5.audioelement.removeEventListener("timeupdate", rs.html5.controls.timer, false)
                }
                rs.html5.stop();
                rs.rshlexit();
                if (document.getElementById("rs_stopimg")) {
                    document.getElementById("rs_stopimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/stop2.png")
                }
                if (document.getElementById("rs_playimg")) {
                    document.getElementById("rs_playimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/play.png")
                }
                if (document.getElementById("rs_pauseimg")) {
                    document.getElementById("rs_pauseimg").setAttribute("src", "http://media.readspeaker.com/images/enterprise/default/pause2.png")
                }
                var b = document.getElementById("duration");
                b.style.width = "0%";
                var a = document.getElementById("durationtxt");
                a.innerHTML = "00:00 | 00:00"
            },
            timer: function() {
                if (rs.html5.audioelement) {
                    var d = document.getElementById("duration");
                    var l = document.getElementById("durationtxt");
                    var b = rs.html5.audioelement.duration;
                    var f = rs.html5.audioelement.currentTime;
                    d.style.width = f / b * 100 + "%";
                    if (!b) {
                        var g = "00";
                        var k = "00";
                        var a = ""
                    } else {
                        var g = parseInt(b % 60) + "";
                        var k = parseInt((b / 60) % 60) + "";
                        var a = parseInt(((b / 60) / 60) % 60) + ""
                    }
                    var n = parseInt(rs.html5.audioelement.currentTime % 60) + "";
                    var c = parseInt((rs.html5.audioelement.currentTime / 60) % 60) + "";
                    var e = parseInt(((rs.html5.audioelement.currentTime / 60) / 60) % 60) + "";
                    if (a != 0) {
                        if (a.length < 2) {
                            a = 0 + a + ":"
                        }
                        if (e.length < 2) {
                            e = 0 + e + ":"
                        }
                    } else {
                        a = "";
                        e = ""
                    }
                    if (k.length < 2) {
                        k = 0 + k
                    }
                    if (g.length < 2) {
                        g = 0 + g
                    }
                    if (c.length < 2) {
                        c = 0 + c
                    }
                    if (n.length < 2) {
                        n = 0 + n
                    }
                    if (b) {
                        l.innerHTML = e + c + ":" + n + " | " + a + k + ":" + g
                    } else {
                        l.innerHTML = "00:00 | 00:00"
                    }
                }
            }
        },
        stop: function() {
            if (rs.html5.state != rs.html5.STATE_BEGIN) {
                if (rs.html5.audioelement) {
                    rs.html5.audioelement.pause()
                }
                rs.html5.audioelement = null;
                var a = document.getElementById("synciframe");
                if (a) {
                    a.src = "about:blank"
                }
            }
            rs.html5.state = rs.html5.STATE_BEGIN;
            rs.html5.lastcurrenttime = -1;
            rs.html5.currentsyncindex = 0;
            rs.html5.synclistindex = 0;
            rs.html5.synclist = []
        },
        receiveMessage: function(a) {
            if (!a.origin.match(/readspeaker.com/gi)) {
                return
            }
            if (rs.html5.lastevent != null && a.data == "rshlsetContent") {
                rshlsetContent(rs.base64.decode(rs.html5.lastevent.data))
            } else {
                if (rs.html5.lastevent != null && a.data == "rshlsetId") {
                    rshlsetId(rs.html5.lastevent.data)
                } else {
                    if (a.data == "rshlinit") {
                        rshlinit()
                    } else {
                        if (rs.html5.lastlastlastevent != null && rs.html5.lastlastevent != null && rs.html5.lastevent != null && a.data == "rshlsync") {
                            rs.html5.synclist[rs.html5.synclistindex] = [rs.html5.lastlastlastevent.data, rs.html5.lastlastevent.data, rs.html5.lastevent.data];
                            rs.html5.synclistindex++
                        }
                    }
                }
            }
            rs.html5.lastlastlastevent = rs.html5.lastlastevent;
            rs.html5.lastlastevent = rs.html5.lastevent;
            rs.html5.lastevent = a
        },
        refresh: function() {
            if (!rs.html5.audioelement) {
                return
            }
            if (rs.html5.lastcurrenttime > rs.html5.audioelement.currentTime) {
                rs.html5.controls.stop();
                return
            }
            rs.html5.lastcurrenttime = rs.html5.audioelement.currentTime;
            if (rs.html5.state == rs.html5.STATE_BEGIN) {
                rs.html5.audioelement.pause();
                rs.html5.state = rs.html5.STATE_USER_START_NOT_READY;
                setTimeout("rs.html5.refresh()", 0)
            } else {
                if (rs.html5.state == rs.html5.STATE_USER_START_NOT_READY) {
                    if (rs.html5.synclist[rs.html5.currentsyncindex] && rs.html5.audioelement.buffered && rs.html5.audioelement.buffered.length > 0 && rs.html5.synclist[rs.html5.currentsyncindex][0] < rs.html5.audioelement.buffered.end(0) * 1000) {
                        rs.html5.state = rs.html5.STATE_USER_START_PLAYING;
                        rs.html5.audioelement.play();
                        setTimeout("rs.html5.refresh()", 0)
                    } else {
                        if (rs.html5.synclist[rs.html5.currentsyncindex]) {
                            if (rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - rs.html5.audioelement.currentTime * 1000 <= 20) {
                                setTimeout("rs.html5.refresh()", 0)
                            } else {
                                var a = rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - rs.html5.audioelement.currentTime * 1000 - 20;
                                if (a > 75) {
                                    setTimeout("rs.html5.refresh()", 75)
                                } else {
                                    if (a < 0) {
                                        setTimeout("rs.html5.refresh()", 0)
                                    } else {
                                        setTimeout("rs.html5.refresh()", a)
                                    }
                                }
                            }
                        } else {
                            setTimeout("rs.html5.refresh()", 75)
                        }
                    }
                } else {
                    if (rs.html5.state == rs.html5.STATE_USER_START_PLAYING) {
                        if (rs.html5.synclist[rs.html5.currentsyncindex] && rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - 20 < rs.html5.audioelement.currentTime * 1000) {
                            rshlsync(rs.html5.synclist[rs.html5.currentsyncindex][1], rs.html5.synclist[rs.html5.currentsyncindex][2]);
                            rs.html5.currentsyncindex++;
                            if (rs.html5.synclist[rs.html5.currentsyncindex]) {
                                if (rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - rs.html5.audioelement.currentTime * 1000 <= 20) {
                                    setTimeout("rs.html5.refresh()", 0)
                                } else {
                                    var a = rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - rs.html5.audioelement.currentTime * 1000 - 20;
                                    if (a > 75) {
                                        setTimeout("rs.html5.refresh()", 75)
                                    } else {
                                        if (a < 0) {
                                            setTimeout("rs.html5.refresh()", 0)
                                        } else {
                                            setTimeout("rs.html5.refresh()", a)
                                        }
                                    }
                                }
                            } else {
                                setTimeout("rs.html5.refresh()", 75)
                            }
                        } else {
                            if (rs.html5.synclist[rs.html5.currentsyncindex]) {
                                if (rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - rs.html5.audioelement.currentTime * 1000 <= 20) {
                                    setTimeout("rs.html5.refresh()", 0)
                                } else {
                                    var a = rs.html5.synclist[rs.html5.currentsyncindex][0] * 1 - rs.html5.audioelement.currentTime * 1000 - 20;
                                    if (a > 75) {
                                        setTimeout("rs.html5.refresh()", 75)
                                    } else {
                                        if (a < 0) {
                                            setTimeout("rs.html5.refresh()", 0)
                                        } else {
                                            setTimeout("rs.html5.refresh()", a)
                                        }
                                    }
                                }
                            } else {
                                setTimeout("rs.html5.refresh()", 75)
                            }
                        }
                    }
                }
            }
        }
    }
};
if (document.addEventListener) {
    document.addEventListener("mousedown", rs.popup.mousePress, false);
    document.addEventListener("keydown", rs.popup.mousePress, false);
    document.addEventListener("mouseup", rs.copyselected, false);
    document.addEventListener("keyup", rs.copyselected, false);
    window.addEventListener("message", rs.html5.receiveMessage, false, true)
} else {
    if (document.attachEvent) {
        document.attachEvent("onmousedown", rs.popup.mousePress);
        document.attachEvent("onkeydown", rs.popup.mousePress);
        document.attachEvent("onmouseup", rs.copyselected);
        document.attachEvent("onkeyup", rs.copyselected)
    } else {
        document.onmousedown = rs.popup.mousePress;
        document.onkeydown = rs.popup.mousePress;
        document.onmouseup = rs.copyselected;
        document.onkeyup = rs.copyselected
    }
}
function readpage(a, b) {
    rs.readpage(a, b)
}
function rshlsetContent(a) {
    rs.rshlsetContent(a)
}
function rshlsetId(a) {
    rs.rshlsetId(a)
}
function rshlinit() {
    rs.rshlinit()
}
function rshlsync(c, e) {
    var d = c.split(",");
    var a = e.split(",");
    for (var b = 0; b < c.length; b++) {
        rs.rshlsync(d[b], a[b])
    }
}
function rshlexit() {
    rs.rshlexit()
}
var thestylesheet = "<style type='text/css'> ";
thestylesheet += "#rs_playerarea { position: relative !important; float:right; border:0px solid #aeaeae !important; background:#ffffff !important; width: " + rs.phrases.playerwidth + "px !important; height: 39px !important; line-height: normal !important; font-style: normal !important;font-family:Arial !important;}";
thestylesheet += "#rs_playerarea object { max-width: none !important; }";
thestylesheet += "#closebr { border-style: none !important; margin: 0px !important; padding: 0px !important; }";
thestylesheet += "#rs_popup_player { font-family: Arial !important; font-size: 13px !important; width: 97px !important; height: 22px !important; position: absolute !important; border: 1px solid #aeaeae !important; z-index: 9000 !important; background: #fff !important; -moz-box-shadow: 2px 4px 6px #999 !important; -webkit-box-shadow: 2px 4px 6px #999 !important; -box-shadow: 2px 4px 6px #999 !important; line-height: normal !important;}";
thestylesheet += "#rs_popup_link a:hover { background-color: #a4cbff !important; } #rs_selimg { position: absolute !important; border: 1px solid #aeaeae !important; z-index: 10000 !important; background: #fff !important; padding: 5px !important; -moz-box-shadow: 2px 4px 6px #999 !important; -webkit-box-shadow: 2px 4px 6px #999 !important; -box-shadow: 2px 4px 6px #999 !important; line-height: normal !important; }";
thestylesheet += "#rspopup { position: absolute !important; z-index: 1000 !important; background: #fff !important; width: 342px !important; border-color: #a4cbff #aeaeae #aeaeae !important; border-right: 1px solid #aeaeae !important; border-style: solid !important; border-width: 1px !important; margin: 3px 3px 3px 0 !important; font-size: 12px !important; font-family: Arial !important; padding: 3px !important; -moz-box-shadow: 0 7px 6px #999 !important; -webkit-box-shadow: 0 7px 6px #999 !important; -box-shadow: 0 7px 6px #999 !important; }";
thestylesheet += ".rs_block {float: left !important; margin: 0 3px 0 0 !important; padding: 3px !important; border: 1px solid #ddd !important; width: 160px !important; background: none !important; clear: none !important; font-family: inherit !important;}";
thestylesheet += ".rs_block legend { position: static !important; font-weight: bold !important; color: #000 !important; font-size: 12px !important; text-transform: none !important; letter-spacing: 0px !important; padding: 0px !important; font-style: inherit !important; font-family: inherit !important; }";
thestylesheet += ".rs_block ul { margin: 0 !important; padding: 0 !important; list-style: none !important; width: 100% !important; font-family: inherit !important;}";
thestylesheet += ".rs_block li { padding: 0 !important; margin: 0 !important; width: 100% !important; background: none !important; list-style-image: none !important; list-style-type: none !important; font-family: inherit !important;}";
thestylesheet += ".rs_block li a { text-align: left !important; border-style: none !important; display: block !important; padding: 5px 0 5px 20px !important; text-decoration: none !important; color: #000 !important; font-size: 12px !important; font-family: inherit !important; font-weight: normal !important; width: 87% !important; }";
thestylesheet += ".rs_block li a:hover { background: #eee !important; }";
thestylesheet += ".rs_block li.rs_active { background-color: #A4CBFF !important; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, rgb(144,192,240)), color-stop(0.79, rgb(229,237,255))) !important; background-image: -moz-linear-gradient(center bottom, rgb(144,192,240) 0%, rgb(229,237,255) 79%) !important; }";
thestylesheet += ".rs_block li.rs_active a, .rs_block li.rs_active a:hover { background: transparent url(" + rs.settings.protocol + "//media.readspeaker.com/images/enterprise/default/rs_arrow.gif) no-repeat scroll 10px center !important; }";
thestylesheet += "#bottomlinks { font-family: inherit !important;color:#333 !important;font-size:11px !important; margin: 2px 0 2px 0 !important;} #bottomlinks a {color: #000 !important; border-style: none !important; text-decoration: none !important; padding: 2px; font-weight: normal !important; font-size:11px !important; font-family: inherit !important;} #bottomlinks a:hover { background-color: #a4cbff !important; }";
thestylesheet += "a.rs_settings { padding-left: 17px !important; border-style: none !important; background: transparent url(" + rs.settings.protocol + "//media.readspeaker.com/images/enterprise/default/wrench.png) no-repeat 2px 2px !important;}";
thestylesheet += ".sync_word_highlighted { background-color: " + rs.settings.wordColor + " !important; color: " + rs.settings.textColor + " !important; }";
thestylesheet += ".sync_sent_highlighted { background-color: " + rs.settings.sentColor + " !important; color: " + rs.settings.textColor + " !important; }";
thestylesheet += "#timeline { position: absolute !important; top: 4px !important; left: 55px !important; height: 11px !important; background-color: #F4F4F4 !important; width: 170px !important; border: 1px solid #3380CC !important; }";
thestylesheet += "#duration { position: relative !important; height: 11px !important; background-color: #92C0EF !important; width: 0px;} ";
thestylesheet += "#durationtxt { position: absolute !important; top: 1px !important; left: 0px !important; text-align: center !important; font-size: 10px !important; font-weight: bold !important; font-family: Helvetica !important; color: #003399 !important; line-height: 80% !important; width: 100% !important; } .rs_iphone { -webkit-text-size-adjust: none !important; }";
thestylesheet += "</style>";
document.write(thestylesheet);
;

