var mensa = new Array();
// Set your messages below -- follow the pattern.
// To add more messages, just add more elements to the array.
mensa[0] = "Atenção, ";
mensa[1] = "Você recebeu uma nova mensagem";

// Set the number of repetitions (how many times the arrow
// cycle repeats with each message).
var reps	= 2;
var speed	= 200;  // Set the overall speed (larger number = slower action).

// DO NOT EDIT BELOW THIS LINE.
var p	= mensa.length;
var T	= "";
var C	= 0;
var mC	= 0;
var s	= 0;
var sT	= null;
if (reps < 1) reps = 1;

function exibe_mensa()
{
	document.frm1.sinal.value = '1';
	doTheThing();
}

function para_mens()
{
	document.frm1.sinal.value = '0';
}

function doTheThing() 
{
	if (document.frm1.sinal.value == '1')
	{
		T = mensa[mC];
		A();
	}
	else
		document.title = 'Atendimento ao cliente OnLine';
}

function A() 
{
	s++;
	if (s > 8) { s = 1;}
	// you can fiddle with the patterns here...
	if (s == 1) { document.title = '||||||====||| '+T+' -----'; }
	if (s == 2) { document.title = '|||=|||===||| '+T+' -----'; }
	if (s == 3) { document.title = '|||==|||==||| '+T+' -----'; }
	if (s == 4) { document.title = '|||===|||=||| '+T+' -----'; }
	if (s == 5) { document.title = '|||====|||||| '+T+' -----'; }
	if (s == 6) { document.title = '|||===|||=||| '+T+' -----'; }
	if (s == 7) { document.title = '|||==|||==||| '+T+' -----'; }
	if (s == 8) { document.title = '|||=|||===||| '+T+' -----'; }
	if (C < (8 * reps)) 
	{
		sT = setTimeout("A()", speed);
		C++;
	}
	else 
	{
		C = 0;
		s = 0;
		mC++;
		if(mC > p - 1) mC = 0;
		sT = null;
		doTheThing();
   }
}

function scroll()
{
	scrollingDiv=document.getElementById("mensagens");
	scrollingDiv.scrollTop=10000;
}

function scroll_cli()
{
	scrollingDiv=document.getElementById("mensagens_cli");
	scrollingDiv.scrollTop=10000;
}

function popup(w,h,www,scrolling)
{
	var height = window.screen.height - 160;
	var width = window.screen.width;
	var top = 100;
	var left = 100;
	var top = (height- h)/2;
	var left = (width - w)/2;
	window.open(www,"teste","top=" + top + ",left="+ left +",width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+scrolling+",scrolling=no,resizable=no")
}

function popup2(w,h,www,scrolling,nome)
{
	var height = window.screen.height - 160;
	var width = window.screen.width;
	var top = 100;
	var left = 100;
	var top = (height- h)/2;
	var left = (width - w)/2;
	window.open(www,nome,"top=" + top + ",left="+ left +",width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+scrolling+",scrolling=no,resizable=no")
}

function seta_recept(cod, nome, tipo)
{
	//marca o usuário com quem se esta falando
	
	document.frm1.cod.value = cod;
	document.frm1.nome.value = nome;

	$("#pessoa").empty();

	$("#pessoa").append(nome);

	document.frm1.tipo.value = tipo;

	document.frm1.chk_todos_ate.checked = false;
	document.frm1.chk_todos_cli.checked = false;

	document.frm1.mensagem.focus();
}

function cores(id)
{
	popup('200','230','cores.php?id=' + id,'no');
}

function cores_atend(id)
{
	popup('200','230','cores.php?id_atend=' + id,'no');
}

function pergs_padrao()
{
	popup('500','300','perguntas_padrao.php','yes');
}

function atedimentos()
{
	popup('500','500','atendimento.php','yes');
}

function foco_mens()
{
	document.frm1.mensagem.focus();
}

function mens_todos()
{
	mens = '';
	
	if (document.frm1.chk_todos_ate.checked)
		mens = 'Colaboradores';

	if (document.frm1.chk_todos_cli.checked)
		mens = 'Clientes';

	if (document.frm1.chk_todos_cli.checked && document.frm1.chk_todos_ate.checked)
		mens = 'Todos';

	if (mens!='')
	{
		$("#pessoa").empty();
		$("#pessoa").append(mens);

		//03/12/2008
		document.frm1.tipo.value = mens;
	}

	if (!document.frm1.chk_todos_cli.checked && !document.frm1.chk_todos_ate.checked)
		$("#pessoa").empty();

	foco_mens();
}

function derruba_cli(id)
{
	//desconecta o cliente do chat.
	var html = $.ajax({
	  url: "ajax_derruba_usu.php?cod_vistte=" + id,
	  async: false
	 }).responseText;
}


function popup_mens()
{
	var h = 100;
	var w = 100;
	var top = 100;
	var left = 100;
	window.open("./telas/nova_mens.html","teste","top=" + top + ",left="+ left +",width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,scrolling=no,resizable=no")
}

