function getWindowWidth() {
	if (typeof(window.innerWidth) == 'number') return window.innerWidth; // Non-IE
	if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; // IE 6+ in 'standards compliant mode'
	if (document.body && document.body.clientWidth) return document.body.clientWidth; // IE 4 compatible
	return 0;
}


function getWindowHeight() {
	if (typeof(window.innerHeight) == 'number') return window.innerHeight; // Non-IE
	if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; // IE 6+ in 'standards compliant mode'
	if (document.body && document.body.clientHeight) return document.body.clientHeight; // IE 4 compatible
	return 0;
}


function getIsFlashVersion(major, minor) {
    if (window.navigator.plugins["Shockwave Flash"] ) { // this only works by Netscape/Mozilla/Firefox, as M$IE does not have plugins
        var plugin = window.navigator.plugins["Shockwave Flash"];
        if (!plugin) return false;

        var mime = plugin["application/x-shockwave-flash"];
        if (!mime) return false;
        if (mime.type != "application/x-shockwave-flash") return false;
        var enabledPlugin = mime.enabledPlugin;
        if (!enabledPlugin || (enabledPlugin.filename != plugin.filename)) return false;
        
        // searching for version number in description text (for example: "Shockwave Flash 7.0 r19" will return "7" and "0")
        versionCatcher = new RegExp('^.+ ([0-9]+)\.([0-9]+) .+$');
        if (!versionCatcher.test(plugin.description)) return false;
        version = versionCatcher.exec(plugin.description);
        versMajor = version[1];
        versMinor = version[2];
        versionCatcher = null;
        
        if (versMajor < major) return false;
        else if ((versMajor == major) && (versMinor < minor)) return false;
        
        return true;
    }
    
    // This is used by M$IE. Netscape/Mozilla/Firefox will return false, as there are no ActiveX objects in them.
    isFlash = true;
    try {
        obj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
    }
    catch (e) {
        isFlash = false;
    }
    if (isFlash) {
        var version = obj.FlashVersion();
        if ((version >> 16) < major) isFlash = false;
        else if (((version >> 16) == major) && ((version & 0xFFFF) < minor)) isFlash = false;
        obj = null;
    }
    return isFlash;
}
    

function createHttpRequester() {
	if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
		try {
			return new XMLHttpRequest();
		} 
		catch(e) {}
	} 
	else if (window.ActiveXObject) { // IE/Windows ActiveX version
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(e) {}
		}
	}
	return null;
}


function getRemoteFile(url, doReturnXml, callbackFunc, callbackData) {
	var xmlHttp = createHttpRequester();
	if (xmlHttp == null) return null;
	try {
		var isAsync = (callbackFunc != null);
		xmlHttp.open("GET", url, isAsync);
		xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		
		if (isAsync) {
			xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					callbackFunc(doReturnXml ? xmlHttp.responseXML : xmlHttp.responseText, callbackData);
					delete xmlHttp.onreadystatechange;
				}
			};
		}
		
		xmlHttp.send("");
		if (isAsync) return null; // later
		if (doReturnXml) return xmlHttp.responseXML;
		return xmlHttp.responseText;
	}
	catch (e) {}
	return null;
}


function formatNumber(value, numDecimals, decimalChar) {
	if (numDecimals < 1) numDecimals = 1;
	if (numDecimals > 8) numDecimals = 8;
	if (decimalChar == null) decimalChar = ".";
	var factor = 1;
	for (var i = 0; i < numDecimals; i++) factor *= 10;
	value = Math.floor(factor * value) / factor;
	value = value.toString();
	var dotPos = value.indexOf(".");
	if (dotPos < 0) dotPos = value.indexOf(",");
	if (dotPos >= 0) {
		value = value.substring(0, dotPos) + decimalChar + value.substring(dotPos + 1);
		var numZerosToAdd = numDecimals - (value.length - dotPos);
		while (numZerosToAdd >= 0) {
			value += "0";
			numZerosToAdd--;
		}
	}
	else {
		value += decimalChar;
		for (var i = 0; i < numDecimals; i++) value += "0";
	}
	return value;
}


function constructMailLink(user, server) {
    return document.write("<a href='" + "mail" + "to:" + user + "@" + server + "'>" + user + "@" + server + "</a>");
}


function updateClock() {
	var currentTime = new Date(); 
	var currentHours = currentTime.getHours(); 
	var currentMinutes = currentTime.getMinutes(); 
	var currentSeconds = currentTime.getSeconds();
	currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes; 
	currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
	var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
	document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}


function track(str) {
    pageTracker._trackPageview(str);
}

