/*****************************************************************

typeface.js, version 0.13 | typefacejs.neocracy.org

Copyright (c) 2008 - 2009, David Chester davidchester@gmx.net 

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

*****************************************************************/

(function() {

var _typeface_js = {

	faces: {},

	loadFace: function(typefaceData) {

		var familyName = typefaceData.familyName.toLowerCase();
		
		if (!this.faces[familyName]) {
			this.faces[familyName] = {};
		}
		if (!this.faces[familyName][typefaceData.cssFontWeight]) {
			this.faces[familyName][typefaceData.cssFontWeight] = {};
		}

		var face = this.faces[familyName][typefaceData.cssFontWeight][typefaceData.cssFontStyle] = typefaceData;
		face.loaded = true;
	},

	log: function(message) {
		
		if (this.quiet) {
			return;
		}
		
		message = "typeface.js: " + message;
		
		if (this.customLogFn) {
			this.customLogFn(message);

		} else if (window.console && window.console.log) {
			window.console.log(message);
		}
		
	},
	
	pixelsFromPoints: function(face, style, points, dimension) {
		var pixels = points * parseInt(style.fontSize) * 72 / (face.resolution * 100);
		if (dimension == 'horizontal' && style.fontStretchPercent) {
			pixels *= style.fontStretchPercent;
		}
		return pixels;
	},

	pointsFromPixels: function(face, style, pixels, dimension) {
		var points = pixels * face.resolution / (parseInt(style.fontSize) * 72 / 100);
		if (dimension == 'horizontal' && style.fontStretchPrecent) {
			points *= style.fontStretchPercent;
		}
		return points;
	},

	cssFontWeightMap: {
		normal: 'normal',
		bold: 'bold',
		400: 'normal',
		700: 'bold'
	},

	cssFontStretchMap: {
		'ultra-condensed': 0.55,
		'extra-condensed': 0.77,
		'condensed': 0.85,
		'semi-condensed': 0.93,
		'normal': 1,
		'semi-expanded': 1.07,
		'expanded': 1.15,
		'extra-expanded': 1.23,
		'ultra-expanded': 1.45,
		'default': 1
	},
	
	fallbackCharacter: '.',

	configure: function(args) {
		var configurableOptionNames = [ 'customLogFn',  'customClassNameRegex', 'customTypefaceElementsList', 'quiet', 'verbose', 'disableSelection' ];
		
		for (var i = 0; i < configurableOptionNames.length; i++) {
			var optionName = configurableOptionNames[i];
			if (args[optionName]) {
				if (optionName == 'customLogFn') {
					if (typeof args[optionName] != 'function') {
						throw "customLogFn is not a function";
					} else {
						this.customLogFn = args.customLogFn;
					}
				} else {
					this[optionName] = args[optionName];
				}
			}
		}
	},

	getTextExtents: function(face, style, text) {
		var extentX = 0;
		var extentY = 0;
		var horizontalAdvance;
	
		var textLength = text.length;
		for (var i = 0; i < textLength; i++) {
			var glyph = face.glyphs[text.charAt(i)] ? face.glyphs[text.charAt(i)] : face.glyphs[this.fallbackCharacter];
			var letterSpacingAdjustment = this.pointsFromPixels(face, style, style.letterSpacing);
			extentX += Math.max(glyph.ha, glyph.x_max) + letterSpacingAdjustment;
			horizontalAdvance += glyph.ha + letterSpacingAdjustment;
		}
		return { 
			x: extentX, 
			y: extentY,
			ha: horizontalAdvance
			
		};
	},

	pixelsFromCssAmount: function(cssAmount, defaultValue, element) {

		var matches = undefined;

		if (cssAmount == 'normal') {
			return defaultValue;

		} else if (matches = cssAmount.match(/([\-\d+\.]+)px/)) {
			return matches[1];

		} else {
			// thanks to Dean Edwards for this very sneaky way to get IE to convert 
			// relative values to pixel values
			
			var pixelAmount;
			
			var leftInlineStyle = element.style.left;
			var leftRuntimeStyle = element.runtimeStyle.left;

			element.runtimeStyle.left = element.currentStyle.left;

			if (!cssAmount.match(/\d(px|pt)$/)) {
				element.style.left = '1em';
			} else {
				element.style.left = cssAmount || 0;
			}

			pixelAmount = element.style.pixelLeft;
		
			element.style.left = leftInlineStyle;
			element.runtimeStyle.left = leftRuntimeStyle;
			
			return pixelAmount || defaultValue;
		}
	},

	capitalizeText: function(text) {
		return text.replace(/(^|\s)[a-z]/g, function(match) { return match.toUpperCase() } ); 
	},

	getElementStyle: function(e) {
		if (window.getComputedStyle) {
			return window.getComputedStyle(e, '');
		
		} else if (e.currentStyle) {
			return e.currentStyle;
		}
	},

	getRenderedText: function(e) {

		var browserStyle = this.getElementStyle(e.parentNode);

		var inlineStyleAttribute = e.parentNode.getAttribute('style');
		if (inlineStyleAttribute && typeof(inlineStyleAttribute) == 'object') {
			inlineStyleAttribute = inlineStyleAttribute.cssText;
		}

		if (inlineStyleAttribute) {

			var inlineStyleDeclarations = inlineStyleAttribute.split(/\s*\;\s*/);

			var inlineStyle = {};
			for (var i = 0; i < inlineStyleDeclarations.length; i++) {
				var declaration = inlineStyleDeclarations[i];
				var declarationOperands = declaration.split(/\s*\:\s*/);
				inlineStyle[declarationOperands[0]] = declarationOperands[1];
			}
		}

		var style = { 
			color: browserStyle.color, 
			fontFamily: browserStyle.fontFamily.split(/\s*,\s*/)[0].replace(/(^"|^'|'$|"$)/g, '').toLowerCase(), 
			fontSize: this.pixelsFromCssAmount(browserStyle.fontSize, 12, e.parentNode),
			fontWeight: this.cssFontWeightMap[browserStyle.fontWeight],
			fontStyle: browserStyle.fontStyle ? browserStyle.fontStyle : 'normal',
			fontStretchPercent: this.cssFontStretchMap[inlineStyle && inlineStyle['font-stretch'] ? inlineStyle['font-stretch'] : 'default'],
			textDecoration: browserStyle.textDecoration,
			lineHeight: this.pixelsFromCssAmount(browserStyle.lineHeight, 'normal', e.parentNode),
			letterSpacing: this.pixelsFromCssAmount(browserStyle.letterSpacing, 0, e.parentNode),
			textTransform: browserStyle.textTransform
		};

		var face;
		if (
			this.faces[style.fontFamily]  
			&& this.faces[style.fontFamily][style.fontWeight]
		) {
			face = this.faces[style.fontFamily][style.fontWeight][style.fontStyle];
		}

		var text = e.nodeValue;
		
		if (
			e.previousSibling 
			&& e.previousSibling.nodeType == 1 
			&& e.previousSibling.tagName != 'BR' 
			&& this.getElementStyle(e.previousSibling).display.match(/inline/)
		) {
			text = text.replace(/^\s+/, ' ');
		} else {
			text = text.replace(/^\s+/, '');
		}
		
		if (
			e.nextSibling 
			&& e.nextSibling.nodeType == 1 
			&& e.nextSibling.tagName != 'BR' 
			&& this.getElementStyle(e.nextSibling).display.match(/inline/)
		) {
			text = text.replace(/\s+$/, ' ');
		} else {
			text = text.replace(/\s+$/, '');
		}
		
		text = text.replace(/\s+/g, ' ');
	
		if (style.textTransform && style.textTransform != 'none') {
			switch (style.textTransform) {
				case 'capitalize':
					text = this.capitalizeText(text);
					break;
				case 'uppercase':
					text = text.toUpperCase();
					break;
				case 'lowercase':
					text = text.toLowerCase();
					break;
			}
		}

		if (!face) {
			var excerptLength = 12;
			var textExcerpt = text.substring(0, excerptLength);
			if (text.length > excerptLength) {
				textExcerpt += '...';
			}
		
			var fontDescription = style.fontFamily;
			if (style.fontWeight != 'normal') fontDescription += ' ' + style.fontWeight;
			if (style.fontStyle != 'normal') fontDescription += ' ' + style.fontStyle;
		
			this.log("couldn't find typeface font: " + fontDescription + ' for text "' + textExcerpt + '"');
			return;
		}
	
		var words = text.split(/\b(?=\w)/);

		var containerSpan = document.createElement('span');
		containerSpan.className = 'typeface-js-vector-container';
		
		var wordsLength = words.length
		for (var i = 0; i < wordsLength; i++) {
			var word = words[i];
			
			var vector = this.renderWord(face, style, word);
			
			if (vector) {
				containerSpan.appendChild(vector.element);

				if (!this.disableSelection) {
					var selectableSpan = document.createElement('span');
					selectableSpan.className = 'typeface-js-selected-text';

					var wordNode = document.createTextNode(word);
					selectableSpan.appendChild(wordNode);

					if (this.vectorBackend != 'vml') {
						selectableSpan.style.marginLeft = -1 * (vector.width + 1) + 'px';
					}
					selectableSpan.targetWidth = vector.width;
					//selectableSpan.style.lineHeight = 1 + 'px';

					if (this.vectorBackend == 'vml') {
						vector.element.appendChild(selectableSpan);
					} else {
						containerSpan.appendChild(selectableSpan);
					}
				}
			}
		}

		return containerSpan;
	},

	renderDocument: function(callback) { 
		
		if (!callback)
			callback = function(e) { e.style.visibility = 'visible' };

		var elements = document.getElementsByTagName('*');
		
		var elementsLength = elements.length;
		for (var i = 0; i < elements.length; i++) {
			if (elements[i].className.match(/(^|\s)typeface-js(\s|$)/) || elements[i].tagName.match(/^(H1|H2|H3|H4|H5|H6)$/)) {
				this.replaceText(elements[i]);
				if (typeof callback == 'function') {
					callback(elements[i]);
				}
			}
		}

		if (this.vectorBackend == 'vml') {
			// lamely work around IE's quirky leaving off final dynamic shapes
			var dummyShape = document.createElement('v:shape');
			dummyShape.style.display = 'none';
			document.body.appendChild(dummyShape);
		}
	},

	replaceText: function(e) {

		var childNodes = [];
		var childNodesLength = e.childNodes.length;

		for (var i = 0; i < childNodesLength; i++) {
			this.replaceText(e.childNodes[i]);
		}

		if (e.nodeType == 3 && e.nodeValue.match(/\S/)) {
			var parentNode = e.parentNode;

			if (parentNode.className == 'typeface-js-selected-text') {
				return;
			}

			var renderedText = this.getRenderedText(e);
			
			if (
				parentNode.tagName == 'A' 
				&& this.vectorBackend == 'vml'
				&& this.getElementStyle(parentNode).display == 'inline'
			) {
				// something of a hack, use inline-block to get IE to accept clicks in whitespace regions
				parentNode.style.display = 'inline-block';
				parentNode.style.cursor = 'pointer';
			}

			if (this.getElementStyle(parentNode).display == 'inline') {
				parentNode.style.display = 'inline-block';
			}

			if (renderedText) {	
				if (parentNode.replaceChild) {
					parentNode.replaceChild(renderedText, e);
				} else {
					parentNode.insertBefore(renderedText, e);
					parentNode.removeChild(e);
				}
				if (this.vectorBackend == 'vml') {
					renderedText.innerHTML = renderedText.innerHTML;
				}

				var childNodesLength = renderedText.childNodes.length
				for (var i; i < childNodesLength; i++) {
					
					// do our best to line up selectable text with rendered text

					var e = renderedText.childNodes[i];
					if (e.hasChildNodes() && !e.targetWidth) {
						e = e.childNodes[0];
					}
					
					if (e && e.targetWidth) {
						var letterSpacingCount = e.innerHTML.length;
						var wordSpaceDelta = e.targetWidth - e.offsetWidth;
						var letterSpacing = wordSpaceDelta / (letterSpacingCount || 1);

						if (this.vectorBackend == 'vml') {
							letterSpacing = Math.ceil(letterSpacing);
						}

						e.style.letterSpacing = letterSpacing + 'px';
						e.style.width = e.targetWidth + 'px';
					}
				}
			}
		}
	},

	applyElementVerticalMetrics: function(face, style, e) {

		if (style.lineHeight == 'normal') {
			style.lineHeight = this.pixelsFromPoints(face, style, face.lineHeight);
		}

		var cssLineHeightAdjustment = style.lineHeight - this.pixelsFromPoints(face, style, face.lineHeight);

		e.style.marginTop = Math.round( cssLineHeightAdjustment / 2 ) + 'px';
		e.style.marginBottom = Math.round( cssLineHeightAdjustment / 2) + 'px';
	
	},

	vectorBackends: {

		canvas: {

			_initializeSurface: function(face, style, text) {

				var extents = this.getTextExtents(face, style, text);

				var canvas = document.createElement('canvas');
				if (this.disableSelection) {
					canvas.innerHTML = text;
				}

				canvas.height = Math.round(this.pixelsFromPoints(face, style, face.lineHeight));
				canvas.width = Math.round(this.pixelsFromPoints(face, style, extents.x, 'horizontal'));
	
				this.applyElementVerticalMetrics(face, style, canvas);

				if (extents.x > extents.ha) 
					canvas.style.marginRight = Math.round(this.pixelsFromPoints(face, style, extents.x - extents.ha, 'horizontal')) + 'px';

				var ctx = canvas.getContext('2d');

				var pointScale = this.pixelsFromPoints(face, style, 1);
				ctx.scale(pointScale * style.fontStretchPercent, -1 * pointScale);
				ctx.translate(0, -1 * face.ascender);
				ctx.fillStyle = style.color;

				return { context: ctx, canvas: canvas };
			},

			_renderGlyph: function(ctx, face, char, style) {

				var glyph = face.glyphs[char];

				if (!glyph) {
					//this.log.error("glyph not defined: " + char);
					return this.renderGlyph(ctx, face, this.fallbackCharacter, style);
				}

				if (glyph.o) {

					var outline;
					if (glyph.cached_outline) {
						outline = glyph.cached_outline;
					} else {
						outline = glyph.o.split(' ');
						glyph.cached_outline = outline;
					}

					var outlineLength = outline.length;
					for (var i = 0; i < outlineLength; ) {

						var action = outline[i++];

						switch(action) {
							case 'm':
								ctx.moveTo(outline[i++], outline[i++]);
								break;
							case 'l':
								ctx.lineTo(outline[i++], outline[i++]);
								break;

							case 'q':
								var cpx = outline[i++];
								var cpy = outline[i++];
								ctx.quadraticCurveTo(outline[i++], outline[i++], cpx, cpy);
								break;
						}
					}					
				}
				if (glyph.ha) {
					var letterSpacingPoints = 
						style.letterSpacing && style.letterSpacing != 'normal' ? 
							this.pointsFromPixels(face, style, style.letterSpacing) : 
							0;

					ctx.translate(glyph.ha + letterSpacingPoints, 0);
				}
			},

			_renderWord: function(face, style, text) {
				var surface = this.initializeSurface(face, style, text);
				var ctx = surface.context;
				var canvas = surface.canvas;
				ctx.beginPath();
				ctx.save();

				var chars = text.split('');
				var charsLength = chars.length;
				for (var i = 0; i < charsLength; i++) {
					this.renderGlyph(ctx, face, chars[i], style);
				}

				ctx.fill();

				if (style.textDecoration == 'underline') {

					ctx.beginPath();
					ctx.moveTo(0, face.underlinePosition);
					ctx.restore();
					ctx.lineTo(0, face.underlinePosition);
					ctx.strokeStyle = style.color;
					ctx.lineWidth = face.underlineThickness;
					ctx.stroke();
				}

				return { element: ctx.canvas, width: Math.floor(canvas.width) };
			
			}
		},

		vml: {

			_initializeSurface: function(face, style, text) {

				var shape = document.createElement('v:shape');

				var extents = this.getTextExtents(face, style, text);
				
				shape.style.width = shape.style.height = style.fontSize + 'px'; 
				shape.style.marginLeft = '-1px'; // this seems suspect...

				if (extents.x > extents.ha) {
					shape.style.marginRight = this.pixelsFromPoints(face, style, extents.x - extents.ha, 'horizontal') + 'px';
				}

				this.applyElementVerticalMetrics(face, style, shape);

				var resolutionScale = face.resolution * 100 / 72;
				shape.coordsize = (resolutionScale / style.fontStretchPercent) + "," + resolutionScale;
				
				shape.coordorigin = '0,' + face.ascender;
				shape.style.flip = 'y';

				shape.fillColor = style.color;
				shape.stroked = false;

				shape.path = 'hh m 0,' + face.ascender + ' l 0,' + face.descender + ' ';

				return shape;
			},

			_renderGlyph: function(shape, face, char, offsetX, style, vmlSegments) {

				var glyph = face.glyphs[char];

				if (!glyph) {
					this.log("glyph not defined: " + char);
					this.renderGlyph(shape, face, this.fallbackCharacter, offsetX, style);
					return;
				}
				
				vmlSegments.push('m');

				if (glyph.o) {
					
					var outline, outlineLength;
					
					if (glyph.cached_outline) {
						outline = glyph.cached_outline;
						outlineLength = outline.length;
					} else {
						outline = glyph.o.split(' ');
						outlineLength = outline.length;

						for (var i = 0; i < outlineLength;) {

							switch(outline[i++]) {
								case 'q':
									outline[i] = Math.round(outline[i++]);
									outline[i] = Math.round(outline[i++]);
								case 'm':
								case 'l':
									outline[i] = Math.round(outline[i++]);
									outline[i] = Math.round(outline[i++]);
									break;
							} 
						}	

						glyph.cached_outline = outline;
					}

					var prevX, prevY;
					
					for (var i = 0; i < outlineLength;) {

						var action = outline[i++];

						var x = outline[i++] + offsetX;
						var y = outline[i++];
	
						switch(action) {
							case 'm':
								vmlSegments.push('xm ', x, ',', y);
								break;
	
							case 'l':
								vmlSegments.push('l ', x, ',', y);
								break;

							case 'q':
								var cpx = outline[i++] + offsetX;
								var cpy = outline[i++];

								var cp1x = Math.round(prevX + 2.0 / 3.0 * (cpx - prevX));
								var cp1y = Math.round(prevY + 2.0 / 3.0 * (cpy - prevY));

								var cp2x = Math.round(cp1x + (x - prevX) / 3.0);
								var cp2y = Math.round(cp1y + (y - prevY) / 3.0);
								
								vmlSegments.push('c ', cp1x, ',', cp1y, ',', cp2x, ',', cp2y, ',', x, ',', y);
								break;
						}

						prevX = x;
						prevY = y;
					}					
				}

				vmlSegments.push('x e');
				return vmlSegments;
			},

			_renderWord: function(face, style, text) {
				var offsetX = 0;
				var shape = this.initializeSurface(face, style, text);
		
				var letterSpacingPoints = 
					style.letterSpacing && style.letterSpacing != 'normal' ? 
						this.pointsFromPixels(face, style, style.letterSpacing) : 
						0;

				letterSpacingPoints = Math.round(letterSpacingPoints);
				var chars = text.split('');
				var vmlSegments = [];
				for (var i = 0; i < chars.length; i++) {
					var char = chars[i];
					vmlSegments = this.renderGlyph(shape, face, char, offsetX, style, vmlSegments);
					offsetX += face.glyphs[char].ha + letterSpacingPoints ;	
				}

				// make sure to preserve trailing whitespace
				shape.path += vmlSegments.join('') + 'm ' + offsetX + ' 0 l ' + offsetX + ' ' + face.ascender;
				
				return {
					element: shape,
					width: Math.floor(this.pixelsFromPoints(face, style, offsetX, 'horizontal'))
				};
			}

		}

	},

	setVectorBackend: function(backend) {

		this.vectorBackend = backend;
		var backendFunctions = ['renderWord', 'initializeSurface', 'renderGlyph'];

		for (var i = 0; i < backendFunctions.length; i++) {
			var backendFunction = backendFunctions[i];
			this[backendFunction] = this.vectorBackends[backend]['_' + backendFunction];
		}
	},
	
	initialize: function() {

		// quit if this function has already been called
		if (arguments.callee.done) return; 
		
		// flag this function so we don't do the same thing twice
		arguments.callee.done = true;

		// kill the timer
		if (window._typefaceTimer) clearInterval(_typefaceTimer);

		this.renderDocument( function(e) { e.style.visibility = 'visible' } );

	}
	
};

// IE won't accept real selectors...
var typefaceSelectors = ['.typeface-js', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];

if (document.createStyleSheet) { 

	var styleSheet = document.createStyleSheet();
	for (var i = 0; i < typefaceSelectors.length; i++) {
		var selector = typefaceSelectors[i];
		styleSheet.addRule(selector, 'visibility: hidden');
	}

	styleSheet.addRule(
		'.typeface-js-selected-text', 
		'-ms-filter: \
			"Chroma(color=black) \
			progid:DXImageTransform.Microsoft.MaskFilter(Color=white) \
			progid:DXImageTransform.Microsoft.MaskFilter(Color=blue) \
			alpha(opacity=30)" !important; \
		color: black; \
		font-family: Modern; \
		position: absolute; \
		white-space: pre; \
		filter: alpha(opacity=0);'
	);

	styleSheet.addRule(
		'.typeface-js-vector-container',
		'position: relative'
	);

} else if (document.styleSheets && document.styleSheets.length) {

	var styleSheet = document.styleSheets[0];
	document.styleSheets[0].insertRule(typefaceSelectors.join(',') + ' { visibility: hidden; }', styleSheet.cssRules.length); 

	document.styleSheets[0].insertRule(
		'.typeface-js-selected-text { \
			color: rgba(128, 128, 128, 0); \
			opacity: 0.30; \
			position: absolute; \
			font-family: Arial, sans-serif; \
			white-space: pre \
		}', 
		styleSheet.cssRules.length
	);

	try { 
		// set selection style for Mozilla / Firefox
		document.styleSheets[0].insertRule(
			'.typeface-js-selected-text::-moz-selection { background: blue; }', 
			styleSheet.cssRules.length
		); 

	} catch(e) {};

	try { 
		// set styles for browsers with CSS3 selectors (Safari, Chrome)
		document.styleSheets[0].insertRule(
			'.typeface-js-selected-text::selection { background: blue; }', 
			styleSheet.cssRules.length
		); 

	} catch(e) {};

	// most unfortunately, sniff for WebKit's quirky selection behavior
	if (/WebKit/i.test(navigator.userAgent)) {
		document.styleSheets[0].insertRule(
			'.typeface-js-vector-container { position: relative }',
			styleSheet.cssRules.length
		);
	}

}

var backend = !!(window.attachEvent && !window.opera) ? 'vml' : window.CanvasRenderingContext2D || document.createElement('canvas').getContext ? 'canvas' : null;

if (backend == 'vml') {

	document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML");

	var styleSheet = document.createStyleSheet();
	styleSheet.addRule('v\\:shape', "display: inline-block;");
}

_typeface_js.setVectorBackend(backend);
window._typeface_js = _typeface_js;
	
if (/WebKit/i.test(navigator.userAgent)) {

	var _typefaceTimer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			_typeface_js.initialize(); 
		}
	}, 10);
}

if (document.addEventListener) {
	window.addEventListener('DOMContentLoaded', function() { _typeface_js.initialize() }, false);
} 

/*@cc_on @*/
/*@if (@_win32)

document.write("<script id=__ie_onload_typeface defer src=//:><\/script>");
var script = document.getElementById("__ie_onload_typeface");
script.onreadystatechange = function() {
	if (this.readyState == "complete") {
		_typeface_js.initialize(); 
	}
};

/*@end @*/

try { console.log('initializing typeface.js') } catch(e) {};

})();

if (_typeface_js && _typeface_js.loadFace) _typeface_js.loadFace({"glyphs":{"S":{"x_min":62.015625,"x_max":836,"ha":907,"o":"m 62 319 l 182 330 q 222 207 190 255 q 320 130 253 159 q 470 101 386 101 q 600 123 543 101 q 684 184 656 145 q 712 269 712 223 q 685 351 712 316 q 597 410 658 386 q 424 458 558 425 q 236 520 289 491 q 132 612 166 557 q 98 736 98 668 q 139 876 98 811 q 262 976 181 942 q 441 1010 342 1010 q 632 973 549 1010 q 760 867 715 937 q 804 709 804 797 l 683 709 q 615 846 673 798 q 446 894 558 894 q 275 850 329 894 q 222 745 222 806 q 259 657 222 691 q 454 586 297 622 q 670 523 611 550 q 795 421 755 483 q 836 280 836 360 q 791 131 836 201 q 663 21 746 60 q 475 -17 579 -17 q 253 22 342 -17 q 112 140 163 61 q 62 319 62 219 "},"¦":{"x_min":125,"x_max":229,"ha":353,"o":"m 229 1010 l 229 475 l 125 475 l 125 1010 l 229 1010 m 229 244 l 229 -292 l 125 -292 l 125 244 l 229 244 "},"/":{"x_min":0,"x_max":378.15625,"ha":378,"o":"m 0 -17 l 282 1010 l 378 1010 l 96 -17 l 0 -17 "},"y":{"x_min":21.9375,"x_max":668.59375,"ha":681,"o":"m 84 -277 l 71 -162 q 139 -173 110 -173 q 203 -159 179 -173 q 242 -121 227 -145 q 279 -30 253 -103 q 289 0 282 -20 l 21 720 l 150 720 l 297 303 q 348 136 326 224 q 398 300 369 220 l 548 720 l 668 720 l 400 -12 q 332 -175 356 -130 q 259 -263 301 -235 q 161 -292 218 -292 q 84 -277 126 -292 "},"Á":{"x_min":-2,"x_max":909.84375,"ha":908,"o":"m -2 0 l 372 993 l 511 993 l 909 0 l 762 0 l 649 301 l 241 301 l 134 0 l -2 0 m 279 408 l 609 408 l 507 683 q 438 889 461 808 q 386 699 420 793 l 279 408 m 359 1054 l 447 1244 l 604 1244 l 458 1054 l 359 1054 "},"g":{"x_min":44,"x_max":666,"ha":757,"o":"m 66 -59 l 184 -77 q 224 -157 191 -132 q 345 -191 269 -191 q 473 -157 428 -191 q 534 -62 518 -123 q 544 94 544 -25 q 348 0 465 0 q 123 107 203 0 q 44 363 44 214 q 80 554 44 466 q 186 688 117 641 q 349 736 255 736 q 555 632 474 736 l 555 720 l 666 720 l 666 97 q 632 -140 666 -70 q 526 -251 598 -210 q 347 -292 453 -292 q 143 -234 221 -292 q 66 -59 66 -176 m 166 372 q 222 166 166 231 q 360 101 277 101 q 498 165 442 101 q 554 368 554 230 q 496 567 554 500 q 358 635 439 635 q 222 568 278 635 q 166 372 166 502 "},"²":{"x_min":16.953125,"x_max":431,"ha":454,"o":"m 16 497 q 48 574 20 535 q 185 703 90 632 q 299 794 281 774 q 324 851 324 822 q 300 904 324 883 q 232 926 277 926 q 166 910 188 926 q 131 848 145 894 l 30 859 q 97 970 50 934 q 234 1006 145 1006 q 381 966 334 1006 q 428 868 428 926 q 388 760 428 811 q 252 644 359 722 q 174 579 197 603 l 431 579 l 431 497 l 16 497 "},"ë":{"x_min":50,"x_max":700.046875,"ha":757,"o":"m 573 232 l 696 216 q 588 45 667 106 q 386 -16 509 -16 q 140 81 231 -16 q 50 354 50 178 q 141 635 50 535 q 379 736 233 736 q 610 638 520 736 q 700 361 700 539 q 700 329 700 350 l 177 329 q 236 147 177 210 q 385 84 296 84 q 498 119 451 84 q 573 232 545 154 m 182 429 l 574 429 q 529 565 566 520 q 379 636 471 636 q 239 579 296 636 q 182 429 182 523 m 189 861 l 189 1000 l 314 1000 l 314 861 l 189 861 m 437 861 l 437 1000 l 562 1000 l 562 861 l 437 861 "},"Î":{"x_min":-21.203125,"x_max":399.546875,"ha":378,"o":"m 127 0 l 127 994 l 256 994 l 256 0 l 127 0 m 190 1170 l 115 1055 l -21 1055 l 122 1244 l 250 1244 l 399 1055 l 263 1055 l 190 1170 "},"e":{"x_min":50,"x_max":700.046875,"ha":757,"o":"m 573 232 l 696 216 q 588 45 667 106 q 386 -16 509 -16 q 140 81 231 -16 q 50 354 50 178 q 141 635 50 535 q 379 736 233 736 q 610 638 520 736 q 700 361 700 539 q 700 329 700 350 l 177 329 q 236 147 177 210 q 385 84 296 84 q 498 119 451 84 q 573 232 545 154 m 182 429 l 574 429 q 528 565 566 520 q 379 636 471 636 q 239 579 296 636 q 182 429 182 523 "},"Ã":{"x_min":-2.28125,"x_max":909.609375,"ha":908,"o":"m -2 0 l 371 993 l 510 993 l 909 0 l 762 0 l 649 301 l 241 301 l 134 0 l -2 0 m 278 408 l 609 408 l 507 683 q 438 889 460 808 q 385 699 419 793 l 278 408 m 231 1054 q 269 1167 231 1125 q 366 1209 307 1209 q 478 1172 407 1209 q 541 1152 517 1152 q 573 1163 562 1152 q 589 1210 585 1175 l 675 1210 q 638 1094 675 1133 q 546 1056 602 1056 q 435 1094 503 1056 q 370 1119 390 1119 q 333 1102 347 1119 q 319 1054 319 1086 l 231 1054 "},"J":{"x_min":38,"x_max":575,"ha":681,"o":"m 38 281 l 158 297 q 195 142 158 184 q 299 100 233 100 q 383 122 348 100 q 432 184 419 145 q 446 308 446 223 l 446 993 l 575 993 l 575 316 q 545 123 575 191 q 452 18 515 54 q 301 -17 388 -17 q 105 58 173 -17 q 38 281 38 133 "},"»":{"x_min":93.046875,"x_max":662.609375,"ha":757,"o":"m 525 358 l 352 667 l 450 667 l 662 358 l 450 49 l 352 49 l 525 358 m 268 358 l 93 667 l 193 667 l 402 358 l 193 49 l 93 49 l 268 358 "},"©":{"x_min":2,"x_max":1005,"ha":1003,"o":"m 503 1011 q 750 944 630 1011 q 937 755 870 878 q 1005 499 1005 632 q 938 244 1005 366 q 753 55 872 122 q 503 -12 634 -12 q 254 55 373 -12 q 68 244 134 122 q 2 499 2 366 q 69 755 2 632 q 257 944 136 878 q 503 1011 377 1011 m 503 926 q 298 870 398 926 q 141 712 198 815 q 85 499 85 610 q 140 287 85 388 q 295 129 196 186 q 503 73 395 73 q 711 129 612 73 q 866 287 811 186 q 922 499 922 388 q 865 712 922 610 q 709 870 809 815 q 503 926 608 926 m 664 415 l 746 391 q 661 256 726 306 q 504 206 596 206 q 314 283 387 206 q 241 497 241 360 q 274 652 241 586 q 368 752 307 718 q 509 786 430 786 q 656 742 598 786 q 736 625 715 699 l 657 606 q 598 683 637 656 q 506 710 559 710 q 380 654 430 710 q 331 495 331 598 q 377 338 331 391 q 499 285 424 285 q 604 320 559 285 q 664 415 649 355 "},"˘":{"x_min":30.578125,"x_max":423.359375,"ha":453,"o":"m 341 993 l 423 993 q 362 862 413 908 q 227 817 311 817 q 91 862 142 817 q 30 993 40 907 l 112 993 q 149 923 121 946 q 223 901 176 901 q 304 923 277 901 q 341 993 332 945 "},"ò":{"x_min":45,"x_max":706,"ha":757,"o":"m 45 359 q 154 656 45 559 q 375 736 245 736 q 613 638 521 736 q 706 370 706 541 q 665 151 706 231 q 546 28 624 72 q 375 -16 468 -16 q 136 80 227 -16 q 45 359 45 177 m 167 359 q 227 153 167 221 q 375 84 286 84 q 523 153 464 84 q 583 364 583 222 q 523 566 583 497 q 375 635 464 635 q 227 566 286 635 q 167 359 167 498 m 456 809 l 359 809 l 206 998 l 366 998 l 456 809 "},"^":{"x_min":35.890625,"x_max":602.796875,"ha":639,"o":"m 158 468 l 35 468 l 270 1011 l 366 1011 l 602 468 l 482 468 l 318 872 l 158 468 "},"«":{"x_min":89.0625,"x_max":658.625,"ha":757,"o":"m 225 358 l 398 49 l 301 49 l 89 358 l 301 667 l 399 667 l 225 358 m 483 358 l 658 49 l 557 49 l 349 358 l 557 667 l 658 667 l 483 358 "},"D":{"x_min":105,"x_max":911,"ha":983,"o":"m 105 0 l 105 993 l 440 993 q 614 978 554 993 q 757 907 698 959 q 872 737 834 841 q 911 501 911 634 q 885 301 911 388 q 818 156 859 214 q 729 66 778 99 q 613 16 681 33 q 456 0 545 0 l 105 0 m 234 117 l 442 117 q 593 135 538 117 q 680 186 648 153 q 752 312 726 233 q 778 503 778 391 q 727 743 778 659 q 605 855 677 827 q 438 876 553 876 l 234 876 l 234 117 "},"ⁿ":{"x_min":54,"x_max":443,"ha":496,"o":"m 54 352 l 54 803 l 140 803 l 140 755 q 202 797 167 783 q 278 812 236 812 q 371 790 334 812 q 426 735 409 769 q 443 627 443 700 l 443 352 l 349 352 l 349 623 q 327 706 349 683 q 260 730 305 730 q 177 698 207 730 q 148 597 148 667 l 148 352 l 54 352 "},"ÿ":{"x_min":21.4375,"x_max":668.25,"ha":680,"o":"m 83 -277 l 70 -162 q 139 -173 109 -173 q 202 -159 178 -173 q 242 -121 226 -145 q 278 -30 253 -103 q 289 0 282 -20 l 21 720 l 150 720 l 297 303 q 348 136 325 224 q 397 300 369 220 l 548 720 l 668 720 l 399 -12 q 332 -175 356 -130 q 259 -263 300 -235 q 161 -292 218 -292 q 83 -277 126 -292 m 161 861 l 161 1000 l 286 1000 l 286 861 l 161 861 m 409 861 l 409 1000 l 534 1000 l 534 861 l 409 861 "},"￼":{"x_min":0,"x_max":1361,"ha":1361,"o":"m 1361 778 l 1295 778 l 1295 930 l 1146 930 l 1146 998 l 1361 998 l 1361 778 m 979 930 l 764 930 l 764 998 l 979 998 l 979 930 m 1361 390 l 1295 390 l 1295 609 l 1361 609 l 1361 390 m 1184 414 q 1044 251 1184 251 q 952 281 987 251 l 1000 334 q 1043 317 1017 317 q 1107 411 1107 317 l 1107 738 l 1184 738 l 1184 414 m 597 930 l 382 930 l 382 998 l 597 998 l 597 930 m 1361 0 l 1146 0 l 1146 68 l 1295 68 l 1295 219 l 1361 219 l 1361 0 m 946 400 q 763 259 946 259 l 604 259 l 604 739 l 760 739 q 926 612 926 739 q 867 514 926 551 q 946 400 946 483 m 214 930 l 66 930 l 66 778 l 0 778 l 0 998 l 214 998 l 214 930 m 979 0 l 764 0 l 764 68 l 979 68 l 979 0 m 568 498 q 513 316 568 381 q 357 251 458 251 q 201 316 255 251 q 148 498 148 381 q 201 681 148 616 q 357 747 255 747 q 513 681 458 747 q 568 498 568 616 m 66 390 l 0 390 l 0 609 l 66 609 l 66 390 m 597 0 l 382 0 l 382 68 l 597 68 l 597 0 m 214 0 l 0 0 l 0 219 l 66 219 l 66 68 l 214 68 l 214 0 m 849 605 q 740 673 849 673 l 681 673 l 681 541 l 748 541 q 849 605 849 541 m 869