/**
 * 
 * All content on this website (including text, images, source
 * code and any other original works), unless otherwise noted,
 * is licensed under a Creative Commons License.
 * 
 * http://creativecommons.org/licenses/by-nc-sa/2.5/
 * 
 * Copyright (C) 2004-2007 Open-Xchange, Inc.
 * Mail: info@open-xchange.com 
 * 
 * @author Viktor Pracht <viktor.pracht@open-xchange.com>
 * @author Stefan Preuss <stefan.preuss@open-xchange.com>
 * 
 */

var match = /(\w+)([-_](\w+))?/.exec(navigator.language || navigator.userLanguage);
var lang = "de_DE";
if (match) {
	if (match[2]) {
		lang = match[1].toLowerCase() + "_" + match[3].toUpperCase();
		if (!{"de_DE": true, "en_US": true, "fr_FR": true}[lang])
			lang = {de: "de_DE", en: "en_US", fr: "fr_FR"}[match[1].toLowerCase()] || "de_DE";
	} else
		lang = {de: "de_DE", en: "en_US", fr: "fr_FR"}[match[1].toLowerCase()] || "de_DE";
}

function testAJAX() {
	try {
		if (new XMLHttpRequest()) return true;
	} catch (e) {
		try {
			if (new ActiveXObject("Msxml2.XMLHTTP")) return true;
		} catch (e) {
			try {
				if (new ActiveXObject("Microsoft.XMLHTTP")) return true;
			} catch (e) {
				return false;
			}
		}
	}
	return false;
}

function write(text, allow) {
	document.getElementById("browserchecktext_id").innerHTML=text;
	if (allow)
		document.getElementById("browsercheck_button").style.display="";
	else
		document.getElementById("browsercheck_button").style.display="none";
}

function ok() {
	write("Redirecting...");
	window.location = "ox.html" + window.location.hash;
}
function success() {
	window.location = "ox.html" + window.location.hash;
}

var JavaScriptWorks = false;

function check() {	
	if (navigator.appName == "Microsoft Internet Explorer") {
		var version = Number(navigator.appVersion.match(/MSIE (\d+\.\d+)/)[1]);
		if (version < 6) {			
			write("Your Internet Explorer version is not supported.<br>Please update to a newer version.");
		} else if (version == 6) {
			if (lang == "fr_FR") {
				write("<b>Information:</b><br>"
					+ "Il semble que vous n'utilisez pas le navigateur web le plus adapt&eacute; &agrave; cette application.<br>"
					+ "Un des navigateurs suivants devraient contribuer &agrave; am&eacute;liorer les performances:<br>"
					+ "<ul><li>Firefox &agrave; partir de la version 2.0 - <a href=\"http://www.firefox.com\">www.firefox.com</a></li>"
					+ "<li>Internet Explorer 7 - <a href=\"http://www.microsoft.com/windows/downloads/\">www.microsoft.com</a></li></ul>", true);
			} else if (lang == "en_US") {
				write("<b>Information:</b><br>"
					+ "It has been identified that you are not using the most optimal web browser for this application.<br>"
					+ "One of the following should help improve performance:<br>"
					+ "<ul><li>Firefox from 2.0 - <a href=\"http://www.firefox.com\">www.firefox.com</a></li>"
					+ "<li>Internet Explorer 7 - <a href=\"http://www.microsoft.com/windows/downloads/\">www.microsoft.com</a></li></ul>", true);
			} else {
				write("<b>Information:</b><br>"
					+ "Sie verwenden nicht den optimalen Browser f&uuml;r diese Anwendung.<br>"
					+ "Der Einsatz eines der folgenden Browser sollte die Leistung verbessern:<br>"
					+ "<ul><li>Firefox ab Version 2.0 - <a href=\"http://www.firefox.com\">www.firefox.com</a></li>"
					+ "<li>Internet Explorer 7 - <a href=\"http://www.microsoft.com/windows/downloads/\">www.microsoft.com</a></li></ul>", true);
			}		
		} else ok();
	} else if (navigator.appName == "Netscape" && navigator.appVersion.indexOf("KHTML") < 0) {
		var version = Number(navigator.userAgent.match(/rv:(\d+\.\d+)/)[1]);
		if (version < 1.8)
			write("Your Mozilla version is not supported.<br>Please update to a newer version.");
		else ok();
	} else if (!testAJAX())
		write("Your browser does not support AJAX (the XMLHttpRequest object).");
	else write("Your browser is not supported. Continue at your own risk.", true);
	JavaScriptWorks = true;
}
