 // JavaScript Document

// abre uma nova janela com os parâmetros especificados e sem as opções básicas de janela
function novaJanela(url,width,height,left,top,scrol)
{
   window.open(url, 'titulo', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars='+scrol+', status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

// seleciona banner aleatóriamente

function publiBanner()
{
	function estImgUrl(arq,url,tipo)
		{
			this.arq = arq;
			this.url = url;
			this.tipo = tipo;
		}
			
	tabImgUrl = new estImgUrl (3)
	tabImgUrl [0] = new estImgUrl ("/swfs/sky_brasilia.swf","","swf");
	tabImgUrl [1] = new estImgUrl ("/swfs/sky_cursos.swf","","swf");
	tabImgUrl [2] = new estImgUrl ("/swfs/sky_email.swf","","swf");
	tabImgUrl [3] = new estImgUrl ("/swfs/sky_sempre_a_frente.swf","","swf");
	
	var bannerNumero = Math.floor(Math.random()*3);
	
	
	if (tabImgUrl[bannerNumero].tipo == 'gif')		
	document.write("<a href="+tabImgUrl[bannerNumero].url+" target=_blank><img src="+tabImgUrl[bannerNumero].arq+" width=120 height=420 border=0></a>");
		
	if (tabImgUrl[bannerNumero].tipo == 'jpg')
	document.write("<a href="+tabImgUrl[bannerNumero].url+" target=_blank><img src="+tabImgUrl[bannerNumero].arq+" width=120 height=420 border=0></a>");
		
	if (tabImgUrl[bannerNumero].tipo == 'swf')
	document.write("<object><embed src="+tabImgUrl[bannerNumero].arq+" height=420 width=120></embed></object>")

}

function ajax(url)
{
	req = null;
	
	if(window.ActiveXObject)
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if(req)
		{
			req.onreadystatechange = processReqChange;
			req.open("GET",url,true);
			req.send();
		}
	}
	//procura por um objeto nativo mozilla ou safari
	
	else if(window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
//		alert(processReqChange());
		req.open("GET",url,true);
//		alert(url);
		req.send(true);
	}


}

function processReqChange()
{
	
	//apenas quando o etado for "completo"
	if(req.readyState == 4)
	{
		
		//apenas se o servidor retornar OK
		if(req.status == 200)
		{
			//procura pela div 'id=pagina' e insere o conteúdo retornado nela como um texto html
			document.getElementById('atividades').innerHTML = req.responseText;
		}
		else
		{
			//insere mensagem de erro na div 'id=pagina'
			document.getElementById('atividades').innerHTML = 'Falha no carregamento!';
		}
	}
}
