var font = {
	testId:'fontInstalledTest',	// id of container and id-part of test elements
	testString:'mmmmmmmmmwwwwwww',	// chars for measure the length
	testFont:'"Comic Sans MS"',	// default font (be shure you not thest for this font!!)
	notInstalledWidth:0,	// width for default font
	ct:null, // container of test elements
	id:0,	// continous number for new test element

	/**
	 * check if a font is installed
	 * 
	 * @param String font
	 * @return boolean
	 */
	isInstalled : function(font) {
		this.setup();
		var width = this.getTest(font);
//		console.debug('Tested width: ' + width);
		return (width != this.notInstalledWidth);
	},
	/**
	 * initialize the test environment, automatic called by isInstalled
	 */
	setup : function () {
		if (this.ct != null) return;
			// create container
		this.ct = document.createElement('div');
		this.ct.setAttribute('id',this.testId);
		this.ct.style.position='absolute';
		this.ct.style.left='-9999px';
		this.ct.style.visibility='hidden';
			// set container into dom of body (only if exists)
//		var bodys = document.getElementsByTagName('body');
//		if(bodys.length > 0)
//			bodys.item(0).appendChild(this.ct);
		document.body.appendChild(this.ct);
			// apped first test object
		this.notInstalledWidth = this.getTest(this.testFont);
//		console.debug('Default width: ' + this.notInstalledWidth);
	},
	/**
	 * get width of text for specified font
	 * 
	 * @param String font
	 * @return integer
	 */
	getTest:function(font) {
		var txt = document.createElement('span');
		txt.setAttribute('id',this.testId + this.id++);
		txt.style.fontSize='50px';
		txt.style.fontFamily=font+', '+this.testFont;
		txt.appendChild(document.createTextNode(this.testString));
		this.ct.appendChild(txt);
		return txt.offsetWidth;
	}
};
