//AJAX - INICIO
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}


//Fila de conexões
fila=[]
ifila=0

//Carrega via XMLHTTP a url recebida e coloca seu valor
//no objeto com o id recebido
function ajaxHTML(id,url,t){
    //Carregando...
	if(t==0){
    document.getElementById(id).innerHTML='<div class="carregando">Carregando...</div>'
	}else if(t==2){
	document.getElementById('optCarrega').text='Carregando...'
	}else{
	
	}
	
    //Adiciona à fila
    fila[fila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((ifila+1)==fila.length)ajaxRun(t)
}

//Executa a próxima conexão da fila
function ajaxRun(t){
    //Abre a conexão
	if(t==0 || t == 2){
	    xmlhttp.open("GET",fila[ifila][1],true);
	}else{
		xmlhttp.open("POST", fila[ifila][1], true);
	    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
			if(t==0){
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "))
			document.getElementById(fila[ifila][0]).innerHTML=retorno
			}else if(t==2){
			retorno = unescape(xmlhttp.responseText.replace(/\+/g," "))
			//define e limpa o combo
			var cbo;
			cbo = document.getElementById('unidades');
			cbo.length = 1
			if(retorno != 'N/A'){
            retorno = new String(retorno)
			retorno2 = retorno.split("|")
			var xfor = retorno2.length-1
			//adiciona opçoes
			var oOption;
			for(i=0;i<=xfor;i++){
				retorno3 = new String(retorno2[i]);
				retorno4 = retorno3.split(";");
				oOption = document.createElement('OPTION');
				oOption.text = retorno4[0];
				oOption.value = retorno4[1];
				cbo.options.add(oOption);
			}
			document.getElementById('optCarrega').text='Selecione a Unidade'
			}else{
			document.getElementById('optCarrega').text='Nenhuma Unidade Encontrada'
			}
			
			}
            //Roda o próximo
            ifila++
            if(ifila<fila.length)setTimeout("ajaxRun()",20)
        }
    }
    //Executa
    xmlhttp.send(null)
}


atual=0

function carrega(n,p,t){
    //Carrega o HTML
	//t = 1 = xml
	//t = 0 = texto
	if(t==0){
    ajaxHTML(n,'pagina.asp?n='+p+'&rnd='+PegaRND(),t);
	}else{
	ajaxHTML(n,p+'&rnd='+PegaRND(),t);
	}
	return false;
}


function PegaRND(){
	var now = new Date();
	return now.getTime();
};


//AJAX - FIM
//goodies
modoTexto = 0
tms = new Array()
zindex = 100
function over(n){
	zindex += 1
    if(typeof(tms[n])!="undefined")clearTimeout(tms[n])
    document.getElementById("s"+n).style.display="block";
	document.getElementById("s"+n).style.zIndex=zindex;
	if(document.getElementById("estado"))document.getElementById("estado").style.display="none";
	if(document.getElementById("unidades"))document.getElementById("unidades").style.display="none";
//	if(!document.getElementById("unidades")){
//		continue;
//	}else{
//		alert('não encontrou');
//		document.getElementById("unidades").style.display="none";
//	}


}

function out(n){
	if(modoTexto==0){
	tms[n]=setTimeout('document.getElementById("s'+n+'").style.display="none";if(document.getElementById("estado"))document.getElementById("estado").style.display="block";if(document.getElementById("unidades"))document.getElementById("unidades").style.display="block"',500);
	}
}

function hideDiv(n){
	if(modoTexto==0){
	tms[n]=setTimeout('document.getElementById("'+n+'").style.display="none"',100);
	};
	return false;
}
function showDv(n){
	tms[n]=setTimeout('document.getElementById("'+n+'").style.display="block"',100);
}



	function trocacss(css,modo){
		modoTexto = modo;
		var documento = document.styleSheets[0].imports[0];
		documento.href = css;
	}
	
	//popups
	
function AbrePopups(URL,janela,largura,altura,scrolls,status,toolbar,menubar,resizable,fullscreen) {

if (scrolls==''){
alert(janela);
myscrolls = 'no';
}else{
myscrolls = scrolls;
}
//status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no'
if(status==''){
mystatus = 'no';
}else{
mystatus = status;
}
if(toolbar==''){
mytoolbar = 'no';
}else{
mytoolbar = toolbar;
}
if(menubar==''){
mymenubar = 'no';
}else{
mymenubar = menubar;
}
if(resizable==''){
myresizable = 'no';
}else{
myresizable = resizable;
}
if(fullscreen==''){
myfullscreen = 'no';
}else{
myfullscreen = fullscreen;
}



var width = largura;
var height = altura;
var aw = screen.availWidth;
var ah = screen.availHeight;
var myleft = (aw - width)/2;
var mytop = (ah - height)/2;
if (myleft < 0){
myleft = 0;
}

if(mytop < 0){
mytop = 0;
}

   window.open(URL,janela, 'width='+width+', height='+height+', top='+mytop+', left='+myleft+', scrollbars='+myscrolls+', status='+mystatus+', toolbar='+mytoolbar+', location=no, directories=no, menubar='+mymenubar+', resizable='+myresizable+', fullscreen='+myfullscreen);

}


function Favoritos(){
	pagina = 'http://www.bitcompany.com.br'
	titulo = 'Bit Company'
	descricao = '<span class="adicfavoritos">Adicionar aos<br />Favoritos</span>'
	// Internet Explorer
	if(window.external)document.write("<a href=\"javascript:window.external.AddFavorite('"+pagina+"','"+titulo+"');\">"+descricao+"</a>");
	else
	// Gecko (Mozilla, Firefox, Firebird & Netscape)
	if(window.sidebar)document.write("<a href=\"javascript:window.sidebar.addPanel('"+titulo+"','"+pagina+"','');\">"+descricao+"</a>");
	else
	// Opera & Outros
	document.write("<a href='"+pagina+"' rel='sidebar' title='"+titulo+"'>"+descricao+"</a>");
}

function LiberaCampos(){
	sel = document.getElementById('cbxUnidade');
	if(sel.value != ''){
		document.getElementById('txtLogin').disabled=false;
		document.getElementById('txtLogin').style.background='#FFFFFF';
		document.getElementById('txtPassword').disabled=false;
		document.getElementById('txtPassword').style.background='#FFFFFF';
		document.getElementById('bitnetEnviar').disabled=false;
		document.getElementById('bitnetEnviar').style.background='#FFFFFF';
	}else{
		document.getElementById('txtLogin').disabled=true;
		document.getElementById('txtLogin').style.background='#dbdbdb';
		document.getElementById('txtPassword').disabled=true;
		document.getElementById('txtPassword').style.background='#dbdbdb';
		document.getElementById('bitnetEnviar').disabled=true;
		document.getElementById('bitnetEnviar').style.background='#dbdbdb';
	}
}

function SetaCacheCursos(t){
		var contorig = document.getElementById('cursosnaveg');
		var cache = document.getElementById('cursosnavegcache');
		if(t==1){
		contorig.innerHTML = cache.innerHTML;
		}else{
		cache.innerHTML = contorig.innerHTML;
		};
}
function addOpt(){
		numopts = document.getElementById('numopts');
		numopts.value++;
		optatual = 'opcao'+numopts.value;
		lista = document.getElementById('listaopts');
		li = document.createElement('LI');
		input = document.createElement('INPUT');
		input.setAttribute('maxlength','100');
		input.setAttribute('id',optatual);
		input.setAttribute('name',optatual);
		input.setAttribute('type','text');
		li.appendChild(input);
		lista.appendChild(li);
		optcriada = document.getElementById(optatual);
		optcriada.focus();
}

function validanumber(campo,cp)
{
  var checkOK = "0123456789";
  var qtde = "qtd_" + cp
  var checkStr = campo;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
	document.frmCompra.letras.value = '1';
    alert("Digite apenas números na quantidade");	
	return (false);
  }	
	document.frmCompra.letras.value = '2';		
	return (true);
}

<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
<!-- Mensagem -->
function message()
{
window.status = "BIT Company - Educação e Tecnologia"
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
var rand1 = 0;
var useRand = 0;

images = new Array;
images[1] = new Image();
images[1].src = "images/deptet03.jpg";
images[2] = new Image();
images[2].src = "images/deptet01.jpg";
images[3] = new Image();
images[3].src = "images/deptet02.jpg";
images[4] = new Image();
images[4].src = "images/deptet03.jpg";
images[5] = new Image();
images[5].src = "images/deptet04.jpg";
images[6] = new Image();
images[6].src = "images/deptet05.jpg";
images[7] = new Image();
images[7].src = "images/deptet06.jpg";
images[8] = new Image();
images[8].src = "images/deptet07.jpg";
images[9] = new Image();
images[9].src = "images/deptet08.jpg";
images[10] = new Image();
images[10].src = "images/deptet09.jpg";
images[11] = new Image();
images[11].src = "images/deptet10.jpg";
images[12] = new Image();
images[12].src = "images/deptet11.jpg";
images[13] = new Image();
images[13].src = "images/deptet12.jpg";
images[14] = new Image();
images[14].src = "images/deptet13.jpg";
images[15] = new Image();
images[15].src = "images/deptet14.jpg";
images[16] = new Image();
images[16].src = "images/deptet15.jpg";

function swapPic() {
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg.src = images[useRand].src;
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
  newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//DG função de ocultar e desocultar questões do faq da bit company
function sR(n){
	sRN();
	if(document.getElementById("rsp"+n).style.display=="block"){
		document.getElementById("rsp"+n).style.display="none";
	}else{
		document.getElementById("rsp"+n).style.display="block";
	}
}

function sRA(){
	for(i=1;i<=24;i++){
		document.getElementById("rsp"+i).style.display="block";
	}
//	document.getElementById("principal").style.height="3400px";
//	document.getElementById("menuesquerdo").style.height="3400px";
}
function sRN(){
	for(i=1;i<=24;i++){
		document.getElementById("rsp"+i).style.display="none";
	};
//	document.getElementById("principal").style.height="800px";
//	document.getElementById("menuesquerdo").style.height="800px";
}
