/* ----------------------------
 * Redsuns Tecnologia e Design
 * www.redsuns.com.br
 * contato at redsuns.com.br
 * ----------------------------
 * Projeto: Fix Futures 
 * Arquivo: logout.js
 * 
 * Ajax que chama arquivo para inserir a data de logout no sistema do usuario
 * quanto o mesmo fecha o navegador.
 */

var xmlhttp;

function LogOut(){
	
	if (logado){
		//alert("true");
		return;
	} else {
		//alert("Saindo do Trading System.");
	}
	
	xmlhttp = GetXmlHttpObject();
	
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}

	var url="logout.php";
	xmlhttp.onreadystatechange=RetornaLogOut;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
} 

function RetornaLogOut(){
	if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
		//Do nothing
	}
}

function GetXmlHttpObject(){
    try
    {
        // Firefox, Opera, Safari
        return new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
             return new ActiveXObject("Msxml2.XMLHTTP"); // 6.0+
        }
        catch (e)
        {
            return new ActiveXObject("Microsoft.XMLHTTP"); // 5.5+
        }
    }

	return null
}
