// JavaScript Document
function cbXMLHttpRequest(r)
{
    var
	XHR = null,
	browserUtente = navigator.userAgent.toUpperCase();

    if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
    XHR = new XMLHttpRequest();

    else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0)
	{
        if(browserUtente.indexOf("MSIE 5") < 0)
            XHR = new ActiveXObject("Msxml2.XMLHTTP");
        else
            XHR = new ActiveXObject("Microsoft.XMLHTTP");
	}
    return XHR;
}

function changeLang(lang)
{
	var req = cbXMLHttpRequest(Math.random());
    switch (lang)
	{
	    case 'en':
		    req.open("get", "lang/intro_en.txt", true);
			req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
			req.send(null);
			req.onreadystatechange = function() {
                if(req.readyState === 4)
				{
                    if(req.status == 200)
					{
                        document.getElementById("content").innerHTML = req.responseText;
					}
					else
					    alert("Error... sorry, it's impossible to change language.");
                }
            }
			break;
		
		case 'it':
		    location.href = "index.php";
			break;
			
		default:
		    location.href = "index.php";
	}
}
