// JavaScript Document
is_ie=(navigator.userAgent.toLowerCase().indexOf("msie")!=-1)?true:false;
appear = (is_ie==true)?"inline":"table-row";

try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function inicio()
{
	document.login.usuario.focus();
}

function validaLogin(nomeCampo)
{
	var usuario = document.getElementById("usuario").value;
	var senha = document.getElementById("senha").value;
	var Flag_ContinuarConectado = document.getElementById("Flag_ContinuarConectado").value;
	
	if (usuario == "")
	{		
		document.getElementById("usuario").style.background="#4F4F4F";
		document.getElementById("nota_usuario").innerHTML="&nbsp;<img src='imagens/nota.jpg' alt='Digite o login'>";
		document.getElementById("usuario").focus()
	}
	else
	{
		if (senha == "")
		{
			document.getElementById("senha").style.background="#4F4F4F";
			document.getElementById("nota_senha").innerHTML="&nbsp;<img src='imagens/nota.jpg' alt='Digita a senha'>";
			document.getElementById("senha").focus()
		}
	}

	if ((usuario !== "")&&(senha !== ""))
	{
		document.getElementById("validar").innerHTML="<span class='texto'>Processando...</span>"
		xmlhttp.open("GET", "include/validaLogin.asp?usuario="+ usuario +"&senha="+ senha +"&Flag_ContinuarConectado="+ Flag_ContinuarConectado,true);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)
				if (texto!==false){
					if (texto == "login_valido")
					{
						window.open('tarefas.asp?view=minhas_andamento','_top');
					}
					else
					{
						if (texto == "login_invalido")
						{
							alert("Dados incorretos!");
							document.getElementById("validar").innerHTML="<input type='button' name='validar' value='enviar' class='botao' onClick='validaLogin();'>"
							document.getElementById("usuario").value=""
							document.getElementById("senha").value=""
							document.getElementById("usuario").focus()
							
						}						
						else
						{
							if (texto !== "login_valido")
							{
								window.open('tarefa.asp?cod_tarefa='+texto,'_top');
							}
						}
					}
				}
			}
		}
	   xmlhttp.send(null) 
	}
}
/*
function desabilitaNota (nota)
{
	var nome = nota
	document.getElementById("nota_"+nota).innerHTML="&nbsp;";
	document.getElementById(nota).style.background="#000000";
}
*/
function Busca()
{
	var palavra = document.getElementById("palavra_busca").value
	if (palavra=="")
	{
		alert("Digite uma palavra.");
		document.getElementById("palavra_busca").focus()
	}
	else
	{
		if (palavra!=="")
		{
			ordenaTarefas('','data','',palavra,'','','','','','','','')

		}
	}
}

function BuscaAll()
{
	var palavra = document.getElementById("palavra_busca").value
	if (palavra=="")
	{
		alert("Digite uma palavra.");
		document.getElementById("palavra_busca").focus()
	}
	else
	{
		if (palavra!=="")
		{
			window.open("tarefas.asp?buscaAll="+palavra,"_top");
		}
	}
}

function ordenaTarefas(view,ordenacao,posicao,busca,filter_area,filter_usuario,filter_cliente,filter_periodo_de,filter_periodo_ate,filter_status,filter_projeto,filter_tarefa)
{
	var ordem = ordenacao
	var posicionamento = posicao
	var palavra = busca
	var visualiza = view
	
    var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
        loading = loading +"<tr><td width='40%'>&nbsp</td>"
        loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
        loading = loading +"<td width='100px'><img src='imagens/logo_weboffice2.jpg' /></td>"
        loading = loading +"<td width='40%'>&nbsp</td></tr></table>"

    document.getElementById("gridTarefas").innerHTML = loading
	xmlhttp.open("GET", "include/tarefas.asp?view="+ visualiza +"&order="+ ordem +"&Posicao="+ posicionamento +"&Busca="+ palavra +"&filter_area="+ filter_area +"&filter_usuario="+ filter_usuario +"&filter_cliente="+ filter_cliente +"&filter_periodo_de="+ filter_periodo_de +"&filter_periodo_ate="+ filter_periodo_ate +"&filter_status="+ filter_status +"&filter_projeto="+ filter_projeto +"&filter_tarefa="+ filter_tarefa,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){                    
			    document.getElementById("gridTarefas").innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 
}

function novaTarefa()
{
	window.open('nova_tarefa.asp','_top');
    /*
	var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>";
        loading = loading +"<tr><td width='40%'>&nbsp</td>";
        loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>";
        loading = loading +"<td width='100px'><img src='imagens/logo_weboffice2.jpg' /></td>";
        loading = loading +"<td width='40%'>&nbsp</td></tr></table>";
    var titulo = "<h2>cadastro de tarefas</h2>";
    document.getElementById("header_interna").innerHTML = titulo;
    document.getElementById("conteudo").innerHTML = loading;
	xmlhttp.open("GET", "include/nova_tarefa.asp");
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){                    
				document.getElementById("conteudo").innerHTML = texto
			}
		}
	}
   xmlhttp.send(null)
   */
}

function novaTarefa2()
{
    var avanca=""
    var msg=""

	var cliente_tarefa = document.getElementById("cliente_tarefa").value
    if (cliente_tarefa == "")
    {
        msg=msg+"O Cliente precisa ser selecionado.\n"
        avanca="1"
    } 
	
    var projeto_tarefa = document.getElementById("projeto_tarefa").value
	var projeto_tarefa_novo = document.getElementById("projeto_tarefa_novo").value
	if ((projeto_tarefa == "")&&(projeto_tarefa_novo == ""))
    {
        msg=msg+"Selecione um Projeto ou Crie um Novo.\n"
        avanca="1"
    }

    var titulo_tarefa = document.getElementById("titulo_tarefa").value
    if (titulo_tarefa == "")
    {
        msg=msg+"A Tarefa precisa ser preenchida.\n"
        avanca="1"
    }
    
    var prioridade_tarefa = document.getElementById("prioridade_tarefa").value
    if (prioridade_tarefa == "")
    {
        msg=msg+"A Prioridade precisa ser selecionada.\n"
        avanca="1"
    }
    
    var diaInicio_tarefa = document.getElementById("diaInicio_tarefa").value
    if (diaInicio_tarefa == "")
    {
        msg=msg+"O Dia de Início precisa ser preenchido.\n"
        avanca="1"
    }
    
    var mesInicio_tarefa = document.getElementById("mesInicio_tarefa").value
    if (mesInicio_tarefa == "")
    {
        msg=msg+"O Mês de Início precisa ser preenchido.\n"
        avanca="1"
    }    
    
    var anoInicio_tarefa = document.getElementById("anoInicio_tarefa").value
    if (anoInicio_tarefa == "")
    {
        msg=msg+"O Ano de Início precisa ser preenchido.\n"
        avanca="1"
    }
    
    var dataInicio_tarefa = anoInicio_tarefa+"-"+mesInicio_tarefa+"-"+diaInicio_tarefa+" 00:00:00.000"
    
    var diaFim_tarefa = document.getElementById("diaFim_tarefa").value
    if (diaFim_tarefa == "")
    {
        msg=msg+"O Dia de Fim precisa ser preenchido.\n"
        avanca="1"
    }    
    
    var mesFim_tarefa = document.getElementById("mesFim_tarefa").value
    if (mesFim_tarefa == "")
    {
        msg=msg+"O Mês de Fim precisa ser preenchido.\n"
        avanca="1"
    }
    
    var anoFim_tarefa = document.getElementById("anoFim_tarefa").value
    if (anoFim_tarefa == "")
    {
        msg=msg+"O Ano de Fim precisa ser preenchido.\n"
        avanca="1"
    }
    
    var dataFim_tarefa = anoFim_tarefa+"-"+mesFim_tarefa+"-"+diaFim_tarefa+" 00:00:00.000"
    
    /*
	var descricao_tarefa = document.getElementById("descricao_tarefa").value
    if (document.getElementById("descricao_tarefa").value == "")
    {
        msg=msg+"A Descrição precisa ser preenchida.\n"
        avanca="1"
    }
	*/
	if (msg!=="")
    {
        alert(msg);
    }
	
    var horas_exec = document.getElementById("horas_exec_estima").value
    var horas_design = document.getElementById("horas_design_estima").value
    var horas_ti = document.getElementById("horas_ti_estima").value

    var minutos_exec = document.getElementById("minutos_exec_estima").value
    var minutos_design = document.getElementById("minutos_design_estima").value
    var minutos_ti = document.getElementById("minutos_ti_estima").value

    if (avanca !== "1")
	
	{
		document.incluirTarefa.submit();
	}
    /*
	{
        var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
            loading = loading +"<tr><td width='40%'>&nbsp</td>"
            loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
            loading = loading +"<td width='100px'><img src='imagens/logo_weboffice2.jpg' /></td>"
            loading = loading +"<td width='40%'>&nbsp</td></tr></table>"
        var titulo = "<h2>cadastro de tarefas</h2>"
        
        document.getElementById("header_interna").innerHTML = titulo
        document.getElementById("conteudo").innerHTML = loading
	    xmlhttp.open("GET", "include/incluirTarefa.asp?projeto_tarefa="+ projeto_tarefa +"&projeto_tarefa_novo="+ projeto_tarefa_novo +"&titulo_tarefa="+ titulo_tarefa +"&cliente_tarefa="+ cliente_tarefa +"&prioridade_tarefa="+ prioridade_tarefa +"&dataInicio_tarefa="+ dataInicio_tarefa +"&dataFim_tarefa="+ dataFim_tarefa +"&descricao_tarefa="+ descricao_tarefa +"&horas_exec_estima="+ horas_exec +"&horas_design_estima="+ horas_design +"&horas_ti_estima="+ horas_ti +"&minutos_ti_estima="+ minutos_ti +"&minutos_design_estima="+ minutos_design +"&minutos_exec_estima="+ minutos_exec,true);
	    xmlhttp.onreadystatechange=function()
	    {
		    if (xmlhttp.readyState==4){
			    var texto=xmlhttp.responseText
			    texto=texto.replace(/\+/g," ")
			    texto=unescape(texto)
			    if (texto!==false){                    
			        if (texto=="0")
					{
						document.getElementById("conteudo").innerHTML = "Não foi possível criar esta tarefa."
					}
					else
					if (texto!=="0")
					{
						document.getElementById("conteudo").innerHTML = "Tarefa inserida com sucesso."
						//document.writeln(texto);
						avancaTela();
					}
					
			    }
		    }
	    }
       xmlhttp.send(null) 
    }
	*/
}

function avancaTela()
{

	var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
		loading = loading +"<tr><td width='40%'>&nbsp</td>"
		loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
		loading = loading +"<td width='100px'><img src='imagens/logo_weboffice2.jpg' /></td>"
		loading = loading +"<td width='40%'>&nbsp</td></tr></table>"
	var titulo = "<h2>cadastro de tarefas</h2>"
	
	document.getElementById("header_interna").innerHTML = titulo
	document.getElementById("conteudo").innerHTML = loading

	xmlhttp.open("GET", "include/nova_tarefa_2.asp",true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var exibe=xmlhttp.responseText
			exibe=exibe.replace(/\+/g," ")
			exibe=unescape(exibe)
			if (exibe!==false)
			{
				document.getElementById("conteudo").innerHTML = exibe
			}
		}
	}
	xmlhttp.send(null) 
}


function incluirDocumentos(tarefa,cliente)
{
    var msg = ""
    var avanca = ""
    var cod_tarefa = tarefa
    var cod_cliente = cliente
    var titulo_documento = document.getElementById("titulo_documento").value
    if (titulo_documento == "")
    {
        msg=msg+"O Título deve ser preenchido.\n"
        avanca="1"
    }

    var endereco_documento = document.getElementById("endereco_documento").value
    var documento = document.getElementById("documento").value
    if ((endereco_documento == "")&&(documento == ""))
    {
        msg=msg+"O Endereço do documento deve ser preenchido ou Upload de um arquivo deve ser realizado.\n"
        avanca="1"
    }
    
    if (msg!=="")
    {
        alert(msg);
    }
    
    if (avanca=="")
    {
        var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
            loading = loading +"<tr><td width='40%'>&nbsp</td>"
            loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
            loading = loading +"<td width='40%'>&nbsp</td></tr></table>"

        if (endereco_documento !== "")
        {
			document.getElementById("documentos").innerHTML = loading
            xmlhttp.open("GET", "include/incluirDocumentos.asp?titulo="+ titulo_documento +"&arquivo="+ endereco_documento +"&cod_tarefa="+ cod_tarefa +"&cod_cliente="+ cod_cliente +"&tipo=1",true);
	        xmlhttp.onreadystatechange=function()
	        {
		        if (xmlhttp.readyState==4){
			        var texto=xmlhttp.responseText
			        texto=texto.replace(/\+/g," ")
			        texto=unescape(texto)
			        if (texto!==false){                    
			            document.getElementById("documentos").innerHTML = texto
			        }
		        }
	        }
           xmlhttp.send(null) 
        }
        
        if (documento !== "")
        {
		   document.formulario_incluirDocumentos.submit();
        }
    }
}

function incluirParticipantes(selecao,codigo)
{
    var recurso = document.getElementById(selecao).value
    var tarefa = codigo
    xmlhttp.open("GET", "include/incluirParticipante.asp?cod_usuario="+ recurso +"&cod_tarefa="+ tarefa,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
	            document.getElementById("pessoas").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null) 
}

function incluirClientes(selecao,codigo)
{
    var cliente = document.getElementById(selecao).value
    var tarefa = codigo
    xmlhttp.open("GET", "include/incluirCliente.asp?cod_usuario="+ cliente +"&cod_tarefa="+ tarefa,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
	            document.getElementById("clientes").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null) 
}

function concluiTarefa2()
{
    window.open("tarefas.asp","_top");
}

function excluirParticipante(participante,tarefa)
{
	var participante = participante
	var tarefa = tarefa
    xmlhttp.open("GET", "include/excluirParticipante.asp?cod_usuario="+ participante +"&cod_tarefa="+ tarefa,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
				document.getElementById("pessoas").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null)
}

function excluirCliente(cliente,tarefa)
{
    xmlhttp.open("GET", "include/excluirCliente.asp?cod_usuario="+ cliente +"&cod_tarefa="+ tarefa,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
	            document.getElementById("clientes").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null)
}

function excluirDocumento(documento,tarefa)
{
    xmlhttp.open("GET", "include/excluirDocumentos.asp?cod_documento="+ documento +"&cod_tarefa="+ tarefa,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
	            document.getElementById("documentos").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null)
}

function visualizaTarefa(tarefa)
{
    window.open("tarefa.asp?cod_tarefa="+ tarefa,"_top");
}

/*
function inserirComentario(usuario,tarefa)
{
	var tipo = document.getElementById("tipo_comentario").value
	var comentario = document.getElementById("comentario").value
	var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
		loading = loading +"<tr><td width='40%'>&nbsp</td>"
		loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
		loading = loading +"<td width='40%'>&nbsp</td></tr></table>"	
	document.getElementById("aprovacao").innerHTML = loading
    xmlhttp.open("GET", "include/incluirComentario.asp?cod_usuario="+ usuario +"&cod_tarefa="+ tarefa +"&tipo_comentario="+ tipo +"&comentario="+ comentario,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
	            document.getElementById("aprovacao").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null)
}
*/

/*
function inserirConclusao(usuario,tarefa)
{
	var comentario = document.getElementById("conclusao").value
	var tipo = "Conclusão"
	var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
		loading = loading +"<tr><td width='40%'>&nbsp</td>"
		loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
		loading = loading +"<td width='40%'>&nbsp</td></tr></table>"	
	document.getElementById("concluido").innerHTML = loading
    xmlhttp.open("GET", "include/incluirConclusao.asp?cod_usuario="+ usuario +"&cod_tarefa="+ tarefa +"&tipo_comentario="+ tipo +"&comentario="+ comentario,true);
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4){
	        var texto=xmlhttp.responseText
	        texto=texto.replace(/\+/g," ")
	        texto=unescape(texto)
	        if (texto!==false){                    
	            document.getElementById("concluido").innerHTML = texto
	        }
        }
    }
   xmlhttp.send(null)
}
*/

function posiciona(ordenacao,view,filter_lst_area,filter_lst_usuarios,filter_lst_clientes,filter_periodo_de,filter_periodo_ate,filter_lst_status,filter_lst_projeto,filter_lst_tarefa)
{
	var posicao = document.getElementById("posicao").value
	var ordem = ordenacao
	var visualiza = view
	
	var area = ""
	if ((filter_lst_area !== "")&&(filter_lst_area !== 'undefined'))
	{
		area = filter_lst_area
	}

	var usuarios = ""
	if ((filter_lst_usuarios !== "")&&(filter_lst_usuarios !== 'undefined'))
	{
		usuarios = filter_lst_usuarios
	}
	
	var clientes = ""
	if ((filter_lst_clientes !== "")&&(filter_lst_clientes !== 'undefined'))
	{
		clientes = filter_lst_clientes
	}
	
	var periodo_de = ""
	if ((filter_periodo_de !== "")&&(filter_periodo_de !== 'undefined'))
	{
		periodo_de = filter_periodo_de
	}
	
	var periodo_ate = ""
	if ((filter_periodo_ate !== "")&&(filter_periodo_ate !== 'undefined'))
	{
		periodo_ate = filter_periodo_ate
	}
	
	var status_filter = ""
	if ((filter_lst_status !== "")&&(filter_lst_status !== 'undefined'))
	{
		status_filter = filter_lst_status
	}

	var projeto_filter = ""
	if ((filter_lst_projeto !== "")&&(filter_lst_projeto !== 'undefined'))
	{
		projeto_filter = filter_lst_projeto
	}

	var tarefa_filter = ""
	if ((filter_lst_tarefa !== "")&&(filter_lst_tarefa !== 'undefined'))
	{
		tarefa_filter = filter_lst_tarefa
	}

	posicao=posicao-1
	posicao=posicao*10
	ordenaTarefas(visualiza,ordem,posicao,'',area,usuarios,clientes,periodo_de,periodo_ate,status_filter,projeto_filter,tarefa_filter);
	
}

function editaData()
{
	document.getElementById("editData").style.display = appear
	document.getElementById("visuData").style.display = 'none';
	document.alteraData_tarefa.dataInicio_dia.focus();	
}

function SomenteNumero(tecla)
{
	if(typeof(tecla) == 'undefined')
	var tecla = window.event;
	var codigo = (tecla.which ? tecla.which : tecla.keyCode ? tecla.keyCode : tecla.charCode);
	
	if ((codigo >= 48 && codigo <= 57))
	{
		//alert(codigo);
	}
	else
	{
		if (codigo !== 8 && codigo !== 9 && codigo !== 46)
		{
			alert("Apenas nmeros so permitidos !");
			return false;
		}
	}
}


function validaDia(campo)
{
	var dia = document.getElementById(campo).value
	if ((dia == 0) || (dia > 31))
	{
		alert("Dia inválido.");
		document.getElementById(campo).value=""
	}
}

function validaMes(campo)
{
	var mes = document.getElementById(campo).value
	if ((mes == 0) || (mes > 12))
	{
		alert("Mês inválido.");
		document.getElementById(campo).value=""
	}
}

function validaAno(campo)
{
	var ano = document.getElementById(campo).value
	if (ano.length < 4)
	{
		alert("Ano inválido.");
		document.getElementById(campo).value=""
	}
}

function validaNovaDataInicio(tarefa)
{
	var campo = document.getElementById("Nova_DataInicio").value
	if (document.getElementById("Nova_DataInicio").value!="")
	{
		erro=0;
		hoje = new Date();
		anoAtual = hoje.getFullYear();
		barras = document.getElementById("Nova_DataInicio").value.split("/");
		if (barras.length == 3)
		{
		   dia = barras[0];
			mes = barras[1];
			ano = barras[2];
			resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano <= anoAtual && ano >= 1900));
			if (!resultado)
			{
				alert("Data inválida.");
				document.getElementById("Nova_DataInicio").focus();
				return false;
			}
		 } 
		 else
		 {
			 alert("Data inválida.");
			 document.getElementById("Nova_DataInicio").focus();
			 return false;
		 }

		xmlhttp.open("GET", "include/alteraData.asp?campo=Nova_DataInicio&cod_tarefa="+ tarefa +"&data="+ campo,true);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)
				if (texto!==false){
					document.getElementById("DataInicio").innerHTML = texto
				}
			}
		}
		xmlhttp.send(null)
		return true;
	}
}

function validaNovaDataFim(tarefa)
{
	var campo = document.getElementById("Nova_DataFim").value
	if (document.getElementById("Nova_DataFim").value!="")
	{
		erro=0;
		hoje = new Date();
		anoAtual = hoje.getFullYear();
		barras = document.getElementById("Nova_DataFim").value.split("/");
		if (barras.length == 3)
		{
		    dia = barras[0];
			mes = barras[1];
			ano = barras[2];
			resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano <= anoAtual && ano >= 1900));
			if (!resultado)
			{
				alert("Data inválida.");
				document.getElementById("Nova_DataFim").focus();
				return false;
			}
		 } 
		 else
		 {
			 alert("Data inválida.");
			 document.getElementById("Nova_DataFim").focus();
			 return false;
		 }

		xmlhttp.open("GET", "include/alteraData.asp?campo=Nova_DataFim&cod_tarefa="+ tarefa +"&data="+ campo,true);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)
				if (texto!==false){
					document.getElementById("DataFim").innerHTML = texto
				}
			}
		}
		xmlhttp.send(null)
		return true;
	}
}

/*
function editaDescricao(tarefa,descricao)
{
	document.getElementById("Descricao").innerHTML = "<textarea name='descricao_tarefa' id='descricao_tarefa' rows='10' style='width:99%' onBlur='gravaDescricao("+tarefa+");'>"+descricao+"</textarea>"
	document.getElementById("descricao_tarefa").focus();
	
}
*/

function visuEditDescricao()
{
	document.getElementById("visuDescricao").style.display = 'none';
	document.getElementById("editDescricao").style.display = appear
}

function closeEditDescricao()
{
	document.getElementById("visuDescricao").style.display = appear
	document.getElementById("editDescricao").style.display = 'none';
}

function gravaDescricao(tarefa)
{
	var descricao = document.getElementById("descricao_tarefa").value
	xmlhttp.open("GET", "include/alteraDescricao.asp?cod_tarefa="+ tarefa +"&descricao="+ descricao,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
				document.getElementById("Descricao").innerHTML = texto
			}
		}
	}
	xmlhttp.send(null)
	return true;
}

function editaHoras(tarefa,valor,valor2,campo,nome)
{
	var montagem = "<b>"+nome+": </b><input type='text' name='"+campo+"edita' id='"+campo+"edita' value='"+valor+"' onBlur=gravaHora('"+tarefa+"','"+campo+"'); onkeypress='return SomenteNumero(event)' style='width:60px;'> horas "
		montagem = montagem +"<select name='"+campo+"edita_minutos' id='"+campo+"edita_minutos' style='width:60px;' onChange=gravaHora('"+tarefa+"','"+campo+"');><option value=''></option><option value='00'>00</option><option value='15'>15</option><option value='30'>30</option><option value='45'>45</option></select> minutos"
	//alert(montagem);
	document.getElementById(campo).innerHTML = montagem
	//document.getElementById(campo+"edita").focus()
}

function gravaHora(tarefa,campo)
{
	var hora = document.getElementById(campo+"edita").value
	var minutos = document.getElementById(campo+"edita_minutos").value
	//alert("horas"+hora);
	//alert("minutos"+minutos);
	xmlhttp.open("GET", "include/alteraHora.asp?cod_tarefa="+ tarefa +"&campo="+ campo +"&hora="+ hora +"&minutos="+ minutos,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
				//alert(texto);
				document.getElementById(campo).innerHTML = texto
			}
		}
	}
	xmlhttp.send(null)
	return true;
}

function adicionaDocumento(tarefa)
{
	document.getElementById("incluirDocumentos").style.display = appear
}

function adicionaParticipante(tarefa)
{
	document.getElementById("incluirParticipantes").style.display = appear
}

function adicionaCliente(tarefa)
{
	document.getElementById("incluirClientes").style.display = appear
}

function novoCliente()
{
	var msg = ""
	var avanca = "0"
    if (document.getElementById("nome_cliente").value == "")
    {
        msg=msg+"Insira um nome para o Cliente.\n"
        avanca="1"
    }

    if (document.getElementById("razao_social_cliente").value == "")
    {
        msg=msg+"Insira a Razão Social.\n"
        avanca="1"
    }

    if (document.getElementById("cnpj_cliente").value == "")
    {
        msg=msg+"Insira o CNPJ.\n"
        avanca="1"
    }

    if (document.getElementById("inscricao_municipal_cliente").value == "")
    {
        msg=msg+"Insira a Inscrição Municipal.\n"
        avanca="1"
    }

    if (document.getElementById("inscricao_estadual_cliente").value == "")
    {
        msg=msg+"Insira a Inscrição Estadual.\n"
        avanca="1"
    }

    if ((document.getElementById("telefone_1_cliente").value == "") && (document.getElementById("telefone_2_cliente").value == ""))
    {
        msg=msg+"Insira pelo menos um telefone.\n"
        avanca="1"
    }

    if (document.getElementById("url_cliente").value == "")
    {
        msg=msg+"Insira a URL.\n"
        avanca="1"
    }

    if (document.getElementById("endereco_cliente").value == "")
    {
        msg=msg+"Insira o endereço.\n"
        avanca="1"
    }

    if (document.getElementById("numero_cliente").value == "")
    {
        msg=msg+"Insira o número.\n"
        avanca="1"
    }

    if (document.getElementById("bairro_cliente").value == "")
    {
        msg=msg+"Insira o bairro.\n"
        avanca="1"
    }

	if (document.getElementById("cidade_cliente").value == "")
    {
        msg=msg+"Insira o Cidade.\n"
        avanca="1"
    }

	if (document.getElementById("estado_cliente").value == "")
    {
        msg=msg+"Insira o Estado.\n"
        avanca="1"
    }

    if (msg!=="")
    {
        alert(msg);
    }
    
    if (avanca !== "1")
	
	{
		document.incluirCliente.submit();
	}
}

function visuNovoCliente()
{
	document.getElementById("area_novo_cliente").style.display = appear
	document.getElementById("area_editar_cliente").style.display = 'none';
	document.getElementById("area_editando_cliente").style.display = 'none';
}

function editarCliente()
{
	document.getElementById("area_editar_cliente").style.display = appear
	document.getElementById("area_editando_cliente").style.display = 'none';
	document.getElementById("area_novo_cliente").style.display = 'none';
}

function editaCliente()
{
	var cliente = document.getElementById("lst_clientes").value
	window.open("clientes.asp?cod_cliente="+cliente,'_top');
}

function modificaCliente()
{
	var msg = ""
	var avanca = "0"
    if (document.getElementById("nome_cliente").value == "")
    {
        msg=msg+"Insira um nome para o Cliente.\n"
        avanca="1"
    }

    if (document.getElementById("razao_social_cliente").value == "")
    {
        msg=msg+"Insira a Razão Social.\n"
        avanca="1"
    }

    if (document.getElementById("cnpj_cliente").value == "")
    {
        msg=msg+"Insira o CNPJ.\n"
        avanca="1"
    }

    if (document.getElementById("inscricao_municipal_cliente").value == "")
    {
        msg=msg+"Insira a Inscrição Municipal.\n"
        avanca="1"
    }

    if (document.getElementById("inscricao_estadual_cliente").value == "")
    {
        msg=msg+"Insira a Inscrição Estadual.\n"
        avanca="1"
    }

    if ((document.getElementById("telefone_1_cliente").value == "") && (document.getElementById("telefone_2_cliente").value == ""))
    {
        msg=msg+"Insira pelo menos um telefone.\n"
        avanca="1"
    }

    if (document.getElementById("url_cliente").value == "")
    {
        msg=msg+"Insira a URL.\n"
        avanca="1"
    }

    if (document.getElementById("endereco_cliente").value == "")
    {
        msg=msg+"Insira o endereço.\n"
        avanca="1"
    }

    if (document.getElementById("numero_cliente").value == "")
    {
        msg=msg+"Insira o número.\n"
        avanca="1"
    }

    if (document.getElementById("bairro_cliente").value == "")
    {
        msg=msg+"Insira o bairro.\n"
        avanca="1"
    }

	if (document.getElementById("cidade_cliente").value == "")
    {
        msg=msg+"Insira o Cidade.\n"
        avanca="1"
    }

	if (document.getElementById("estado_cliente").value == "")
    {
        msg=msg+"Insira o Estado.\n"
        avanca="1"
    }

    if (msg!=="")
    {
        alert(msg);
    }
    
    if (avanca !== "1")
	
	{
		document.alterarCliente.submit();
	}	
	
}

function excluiCliente()
{
	var cliente = document.getElementById("lst_clientes").value
	window.open("include/excluindoCliente.asp?cod_cliente="+cliente+"&excluir=1",'_top');
}

function visuNovoUsuario()
{
	document.getElementById("area_novo_usuario").style.display = appear
	document.getElementById("area_editar_usuario").style.display = 'none';
	document.getElementById("area_editando_usuario").style.display = 'none';
}

function editarUsuario()
{
	document.getElementById("area_editar_usuario").style.display = appear
	document.getElementById("area_editando_usuario").style.display = 'none';
	document.getElementById("area_novo_usuario").style.display = 'none';
}

function editaUsuario()
{
	var usuario = document.getElementById("lst_usuarios").value
	window.open("usuarios.asp?cod_usuario="+usuario,'_top');
}

function modificaUsuario()
{
	var msg = ""
	var avanca = "0"
    if (document.getElementById("nome_usuario").value == "")
    {
        msg=msg+"Insira um nome para o Usuário.\n"
        avanca="1"
    }
	
    if (document.getElementById("email_usuario").value == "")
    {
        msg=msg+"Insira um email para o Usuário.\n"
        avanca="1"
    }

    if ((document.getElementById("telefone_1_usuario").value == "") && (document.getElementById("telefone_2_usuario").value == "") && (document.getElementById("celular_usuario").value == ""))
    {
        msg=msg+"Insira um telefone para o Usuário.\n"
        avanca="1"
    }
	
    if (document.getElementById("endereco_usuario").value == "")
    {
        msg=msg+"Insira um endereço.\n"
        avanca="1"
    }
	
    if (document.getElementById("numero_usuario").value == "")
    {
        msg=msg+"Insira um número.\n"
        avanca="1"
    }
	
    if (document.getElementById("bairro_usuario").value == "")
    {
        msg=msg+"Insira um bairro.\n"
        avanca="1"
    }

    if (document.getElementById("cep_usuario").value == "")
    {
        msg=msg+"Insira um cep.\n"
        avanca="1"
    }
	
    if (document.getElementById("cidade_usuario").value == "")
    {
        msg=msg+"Insira uma cidade.\n"
        avanca="1"
    }

    if (document.getElementById("estado_usuario").value == "")
    {
        msg=msg+"Selecione um estado.\n"
        avanca="1"
    }

    if (document.getElementById("area_usuario").value == "")
    {
        msg=msg+"Selecione uma área.\n"
        avanca="1"
    }

    if (document.getElementById("perfil_usuario").value == "")
    {
        msg=msg+"Selecione um perfil.\n"
        avanca="1"
    }

    if (document.getElementById("cliente_usuario").value == "")
    {
        msg=msg+"Selecione um cliente.\n"
        avanca="1"
    }
	
    if (document.getElementById("senha_usuario").value !== "")
    {
		var senha = document.getElementById("senha_usuario").value
		if (senha.length < 6)
		{
        	msg=msg+"Digite pelo menos 6 caracteres para senha.\n"
        	avanca="1"
		}
    }

	if (msg!=="")
    {
        alert(msg);
    }
    
    if (avanca !== "1")
	
	{
		document.alterarUsuario.submit();
	}	
	
}

function cadastraUsuario()
{
	var msg = ""
	var avanca = "0"
    if (document.getElementById("nome_usuario").value == "")
    {
        msg=msg+"Insira um nome para o Usuário.\n"
        avanca="1"
    }
	
    if (document.getElementById("email_usuario").value == "")
    {
        msg=msg+"Insira um email para o Usuário.\n"
        avanca="1"
    }

    if ((document.getElementById("telefone_1_usuario").value == "") && (document.getElementById("telefone_2_usuario").value == "") && (document.getElementById("celular_usuario").value == ""))
    {
        msg=msg+"Insira um telefone para o Usuário.\n"
        avanca="1"
    }
	
    if (document.getElementById("endereco_usuario").value == "")
    {
        msg=msg+"Insira um endereço.\n"
        avanca="1"
    }
	
    if (document.getElementById("numero_usuario").value == "")
    {
        msg=msg+"Insira um número.\n"
        avanca="1"
    }
	
    if (document.getElementById("bairro_usuario").value == "")
    {
        msg=msg+"Insira um bairro.\n"
        avanca="1"
    }

    if (document.getElementById("cep_usuario").value == "")
    {
        msg=msg+"Insira um cep.\n"
        avanca="1"
    }
	
    if (document.getElementById("cidade_usuario").value == "")
    {
        msg=msg+"Insira uma cidade.\n"
        avanca="1"
    }

    if (document.getElementById("estado_usuario").value == "")
    {
        msg=msg+"Selecione um estado.\n"
        avanca="1"
    }

    if (document.getElementById("area_usuario").value == "")
    {
        msg=msg+"Selecione uma área.\n"
        avanca="1"
    }

    if (document.getElementById("perfil_usuario").value == "")
    {
        msg=msg+"Selecione um perfil.\n"
        avanca="1"
    }

    if (document.getElementById("cliente_usuario").value == "")
    {
        msg=msg+"Selecione um cliente.\n"
        avanca="1"
    }
	
    if (document.getElementById("senha_usuario").value == "")
    {
        msg=msg+"Insira uma senha.\n"
        avanca="1"
    }
	
    if (document.getElementById("senha_usuario").value !== "")
    {
		var senha = document.getElementById("senha_usuario").value
		if (senha.length < 6)
		{
        	msg=msg+"Digite pelo menos 6 caracteres para senha.\n"
        	avanca="1"
		}
    }

	if (msg!=="")
    {
        alert(msg);
    }
    
    if (avanca !== "1")
	
	{
		document.incluirUsuario.submit();
	}	
	
}

function excluiUsuario()
{
	var usuario = document.getElementById("lst_usuarios").value
	window.open("include/excluindoUsuario.asp?cod_usuario="+usuario+"&excluir=1",'_top');
}

function geraXLS()
{
	window.open('geraXLS.asp', 'newWin', 'toolbar=no,location=no,directories=no,FLAG_CAD=no,menubar=no,scrollbars=yes,resizable=no,width=650,height=200,left=' + (screen.width - 600)/2 + ',top=' + (screen.height - 400)/2);
}

function atualizarDescricao()
{
	var msg = ""
	var avanca = "0"
	if (document.getElementById("descricao_tarefa").value == "")
	{
        msg=msg+"Insira uma Descrição para esta tarefa.\n"
        avanca="1"
	}

	if (msg!=="")
    {
        alert(msg);
		document.getElementById("descricao_tarefa").focus();
    }
    
    if (avanca !== "1")
	
	{
		document.alteraDescricao.submit();
	}	
}

function inserirComentario()
{
	document.insereComentario.submit();
}

function inserirConclusao()
{
	document.insereConclusao.submit();
}

function validaDataTarefa()
{
	var msg = ""
	var avanca = "0"
	if (document.getElementById("dataInicio_dia").value == "")
	{
        msg=msg+"Insira o dia para Data Início.\n"
        avanca="1"
	}
	
	if (document.getElementById("dataInicio_mes").value == "")
	{
        msg=msg+"Insira o mês para Data Início.\n"
        avanca="1"
	}
	
	if (document.getElementById("dataInicio_ano").value == "")
	{
        msg=msg+"Insira o ano para Data Início.\n"
        avanca="1"
	}
	
	if (document.getElementById("dataFim_dia").value == "")
	{
        msg=msg+"Insira o dia para Data Fim.\n"
        avanca="1"
	}
	
	if (document.getElementById("dataFim_mes").value == "")
	{
        msg=msg+"Insira o mês para Data Fim.\n"
        avanca="1"
	}
	
	if (document.getElementById("dataFim_ano").value == "")
	{
        msg=msg+"Insira o ano para Data Fim.\n"
        avanca="1"
	}
	
	if (msg!=="")
    {
        alert(msg);
    }
    
    if (avanca !== "1")
	
	{
		document.alteraData_tarefa.submit();
	}		
}

function closeEditDataTarefa()
{
	document.getElementById("visuData").style.display = appear
	document.getElementById("editData").style.display = 'none';
}

function dropDownClientesNT(identificador,selId,selNome)
{
	document.getElementById(identificador).innerHTML = "Carregando...";
	xmlhttp.open("GET", "include/dropDownClientesNT.asp?selId="+selId+"&selNome="+selNome,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById(identificador).innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 
}

function carregaProjetos(id)
{
	var codigo = document.getElementById(id).value
	document.getElementById("carregaProjetos").style.display = appear
	document.getElementById("carregaProjetos").innerHTML = "<p>Projeto: Carregando...</p>";
	xmlhttp.open("GET", "include/dropDownProjetosNT.asp?value="+codigo,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById("carregaProjetos").innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 
}

function carregaProjetos2(id)
{
	var codigo = document.getElementById(id).value
	document.getElementById("carregaProjetos").style.display = appear
	document.getElementById("carregaProjetos").innerHTML = "<p>Carregando...</p>";
	xmlhttp.open("GET", "include/dropDownProjetosNT2.asp?value="+codigo,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById("carregaProjetos").innerHTML = texto
				carregaTarefas('','');
			}
		}
	}
   xmlhttp.send(null) 
}

function carregaTarefas(projeto,cliente)
{
	document.getElementById("carregaTarefas").style.display = appear
	document.getElementById("carregaTarefas").innerHTML = "<p>Carregando...</p>";
	xmlhttp.open("GET", "include/dropDownTarefasNT.asp?projeto="+projeto+"&cliente="+cliente,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById("carregaTarefas").innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 
}

function dropDownClientes(identificador,selId,selNome)
{
	document.getElementById(identificador).innerHTML = "Carregando...";
	xmlhttp.open("GET", "include/dropDownClientes.asp?selId="+selId+"&selNome="+selNome,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById(identificador).innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 	
}

function dropDownUsuarios(identificador,selId,selNome)
{
	document.getElementById(identificador).innerHTML = "Carregando...";
	xmlhttp.open("GET", "include/dropDownUsuarios.asp?selId="+selId+"&selNome="+selNome,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById(identificador).innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 	
}

function dropDownArea(identificador,selId,selNome)
{
	document.getElementById(identificador).innerHTML = "Carregando...";
	xmlhttp.open("GET", "include/dropDownArea.asp?selId="+selId+"&selNome="+selNome,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
			    document.getElementById(identificador).innerHTML = texto
			}
		}
	}
   xmlhttp.send(null) 	
}

function lembrarSenha()
{
	if (document.login.usuario.value=='')
	{
		alert("Preencha seu login!");
		document.login.usuario.focus();
	}
	if (document.login.usuario.value!=='')
	{
		var email = document.login.usuario.value;
		document.getElementById("lembraSenha").innerHTML = "Validando email...";
		xmlhttp.open("GET", "include/lembraSenha.asp?email="+email,true);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4){
				var texto=xmlhttp.responseText
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)
				if (texto!==false){
					document.getElementById("lembraSenha").innerHTML = texto
				}
			}
		}
	   xmlhttp.send(null)
	}
}

function ContinuarConectado()
{
	if (document.getElementById("Flag_ContinuarConectado").value == "0")
	{
		document.getElementById("ContinuarConectado").innerHTML = "seus dados ser&atilde;o salvos";
		document.getElementById("Flag_ContinuarConectado").value = "1";
	}
}

function MudarConexao()
{
	document.getElementById("usuario").value = "";
	document.getElementById("senha").value = "";
	document.getElementById("MudarConexao").style.display = 'none';
	document.getElementById("ContinuarConectado").style.display = appear;
	document.getElementById("Flag_ContinuarConectado").value = "0";
}

function checkmail(objeto)
{
	// executa a exp. regular
	var retorno=objeto.value;

	var conta = retorno.indexOf("@");
	var primeiro_caracter = retorno.substring(conta+2,conta+1);
	var segundo_caracter = retorno.substring(conta,conta-1);
	var strValidos = "0123456789ABCDEFGHIJLMNOPQRSTUVXWYZabcdefghijlmnopqrstuvwyz"
	if (( strValidos.indexOf( primeiro_caracter ) == -1 )||( strValidos.indexOf( segundo_caracter ) == -1 ))
	{
		alert('Email incorreto');
		objeto.value = ""
		objeto.focus();
		return false;
	}
	

	if ((retorno.length != 0) && (retorno.indexOf("@") < 1) || (retorno.indexOf('.') < 7))
	{
		alert('Email incorreto');
		objeto.value = ""
		objeto.focus();
		return false;
	}
	return true;
}

/*
function exibeWebOfficeFiltro()
{
	document.getElementById("weboffice_filtro").style.display = appear	
	document.getElementById("ln_abre_aba_filter").style.display = appear
	document.getElementById("ln_abre_abas").style.display = 'none';
	document.getElementById("ln_abre_aba_timeline").style.display = 'none';
	
	document.getElementById("lineTop_Filter").style.display = appear
	document.getElementById("lineTop_Timeline").style.display = 'none';	
	document.getElementById("weboffice_timeline").style.display = 'none';
}

function fechaWebOfficeFiltro()
{
	document.getElementById("weboffice_filtro").style.display = 'none';
	document.getElementById("weboffice_timeline").style.display = 'none';
	document.getElementById("ln_abre_aba_filter").style.display = 'none';
	document.getElementById("ln_abre_abas").style.display = appear
	document.getElementById("ln_abre_aba_timeline").style.display = 'none';
}

function exibeWebOfficeTimeline()
{
	document.getElementById("weboffice_filtro").style.display = 'none';
	document.getElementById("ln_abre_aba_filter").style.display = 'none';
	document.getElementById("ln_abre_abas").style.display = 'none';
	document.getElementById("ln_abre_aba_timeline").style.display = appear
	
	document.getElementById("lineTop_Filter").style.display = 'none';
	document.getElementById("lineTop_Timeline").style.display = appear
	document.getElementById("weboffice_timeline").style.display = appear

}

function fechaWebOfficeTimeline()
{
	document.getElementById("weboffice_filtro").style.display = 'none';
	document.getElementById("weboffice_timeline").style.display = 'none';
	document.getElementById("ln_abre_aba_filter").style.display = 'none';
	document.getElementById("ln_abre_abas").style.display = appear
	document.getElementById("ln_abre_aba_timeline").style.display = 'none';
}
*/

function exibeWebOfficeFiltro()
{
	document.getElementById("weboffice_filtro").style.display = appear	
	document.getElementById("bt_exibeWebOfficeFiltro").style.display = 'none';	
	document.getElementById("bt_fecharWebOfficeFiltro").style.display = appear	
}

function fechaWebOfficeFiltro()
{
	document.getElementById("weboffice_filtro").style.display = 'none';
	document.getElementById("bt_exibeWebOfficeFiltro").style.display = appear
	document.getElementById("bt_fecharWebOfficeFiltro").style.display = 'none';	
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}


function idata(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que no  dgito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca hfen entre o quarto e o quinto dgitos
	v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca hfen entre o quarto e o quinto dgitos
    return v
}

function icep(v){
    v=v.replace(/\D/g,"")                //Remove tudo o que no  dgito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse  to fcil que no merece explicaes
    return v
}

function itelefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que no  dgito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parnteses em volta dos dois primeiros dgitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hfen entre o quarto e o quinto dgitos
    return v
}

function aplicarFiltro()
{
	var filter_lst_area = ""
	var filter_lst_usuarios = ""
	var filter_lst_clientes = ""
	var filter_periodo_de = ""
	var filter_periodo_ate = ""
	var filter_lst_status = ""
	var filter_lst_projeto = ""
	var filter_lst_tarefa = ""
	
	if ((document.getElementById("filter_lst_area").value == "")&&(document.getElementById("filter_lst_usuarios").value == "")&&(document.getElementById("filter_lst_clientes").value == "")&&(document.getElementById("filter_periodo_de").value == "")&&(document.getElementById("filter_periodo_ate").value == "")&&(document.getElementById("filter_lst_status").value == "")&&(document.getElementById("filter_lst_projeto").value == "")&&(document.getElementById("filter_lst_tarefa").value == ""))
	{
		alert("Selecione um filtro!");
	}
	
	else
	{
		var msg = ""

		if (document.getElementById("filter_lst_area").value !== "")
		{
			var filter_lst_area = document.getElementById("filter_lst_area").value
			var msg=msg+filter_lst_area+"\n";
		}

		if (document.getElementById("filter_lst_usuarios").value !== "")
		{
			var filter_lst_usuarios = document.getElementById("filter_lst_usuarios").value
			var msg=msg+filter_lst_usuarios+"\n";
		}
		
		if (document.getElementById("filter_lst_clientes").value !== "")
		{
			var filter_lst_clientes = document.getElementById("filter_lst_clientes").value
			var msg=msg+filter_lst_clientes+"\n";
		}
		
		if (document.getElementById("filter_periodo_de").value !== "")
		{
			var filter_periodo_de = document.getElementById("filter_periodo_de").value
			var msg=msg+filter_periodo_de+"\n";
		}
	
		if (document.getElementById("filter_periodo_ate").value !== "")
		{
			var filter_periodo_ate = document.getElementById("filter_periodo_ate").value
			var msg=msg+filter_periodo_ate+"\n";
		}
	
		if (document.getElementById("filter_lst_status").value !== "")
		{
			var filter_lst_status = document.getElementById("filter_lst_status").value
			var msg=msg+filter_lst_status+"\n";
		}

		if (document.getElementById("filter_lst_projeto").value !== "")
		{
			var filter_lst_projeto = document.getElementById("filter_lst_projeto").value
			var msg=msg+filter_lst_projeto+"\n";
		}
		
		if (document.getElementById("filter_lst_tarefa").value !== "")
		{
			var filter_lst_tarefa = document.getElementById("filter_lst_tarefa").value
			var msg=msg+filter_lst_tarefa+"\n";
		}
		
		ordenaTarefas('','','','',filter_lst_area,filter_lst_usuarios,filter_lst_clientes,filter_periodo_de,filter_periodo_ate,filter_lst_status,filter_lst_projeto,filter_lst_tarefa);
	}

}

function aplicarTimeline()
{
	var timeline_lst_area = ""
	var timeline_periodo_de = ""
	var timeline_periodo_ate = ""
	
	if (document.getElementById("timeline_lst_area").value == "")
	{
		alert("Selecione um filtro!");
	}
	
	else
	{
		var msg = ""

		if (document.getElementById("timeline_lst_area").value !== "")
		{
			var timeline_lst_area = document.getElementById("timeline_lst_area").value
			var msg=msg+timeline_lst_area+"\n";
		}

		if (document.getElementById("timeline_periodo_de").value !== "")
		{
			var timeline_periodo_de = document.getElementById("timeline_periodo_de").value
			var msg=msg+timeline_periodo_de+"\n";
		}
	
		if (document.getElementById("timeline_periodo_ate").value !== "")
		{
			var timeline_periodo_ate = document.getElementById("timeline_periodo_ate").value
			var msg=msg+timeline_periodo_ate+"\n";
		}
	
		window.open("timeline.asp?timeline_lst_area="+timeline_lst_area+"&timeline_periodo_de="+timeline_periodo_de+"&timeline_periodo_ate="+timeline_periodo_ate , "TimeLine" , "location=no, status=yes, scrollbars=yes, toolbar=no, resizable=yes, width=800, height=350 , top=100 , left=100"); 
	}

}

function executaTimeLine(timeline_lst_area,timeline_periodo_de,timeline_periodo_ate)
{
    var loading = "<table style='width:100%;height:100%;' border='0' cellpadding='0' cellspacing='0'>"
        loading = loading +"<tr><td width='40%'>&nbsp</td>"
        loading = loading +"<td width='35px'><img src='imagens/loading.gif' /></td>"
        loading = loading +"<td width='100px'><img src='imagens/logo_weboffice2.jpg' /></td>"
        loading = loading +"<td width='40%'>&nbsp</td></tr></table>"
	
	document.getElementById("exibeTimeLine").innerHTML = loading
	xmlhttp.open("GET", "include/geraTimeLine.asp?timeline_lst_area="+timeline_lst_area+"&timeline_periodo_de="+timeline_periodo_de+"&timeline_periodo_ate="+timeline_periodo_ate,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
				 document.getElementById("exibeTimeLine").innerHTML = texto
			}
		}
	}
   xmlhttp.send(null)
}

function intervalo(tempo)
{
	setTimeout("redireciona()",tempo)
}

function redireciona()
{
	document.getElementById("reconecta").style.display = 'none';
	setTimeout("reconecta()",30000)
}

function reconecta()
{
	xmlhttp.open("GET", "include/reconecta.asp",true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText
			texto=texto.replace(/\+/g," ")
			texto=unescape(texto)
			if (texto!==false){
				document.getElementById("reconecta").style.display = appear
				document.getElementById("reconecta").innerHTML=texto
				intervalo(5000);
			}
		}
	}
   xmlhttp.send(null)
}

function novoTopico()
{
	document.getElementById("abreNovoTopico").style.display = appear
}

function cancelarNovoTopico()
{
	document.getElementById("abreNovoTopico").style.display = 'none';
}

function validaNovoTopico()
{
	if (document.frm_mensagem.novoTopico_titulo.value == "")
	{
		alert("Digite o titulo");
		document.frm_mensagem.novoTopico_titulo.focus();
		return false;
	}

	document.frm_mensagem.submit();
}

function validaNovoPost()
{
	document.frm_mensagem.submit();
}

function alterarTopico(codigo)
{
	document.getElementById("abreAlterarTopico"+codigo).style.display = appear
	document.getElementById("trEditarMensagem"+codigo).style.display = 'none';
}

function cancelarAlterarTopico(codigo)
{
	document.getElementById("abreAlterarTopico"+codigo).style.display = 'none';
	document.getElementById("trEditarMensagem"+codigo).style.display = appear
}

function abreoutroTopico()
{
	document.getElementById("outroTopico").style.display = appear
	document.getElementById("trMensagemPost").style.display = 'none';
	document.getElementById("trBotoesPost").style.display = 'none';
}

function fechaoutroTopico()
{
	document.getElementById("outroTopico").style.display = 'none';
	document.getElementById("trMensagemPost").style.display = appear
	document.getElementById("trBotoesPost").style.display = appear
	document.getElementById("topico0").checked = true;
}

function validaNovoPost_Topico()
{
	if (document.getElementById("titulo_topico").value == "")
	{
		alert("Digite o titulo");
		document.getElementById("titulo_topico").focus();
		return false;
	}
	document.frm_mensagem.submit();
}

