// Thanks to Marko Dugonjic 
// http://www.maratz.com
var fontList = function(user_fonts) {
    var obj = document.getElementById('font_getter'),
        fonts;
    if (typeof(user_fonts) != 'undefined') {
        /* getURL works well in Safari, Opera nad Firefox, but poorly in IE */
        fonts = unescape(user_fonts);
    } else if (typeof(obj.GetVariable) != 'undefined') {
        /* element.GetVariable doesn't work in Opera and Safari,
        but works well in IE where JavaScript directly speaks with Flash */
        fonts = obj.GetVariable('/:user_fonts');
    };
    if(typeof(fonts) == 'string') {
        /* convert string to array */
        fonts = fonts.split(',');
    };
    return fonts;
};

// Thanks to Hannes Pfeiffer
// http://www.pfeiffer.it
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();
function getFontList() {
	var fonts = fontList();
	http.open('post','fontstat.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.send('fonts='+fonts);
	http.send('os='+navigator.platform);
}

// Thanks to Myself
// http://www.manuelbieh.de
window.onload = getFontList();
