// JavaScript Document
// Carrega um arquivo com XMLHttpRequest
function carregar(id,Cid,arq){
	gE('preLoad').innerHTML = '<img src="anima/ajax-loaderD.gif">';
	var xmlHttp;
	try{
		xmlHttp = XMLHttpRequest();
	}
	catch(e){
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				xmlHttp = new ActiveXObject("microsoft.XMLHTTP");
			}
			catch(e){
				alert('Seu browse não suporta AJAX.');
				return false;
			}
		}
	}
	oarq = arq.substring(0,arq.indexOf('.'));
	postag = '';
//alert(oarq);
	switch(oarq){
		case 'site/areaRestrita':
			gE('fundo').style.display = 'block';
			gE('LB1').style.display = 'block';
			break;
		case 'sistema/apoio':
			postag = arq.substring(arq.indexOf('.')+1);
			arq  = oarq+'.php';
			break;
	}
// Indica o tipo de requisição
	var arq=arq;
	arq=arq+"?id="+id;
	arq=arq+"&sid="+Math.random();
	arq=arq+postag;
	xmlHttp.onreadystatechange=function(){
		 if(xmlHttp.readyState == 1 ){
		 }
		 if(xmlHttp.readyState == 4 ){
		 }
	}
	// Envia requisição
    xmlHttp.open("GET", arq, false );
    xmlHttp.send(null);
	
	// Recupera resposta
	document.getElementById(Cid).innerHTML = xmlHttp.responseText; // aqui funciona no FF com FALSE
//  resposta após o carregamento da pagina
	switch(oarq){
		case 'site/areaRestrita':
	//	alert(xmlHttp.responseText);
		//	alert(gE('Lemail').value);
			gE('fundo').onclick = fecharBL1;
			gE('Lbt').onclick = areaRest;
			gE('Lsenha').onkeypress = function(){return entrar();}
			break;
		case 'home':
			//carregar(2,'menuV','site/menuVisit.php');
			window.location.href = 'index.php';
			break;
		case 'sistema/apoio':
			gE('preLoad').innerHTML = '';
			return xmlHttp.responseText;
			break;
	}
	gE('preLoad').innerHTML = '';
}
/*--------------------------------------------------------------------*/
function OnEnter(evt)
{
    var key_code = evt.keyCode  ? evt.keyCode  :
                       evt.charCode ? evt.charCode :
                       evt.which    ? evt.which    : void 0;


    if (key_code == 13)
    {
        return true;
    }else if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
	{
		return true;
	} 
}
function entrar(e){
// if (!e) e = window.event;
//     if (e.keyCode) code = e.keyCode;
//     else if (e.which) code = e.which;
//     if (code == 13) {
//		return areaRest();
//    } else {
//       return true;
//     }
//}

try{
		e = window.event;
		var code = e.keyCode;
//		OnEnter(e);
	}catch(e){
		var code = e.which;
	//alert('tecla='+code+'-----------'+e.which);
	}
    if(code == 13){
		return areaRest();
    }
}  
	  
//    if(OnEnter(e))
//    {
//		return areaRest();
//	}
//    else
//    {
//        return true;
//    }

//e = e || window.event || event; var code = e.charCode || e.keyCode || e.which; if (code == 13) { return areaRest(); }
//}