//
<!--Inicio-->
/*


#### jQuery ####////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
*/
jQuery(document).ready(function() {

    // Se o modelo de menu for treeview
	if ($("#c1966").val() == "1")
	{
		// Exibe o Menu XML
		$.ajax({
			type: "GET",
			url: "/osweb/menu.xml",
			dataType: "xml",
			complete: function(data) {
				
				var xml = data.responseXML;
				
				var tree = $("#menu").treeview();
				var xmlNode = xml.getElementsByTagName("menu")[0];
				
				var lista = ArvoreXML(xmlNode);
				var itens = lista.substr(0,lista.length-5);
				
				var newSublist = $(itens).appendTo(tree);
				tree.treeview({
					add: newSublist
				});
				
			} // complete function
		});
		
		// altera tamanho do iframe
		$("#principal").css("width", parseInt($(window).width() - 215,10));
		$("#principal").css("height", parseInt($(window).height() - 2,10));
		
		// altera tamanho do Menu
		$("#divMenu").css("height", parseInt($(window).height() - 2,10));
		
	} // c1966 = 1



		// Plugin Maskedinput
		$.mask.addPlaceholder('h',"[0-2]"); //Placeholder para hora "h"
		$.mask.addPlaceholder('m',"[0-5]"); //Placeholder para minuto "m"
		
		
		// mouseOver/mouseOut da TABELA ZEBRADA DA TELA DE PESQUISA
		$("table.tab_pesq tr:nth-child(odd)").addClass("odd_out");
		$("table.tab_pesq tr:nth-child(even)").addClass("odd_even");
		
		$("table.tab_pesq tr:nth-child(odd)").hover(function(){
			$(this).attr("class","odd_over");
		},function(){
			$(this).attr("class","odd_out");
		});
		$("table.tab_pesq tr:nth-child(even)").hover(function(){
			$(this).attr("class","even_over");
		},function(){
			$(this).attr("class","even_out");
		});
		
		
		
		
		
		/*######### Cria OS #########//////////////
		/////////////////////////////////////////*/
		
		// Máscaras dos campos
		$("#GeraOS #OS_Terceiro").validation({ type: "int" });
		
		// Campos de Data com calendário
		$("#GeraOS #requiredDataSolicitada").calendar();
		
		
		// Exibição dos itens do QUESTIONÁRIO de acordo com o Tipo de OS selecionado
		if ( $("#c1818").val() == "1")
		{
            $("#inforauxil").css("display","none");
            
			$("#requiredTipo").change( function() {
				$("tr.hide_class").each( function() {
					$("tr.hide_class").hide();
				});
				$("tr[@id=" + this.value + "]").show();
				
				if ($("tr[@id=" + this.value + "]").length == 0)
                {
                     $("#inforauxil").css("display","none");
                     $("#reclame_avulso").css("display","");
                }
                else
                {
                     $("#inforauxil").css("display","");
                     $("#reclame_avulso").css("display","none");
                     $("#requiredDescricao Solicitacao").value = "";
                }
			});
		};
		
		
		// onClick Registros da Pesquisa -> Retornos
        $("[id^=reg]").click(function() {
        	varCampo1 = $(this).find("td:eq(0)").html();
        	varCampo2 = $(this).find("td:eq(1)").html();
        	varCampo3 = $(this).find("td:eq(2)").html();
        	varCampo4 = $(this).find("td:eq(3)").html();
        	
        	if(varCampo1 == null)
        		varCampo1="";
        	if(varCampo2 == null)
        		varCampo2="";
        	if(varCampo3 == null)
        		varCampo3="";
        	if(varCampo4 == null)
        		varCampo4="";
        		
            RetornaDadosPesquisa(varCampo1,varCampo2,varCampo3,varCampo4);
        });
        		            		
		//-----------------------------------------
		
		
		/*######### Imprimir OS #########//////////
		/////////////////////////////////////////*/
		
		// Máscaras/Validação dos campos
		$("#txtOS_ini, #txtItem_ini, #txtItem_fim, #txtEtapa_ini").validation({ type: "int" });
		
		// Botão Impressão
		$("#btnImpressao").click( function() {
			window.location = $("#arquivo_final").val();
		});
		
		//-----------------------------------------
		
		
		
		/////////////////////////////////////////////////////*/
		/*######### INICIO IMPRESSÃO VERSÃO #########//////////
		/////////////////////////////////////////////////////*/
		
		// Campos de Data com calendário
		//$("#frmImprimirVersao #txtData_Conclusao_ini").calendar();
		//$("#frmImprimirVersao #txtData_Conclusao_fim").calendar();
		
		// Máscaras/Validação dos campos
		 $("#txtRelease_ini, #txtRelease_fim, #txtRelease_oficial_ini, #txtRelease_oficial_fim, #txtOS_ini, #txtOS_fim, #txtItem_ini, #txtItem_fim").validation({ type: "int" });
		
		
		//*### INITS DOS CAMPOS ###*// 
		
		$("#txtRelease_ini").blur( function() {
			$("#txtRelease_fim").val($(this).val());
		});
		 
		$("#txtRelease_oficial_ini").blur( function() {
			$("#txtRelease_oficial_fim").val($(this).val());
		});
		
		$("#txtOS_ini").blur( function() {
			$("#txtOS_fim").val($(this).val());
		});
		
		$("#txtItem_ini").blur( function() {
			$("#txtItem_fim").val($(this).val());
		});
		
		$("#txtOS_Terceiro_ini").blur( function() {
			$("#txtOS_Terceiro_fim").val($(this).val());
		});
		
		$("#cboGrau_Inovacao_ini").blur( function() {
			$("#cboGrau_Inovacao_fim").val($(this).val());
		});
		
		$("#cboSit_Liberacao_ini").blur( function() {
			$("#cboSit_Liberacao_fim").val($(this).val());
		});
		
		$("#txtData_Conclusao_ini").blur( function() {
			$("#txtData_Conclusao_fim").val($(this).val());
		});
		//*### FIM INITS DOS CAMPOS ###*// 
		
		
		//*### INICIO BOTÃO IMPRIMIR VERSÃO ###*//
		$("#btnImpressaoVersao").submit( function() {
			
			//validação dos campos de filtros da tela	
			if(!isDate($("#txtData_Conclusao_ini").val()))
			{
				$("#txtData_Conclusao_ini").focus();
				return false;
			}
			if(!isDate($("#txtData_Conclusao_fim").val()))
			{
				$("#txtData_Conclusao_fim").focus();
				return false;
			}
			
		});
		//*### FIM BOTÃO IMPRIMIR VERSÃO ###*//
		
		
		// Botão Exibir Versão
		$("#btnExibeVersao").click( function() {
			window.location = $("#arquivo_final_versao").val();
		});
		
		//////////////////////////////////////////////////*/
		/*######### FIM IMPRESSÃO VERSÃO #########//////////
		//////////////////////////////////////////////////*/
		
			
			
			
		/////////////////////////////////////////////////*/
		/*######### Controle de Atividades #########///////
		/////////////////////////////////////////////////*/
		
/*
-----> onClick das ATIVIDADES
*/
		$("[id^=linha]").click(function() {
			if ($(this).attr("class") == "unsel")
			{
				var id = $(this).attr("id").toString();
				var linha = id.slice(5,id.length);
				
				var aux_str = $("#os" + linha).text();
				var os = aux_str.slice(0, aux_str.lastIndexOf("/"));
				var item = aux_str.slice(aux_str.lastIndexOf("/") + 1);
				var etapa = $("#etapa" + linha).text();
				
				$("#os").val(os);
				$("#item").val(item);
				$("#etapa_ativ").val(etapa);
			    
				
				var url = { v_os: os, v_item: item, v_etapa: etapa, t_ativ: $("#T_Ativ").val(), t_os: $("#T_os").val(), t_tipo_ativ: $("#T_tipo_ativ").val(), t_item_os: $("#T_item_os").val(), t_tipo_os: $("#T_tipo_os").val(), t_prod_cli: $("#T_prod_cli").val(), t_num_serie: $("#T_num_serie").val(), t_mat: $("#T_mat").val(), t_emp: $("#T_emp").val(), t_def_sol: $("#T_def_sol").val(), t_det_def_sol: $("#T_det_def_sol").val(), t_apontamento: $("#T_apontamento").val(), t_usuario: $("#T_usuario").val(), c549: $("#C549").val(), rdm: Math.random() }
		
				$.get( "/osweb/pesquisaos.asp", url, 
					function(result) {
						var arrayResult = eval(result);
						
						var arrayIds = [
							{ id: "#tipo_ativ", tipo: "html" },
							{ id: "#cd_reclamado", tipo: "value" },
							//{ id: "#Reclamado", tipo: "value" },
							{ id: "#Obs", tipo: "value" },
							{ id: "#data_item", tipo: "html" },
							{ id: "#ult_atend", tipo: "html" },
							{ id: "#prioridade", tipo: "html" },
							
							{ id: "#tecnico_atividade", tipo: "value" },
							{ id: "#cod_tecnico_atividade", tipo: "value" },
							{ id: "#tecnico_ativ", tipo: "html" },
							{ id: "#cod_cliente", tipo: "value" },
							{ id: "#cliente", tipo: "html" }, 
							{ id: "#representante", tipo: "html" },
							{ id: "#reclamante", tipo: "html" },
							
							{ id: "#tipo_os", tipo: "html" },
							{ id: "#produto", tipo: "html" },
							{ id: "#num_serie", tipo: "html" },
							{ id: "#num_logico", tipo: "html" },
							{ id: "#contato", tipo: "html" },
							{ id: "#orcamento", tipo: "html" },
							{ id: "#data_solicitada", tipo: "html" },
							
							{ id: "#cd_solucao", tipo: "value" },
							//{ id: "#Solucao", tipo: "value" },
							{ id: "#situacao_ativ", tipo: "value" },
							{ id: "#situacao_apont",  tipo: "value" },
						];
						
						
						//Popula campos da tela
						$.each(arrayResult, function(index, value) {
							switch (arrayIds[index].tipo)
							{
								case "value": $(arrayIds[index].id).val(value); break;
								case "html": $(arrayIds[index].id).html(value); break;
								default: break;
							}
						});
						
						//----> Popula Separado a Descrição do Reclamado e da Solução
						var url_recl = { id: "Reclamado", v_os: os, v_item: item, t_item_os: $("#T_item_os").val(), t_def_sol: $("#T_def_sol").val(), t_det_def_sol: $("#T_det_def_sol").val(), rdm: Math.random() }
				        var url_sol = { id: "Solucao", v_os: os, v_item: item, t_item_os: $("#T_item_os").val(), t_def_sol: $("#T_def_sol").val(), t_det_def_sol: $("#T_det_def_sol").val(), rdm: Math.random() }
        				
				        $.get( "/osweb/busca_reclamado_solucao.asp", url_recl,
				            function(reclamado) {
        				        $("#Reclamado").val(reclamado);
				        });
				        $.get( "/osweb/busca_reclamado_solucao.asp", url_sol,
				            function(solucao) {
				                $("#Solucao").val(solucao);
				        });
				        //----> fim
                        
						LiberaBotoes();
						buscaTempo();
       					sel(id);
						global_idlinha = id;
																		
						$("#Solucao2").val(trim($("#Solucao").val()));
						$("#Reclamado2").val(trim($("#Reclamado").val()));
					} // success
				); //ajax -> pesquisaos.asp
				
			} // if
			
			//----> Permissões para Alteração da Solução
			if( (trim($("#Solucao").val()) == "") || ($("#gesman").val() == "S") || ($("#bloq_alt_solucao").val() != "S") || ( ($("#Resp_os").val() == $("#empresa_usuario").val()) && ( ($("#Situacao_item").val() == "A") || ($("#Situacao_item").val() == "P") || ($("#Situacao_item").val() == "I") )) )
				$("#btnAltera_Solucao").css("display","")
			else
				$("#btnAltera_Solucao").css("display","");
				
			$("#permite_inicio").val($("#permite" + linha).text());
			
		}); // click ativ
				
/*
-----> Fim
*/	



/*
-----> jqModal - Alterar Reclamado/Solução
*/
		//----> Tooltip
		$("#btnAltera_Solucao, #btnAltera_Reclamado").tooltip({
			track: true, 
    		delay: 0, 
			showURL: false, 
			opacity: 0.65,
			extraClass: "classeTooltip"
		});
		
		//----> Solução
		$("#pSolucao2").jqm({ trigger: "#btnAltera_Solucao" });
		$("#pSolucao2").jqmAddClose("#btnOk_Solucao");
		$("#btnOk_Solucao").click(function() {
			$.post( "/osweb/altera_campo.asp", { os: $("#os").val(), item: $("#item").val(), 
				descricao: $("#Solucao2").val(), tab: $("#T_det_def_sol").val(), 
				campo: "Solucao", cod_usu: $("#cod_usuario").val() }, 
				function() { 
					$("#Solucao").val($("#Solucao2").val()); 
			});
		});
		
		//----> Reclamado
		$("#pReclamado2").jqm({ trigger: "#btnAltera_Reclamado" });
		$("#pReclamado2").jqmAddClose("#btnOk_Reclamado");
		$("#btnOk_Reclamado").click(function() {
			$.post( "/osweb/altera_campo.asp", { os: $("#os").val(), item: $("#item").val(), 
				descricao: $("#Reclamado2").val(), tab: $("#T_item_os").val(), 
				campo: "Reclamado", cod_usu: $("#cod_usuario").val() },
				function() { 
					$("#Reclamado").val($("#Reclamado2").val()); 
			});
		});			
/*
-----> Fim
*/
		
		
		// hack IE - controle de atividades
		if($.browser.msie)
		{
			$("#divTempoTotal").css("margin-top", 240);
			
			$(".TitListaAtividades").css("width", "95.5%");
			$("#tableListaAtividades").css("width", "95.5%");
		}
		else
		{
			$("#divTempoTotal").css("margin-top", 0);
			
			if ($("#c1966").val() == "1") 
			{
				$(".TitListaAtividades").css("width", "96%");
			}
			else 
			{
				$(".TitListaAtividades").css("width", "97%");
			}
			$("#tableListaAtividades").css("width", "100%");
		}
		
		//-----------------------------------------
		
		
		
		/*######### Nova Atividade #########///////
		/////////////////////////////////////////*/
		
		
		//----> Botões Confirmar e Cancelar
		$("#ConfirmaNovaAtiv").click(function() {
			if (Compara_Datas("data_ini","data_fim"))
				ExecIniciarFinalizar('F');
		});
		$("#CancelaNovaAtiv").click(function() {
			history.go(-1);
		});
		
		// Se nao usar C1645 - Play/Pause
		if ( $("#C1645").val() != "S" )
		{		
			//----> Data Inicio/Final Atividade			
			$("[@name=vData]").map(function() {
				$(this).calendar({
					buttonImageOnly: true,
					buttonImage: "/images/calendar.gif",
					buttonText: "Calendario"
				});
				$(this).attr("disabled","");
				$(this).blur(function() {
					if ( ($(this).val() != "00/00/0000") && (isDate($(this).val())) )
						return true;
					else 
					{
						$(this).val("");
						$("#quant_util").html("0.00");
					}
				}); // onBlur
			}); // map
			
			
			//----> Tempo Inicio/Final Atividade
			var arrCampos = ["quant_horas_ini","quant_horas_fim","quant_min_ini","quant_min_fim","quant_horas_util","quant_min_util"];
			var arrTipoCampos = ["h","h","m","m","","m"];
			
			
			//----> atribui os eventos aos campos
			$.each(arrCampos, function(index, value) {
				$("#" + value).attr("disabled","");
				$("#" + value).validation({ type: "int" });
				
				//----> onBlur dos campos
				$("#" + value).blur( function() {
					this.value = validaHorasMinutos(this,arrTipoCampos[index]);
					
					if (value == "quant_horas_util")
						$("#quant_util").html(calcTempoAtiv(this.value, $("#quant_min_util").val(),"","","quant"));
					if (value == "quant_min_util")
						$("#quant_util").html(calcTempoAtiv($("#quant_horas_util").val(), this.value,"","","quant"));
						
					//----> Calcula Quantidade de Horas Utilizadas da Atividade	
					if ( (value == "quant_horas_ini") || (value == "quant_min_ini") || (value == "quant_horas_fim") || (value == "quant_min_fim") )
						if ($("#data_ini").val() == $("#data_fim").val())
						{
							var t = calcTempoAtiv($("#quant_horas_ini").val(), $("#quant_min_ini").val(), $("#quant_horas_fim").val(), $("#quant_min_fim").val(),"horas");
							$("#quant_horas_util").val(parseInt(t.slice(0,t.indexOf(":")),10));
							$("#quant_min_util").val(parseInt(t.slice(t.indexOf(":") + 1),10));
							$("#quant_util").attr("innerHTML",calcTempoAtiv($("#quant_horas_util").val(), $("#quant_min_util").val(),"","","quant"));
							$("#quant_horas_util").blur();
							$("#quant_min_util").blur();
						}			
						
					//if ( !(isDate($("#data_ini").val()) && $("#data_ini").val() != "00/00/0000") || !(isDate($("#data_fim").val()) && $("#data_fim").val() != "00/00/0000") )
					if ( ($("#data_ini").val() == "") || ($("#data_fim").val() == "") )
						$("#quant_util").attr("innerHTML","0.00");

			
				}); // onBlur
				
			}); // each
			
		}
		
		//-----------------------------------------


});
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
<!--Fim-->



//------------------------------------------------------------------
//		P E S Q U I S A S      G E R A I S
//------------------------------------------------------------------

/*
----> Funções para Exibição de janela e retorno de PESQUISA
*/
		function QueryString(variable)
		{
			var query = window.location.search.substring(1);
			var vars = query.split("&");
			for (var i = 0; i < vars.length; i++) 
			{
				var pair = vars[i].split("=");
				if (pair[0] == variable) 
					return pair[1];
			} 
		}
		
		function RetornaDadosPesquisa(selCodigo, selDesc, selCampo3, selCampo4)
		{
		  recebeCod = QueryString("campo1");
	      recebeDesc = QueryString("campo2");
	      recebeCampo3 = QueryString("campo3");
	      recebeCampo4 = QueryString("campo4");
		  		  
		  if(recebeDesc == null) recebeDesc="";
		  if(recebeCampo3 == null) recebeCampo3="";
		  if(recebeCampo4 == null) recebeCampo4="";

	      //trata o retorno do código 
	      var vCod = "opener.document." + recebeCod;
	      var objName = eval(vCod);
	      objName.value = trim(selCodigo);
	        			
	      //trata o retorno da descrição
		  if (recebeDesc != "") {
	        	var vDesc = "opener.document." + recebeDesc;
	        	var objName = eval(vDesc);
	        	objName.value = trim(selDesc);
		  }
		  
		  if (recebeCampo3 != "") { 
	        	var vCampo3 = "opener.document." + recebeCampo3;
	        	var objName = eval(vCampo3);
	        	objName.value = trim(selCampo3);
		  }
		  
		  if (recebeCampo3 != "") {
	        	var vCampo4 = "opener.document." + recebeCampo4;
	        	var objName = eval(vCampo4);
	        	objName.value = trim(selCampo4);
		  }

       	  window.close();
		}
		
		function TelaPesquisa(url, Width, Height)
		{
			var Top = parseInt((($(window).height() - Height) / 2),10);
			var Left = parseInt((($(document).width() - Width) / 2),10);
			
			var propriedades = "height=" + Height + ",width=" + Width + ",left=" + Left + ",top=" + Top + ",resizable=no,status=no,chrome=yes";
			var janela = window.open( "/osweb/" + url, "", propriedades);
			janela.focus();
		}
		
		
		// Abre Pesquisa de EMPRESAS
		function Pesquisa_Empresa(CodEmpresa,NomeEmpresa){
			TelaPesquisa("pesq_empresa.asp?mod=L&tab=" + $("#T_emp").val() + "&campo1=" + CodEmpresa + "&campo2=" + NomeEmpresa, 650, 580);
		}
		
		
		// Abre Pesquisa de CONTATOS
		function Pesquisa_Contato(CodCliente,CodReclamante,CodContato,NomeContato){
			var vinculo = CodCliente;
			
			if ($("#c1544").val() == "R")
			   vinculo = CodReclamante;
					
			if(isNull(vinculo))
				vinculo = "";

			if ( trim(vinculo) == "")
				alert("Informe um cliente para realizar esta pesquisa.");
			else
				TelaPesquisa("pesq_contato.asp?mod=L&tab=" + $("#T_contato").val() + "&vinculo=" + vinculo + "&campo1=" + CodContato + "&campo2=" + NomeContato, 650, 520);
		}
				
		// Abre Pesquisa de PRODUTO
		function Pesquisa_Produto(CodCliente,CodProduto,DescrProduto){
			TelaPesquisa("pesq_produto.asp?mod=L&cliente=" + CodCliente + "&campo1=" + CodProduto + "&campo2=" + DescrProduto, 720, 580);
		};
		
		// Abre Pesquisa de ATIVIDADE
		function Pesquisa_Atividade(CodAtividade,DescrAtividade,ValorUnitario,Faturar){
			TelaPesquisa("pesq_atividade.asp?mod=L&campo1=" + CodAtividade + "&campo2=" + DescrAtividade + "&campo3=" + ValorUnitario + "&campo4=" + Faturar, 580, 580);
		};

		// Abre Pesquisa de RECLAME/SOLUCAO
		function Pesquisa_RecSol(Tipo,Codigo,Descricao){
			TelaPesquisa("pesq_recsol.asp?mod=L&tipo=" + Tipo + "&campo1=" + Codigo + "&campo2=" + Descricao, 550, 580);
		};

		// Abre Pesquisa de VERSAO
		function Pesquisa_Versao(Versao){
			TelaPesquisa("pesq_versao.asp?mod=L&campo1=" + Versao, 650, 580);
		};

/*
---------------------------> Fim
*/




<!-- Funções para mudar a cor da linha de uma tabela ao passar o mouse sobre ela. -->
<!-- Início -->
function mOvr(src,clrOver) {
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
src.bgColor = clrOver;
}
}
function mOut(src,clrIn) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
src.bgColor = clrIn;
}
}
function mClk(src) {
if(event.srcElement.tagName=='TR'){
src.children.tags('A')[0].click();
}
}
<!-- Fim -->

<!-- Função para criação de mascaras em campo text do formulário. Esta função trabalha com keypress. -->
<!-- Início -->
function Mascara(formato, keypress, objeto){
Campo = eval(objeto);
// Mascara de Data
if(formato=='DATA'){
Separador = '/'; 
Conjunto1 = 2;
Conjunto2 = 5;
if(Campo.value.length == Conjunto1){
Campo.value = Campo.value + Separador;
}
if(Campo.value.length == Conjunto2){
Campo.value = Campo.value + Separador;
}
}
}
<!-- Fim -->

<!--Funcao de validacao-->
<!--Inicio-->


function checkrequired(which) {

	//VALIDA CAMPOS
	if (document.getElementById('requiredTipo').value == "SUO" || document.getElementById('requiredTipo').value == "") {
		alert( "Campo Tipo OS deve ser informado!");
		return false;
    }
	if (document.getElementById('requiredEquipe').value == "SUO" || document.getElementById('requiredEquipe').value == "") {
		alert( "Campo Equipe deve ser informado!");
		return false;
    }
	if (document.getElementById('requiredReclamante').value == "" || document.getElementById('requiredReclamante').value == "SUO") {
		alert( "Campo Reclamante deve ser informado!");
		return false;
    }
	if (document.getElementById('requiredSeqContato').value == "" ) {
		alert( "Campo Contato deve ser informado!");
		return false;
    }
    if (document.getElementById('Local').value == "SUO" || document.getElementById('Local').value == "") {
		alert( "Campo Produto deve ser informado!");
		return false;
    }
	if (document.getElementById('requiredSolicitacao').value == "SUO" || document.getElementById('requiredSolicitacao').value == "") {
		alert( "Campo Solicitação deve ser informado!");
		return false;
    }
	if (document.getElementById('c744').value == "Sim") { 
    	if (document.getElementById('requiredVersao').value == "") { 
      	  alert( "Campo Versão deve ser informado!");
          return false;
		}
    }
	
	var DsSolicitadoVisible = true;
	var PosicaoQuestionario = 0;
	
	//VALIDA QUESTIONARIO
	
	for( var i = 0; i < GeraOS.elements.length; i++ )
	{
		var tempobj = GeraOS.elements[i];
		if ( tempobj.name == "c1818")
		{		
			PosicaoQuestionario = i+1;
			break;
		}
	}
	
	//1818 MARCADA
	if ( $("#c1818").val() == "1" )
	{
		for( var PosicaoQuestionario; PosicaoQuestionario < GeraOS.elements.length; PosicaoQuestionario++ ){
			var tempobj = GeraOS.elements[PosicaoQuestionario];
			if ( tempobj.name.substring(0,9) == ( "required" + ((document.getElementById('requiredTipo').value).toUpperCase())))
			{		
				DsSolicitadoVisible = false;
				//alert(tempobj.value);
				if ( ((tempobj.type=="text" || tempobj.type=="textarea") && tempobj.value=='') || (tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==0)) 
				//if ( ((tempobj.type=="text" || tempobj.type=="textarea") && tempobj.value=='') || (tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==0) || (tempobj.type="radio" && tempobj.selected==null)) 
				{
					alert( "Preencha todos os campos das Informações Complementares" );
					return false;
				}
			}
		}
	
		if(document.getElementById('requiredDescricao Solicitacao').value == "" && DsSolicitadoVisible == true ){
			alert( "Campo Descrição Solicitado deve ser informado" );
			return false;
		}
	}
	
	//1818 DESMARCADA
	else
	{	
		if (document.getElementById('questionario').value=='1')
		{
			for( PosicaoQuestionario; PosicaoQuestionario < GeraOS.elements.length; PosicaoQuestionario++ ){
				var tempobj = GeraOS.elements[PosicaoQuestionario];
				if ( tempobj.value == "" )
				{		
					alert( "Preencha todos os campos das Informações Complementares" );
					return false;
				}
			}
		}
		else
		{
			if(document.getElementById('requiredDescricao Solicitacao').value == ""){
				alert( "Campo Descrição Solicitado deve ser informado" );
				return false;
			}
		}
	}
	
	return true;
}


function diasDecorridos(dt1, dt2) {
	// variáveis auxiliares
	var minuto = 60000; 
	var dia = minuto * 60 * 24;
	var horarioVerao = 0;

	// ajusta o horario de cada objeto Date
	dt1.setHours(0);
	dt1.setMinutes(0);
	dt1.setSeconds(0);
	dt2.setHours(0);
	dt2.setMinutes(0);
	dt2.setSeconds(0);

	// determina o fuso horário de cada objeto Date
	var fh1 = dt1.getTimezoneOffset();
	var fh2 = dt2.getTimezoneOffset();

	// retira a diferença do horário de verão
	if(dt2 > dt1){
		horarioVerao = (fh2 - fh1) * minuto;
	} 
	else{
		horarioVerao = (fh1 - fh2) * minuto;
	}

	var dif = Math.abs(dt2.getTime() - dt1.getTime()) - horarioVerao;
	return Math.ceil(dif / dia);
}


function Compara_Datas(data_inicial, data_final){  
	//Verifica se a data inicial é maior que a data final  
    var data_inicial = document.getElementById(data_inicial);  
    var data_final   = document.getElementById(data_final);  
    str_data_inicial = data_inicial.value;  
    str_data_final   = data_final.value;  
    dia_inicial      = data_inicial.value.substr(0,2);  
    dia_final        = data_final.value.substr(0,2);  
    mes_inicial      = data_inicial.value.substr(3,2);  
    mes_final        = data_final.value.substr(3,2);  
    ano_inicial      = data_inicial.value.substr(6,4);  
    ano_final        = data_final.value.substr(6,4);  
    
    if(ano_inicial > ano_final)
    {
		alert("A data inicial deve ser menor que a data final.");
        data_inicial.focus();
        return false
    }
    else
    {
		if(ano_inicial == ano_final)
    	{
    		if(mes_inicial > mes_final)
    		{
    			alert("A data inicial deve ser menor que a data final.");
                data_final.focus();
                return false
            }
            else
            {
                if(mes_inicial == mes_final)
                {
                    if(dia_inicial > dia_final)
                    {
                        alert("A data inicial deve ser menor que a data final.");
                        data_final.focus();
                        return false
                    }
                }
            }
        }
    }
    
    return true
}

	
function isDate(dateStr) {
    
	if ( dateStr == "00/00/0000" || dateStr == "" )
		return true;
    
    if ( (dateStr.length == 10) && (dateStr.indexOf("/") != dateStr.lastIndexOf("/")) )
    {
    	day = dateStr.split("/")[0];
    	month = dateStr.split("/")[1];
    	year = dateStr.split("/")[2];
    }
    else 
    {
    	alert("Entre com a data no formato correto 'DD/MM/AAAA'");
    	return false;
    }    
    
    if (year < 1920) {
		alert("Ano deve ser superior a 1920.");
        return false;
    }
    
    if (month < 1 || month > 12) { // verifica o período dos meses
        alert("Mês deve ser entre 1 e 12.");
        return false;
    }

    if (day < 1 || day > 31) {
        alert("Dia deve ser entre 1 e 31.");
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Mês "+month+" não tem 31 dias!")
        return false;
    }

    if (month == 2) { // verifica dia 29th de fereveiro
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            alert("Fevereiro " + year + " não tem " + day + " dias!");
            return false;
        }
    }
    return true; // data é válida
}

<!--Fim-->

<!--Funcao de validacao consulta-->
<!--Inicio-->

function validaFormulario(acao) {
  var formulario = document.consulta;
  var digitou = 1;
  var opcoes = '';

  
  for(i=0;i<=8;i++){
	  if (document.getElementById('chkSituacao'+i).checked) {
		if ( opcoes=='' ) {
			//essa linha vai fazer com que não comece por ";"
			opcoes = "'" + document.getElementById('chkSituacao'+i).value + "'";
		}
		else {
			opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao'+i).value + "'";
		}
	  }
  }
/*  if (document.getElementById('chkSituacao1').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao1').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao1').value + "'";
	}
  }
  if (document.getElementById('chkSituacao2').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao2').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao2').value + "'";
	}
  }
  if (document.getElementById('chkSituacao3').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao3').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao3').value + "'";
	}
  }
  if (document.getElementById('chkSituacao4').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao4').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao4').value + "'";
	}
  }
  if (document.getElementById('chkSituacao5').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao5').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao5').value + "'";
	}
  }
  if (document.getElementById('chkSituacao6').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao6').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao6').value + "'";
	}
  }
  if (document.getElementById('chkSituacao7').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao7').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao7').value + "'";
	}
  }
  if (document.getElementById('chkSituacao8').checked) {
	if ( opcoes=='' ) {
		//essa linha vai fazer com que não comece por ";"
		opcoes = "'" + document.getElementById('chkSituacao8').value + "'";
	}
	else {
		opcoes = opcoes + ';' + "'" + document.getElementById('chkSituacao8').value + "'";
	}
  }
  */
  if( opcoes == "'A';'C';'E';'F';'I';'L';'P';'R'" ) {
		opcoes = '';
  }
  document.getElementById('hidSituacoesAleatorias').value = opcoes;


  with ( formulario ) {
    // OS Inicial
    if (OS_Inicial.value != "" && OS_Inicial.value != "000000")
      digitou = 0;
    
    // OS Final
    if (OS_Final.value != "" && OS_Final.value != "000000")
      digitou = 0;
    
    // Data Inicial
    if (Data_Inicial.value != "" && Data_Inicial.value != "00/00/0000")
      digitou = 0;   
    
    // Data Final
    if (Data_Final.value != "" && Data_Final.value != "00/00/0000")
      digitou = 0;
  
    // Prazo Programado Inicial
    if (Prazo_Programado_I.value != "" & Prazo_Programado_I.value != "00/00/0000")
      digitou = 0;
    
    // Prazo Programado Final
    if (Prazo_Programado_F.value != "" && Prazo_Programado_F.value != "00/00/0000")
      digitou = 0;

    // Data Conclusão Inicial
    if (Data_Concl_Inicial.value != "" & Data_Concl_Inicial.value != "00/00/0000")
      digitou = 0;
    
    // Data Conclusão Final
    if (Data_Concl_Final.value != "" && Data_Concl_Final.value != "00/00/0000")
      digitou = 0;
  }

  switch (digitou) 
  {
  	case 1:
  		alert( "Deve ser informada a Ordem de Serviço ou a Data do Item ou o Prazo Programado ou a Data Conclusão do Item!");
  		break;
  	default:
		//if( acao == "Grafico" ){
		if( acao == "1" ){
			document.getElementById('GerarGrafico').value = 'S';
		}else{
			document.getElementById('GerarGrafico').value = 'N';
		}
		formulario.submit();
		break;
  		
  } // switch
}

<!--Fim-->

<!--Funcao de controle das informacoes auxiliares-->
<!--Inicio-->

function existequestionario(){

	if (document.getElementById('questionario').value=='1')
	{
		document.getElementById('inforauxil').style.display='';
		
	}else{
		document.getElementById('reclame_avulso').style.display='';
		document.getElementById('tabbody').height='350';
	}
		
}

<!--Fim-->




/*
############################################################################################
##----------------------------------------------------------------------------------------##
##----------------------------------------------------------------------------------------##
##-------########-########-####-----##-########-########-########-##-------#######--------##
##-------##-------##----##-##-##----##----##----##----##-##----##-##-------##-------------##
##-------##-------##----##-##--##---##----##----########-##----##-##-------#####----------##
##-------##-------##----##-##---##--##----##----##-##----##----##-##-------##-------------##
##-------##-------##----##-##----##-##----##----##--###--##----##-##-------##-------------##
##-------########-########-##-----####----##----##---###-########-########-#######--------##
##----------------------------------------------------------------------------------------##
##-----------------------------------#####---#######--------------------------------------##
##-----------------------------------##--##--##-------------------------------------------##
##-----------------------------------##---##-#####----------------------------------------##
##-----------------------------------##---##-##-------------------------------------------##
##-----------------------------------##--##--##-------------------------------------------##
##-----------------------------------#####---#######--------------------------------------##
##----------------------------------------------------------------------------------------##
##----#######-########-######-##-----##-######-#####---#######-#####---#######-#######----##
##----##---##----##------##---##-----##---##---##--##--##---##-##--##--##------##---------##
##----#######----##------##---##-----##---##---##---##-#######-##---##-#####---#######----##
##----##---##----##------##----##---##----##---##---##-##---##-##---##-##-----------##----##
##----##---##----##------##-----##-##-----##---##--##--##---##-##--##--##-----------##----##
##----##---##----##----######-----##----######-#####---##---##-#####---#######-#######----##
##----------------------------------------------------------------------------------------##
##----------------------------------------------------------------------------------------##
############################################################################################
*/

// >>>>>>>>>>>>>>>>>>>>>>>  Variáveis GLOBAIS  <<<<<<<<<<<<<<<<<<<<<<<<<<<<

// objetos HTTP request do AJAX
var xmlHttp, xmlHttp2, xmlHttp3;

// ids para Statechange do AJAX
var id_nome, id_nome2;

// global_parametros para Iniciar/Pausar/Continuar/Finalizar Atividade
var param;
var global_btn_Iniciar = false;
var global_btn_Finalizar = false;
var global_parametros = "";

// cronômetro
var hrs = 0; 
var mins = 0; 
var segs = 0;
var timer;
var global_play = true;
var global_pause = true;

// linha da Atividade selecionada
var global_idlinha;


// >>>>>>>>>>>>>>>>>>>  Fim das Variáveis GLOBAIS  <<<<<<<<<<<<<<<<<<<<<<<<



<!-- Início -->
/***************  Verifica se algum Valor é Nulo  ****************/
function isNull(val) { 
	return(val == null);
}
/*****************************************************************/
<!-- Fim -->



<!-- Início -->
/***************  Troca Class da Atividade selecionada  ****************/
function sel(idlinha) {
	var linha = document.getElementById(idlinha);
	var i = 1;
	while (document.getElementById("linha" + String(i)) != null)
	{
  		idlinha = "linha" + String(i);
  		document.getElementById(idlinha).className = "unsel";
  		i++;
	}		
	linha.className = "sel";
}
/***********************************************************************/
<!-- Fim -->




/************************ Atualiza CORES das Atividades **************************/
<!-- Início -->
function AtualizaCores() {
	var idlinha;
	var linha = global_idlinha.replace(/linha/i,"tds");
	
	var i = 1;
	while (document.getElementById("tds" + String(i)) != null)
	{
  		idlinha = "tds" + String(i);
  		if (document.getElementById(idlinha).className == "tdsPlay")
  		{
  			document.getElementById(idlinha).className = "tdsPause";
  		}
  		i++;
	}
	
	if (global_play)
	{
		document.getElementById(linha).className = "tdsPlay";
	}	
}

/**************************************************************************************/
<!-- Fim -->



<!-- Início -->
/******************  Funções de TRIM  *******************/
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}

function rtrim(str) {
	for(var j=str.length-1; j >= 0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}

function trim(str) {
	return ltrim(rtrim(str));
}

function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
/********************************************************/
<!-- Fim -->



<!-- Início -->
/***********************  Funções para Máscara de Campo  **************************/

var v_obj, v_obj2, v_fun, v_fun2;
var v_obj3, v_obj3a, v_obj3b, v_fun3;

function mascara(o, f) {
    v_obj = o;
    v_fun = f;
    setTimeout("execmascara()", 1);
}

function execmascara() {
    v_obj.value = v_fun(v_obj.value);
}

function soNumeros(v) {
    return v.replace(/\D/g, "");
}


function mascara2(o, f) {
    v_obj2 = o;
    v_fun2 = f;
    setTimeout("execmascara2()", 1);
}

function execmascara2() {
    v_obj2.value = v_fun2(v_obj2);
}

function validaHorasMinutos(campo,tipo) {
	switch (tipo) 
	{
		case "h": max = 23; zero = "0"; break;
		case "m": max = 59; zero = "00"; break;
		case "": max = 999999999999; zero = "0"; break;
		default: break;
	}
	if ( (campo.value > max) || (campo.value == "") )
		return zero;
	else
	{	
		campo.value = (campo.value < 10) ? "0" + parseInt(campo.value,10) : campo.value;
		return campo.value;
	}
	
}
/*********************************************************************************/
<!-- Fim -->



<!-- Início -->

// Mascara3 - Calcula campos de Horas e Minutos em Quantidade Utilizada
function mascara3(o, a, b, f) {
	v_obj3 = o;
    v_obj3a = a;
    v_obj3b = b;
    v_fun3 = f;
    setTimeout("execmascara3()", 1);
}

function execmascara3() {
    v_obj3.innerHTML = v_fun3(v_obj3a.value, v_obj3b.value);
}

					// HrIni   MinIni  HrFim   MinFim
function calcTempoAtiv(campo1, campo2, campo3, campo4, tipo) {
	switch (tipo)
	{
		case "quant":
			var a = parseInt(campo1,10);
			var b = parseInt(parseInt(campo2,10) / 0.6,10);
			var c = (b < 10) ? "0" + String(b) : String(b);
			
			if (campo2 < 60)
				return String(a) + "." + String(c);
			else
				return a + ".00";
		break;
		case "horas":
			var a = parseInt(parseInt(campo2,10) / 0.6,10);
			var b = parseInt(parseInt(campo4,10) / 0.6,10);			
			var c = (a < 10) ? "0" + String(a) : String(a);
			var d = (b < 10) ? "0" + String(b) : String(b);
			
			var ini = campo1 + "." + c;
			var fim = campo3 + "." + d;
			var t = parseFloat(fim) - parseFloat(ini);
			var r = String(t);
			
			if (t <= 0)
			{
				h = "0"; m = "00";
			}
			else
				if (t === parseInt(t,10))
				{
					h = r; m = "00";
				}
				else
				{
					var h = r.slice(0,r.indexOf("."));
					var m = String(parseInt(parseFloat(r.slice(r.indexOf(".") + 1,r.indexOf(".") + 3)) * 0.6,10));
				}
			
			return h + ":" + m;
		break;
		default:
		break;
	}
}


/***************************************************************************************/
<!-- Fim -->






<!-- Início -->
/***********************  Click em Continuar Mesma Atividade  **************************/
function ContinuarMesmaAtiv() {
	if (document.getElementById('criar_ativ_apos').checked)
	{
		document.getElementById('criar_ativ_apos').value = "S";
		document.getElementById('tecnico').value = document.getElementById('tec').value;
		document.getElementById('nome_tecnico').value = document.getElementById('nome_tec').value;
		document.getElementById('atividade').value = document.getElementById('ativ').value;
		document.getElementById('atividade_desc').value = document.getElementById('ativ_desc').value;
		
		document.getElementById('data_prev_ini').innerHTML = document.getElementById('ini_prev').value;
		document.getElementById('data_prev_fim').innerHTML = document.getElementById('fim_prev').value;
	}
	else
	{
		document.getElementById('criar_ativ_apos').value = "N";
		document.getElementById('tecnico').value = document.getElementById('prox_tec').value;
		document.getElementById('nome_tecnico').value = document.getElementById('nome_prox_tec').value;
		document.getElementById('atividade').value = document.getElementById('prox_ativ').value;
		document.getElementById('atividade_desc').value = document.getElementById('prox_ativ_desc').value;
		
		document.getElementById('data_prev_ini').innerHTML = document.getElementById('ini_prev_prox').value;
		document.getElementById('data_prev_fim').innerHTML = document.getElementById('fim_prev_prox').value;
	}

}
/******************************************************************************/
<!-- Fim -->



<!-- Início -->
/********************** INICIAR / FINALIZAR / NOVA ATIVIDADE ***********************/
function ExecIniciarFinalizar(acao) {

	var os = trim(document.getElementById('os').value);
	var item = trim(document.getElementById('item').value);
	var etapa = trim(document.getElementById('etapa_ativ').value);
	var i = 1;
	var achou = false;
	
	if (acao == "F")
	{
		achou = true;
	}
	
	var idlinha;
	while ((document.getElementById("linha" + String(i)) != null) && !achou)
	{	
  		idlinha = "linha" + String(i);
  		if (document.getElementById(idlinha).className == "sel")
  		{
  			achou = true;
  		}
  		i++;
	}		

	if (achou)
	{
		global_parametros = trim(document.getElementById('CIGAM_SID').value);
		global_parametros += ",-A" + acao + ",-N" + os + ",-N" + item + ",-N" + etapa;
		
		switch (acao) {
				case "I":
			
			    if (document.getElementById('permite_inicio').value != 'S')
			    {
			        alert('Atividade do tipo Coletivo Sequencial. Não é permitido Iniciar/Finalizar esta atividade sem concluir a anterior.');
			    }
			    else
			    {
				    if (document.getElementById('C1645').value == 'S')
				    {
					    global_btn_Iniciar = true;
					    global_play = false;
					    PlayPause('play');
				    }
				    else
				    {
    					document.location = document.getElementById('webrequest2').value + global_parametros;
				    }
				}
			break;
			case "F":
				if (trim(document.getElementById('quant_util').innerHTML) == "0.00")
				{
					alert('Por Favor! Informe o tempo da Atividade!');
				}
				else
				{
					//var quant = trim(document.getElementById('quant_util').innerHTML);
					var quant = $("#quant_util").attr("innerHTML").replace(/,/,".");
					//alert(quant);
					global_parametros += ",-N" + quant + ",-A" + document.getElementById('criar_ativ_apos').value;
					global_parametros += ",-A" + $("#data_ini").val() + ",-A" + $("#quant_horas_ini").val() + ":" + $("#quant_min_ini").val();
					global_parametros += ",-A" + $("#data_fim").val() + ",-A" + $("#quant_horas_fim").val() + ":" + $("#quant_min_fim").val();
					
					if (document.getElementById('C1645').value == "S")
					{
						PlayPause('finaliza');
					}
					else
					{
						document.location = document.getElementById('webrequest2').value + global_parametros;
					}
				}
			break;
			case "N":
				if (document.getElementById('C1645').value == 'S')
				{
					if (document.getElementById('situacao_apont').value == '1')
					{
						global_btn_Finalizar = true;
						global_pause = false;
						PlayPause('pause');
					}
					else
					{
						document.location = document.getElementById('webrequest2').value + global_parametros;
					}
				}
				else
				{
					document.location = document.getElementById('webrequest2').value + global_parametros;
				}
			break;
			default:
				alert("Operação Cancelada!");
			break;
		}
	}
}
   
/********************************************************************************************/
<!-- Fim -->


<!-- Início -->
/************************************  Busca TEMPO  ****************************************/
function buscaTempo() {
	var url = "/osweb/busca_tempo.asp?os=" + document.getElementById('os').value;
	url = url + "&item=" + document.getElementById('item').value;
	url = url + "&etapa=" + document.getElementById('etapa_ativ').value;
	url = url + "&tec=" + document.getElementById('tecnico_atividade').value;
	url = url + "&t_aponta=" + document.getElementById('T_apontamento').value;
	url = url + "&rdm=" + Math.random();
		
	mostraInfos2(url,"crono");
}	
/********************************************************************************************/
<!-- Fim -->



<!-- Início -->
/**********************  CRONÔMETRO  **************************/

function turnTo(act, id) {
	document.getElementById(id).disabled = act;
	
	if (id == "start")
	{
		document.getElementById('imgPlay').src = "/images/btn_play" + act + ".png";
		if (act == "disabled")
			document.getElementById('imgPlay').style.cursor = "default";
		else
			document.getElementById('imgPlay').style.cursor = "pointer";

	}
	else
	{
		document.getElementById('imgPause').src = "/images/btn_pause" + act + ".png";
		if (act == "disabled")
			document.getElementById('imgPause').style.cursor = "default";
		else
			document.getElementById('imgPause').style.cursor = "pointer";
	}
}

function textReplace(vlu, id) {
	document.getElementById(id).value = vlu;
}


function cronometro() {
	var acoes = new Array("disabled","");
	var ids = new Array("start","pause");
	var j = 0;
	
	while(j < acoes.length) 
	{
  		turnTo(acoes[j],ids[j]);
  		j++;
	}
	
	cronoStart();
}

function cronoStart() {
	segs++;
	if(segs == 60) 
	{
		mins++;
  		segs = 0;
  		if(mins == 60) 
  		{
  			hrs++;
  			mins = 0;
  		}
	}
	var formSegs = (segs < 10) ? "0" + segs : segs;
	var formMins = (mins < 10) ? "0" + mins : mins;
	var formHrs = (hrs < 10) ? "0" + hrs : hrs;
	
	textReplace(formHrs + ":" + formMins + ":" + formSegs,"crono");
	textReplace("A atividade está iniciada.","instr");
	timer = window.setTimeout("cronoStart();",1000);
			
}

function cronoPause() {
	if (document.getElementById('situacao_apont').value == '4')
	{
		textReplace("A atividade está pausada.","instr");
	}
	else
	{
		textReplace("A atividade está parada.","instr");
	}

	window.clearTimeout(timer);
	var acoes = new Array("","disabled");
	var ids = new Array("start","pause");
	
	var k = 0;
	while(k < acoes.length) 
	{
		turnTo(acoes[k],ids[k]);
		k++;
	}

}


/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> INATIVO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
function cronoZero() {
	window.clearTimeout(timer);
	segs = 0;
	mins = 0;
	hrs = 0;
	textReplace("00:00:00","crono");
	textReplace("A atividade está parada.","instr");
	var acoes = new Array(false,true,true);
	var ids = new Array("start","pause","pontozero");
	var l = 0;
	while(l < acoes.length) 
	{
		turnTo(acoes[l],ids[l]);
  		l++;
	}
}
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> INATIVO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */

<!-- Fim -->
/************************************************************/


<!-- Início -->
/******************************  Verifica Apontamento  ***********************************/
function VerificaApontamento() {
	var url = "/osweb/verifica_apontamento.asp?os=" + document.getElementById('os').value;
	url = url + "&item=" + document.getElementById('item').value;
	url = url + "&etapa=" + document.getElementById('etapa_ativ').value;
	url = url + "&tec=" + document.getElementById('tecnico_atividade').value;
	url = url + "&t_aponta=" + document.getElementById('T_apontamento').value;
	url = url + "&rdm=" + Math.random();

	mostraInfos2(url,"existe_apont_iniciado");
}
<!-- Fim -->
/****************************************************************************************/


<!-- Início -->
/********************  Atualiza Atividade no BANCO (Iniciar / Finalizar / Continuar)  *******************/
function AtualizaAtiv(acao,apont_ini) {
	var url = "/osweb/atualiza_ativ.asp?acao=" + acao;
	url = url + "&os=" + document.getElementById('os').value;
	url = url + "&item=" + document.getElementById('item').value;
	url = url + "&etapa=" + document.getElementById('etapa_ativ').value;
	url = url + "&tec=" + document.getElementById('tecnico_atividade').value;
	url = url + "&cod_tec=" + document.getElementById('cod_tecnico_atividade').value;
	url = url + "&t_aponta=" + document.getElementById('T_apontamento').value;
	url = url + "&apont_ini=" + apont_ini;
	url = url + "&c549=" + document.getElementById('C549').value;
	url = url + "&rdm=" + Math.random();

	mostraInfos3(url);
}
<!-- Fim -->
/****************************************************************************************/

<!-- Início -->
/******************************  Play / Pause  ***********************************/
function PlayPause(acao) {

	if (acao == 'play' && !global_play)
	{
		param = "C"; VerificaApontamento();
	}
	else if (acao == 'pause' && !global_pause)
	{
		param = "P"; VerificaApontamento();
	}
	else if (acao == 'finaliza')
	{
		param = "F"; AtualizaAtiv("F","N");
	}
	
}
<!-- Fim -->
/****************************************************************************************/

<!-- Início -->
/******************************  Adicionar TEMPO  ***********************************/
function addTempo() {
	
}
<!-- Fim -->
/****************************************************************************************/




<!-- Início -->
/*********************  onClick botões OBJETOS / ACOMPANHAMENTO / VERSÃO  **********************/
function chamaObjAcompVersao(opcao) {
	
	var parametros = document.getElementById('CIGAM_SID').value + ",-N" + trim(document.getElementById('os').value) + ',-N' + trim(document.getElementById('item').value);
	var impressao = "-AI,"+ document.getElementById('CIGAM_SID').value + ",-N" + trim(document.getElementById('os').value) + ",-N" + trim(document.getElementById('os').value) + ',-N' + trim(document.getElementById('item').value) + ',-N' + trim(document.getElementById('item').value);
	var dadosOS = document.getElementById('CIGAM_SID').value + ",-N" + trim(document.getElementById('os').value) + ",-N" + trim(document.getElementById('os').value);
	dadosOS = dadosOS + ",-A00/00/0000,-A00/00/0000,-A00/00/0000,-A00/00/0000,-AA,-AR,-A*,-A*,-A,-A,-A,-A,-AN,-AN,-A,-N0,-A,-A,-A,-A,-A";
	dadosOS = dadosOS + ',-N' + trim(document.getElementById('item').value) + ',-N' + trim(document.getElementById('item').value);
	dadosOS = dadosOS + ",-A*,-A ,-A,-A,-A00/00/0000,-A00/00/0000";
	
	switch (opcao) {
		case "O":
			document.location = document.getElementById('webrequestObj').value + parametros;
		break;
		case "A":
			if (document.getElementById('cod_cliente').value != "")
			{
				parametros = parametros + ",-A" + document.getElementById('cod_cliente').value;
				document.location = document.getElementById('webrequestAcomp').value + parametros;
			}
		break;
		case "V":
			document.location = document.getElementById('webrequestVersao').value + parametros;
		break;
		case "I":
			document.location = document.getElementById('webrequestImpressao').value + impressao;
		break;
		case "S":
			document.location = document.getElementById('webrequestOS').value + dadosOS;
			//alert (dadosOS);
		break;

		default:
		break;
	}
}
/*******************************************************************************************/
<!-- Fim -->




<!-- Início -->
/***************************  onClick das ATIVIDADES  ************************************/

function buscaInfos(hid1, hid2, idLinha) { // não referenciado neste arquivo??? 

if (document.getElementById(idLinha).className != "sel")
	{
		var aux_str = trim(hid1.innerHTML);
		var os = aux_str.slice(0,aux_str.lastIndexOf("/"));
		var item = aux_str.slice(aux_str.lastIndexOf("/")+1);
		var etapa = trim(hid2.innerHTML);
	
		document.getElementById("os").value = os;
		document.getElementById("item").value = item;
		document.getElementById("etapa_ativ").value = etapa;
		
		var url = "/osweb/pesquisaos.asp?v_os=" + os;
		url = url + "&v_item=" + item;
		url = url + "&v_etapa=" + etapa;
		url = url + "&t_ativ=" + document.getElementById('T_Ativ').value;
		url = url + "&t_os=" + document.getElementById('T_os').value;
		url = url + "&t_tipo_ativ=" + document.getElementById('T_tipo_ativ').value;
		url = url + "&t_item_os=" + document.getElementById('T_item_os').value;
		url = url + "&t_tipo_os=" + document.getElementById('T_tipo_os').value;
		url = url + "&t_prod_cli=" + document.getElementById('T_prod_cli').value;
		url = url + "&t_num_serie=" + document.getElementById('T_num_serie').value;
		url = url + "&t_mat=" + document.getElementById('T_mat').value;
		url = url + "&t_emp=" + document.getElementById('T_emp').value;
		url = url + "&t_def_sol=" + document.getElementById('T_def_sol').value;
		url = url + "&t_det_def_sol=" + document.getElementById('T_det_def_sol').value;
		url = url + "&t_apontamento=" + document.getElementById('T_apontamento').value;
		url = url + "&t_usuario=" + document.getElementById('T_usuario').value;
		url = url + "&c549=" + document.getElementById('C549').value;
		url = url + "&rdm=" + Math.random();
	
		mostraInfos(url,"divDados");
		sel(idLinha);
		
		
		global_idlinha = idLinha;
	}
	
}
/**************************************************************************************/
<!-- Fim -->




/************************ Libera Botões - Enable/Disable **************************/
<!-- Início -->
function LiberaBotoes() {
	if (document.getElementById('situacao_ativ').value != "I")
	{
		document.getElementById('Iniciar').disabled = "";
		document.getElementById('Iniciar').className = "botaoAtiv";
		document.getElementById('Finalizar').disabled = "disabled";
		document.getElementById('Finalizar').className = "botaoAtivDisabled";
		
		textReplace("A atividade está parada.","instr");

		var acoes = new Array("disabled","disabled");
		var ids = new Array("start","pause");
				
		global_play = true;
		global_pause = true;

		var k = 0;
		while(k < acoes.length) 
		{
			turnTo(acoes[k],ids[k]);
			k++;
		}

	}
	else
	{
		document.getElementById('Iniciar').disabled = "disabled";
		document.getElementById('Iniciar').className = "botaoAtivDisabled";
		document.getElementById('Finalizar').disabled = "";
		document.getElementById('Finalizar').className = "botaoAtiv";
	
		if (document.getElementById('C1645').value == "S")
		{
			if (document.getElementById('situacao_ativ').value == "I")
			{
				if (document.getElementById('situacao_apont').value == "1")
				{
					var acoes = new Array("disabled","");
					var ids = new Array("start","pause");
					
					global_play = true;
					global_pause = false;
					
				}
				else
				{
					var acoes = new Array("","disabled");
					var ids = new Array("start","pause");
					
					global_play = false;	
					global_pause = true;
					
				}
			}
			else
			{
				var acoes = new Array("disabled","disabled");
				var ids = new Array("start","pause");
					
				global_play = true;
				global_pause = true;
			}
		
			var k = 0;
			while(k < acoes.length) 
			{
				turnTo(acoes[k],ids[k]);
				k++;
			}
		
		}
	}
	
	try
	{ document.getElementById('btnObj').disabled = ""; }
    catch(e) {}
    try
    { document.getElementById('btnAcomp').disabled = ""; }
    catch(e) {}
    try
    { document.getElementById('btnVersao').disabled = ""; }
    catch(e) {}
    try
    { document.getElementById('btnImprimir').disabled = ""; }
    catch(e) {}
    try
    { document.getElementById('btnOS').disabled = ""; }
    catch(e) {}
    try
    { document.getElementById('btnObj').className = "botaoAtiv"; }
    catch(e) {}
    try
    { document.getElementById('btnAcomp').className = "botaoAtiv"; }
    catch(e) {}
    try
    { document.getElementById('btnVersao').className = "botaoAtiv"; }
    catch(e) {}
    try
    { document.getElementById('btnImprimir').className = "botaoAtiv"; }
    catch(e) {}
    try
    { document.getElementById('btnOS').className = "botaoAtiv"; }
    catch(e) {}
	

	try
    { document.getElementById('btnAltera_Solucao').disabled = ""; }
    catch(e) {}
	try
    { document.getElementById('btnAltera_Reclamado').disabled = ""; }
    catch(e) {}
	
}
/**************************************************************************/
<!-- Fim -->


<!-- Início -->
/****************************  PLAY / PAUSE  *******************************/
function PlayPauseCrono() {	
	var str = document.getElementById('crono').value;
	if (document.getElementById('situacao_apont').value == '1')
	{
		hrs = parseInt(str.slice(0,2),10);
		mins = parseInt(str.slice(3,5),10);
		segs = parseInt(str.slice(6,8),10);

		cronometro();
		
	}
	else
	{
		cronoPause();
	}
}
/**************************************************************************/
<!-- Fim -->




<!-- Início -->
/******************************  Funções AJAX  *********************************/

function mostraInfos(url,q_id) 
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) 
	{
		alert ("Este Browser não suporta AJAX!");
		return
	}
	id_nome = q_id;

	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.send(null);
}

function mostraInfos2(url,q_id) 
{
	xmlHttp2 = GetXmlHttpObject();
	if (xmlHttp2 == null) 
	{
		alert ("Este Browser não suporta AJAX!");
		return
	}
	id_nome2 = q_id;

	xmlHttp2.open("GET",url,true);
	xmlHttp2.onreadystatechange = stateChanged2;
	xmlHttp2.send(null);
}

function mostraInfos3(url) 
{
	xmlHttp3 = GetXmlHttpObject();
	if (xmlHttp3 == null) 
	{
		alert ("Este Browser não suporta AJAX!");
		return
	}
	
	xmlHttp3.open("GET",url,true);
	xmlHttp3.onreadystatechange = stateChanged3;
	xmlHttp3.send(null);
}

function stateChanged() 
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") 
	{
		//alert(xmlHttp.responseText);
		document.getElementById(id_nome).innerHTML = xmlHttp.responseText;
		LiberaBotoes();
		buscaTempo();
	}
}

function stateChanged2() 
{
	if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == "complete") 
	{
		//alert(xmlHttp2.responseText);
		document.getElementById(id_nome2).value = xmlHttp2.responseText;
				
		if (document.getElementById('C1645').value == 'S')
		{
			if (id_nome2 == "crono" && document.getElementById('situacao_ativ').value == "I")
			{
				PlayPauseCrono();	
			}
			else
			{
				window.clearTimeout(timer);				
			}
		
			if (id_nome2 == "existe_apont_iniciado")
			{
				var pausar_ativ;
				var apont_ini = document.getElementById('existe_apont_iniciado').value;
				if (apont_ini == 'S')
				{
					pausar_ativ = confirm('Deseja pausar a atividade atual?');
					if (pausar_ativ)
					{
						AtualizaAtiv(param,apont_ini);
					}
					else
					{
						global_btn_Iniciar = false;
					}
				}
				else
				{
					apont_ini = 'N';
					AtualizaAtiv(param,apont_ini);
				}	
			}
		
		}
	}
}

function stateChanged3() 
{
	if (xmlHttp3.readyState == 4 || xmlHttp3.readyState == "complete") 
	{		
		//alert(xmlHttp3.responseText);
		document.getElementById('aux').value = xmlHttp3.responseText;
		
		if (param == "P")
		{
			document.getElementById('situacao_apont').value = "4";
			LiberaBotoes();
			PlayPauseCrono();
			AtualizaCores();
			
			if (global_btn_Finalizar)
			{
				global_btn_Finalizar = false;
				document.location = document.getElementById('webrequest2').value + global_parametros;
			}
		}
		
		if (param == "C")
		{
			document.getElementById('situacao_apont').value = "1";
			LiberaBotoes();
			PlayPauseCrono();
			AtualizaCores();
		}
			
		if (global_btn_Iniciar)
		{
			global_btn_Iniciar = false;
			document.location = document.getElementById('webrequest2').value + global_parametros;
		}
		
		if(param == "F")
		{
			document.location = document.getElementById('webrequest2').value + global_parametros;
		}
				
	}
}



function GetXmlHttpObject() 
{
	var xmlHttp = null;
	try 
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} 
	catch (e) 
		{
			try 
			{
				//Internet Explorer 6.0+
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) 
				{
					//Internet Explorer 5.5+
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
		}
	return xmlHttp;
}




<!-- Fim -->






<!-- Início -->
/**************************  Construção do Menu CIGAM - XML  *****************************/
function ArvoreXML(xmlNode){
	
	var arvoreTxt = "";
	var count = 0;
	var countT = 0;
	var ultimaTag = "";
	
	for(var i = 0; i < xmlNode.childNodes.length; i++)
	{ if(xmlNode.childNodes[i].nodeType == 1) { countT++; } }
	
	for(var i = 0; i < xmlNode.childNodes.length; i++)
	{
		if(xmlNode.childNodes[i].nodeType == 1) //ignorar espaços em branco
		{	
			if(temDireitos(xmlNode.childNodes[i].getAttribute("direitos")))
			{
				arvoreTxt += "<li>";
				count++;
				
				if(xmlNode.childNodes[i].childNodes.length > 0)
				{
					arvoreTxt += "<span class='" + xmlNode.childNodes[i].getAttribute("tipo") + "'>";
					
					//-----> link
					if (xmlNode.childNodes[i].getAttribute("link"))
					{ arvoreTxt += "<a target='principal' href='" + xmlNode.childNodes[i].getAttribute("link") + "'>"; }
					
					//-----> programa
					if (xmlNode.childNodes[i].getAttribute("programa"))
   					{
   						arvoreTxt += "<a target='principal' href='" + $("#webrequest").val();
   						arvoreTxt += "?APPNAME=" + xmlNode.childNodes[i].getAttribute("aplicacao");
   						arvoreTxt += "&PRGNAME=" + xmlNode.childNodes[i].getAttribute("programa");
   						arvoreTxt += "&ARGUMENTS=" + xmlNode.childNodes[i].getAttribute("args1");
   						arvoreTxt += "-A" + $("#cigam_sid").val();
   						arvoreTxt += xmlNode.childNodes[i].getAttribute("args2") + "'>";
   					}
					
					//-----> descrição do Menu
					arvoreTxt += xmlNode.childNodes[i].firstChild.nodeValue;
   					
   					
   					//-----> link ou programa
   					if (xmlNode.childNodes[i].getAttribute("link") || xmlNode.childNodes[i].getAttribute("programa"))
   					{ arvoreTxt += "</a>"; }
   					
   					arvoreTxt += "</span>";
   					
   					if (xmlNode.childNodes[i].getAttribute("tipo") == "file")
   					{ arvoreTxt += "</li>"; ultimaTag = "file"; }
					
					if (xmlNode.childNodes[i].getAttribute("tipo") != "file")
   					{ arvoreTxt += "<ul>"; ultimaTag = "folder"; }
   					
				    arvoreTxt += ArvoreXML(xmlNode.childNodes[i]);
				    
   				}
   				
   				//Internet Explorer
   				if($.browser.msie)
   					if((countT == count) && (ultimaTag == "folder")) { arvoreTxt += "</ul>"; }
   				
   				//Firefox Mozilla
   				if($.browser.mozilla)
   					if(countT == count) { arvoreTxt += "</ul>"; }
   				
   				
   				if (xmlNode.childNodes[i].getAttribute("tipo") != "file")
   				{ arvoreTxt += "</li>"; }
				
				
			} //if 'temDireitos'
		}
    }
    
    return arvoreTxt;
}


function get_nextSibling(n)
{
	var y = n.nextSibling;
	while (y.nodeType != 1)
	{
		y = y.nextSibling;
	}
	return y;
}


/*******************  Verifica Direitos para exibir itens do menu  **********************/
function temDireitos(tiposPermitidos)
{
	var tipo = $("#tipo_usuario").val();
	
	if(tiposPermitidos.indexOf(tipo) >= 0)
	return true;
	
	return false;
}

/****************************************************************************************/
<!-- Fim -->




