/*
html2canvas v0.34
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
(function(t,u,l){function E(c){i.logging&&t.console&&t.console.log&&t.console.log(c)}function U(c,g){var e=[];return{storage:e,width:c,height:g,fillRect:function(){e.push({type:"function",name:"fillRect",arguments:arguments})},drawImage:function(){e.push({type:"function",name:"drawImage",arguments:arguments})},fillText:function(){e.push({type:"function",name:"fillText",arguments:arguments})},setVariable:function(a,d){e.push({type:"variable",name:a,arguments:d})}}}var i={},T,L;i.Util={};i.Util.backgroundImage=
function(c){if(/data:image\/.*;base64,/i.test(c)||/^(-webkit|-moz|linear-gradient|-o-)/.test(c))return c;c.toLowerCase().substr(0,5)==='url("'?(c=c.substr(5),c=c.substr(0,c.length-2)):(c=c.substr(4),c=c.substr(0,c.length-1));return c};i.Util.Bounds=function(c){var g={};if(c.getBoundingClientRect)return c=c.getBoundingClientRect(),g.top=c.top,g.bottom=c.bottom||c.top+c.height,g.left=c.left,g.width=c.width||c.right-c.left,g.height=c.height||c.bottom-c.top,g};i.Util.getCSS=function(c,g){function e(a,
b){var g=c.runtimeStyle&&c.runtimeStyle[a],e,k=c.style;if(!/^-?[0-9]+\.?[0-9]*(?:px)?$/i.test(b)&&/^-?\d/.test(b)){e=k.left;if(g)c.runtimeStyle.left=c.currentStyle.left;k.left=a==="fontSize"?"1em":b||0;b=k.pixelLeft+"px";k.left=e;if(g)c.runtimeStyle.left=g}return!/^(thin|medium|thick)$/i.test(b)?Math.round(parseFloat(b))+"px":b}var a;if(t.getComputedStyle)void 0!==c&&(T=u.defaultView.getComputedStyle(c,null)),a=T[g],g==="backgroundPosition"&&(a=(a.split(",")[0]||"0 0").split(" "),a[0]=a[0].indexOf("%")===
-1?e(g+"X",a[0]):a[0],a[1]=a[1]===l?a[0]:a[1],a[1]=a[1].indexOf("%")===-1?e(g+"Y",a[1]):a[1]);else if(c.currentStyle)if(g==="backgroundPosition")a=[e(g+"X",c.currentStyle[g+"X"]),e(g+"Y",c.currentStyle[g+"Y"])];else if(a=e(g,c.currentStyle[g]),/^(border)/i.test(g)&&/^(medium|thin|thick)$/i.test(a))switch(a){case "thin":a="1px";break;case "medium":a="0px";break;case "thick":a="5px"}return a};i.Util.BackgroundPosition=function(c,g,e){var c=i.Util.getCSS(c,"backgroundPosition"),a,d;c.length===1&&(a=
c,c=[],c[0]=a,c[1]=a);c[0].toString().indexOf("%")!==-1?(d=parseFloat(c[0])/100,a=g.width*d-e.width*d):a=parseInt(c[0],10);c[1].toString().indexOf("%")!==-1?(d=parseFloat(c[1])/100,g=g.height*d-e.height*d):g=parseInt(c[1],10);return{top:g,left:a}};i.Util.Extend=function(c,g){for(var e in c)c.hasOwnProperty(e)&&(g[e]=c[e]);return g};i.Util.Children=function(c){var g;try{g=c.nodeName&&c.nodeName.toUpperCase()==="IFRAME"?c.contentDocument||c.contentWindow.document:function(a){var d=[];a!==null&&function(a,
d){var c=a.length,g=0;if(typeof d.length==="number")for(var e=d.length;g26);return e};i.Generate.ListRoman=function(c){var e=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"],a=[1E3,900,500,400,100,90,50,40,10,9,5,4,1],d="",b,h=e.length;if(c<=
0||c>=4E3)return c;for(b=0;b=a[b];)c-=a[b],d+=e[b];return d}})();i.Parse=function(c,g){function e(){return{width:Math.max(Math.max(z.body.scrollWidth,z.documentElement.scrollWidth),Math.max(z.body.offsetWidth,z.documentElement.offsetWidth),Math.max(z.body.clientWidth,z.documentElement.clientWidth)),height:Math.max(Math.max(z.body.scrollHeight,z.documentElement.scrollHeight),Math.max(z.body.offsetHeight,z.documentElement.offsetHeight),Math.max(z.body.clientHeight,z.documentElement.clientHeight))}}
function a(a,b){var c=parseInt(y(a,b),10);return isNaN(c)?0:c}function d(a,b,c,d,g,e){e!=="transparent"&&(a.setVariable("fillStyle",e),a.fillRect(b,c,d,g),H+=1)}function b(a,b){switch(b){case "lowercase":return a.toLowerCase();case "capitalize":return a.replace(/(^|\s|:|-|\(|\))([a-z])/g,function(a,b,V){if(a.length>0)return b+V.toUpperCase()});case "uppercase":return a.toUpperCase();default:return a}}function h(a){return a.replace(/^\s*/g,"").replace(/\s*$/g,"")}function f(a,c,e){var e=e.ctx,f=y(a,
"fontFamily"),j=y(a,"fontSize"),k=y(a,"color"),n=y(a,"textDecoration"),F=y(a,"textAlign"),p=y(a,"letterSpacing"),I,q,m=y(a,"fontWeight"),r=y(a,"fontStyle"),s=y(a,"fontVariant"),A=0,o;c.nodeValue=b(c.nodeValue,y(a,"textTransform"));if(h(c.nodeValue).length>0){if(n!=="none")if(w[f+"-"+j]!==l)q=w[f+"-"+j];else{q=z.createElement("div");a=z.createElement("img");o=z.createElement("span");var v;q.style.visibility="hidden";q.style.fontFamily=f;q.style.fontSize=j;q.style.margin=0;q.style.padding=0;O.appendChild(q);
a.src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=";a.width=1;a.height=1;a.style.margin=0;a.style.padding=0;a.style.verticalAlign="baseline";o.style.fontFamily=f;o.style.fontSize=j;o.style.margin=0;o.style.padding=0;o.appendChild(z.createTextNode("Hidden Text"));q.appendChild(o);q.appendChild(a);v=a.offsetTop-o.offsetTop+1;q.removeChild(o);q.appendChild(z.createTextNode("Hidden Text"));q.style.lineHeight="normal";a.style.verticalAlign="super";a={baseline:v,lineWidth:1,middle:a.offsetTop-
q.offsetTop+1};w[f+"-"+j]=a;O.removeChild(q);q=a}F=F.replace(["-webkit-auto"],["auto"]);F=g.letterRendering===!1&&/^(left|right|justify|auto)$/.test(F)&&/^(normal|none)$/.test(p)?c.nodeValue.split(/(\b| )/):c.nodeValue.split("");switch(parseInt(m,10)){case 401:m="bold";break;case 400:m="normal"}e.setVariable("fillStyle",k);e.setVariable("font",r+" "+s+" "+m+" "+j+" "+f);e.setVariable("textAlign","left");j=c;m=0;for(f=F.length;m0&&(a.fillText(r,s,p),H+=1);switch(n){case "underline":d(e,
I.left,Math.round(I.top+q.baseline+q.lineWidth),I.width,1,k);break;case "overline":d(e,I.left,I.top,I.width,1,k);break;case "line-through":d(e,I.left,Math.ceil(I.top+q.middle+q.lineWidth),I.width,1,k)}A+=F[m].length}}}function k(a){return(a=c[a])&&a.succeeded===!0?a.img:!1}function n(a,b){var c=Math.max(a.left,b.left),d=Math.max(a.top,b.top);return{left:c,top:d,width:Math.min(a.left+a.width,b.left+b.width)-c,height:Math.min(a.top+a.height,b.top+b.height)-d}}function Q(b,c,e,g){for(var f=e.left,j=
e.top,h=e.width,e=e.height,k,p,B,q,m,i=function(b){var c=[],d=["Top","Right","Bottom","Left"],e;for(e=0;e<4;e+=1)c.push({width:a(b,"border"+d[e]+"Width"),color:y(b,"border"+d[e]+"Color")});return c}(b),b=0;b<4;b+=1)if(k=i[b],k.width>0){p=f;B=j;q=h;m=e-i[2].width;switch(b){case 0:m=i[0].width;break;case 1:p=f+h-i[1].width;q=i[1].width;break;case 2:B=B+e-i[2].width;m=i[2].width;break;case 3:q=i[3].width}q={left:p,top:B,width:q,height:m};g&&(q=n(q,g));q.width>0&&q.height>0&&d(c,p,B,q.width,q.height,
k.color)}return i}function P(a,b,c){var d=z.createElement("valuewrap"),e=["lineHeight","textAlign","fontFamily","color","fontSize","paddingLeft","paddingTop","width","height","border","borderLeftWidth","borderTopWidth"],g,j,h;g=0;for(j=e.length;g0&&(h=f-c);j-d>0&&(k=j-d);a.drawImage(b,h,k,e-h,g-k,c+h,d+k,e-h,g-k);H+=1}function x(a,b,c,d,e,g,f){var f=Math.min(b.height,f),h,j;c.left-=Math.ceil(c.left/b.width)*b.width;for(j=d+c.left;j
g+d?g+d-j:b.width,v(a,b,j,e+c.top,h,f,d,e),j=Math.floor(j+b.width)}function K(b,c){var j=i.Util.Bounds(b),f=j.left,B=j.top,w=j.width,D=j.height,F,p=y(b,"backgroundColor"),t=y(b,"position"),q,m=y(b,"opacity"),r,s;c?L={}:(L=e(),c={opacity:1});s=y(b,"zIndex");(q=c.zIndex)?s!=="auto"&&(s={zindex:s,children:[]},q.children.push(s),q=s):q=s={zindex:0,children:[]};r={ctx:U(L.width||w,L.height||D),zIndex:q,opacity:m*c.opacity,cssPosition:t};if(c.clip)r.clip=i.Util.Extend({},c.clip);if(g.useOverflow===!0&&
/(hidden|scroll|auto)/.test(y(b,"overflow"))===!0&&/(BODY)/i.test(b.nodeName)===!1)r.clip=r.clip?n(r.clip,j):j;t=q.children.push(r);s=q.children[t-1].ctx;s.setVariable("globalAlpha",r.opacity);m=Q(b,s,j,!1);r.borders=m;A.test(b.nodeName)&&g.iframeDefault!=="transparent"&&(p=g.iframeDefault==="default"?"#efefef":g.iframeDefault);w={left:f+m[3].width,top:B+m[0].width,width:w-(m[1].width+m[3].width),height:D-(m[0].width+m[2].width)};r.clip&&(w=n(w,r.clip));if(w.height>0&&w.width>0){d(s,w.left,w.top,
w.width,w.height,p);var C=w,o=y(b,"backgroundImage"),l=y(b,"backgroundRepeat").split(",")[0],u,G,J;!/data:image\/.*;base64,/i.test(o)&&!/^(-webkit|-moz|linear-gradient|-o-)/.test(o)&&(o=o.split(",")[0]);if(typeof o!=="undefined"&&/^(1|none)$/.test(o)===!1)if(o=i.Util.backgroundImage(o),p=k(o),D=i.Util.BackgroundPosition(b,C,p),p)switch(l){case "repeat-x":x(s,p,D,C.left,C.top,C.width,C.height);break;case "repeat-y":o=C.left;l=C.top;u=C.height;G=Math.min(p.width,C.width);D.top-=Math.ceil(D.top/p.height)*
p.height;for(J=l+D.top;Ju+l?u+l-J:p.height,v(s,p,o+D.left,J,G,C,o,l),J=Math.floor(J+p.height);break;case "no-repeat":o=C.width-D.left;J=C.height-D.top;l=D.left;u=D.top;G=D.left+C.left;D=D.top+C.top;l<0?(l=Math.abs(l),G+=l,o=Math.min(C.width,p.width-l)):(o=Math.min(o,p.width),l=0);u<0?(u=Math.abs(u),D+=u,J=Math.min(C.height,p.height-u)):(J=Math.min(J,p.height),u=0);J>0&&o>0&&(s.drawImage(p,l,u,o,J,G,D,o,J),H+=1);break;default:D.top-=Math.ceil(D.top/p.height)*p.height;
for(o=C.top+D.top;ol+o?l+o-o:p.height,o0&&(D.top+=u),o=Math.floor(o+p.height)-u}else E("html2canvas: Error loading background:"+o)}switch(b.nodeName){case "IMG":r=b.getAttribute("src");(F=k(r))?(r=a(b,"paddingLeft"),w=a(b,"paddingTop"),p=a(b,"paddingRight"),D=a(b,"paddingBottom"),s.drawImage(F,0,0,F.width,F.height,f+r+m[3].width,B+w+m[0].width,j.width-(m[1].width+
m[3].width+r+p),j.height-(m[0].width+m[2].width+w+D)),H+=1):E("html2canvas: Error loading :"+r);break;case "INPUT":/^(text|url|email|submit|button|reset)$/.test(b.type)&&b.value.length>0&&P(b,j,r);break;case "TEXTAREA":b.value.length>0&&P(b,j,r);break;case "SELECT":b.options.length>0&&P(b,j,r);break;case "LI":j=w;f=y(b,"listStylePosition");m=y(b,"listStyleType");B=y(b,"fontWeight");if(/^(decimal|decimal-leading-zero|upper-alpha|upper-latin|upper-roman|lower-alpha|lower-greek|lower-latin|lower-roman)$/i.test(m)){s=
-1;r=1;w=b.parentNode.childNodes;if(b.parentNode){for(;w[++s]!==b;)w[s].nodeType===1&&r++;s=r}else s=-1;switch(m){case "decimal":F=s;break;case "decimal-leading-zero":F=s.toString().length===1?"0"+s.toString():s.toString();break;case "upper-roman":F=i.Generate.ListRoman(s);break;case "lower-roman":F=i.Generate.ListRoman(s).toLowerCase();break;case "lower-alpha":F=i.Generate.ListAlpha(s).toLowerCase();break;case "upper-alpha":F=i.Generate.ListAlpha(s)}F+=". ";r=F;m=z.createElement("boundelement");
m.style.display="inline";s=b.style.listStyleType;b.style.listStyleType="none";m.appendChild(z.createTextNode(r));b.insertBefore(m,b.firstChild);r=i.Util.Bounds(m);b.removeChild(m);b.style.listStyleType=s;switch(B){case 401:B="bold";break;case 400:B="normal"}R.setVariable("fillStyle",y(b,"color"));R.setVariable("font",y(b,"fontVariant")+" "+B+" "+y(b,"fontStyle")+" "+y(b,"fontSize")+" "+y(b,"fontFamily"));if(f==="inside")R.setVariable("textAlign","left"),j=j.left,f=r.bottom,B=R,h(F).length>0&&(B.fillText(F,
j,f),H+=1)}break;case "CANVAS":r=a(b,"paddingLeft"),w=a(b,"paddingTop"),p=a(b,"paddingRight"),D=a(b,"paddingBottom"),s.drawImage(b,0,0,b.width,b.height,f+r+m[3].width,B+w+m[0].width,j.width-(m[1].width+m[3].width+r+p),j.height-(m[0].width+m[2].width+w+D)),H+=1}return q.children[t-1]}function G(a,b){if(y(a,"display")!=="none"&&y(a,"visibility")!=="hidden"&&(b=K(a,b)||b,R=b.ctx,!A.test(a.nodeName))){var c=i.Util.Children(a),d,e,j;d=0;for(j=c.length;dsup
";try{c.drawImage(a,0,0),b.toDataURL()}catch(d){return!1}E("html2canvas: Parse: SVG powered rendering available");
return!0}()},j=g.elements===l?u.body:g.elements[0],H=0,w={},z=j.ownerDocument,A=RegExp("("+g.ignoreElements+")"),O=z.body,M,N,S,R,L,c=c||{};if(z.createRange&&(M=z.createRange(),M.getBoundingClientRect)){N=z.createElement("boundtest");N.style.height="123px";N.style.display="block";O.appendChild(N);M.selectNode(N);M=M.getBoundingClientRect();M=M.height;if(M===123)B.rangeBounds=!0;O.removeChild(N)}var y=i.Util.getCSS;S=K(j,null);B.svgRendering&&function(a){function b(a){var a=i.Util.Children(a),c=a.length,
d,e,g,f,h;for(h=0;h/g,">");else if(f.nodeType===1&&!/^(script|meta|title)$/.test(f.nodeName.toLowerCase())){j+="<"+f.nodeName.toLowerCase();if(f.hasAttributes()){d=f.attributes;g=d.length;for(e=0;e";b(f);j+=""+f.nodeName.toLowerCase()+">"}}var c=new Image,d=e(),j="";b(a);c.src=["data:image/svg+xml,",""].join("");c.onload=function(){S.svgRender=c}}(u.documentElement);N=0;j=j.children;for(M=j.length;N=b.numTotal&&(E("Finished loading images: # "+b.numTotal+" (failed: "+b.numFailed+")"),typeof c.complete==="function"&&c.complete(b))}function e(a,e,f){var h,k=c.proxy,i;x.href=a;a=x.href;h="html2canvas_"+n++;f.callbackname=h;k+=k.indexOf("?")>-1?"&":"?";k+="url="+encodeURIComponent(a)+"&callback="+h;i=Q.createElement("script");t[h]=function(a){a.substring(0,6)==="error:"?(f.succeeded=!1,b.numLoaded++,b.numFailed++,g()):(d(e,f),e.src=a);t[h]=l;try{delete t[h]}catch(c){}i.parentNode.removeChild(i);
i=null;delete f.script;delete f.callbackname};i.setAttribute("type","text/javascript");i.setAttribute("src",k);f.script=i;t.document.body.appendChild(i)}function a(c){var d=i.Util.Children(c),e,h,k=!1;try{var n=d.length;for(e=0;e0&&(G=t.setTimeout(f.cleanupDOM,c.timeout));E("html2canvas: Preload starts: finding background-images");b.firstRun=!0;a(k);E("html2canvas: Preload: Finding images");for(k=0;k0?(b.push(k),g.push(k.zindex)):a.push(k);g.sort(function(a,b){return a-b});c=0;for(f=g.length;c0&&A.arguments[7]){if(j&&c.taintTest&&H.indexOf(A.arguments[0].src)===-1){w.drawImage(A.arguments[0],0,0);try{w.getImageData(0,0,1,
1)}catch(L){w=h.createElement("canvas");w=w.getContext("2d");continue}H.push(A.arguments[0].src)}v.drawImage.apply(v,A.arguments)}}}x.clip&&v.restore()}}E("html2canvas: Renderer: Canvas renderer done - returning canvas obj");G=c.elements.length;return G===1&&typeof c.elements[0]==="object"&&c.elements[0].nodeName!=="BODY"&&e===!1?(H=t.Util.Bounds(c.elements[0]),j=h.createElement("canvas"),j.width=H.width,j.height=H.height,v=j.getContext("2d"),v.drawImage(g,H.left,H.top,H.width,H.height,0,0,H.width,
H.height),g=null,j):g}}};t.html2canvas=L})(window,document);