//*****************************************************************************
//Objetivo:					Encapsular funcionalidades do Site Responsabilidade Social Admin
//Autor:					- Marcelo Pacheco (7COMm)
//Data:						- 10/03/2006
//Autor:					
//Data Ultima alteração:	
//Motivo:					
//*****************************************************************************
//*****************************************************************************
// DECLARAÇÃO DAS VARIÁVEIS
//*****************************************************************************
//Variáveis Globais
var PATH = "C:\\BovRespSocial\\"			// Caminho para gravação dos arquivos na máquina cliente
var strNome = "Projetos.xml"				// Nome do arquivo que contém os informações de Projetos
var strNomeDados = "DadosCadastrais.xml"	// Nome do arquivo que contém os informações da Empresa
var strNoticias = "Noticias.xml"			// Nome do arquivo que cotém os informações das Notícias
var strDataXML = "Data.xml"					// Nome do arquivo que cotém os informações de Datas de Atualizações
var intIndice = 0							// Variavel utilizada como contador
// ----------------------------------------------------------------------------
// Objetivo  : Sortea as imagens para exibir no site
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum 
// ----------------------------------------------------------------------------
function SortearImg()
{
	
	var arrTrocaOrdem = new Array() // array bidimensional Recebe o valores para trocara ordem do Array
	var arrTrocaOrdemFoto = new Array() // array bidimensional Recebe o valores para trocara ordem do Array
	var arrAux = new Array(2)// Array Auxiliar para monta o array bidimencional
	
	//var arrNomeImg = new Array('\/wrs/Imagem\/QuadroHome03.gif','\/wrs/Imagem\/QuadroHome26.gif','\/wrs/Imagem\/QuadroHome10.gif','\/wrs/Imagem\/QuadroHome15.gif','\/wrs/Imagem\/QuadroHome25.gif','\/wrs/Imagem\/QuadroHome27.gif','\/wrs/Imagem\/QuadroHome28.gif','\/wrs/Imagem\/QuadroHome29.gif','\/wrs/Imagem\/QuadroHome30.gif','\/wrs/Imagem\/QuadroHome31.gif','\/wrs/Imagem\/QuadroHome32.gif','\/wrs/Imagem\/QuadroHome34.gif','\/wrs/Imagem\/QuadroHome35.gif','\/wrs/Imagem\/QuadroHome36.gif','\/wrs/Imagem\/QuadroHome37.gif','\/wrs/Imagem\/QuadroHome38.gif','\/wrs/Imagem\/QuadroHome39.gif','\/wrs/Imagem\/QuadroHome40.gif','\/wrs/Imagem\/QuadroHome41.gif','\/wrs/Imagem\/QuadroHome42.gif','\/wrs/Imagem\/QuadroHome43.gif','\/wrs/Imagem\/QuadroHome44.gif','\/wrs/Imagem\/QuadroHome45.gif','\/wrs/Imagem\/QuadroHome46.gif','\/wrs/Imagem\/QuadroHome47.gif','\/wrs/Imagem\/QuadroHome48.gif','\/wrs/Imagem\/QuadroHome49.gif')	// Recebe Array Logos
	//var arrNomeImg = new Array(arrNomeImg1.toString())
	//var arrLinkImg = new Array(strLink + '22',strLink + '27',strLink + '15',strLink + '17',strLink + '19',strLink + '16',strLink + '23',strLink + '24',strLink + '21',strLink + '25',strLink + '20',strLink + '28',strLink + '29',strLink + '30',strLink + '31',strLink + '32',strLink + '33',strLink + '35',strLink + '39',strLink + '42',strLink + '37',strLink + '41',strLink + '43',strLink + '36',strLink + '46',strLink + '38',strLink + '45')	// Recebe Array Logos
	//var arrLinkImg = new Array(arrLinkImg1.toString())
	
	var arrNomeFoto = new Array('\/wrs/Imagem\/QuadroHome04.gif','\/wrs/Imagem\/QuadroHome07.jpg','\/wrs/Imagem\/QuadroHome12.jpg','\/wrs/Imagem\/QuadroHome16.jpg','\/wrs/Imagem\/QuadroHome21.gif','\/wrs/Imagem\/QuadroHome23.gif','\/wrs/Imagem\/QuadroHome24.gif')// Recebe Array Fotos
	var intcont = 0 // Variavel utilizada no laço for
	
	// Inverte o Array de Imagens
	arrNomeImg.reverse();
	arrLinkImg.reverse();
	  
	// Monta o array bidimensioinal
	for(intcont==0;intcont<arrNomeImg.length;intcont++)
	{		
		arrAux[0] = Math.random();
		arrAux[1] = arrNomeImg[intcont];
		arrAux[2] = arrLinkImg[intcont];
		arrTrocaOrdem[intcont] = arrAux.toString();
	}	

	// Monta o Array Aleatoriamente
	arrTrocaOrdem.sort();
    // Relaciona as imagens com os objetos img
    if(arrTrocaOrdem.length>=1)
	{
	    document.getElementById('img1').src=arrTrocaOrdem[0].split(',')[1]
	    document.getElementById('aimg1').href=arrTrocaOrdem[0].split(',')[2]
	}
	if(arrTrocaOrdem.length>=2)
	{
	    document.getElementById('img2').src=arrTrocaOrdem[1].split(',')[1]
	    document.getElementById('aimg2').href=arrTrocaOrdem[1].split(',')[2]
	}
	if(arrTrocaOrdem.length>=3)
	{
	    document.getElementById('img3').src=arrTrocaOrdem[2].split(',')[1]
	    document.getElementById('aimg3').href=arrTrocaOrdem[2].split(',')[2]
	}
	if(arrTrocaOrdem.length>=4)
	{
	    document.getElementById('img4').src=arrTrocaOrdem[3].split(',')[1]
	    document.getElementById('aimg4').href=arrTrocaOrdem[3].split(',')[2]
	}
	if(arrTrocaOrdem.length>=5)
	{
	    document.getElementById('img5').src=arrTrocaOrdem[4].split(',')[1]
	    document.getElementById('aimg5').href=arrTrocaOrdem[4].split(',')[2]
	}
	if(arrTrocaOrdem.length>=6)
	{
	    document.getElementById('img6').src=arrTrocaOrdem[5].split(',')[1]
	    document.getElementById('aimg6').href=arrTrocaOrdem[5].split(',')[2]
	}
	if(arrTrocaOrdem.length>=7)
	{
	    document.getElementById('img7').src=arrTrocaOrdem[6].split(',')[1]
	    document.getElementById('aimg7').href=arrTrocaOrdem[6].split(',')[2]
	}
	if(arrTrocaOrdem.length>=8)
	{
	    document.getElementById('img8').src=arrTrocaOrdem[7].split(',')[1]
	    document.getElementById('aimg8').href=arrTrocaOrdem[7].split(',')[2]
	}
	for(intcont=0;intcont<arrNomeFoto.length;intcont++)
	{		
		arrAux[0] = Math.random();
		arrAux[1] = arrNomeFoto[intcont];
		arrTrocaOrdemFoto[intcont] = arrAux.toString();
	}	
	// Monta o Array Aleatoriamente
	arrTrocaOrdemFoto.sort();
	// Relaciona as imagens com os objetos img
	document.getElementById('img9').src=arrTrocaOrdemFoto[0].split(',')[1]
	document.getElementById('img10').src=arrTrocaOrdemFoto[1].split(',')[1]
	document.getElementById('img11').src=arrTrocaOrdemFoto[2].split(',')[1]
	document.getElementById('img12').src=arrTrocaOrdemFoto[3].split(',')[1]
	document.getElementById('img13').src=arrTrocaOrdemFoto[4].split(',')[1]
}
// ----------------------------------------------------------------------------
// Objetivo  : Enviar dados do formulário
// Premissas : Nenhuma
// Entradas  : strDestino página destino
// ..........: objFrm - nome do fornulário
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function SubmeterForm(strDestino,objFrm ,strNomeEmpresa)
{
	try
	{
		document.getElementById(objFrm).action = strDestino;
		document.getElementById('hdnNomeArquivo').value = strNomeEmpresa
		document.getElementById(objFrm).submit();
	}
	catch(objEx)
	{
		alert(objEx.message)
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Instancia o objeto xmldom para ler o xml e consulta a quantidade de projeto
// Premissas : Nenhuma
// Entradas  :
// Retorno   : número de projetos
// ----------------------------------------------------------------------------
function ConsultarXmlQdadeProj()
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for
	MontaNomeEmp(strNomeArquivo)
	try
	{
		objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
		objDocXmlDom.async = false;
		objDocXmlDom.load(PATH+strNomeArquivo+strNome);
		return objDocXmlDom.getElementsByTagName("recordset").length;
		
	}
	catch(objEx)
	{
		alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Instancia o objeto xmldom para ler o xml
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarXml()
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for
	MontaNomeEmp(strNomeArquivo)
	try
	{
		objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
		objDocXmlDom.async = false;
		objDocXmlDom.load(PATH+strNomeArquivo+strNome);
		CarregaXMLAtualizado = objDocXmlDom.getElementsByTagName("recordset");
		for(intIaux=0;intIaux<CarregaXMLAtualizado.length;intIaux++)
		{
			document.frmProjeto.cboProjeto.options[document.frmProjeto.cboProjeto.options.length] = new Option (TrocarCaracter(CarregaXMLAtualizado(intIaux).getAttribute("Projeto"),1),CarregaXMLAtualizado(intIaux).getAttribute("ID"))
			
		}
	}
	catch(objEx)
	{
		alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Popula Combo com as notícias cadastradas
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarXmlNoticiaCombo()
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for
	MontaNomeEmp(strNomeArquivo)
	try
	{
		objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
		objDocXmlDom.async = false;
		objDocXmlDom.load(PATH+strNomeArquivo+strNoticias);
		CarregaXMLAtualizado = objDocXmlDom.getElementsByTagName("recordset");
		for(intIaux=0;intIaux<CarregaXMLAtualizado.length;intIaux++)
		{
			document.frmProjeto.cboNoticias.options[document.frmProjeto.cboNoticias.options.length] = new Option (TrocarCaracter(CarregaXMLAtualizado(intIaux).getAttribute("Noticia"),1),CarregaXMLAtualizado(intIaux).getAttribute("ID"))
			
		}
	}
	catch(objEx)
	{
		alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Popula Campos do formulário com os dados do Projeto escolhido
// Premissas : Nenhuma
// Entradas  : intID identificador do projeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function PopulaCampos(intID)
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for
	var intJaux					// Variavel utilisada no laço for
	var arrImageP				// Recebe Array de Imagens Preview
	var arrImageF				// Recebe Array de Imagens Full
	var arrLegenda				// Recebe Array de Legenda
	
	MontaNomeEmp(strNomeArquivo)
	try
	{
		if (intID!=0)
		{
			objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
			objDocXmlDom.async = false;
			objDocXmlDom.load(PATH+strNomeArquivo+strNome);
			
			CarregaXMLAtualizado = objDocXmlDom.getElementsByTagName("recordset[@ID='"+ intID +"']");
			document.frmProjeto.txtNome.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Projeto"),1);
			for (intJaux=0;intJaux<document.frmProjeto.cboAtuacao.length;intJaux++)
			{
				if (document.frmProjeto.cboAtuacao.options[intJaux].value == CarregaXMLAtualizado(0).getAttribute("Atuacao"))
				{
					document.frmProjeto.cboAtuacao.selectedIndex = document.frmProjeto.cboAtuacao[intJaux].index
					break;
				}
			}
			document.frmProjeto.txtAlvo.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Alvo"),1);
			document.frmProjeto.txtObjetivo.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Objetivo"),1);
			
			if(CarregaXMLAtualizado(0).getAttribute("Periodo")!='Permanente')
			{
				var strPeriodo =  CarregaXMLAtualizado(0).getAttribute("Periodo")
				var intPosPeriodoIni = CarregaXMLAtualizado(0).getAttribute("Periodo").indexOf('até')
				var intPosPeriodoFim = CarregaXMLAtualizado(0).getAttribute("Periodo").lastIndexOf('até')+5
				document.frmProjeto.txtPeriodo.value = strPeriodo.substring(0,intPosPeriodoIni-1);
				document.frmProjeto.txtPeriodo1.value = strPeriodo.substr(intPosPeriodoFim-1);
				document.frmProjeto.optPeriodoData.checked=true;
			}
			else
			{
				document.frmProjeto.optPeriodoPer.checked=true;
				document.frmProjeto.txtPeriodo.value = "";
				document.frmProjeto.txtPeriodo1.value ="";
			}
			
			document.frmProjeto.txtInvestimento.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Investimento"),1);
			document.frmProjeto.txtResultados.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Resultado"),1);
			document.frmProjeto.txtDescritivo.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Descritivo"),1);
			document.frmProjeto.txtSite.value = CarregaXMLAtualizado(0).getAttribute("Site");
			document.frmProjeto.txtEmail.value = CarregaXMLAtualizado(0).getAttribute("Email");
			
			//arrImageP =  CarregaXMLAtualizado(0).getAttribute("ImgP").split('|');
			//arrImageF =  CarregaXMLAtualizado(0).getAttribute("ImgF").split('|');
			//arrLegenda = CarregaXMLAtualizado(0).getAttribute('Legenda').split('|');
			
			/*if (arrImageP.length>0)
			{
				if (arrImageF[0]!='')
				{
					document.frmProjeto.txtImgMin.value =  arrImageP[0];
					document.frmProjeto.txtImgFull.value = arrImageF[0];
					document.frmProjeto.txtLegenda.value = arrLegenda[0];
				}
				
			}
			ExcluiLinha('tbImg')
			for(intJaux=1;intJaux<arrImageP.length;intJaux++)
			{ 
				InsereLinha('tbImg',arrImageP[intJaux],arrImageF[intJaux],intJaux,arrLegenda[intJaux])
			}*/
		}
		else
		{
			alert('Escolhaum Projeto')
		}
	}
	catch(objEx)
	{
		alert(objEx.message);

	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Popula Campos do formulário com os dados da Notícia escolhida
// Premissas : Nenhuma
// Entradas  : intID identificador da Notícia
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function PopulaCamposNoticias(intID)
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for
	var intJaux					// Variavel utilisada no laço for
	
	MontaNomeEmp(strNomeArquivo)
	try
	{
		if(intID!=0)
		{
			objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
			objDocXmlDom.async = false;
			objDocXmlDom.load(PATH+strNomeArquivo+strNoticias);
			
			CarregaXMLAtualizado = objDocXmlDom.getElementsByTagName("recordset[@ID='"+ intID +"']");
			
			document.frmProjeto.txtChapeu.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Chapeu"),1);
			document.frmProjeto.txtNoticia.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Noticia"),1);
			document.frmProjeto.txtIntegra.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Integra"),1);
			
		}
		else
		{
			alert('Selecione uma notícia')
		}
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Cadastrar dados do projeto
// Premissas : Nenhuma
// Entradas  : intID Código do projeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function CadastrarDados(intID)
{
	var objXml		// Objeto xml
	var objRaiz		// Aponta para a raiz do xml	
	var objRegistro	// Define um registro
	var objExiste	// Carrega o xml para verificar existencia do registro
	MontaNomeEmp(strNomeArquivo)
	
	try
	{
		
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNome)
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='"+ intID +"']")
		
		if (objExiste.length == 0)
		{
			objRegistro = objXml.createElement("recordset");
			
			objRaiz.appendChild(objRegistro);
			IncluirProjetos(objRegistro)
			
			objXml.save(PATH+strNomeArquivo+strNome);
			
			alert("Projeto Cadastrado com Sucesso.");
			 AlterarDataAtualizacao()
			document.frmProjeto.submit();
		}
		else
		{
			alert ("Já existe um projeto cadastrado com este Número.")
		}
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Cadastrar dados da Notícia
// Premissas : Nenhuma
// Entradas  : intID Código da Notícia
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function CadastrarNoticia(intID)
{
	var objXml		// Objeto xml
	var objRaiz		// Aponta para a raiz do xml	
	var objRegistro	// Define um registro
	var objExiste	// Carrega o xml para verificar existencia do registro
	MontaNomeEmp(strNomeArquivo)
	
	try
	{
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNoticias)
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='"+ intID +"']")
		
		if (objExiste.length == 0)
		{
			objRegistro = objXml.createElement("recordset");
			objRaiz.appendChild(objRegistro);
			IncluirNoticia(objRegistro)
			objXml.save(PATH+strNomeArquivo+strNoticias);
			alert("Notícia Cadastrada com Sucesso.");
			 AlterarDataAtualizacao()
			document.frmProjeto.submit();
		}
		else
		{
			alert ("Já existe uma Notícia cadastrada com este Número.")
		}
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}	
// ----------------------------------------------------------------------------
// Objetivo  : Incluir mais um elemento no xml de Projetos
// Premissas : Nenhuma
// Entradas  : objRegistro objeto com a referencia do xml em questão
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function IncluirProjetos(objRegistro)
{
	try
	{
		objRegistro.setAttribute ("ID",TrocarCaracter(document.frmProjeto.hdnID.value,0));
		objRegistro.setAttribute ("Projeto",TrocarCaracter(document.frmProjeto.txtNome.value,0));
		objRegistro.setAttribute ("Alvo",TrocarCaracter(document.frmProjeto.txtAlvo.value,0));
		objRegistro.setAttribute ("Atuacao",TrocarCaracter(document.frmProjeto.cboAtuacao.value,0));
		objRegistro.setAttribute ("Objetivo",TrocarCaracter(document.frmProjeto.txtObjetivo.value,0));
		if(document.frmProjeto.optPeriodoPer.checked==true)
		{
			objRegistro.setAttribute ("Periodo",'Permanente');
		}
		else
		{
			objRegistro.setAttribute ("Periodo",TrocarCaracter(document.frmProjeto.txtPeriodo.value + ' até '+ document.frmProjeto.txtPeriodo1.value,0));
		}
		
		objRegistro.setAttribute ("Investimento",TrocarCaracter(document.frmProjeto.txtInvestimento.value,0));
		if(document.frmProjeto.txtResultados.value !='Máximo de 1.500 caracteres')
		{
			objRegistro.setAttribute ("Resultado",TrocarCaracter(document.frmProjeto.txtResultados.value,0));
		}
		else
		{
			objRegistro.setAttribute ("Resultado",'');
		}
		objRegistro.setAttribute ("Descritivo",TrocarCaracter(document.frmProjeto.txtDescritivo.value,0));
		objRegistro.setAttribute ("Site",TrocarCaracter(document.frmProjeto.txtSite.value,0));
		objRegistro.setAttribute ("Email",TrocarCaracter(document.frmProjeto.txtEmail.value,0));
		
		//objRegistro.setAttribute ("ImgP",document.frmProjeto.hdnImgP.value);
		//objRegistro.setAttribute ("ImgF",document.frmProjeto.hdnImgF.value);
		//objRegistro.setAttribute ("Legenda",TrocarCaracter(document.frmProjeto.hdnLegenda.value,0));
		
		objRegistro.setAttribute ("ImgP",'');
		objRegistro.setAttribute ("ImgF",'');
		objRegistro.setAttribute ("Legenda",'');
		
		document.frmProjeto.hdnID.value = document.frmProjeto.hdnID.value + 1
						
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Incluir mais um elemento no xml de Notícia
// Premissas : Nenhuma
// Entradas  : objRegistro objeto com a referencia do xml em questão
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function IncluirNoticia(objRegistro)
{
	try
	{
		objRegistro.setAttribute ("ID",document.frmProjeto.hdnID.value);
		objRegistro.setAttribute ("Chapeu",TrocarCaracter(document.frmProjeto.txtChapeu.value,0));
		objRegistro.setAttribute ("Noticia",TrocarCaracter(document.frmProjeto.txtNoticia.value,0));
		objRegistro.setAttribute ("Integra",TrocarCaracter(document.frmProjeto.txtIntegra.value,0));
		objRegistro.setAttribute ("Data",TrocarCaracter(document.frmProjeto.hdnDate.value,0));
		document.frmProjeto.hdnID.value = document.frmProjeto.hdnID.value + 1
						
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar um elemento específico no xml de Projetos
// Premissas : Nenhuma
// Entradas  : objRegistro objeto com a referencia do xml em questão
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarProjetos(objRegistro)
{
	try
	{
		objRegistro.setAttribute ("ID",document.frmProjeto.cboProjeto.value);
		objRegistro.setAttribute ("Projeto",TrocarCaracter(document.frmProjeto.txtNome.value,0));
		objRegistro.setAttribute ("Alvo",TrocarCaracter(document.frmProjeto.txtAlvo.value,0));
		objRegistro.setAttribute ("Atuacao",TrocarCaracter(document.frmProjeto.cboAtuacao.value,0));
		objRegistro.setAttribute ("Objetivo",TrocarCaracter(document.frmProjeto.txtObjetivo.value,0));
		if(document.frmProjeto.optPeriodoPer.checked==true)
		{
			objRegistro.setAttribute ("Periodo",'Permanente');
		}
		else
		{
			objRegistro.setAttribute ("Periodo",TrocarCaracter(document.frmProjeto.txtPeriodo.value + ' até '+ document.frmProjeto.txtPeriodo1.value,0));
		}
		objRegistro.setAttribute ("Investimento",TrocarCaracter(document.frmProjeto.txtInvestimento.value,0));
		objRegistro.setAttribute ("Resultado",TrocarCaracter(document.frmProjeto.txtResultados.value,0));
		objRegistro.setAttribute ("Descritivo",TrocarCaracter(document.frmProjeto.txtDescritivo.value,0));
		objRegistro.setAttribute ("Site",TrocarCaracter(document.frmProjeto.txtSite.value,0));
		objRegistro.setAttribute ("Email",TrocarCaracter(document.frmProjeto.txtEmail.value,0));
		objRegistro.setAttribute ("ImgP",document.frmProjeto.hdnImgP.value);
		objRegistro.setAttribute ("ImgF",document.frmProjeto.hdnImgF.value);
		objRegistro.setAttribute ("Legenda",TrocarCaracter(document.frmProjeto.hdnLegenda.value,0));
		document.frmProjeto.hdnID.value = document.frmProjeto.hdnID.value + 1
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar um elemento específico no xml de Notícias
// Premissas : Nenhuma
// Entradas  : objRegistro objeto com a referencia do xml em questão
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarNoticias(objRegistro)
{
	try
	{
		objRegistro.setAttribute ("ID",document.frmProjeto.cboNoticias.value);
		objRegistro.setAttribute ("Chapeu",TrocarCaracter(document.frmProjeto.txtChapeu.value,0));
		objRegistro.setAttribute ("Noticia",TrocarCaracter(document.frmProjeto.txtNoticia.value,0));
		objRegistro.setAttribute ("Integra",TrocarCaracter(document.frmProjeto.txtIntegra.value,0));
		objRegistro.setAttribute ("Data",TrocarCaracter(document.frmProjeto.hdnDate.value,0));
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar um elemento específico no xml de DadosCadastrais
// Premissas : Nenhuma
// Entradas  : objRegistro objeto com a referencia do xml em questão
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarDadosEmpresa(objRegistro)
{
	try
	{
		objRegistro.setAttribute ("ID",'1');
		objRegistro.setAttribute ("NomeEmpresa",document.frmProjeto.txtNomeEmpresa.value);
		/*if(document.frmProjeto.txtLogo.value!='')
		{
			objRegistro.setAttribute ("LogoEmpresa",strNomeArquivo + document.frmProjeto.txtLogo.value.substr(document.frmProjeto.txtLogo.value.lastIndexOf('\\')+1));
		}
		else
		{
			objRegistro.setAttribute ("LogoEmpresa",'')
		}
		if(document.frmProjeto.txtFotoEmp.value!='')
		{
			objRegistro.setAttribute ("FotoEmpresa",strNomeArquivo + document.frmProjeto.txtFotoEmp.value.substr(document.frmProjeto.txtFotoEmp.value.lastIndexOf('\\')+1));
		}
		else
		{
			objRegistro.setAttribute ("FotoEmpresa",'')
		}*/
		
		objRegistro.setAttribute ("LogoEmpresa",'')
		objRegistro.setAttribute ("FotoEmpresa",'')
		objRegistro.setAttribute ("Responsabilidade",TrocarCaracter(document.frmProjeto.txtResponsabilidade.value,0));
		objRegistro.setAttribute ("Investimento",TrocarCaracter(document.frmProjeto.txtInvestimento.value,0));
		objRegistro.setAttribute ("Porcentagem",TrocarCaracter(document.frmProjeto.txtfaturamento.value,0));
		objRegistro.setAttribute ("SiteResp",TrocarCaracter(document.frmProjeto.txtSiteEmpresa.value,0));
		objRegistro.setAttribute ("EmailResp",TrocarCaracter(document.frmProjeto.txtEmailEmpresa.value,0));
		objRegistro.setAttribute ("Destacar",TrocarCaracter(document.frmProjeto.chkDestacar.checked,0));
		objRegistro.setAttribute ("SiteOpciona",TrocarCaracter(document.frmProjeto.txtSiteEmpresaRes.value,0));
		objRegistro.setAttribute ("Cotacoes",TrocarCaracter(document.frmProjeto.txtCotacoes.value,0));
		AlterarDataAtualizacao()
		document.frmProjeto.action = 'FormConsultaHomeAdmin.asp';
		document.frmProjeto.submit();
	}
	catch(objEx)
	{
		alert(objEx.message);
		//alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Remover projeto
// Premissas : Nenhuma
// Entradas  : intID Código do projeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ExcluirDados(intID)
{
	var objXml		// Objeto xml
	var objRaiz		// Aponta para a raiz do xml	
	var objRegistro	// Define um registro
	var objExiste	// Carrega o xml para verificar existencia do registro
	MontaNomeEmp(strNomeArquivo)
	
	try
	{
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNome)
	
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='"+ intID +"']")
		if (objExiste.length > 0)
		{
			if (confirm("Deseja realmente excluir o Projeto " + intID))
			{
				objRegistro = objRaiz.selectSingleNode("recordset[@ID='"+ intID +"']")
				objRaiz.removeChild(objRegistro)
				objXml.save(PATH+strNomeArquivo+strNome)
				alert ("Projeto Excluido com Sucesso.")
				 AlterarDataAtualizacao()
				document.frmProjeto.submit();
			}
			else
			{
				alert("Exclusão Cancelada.")
			}
		}
		else
		{
			alert ("Não existe um projeto cadastrado com este Número")
		}
	}
	catch(objEx)
	{
		alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Remover Notícia
// Premissas : Nenhuma
// Entradas  : intID Código do notícia
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ExcluirNoticia(intID)
{
	
	var objXml		// Objeto xml
	var objRaiz		// Aponta para a raiz do xml	
	var objRegistro	// Define um registro
	var objExiste	// Carrega o xml para verificar existencia do registro
	MontaNomeEmp(strNomeArquivo)
	
	try
	{
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNoticias)
	
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='"+ intID +"']")

		if (objExiste.length > 0)
		{
			
			if (confirm("Deseja realmente excluir a Notícia " + intID))
			{
				objRegistro = objRaiz.selectSingleNode("recordset[@ID='"+ intID +"']")
				objRaiz.removeChild(objRegistro)
				objXml.save(PATH+strNomeArquivo+strNoticias)
				alert ("Notícia Excluida com Sucesso.")
				 AlterarDataAtualizacao()
				document.frmProjeto.submit();
			}
			else
			{
				alert("Exclusão Cancelada.")
			}
		}
		else
		{
			alert ("Não existe um projeto cadastrado com este Número")
		}
	}
	catch(objEx)
	{
		alert(objEx);
	}
}	
// ----------------------------------------------------------------------------
// Objetivo  : Alterar dados do projeto
// Premissas : Nenhuma
// Entradas  : intID Código do projeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarDados(intID)
{	
	var objXml			// Objeto xml
	var objRaiz			// Aponta para a raiz do xml	
	var objRegistro		// Define um registro
	var objExiste		// Carrega o xml para verificar existencia do registro
	var objRegistro1	// Define um registro Antigo
	MontaNomeEmp(strNomeArquivo)
	
	try
	{	
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNome)
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='"+ intID +"']")
	
		if (objExiste.length > 0)
		{ 
			if (confirm("Deseja realmente Alterar o Projeto " + intID))
			{
				objRegistro = objXml.createElement("recordset")
				objRaiz.appendChild(objRegistro)
	
				AlterarProjetos(objRegistro)
	
				objRegistro1 = objRaiz.selectSingleNode("recordset[@ID='"+ intID +"']")
	
				objRaiz.replaceChild(objRegistro,objRegistro1)
	
				objXml.save(PATH+strNomeArquivo+strNome)
				alert("Projeto Alterado com Sucesso.")
				 AlterarDataAtualizacao()
				document.frmProjeto.submit();
			}
			else
			{
				alert("Alteração Cancelada.")	
			}
		}
		else
		{
			alert("Não existe um projeto cadastrado com este Número.")
		}
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar dados da Notícia
// Premissas : Nenhuma
// Entradas  : intID Código da Notícia
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarNoticia(intID)
{	
	var objXml			// Objeto xml
	var objRaiz			// Aponta para a raiz do xml	
	var objRegistro		// Define um registro
	var objExiste		// Carrega o xml para verificar existencia do registro
	var objRegistro1	// Define um registro Antigo
	MontaNomeEmp(strNomeArquivo)
	
	try
	{	
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNoticias)
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='"+ intID +"']")
	
		if (objExiste.length > 0)
		{ 
			if (confirm("Deseja realmente Alterar a Notícia  " + intID))
			{
				objRegistro = objXml.createElement("recordset")
				objRaiz.appendChild(objRegistro)
	
				AlterarNoticias(objRegistro)
	
				objRegistro1 = objRaiz.selectSingleNode("recordset[@ID='"+ intID +"']")
	
				objRaiz.replaceChild(objRegistro,objRegistro1)
	
				objXml.save(PATH+strNomeArquivo+strNoticias)
				alert("Notícia Alterada com Sucesso.")
				 AlterarDataAtualizacao()
				document.frmProjeto.submit();
			}
			else
			{
				alert("Alteração Cancelada.")	
			}
		}
		else
		{
			alert("Não existe uma Notícia cadastrado com este Número.")
		}
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Verificar se o usuario possui a estrutura de diretórios e a cria
// Premissas : Nenhuma
// Entradas  : Nenhuma
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function VerificaEstrutura()
{
	var objFso = new ActiveXObject("Scripting.FileSystemObject") // Objeto file system object
	var strConteudo = '<?xml version="1.0" encoding="ISO-8859-1"?><recordsets></recordsets>' // Estrutura do xml Projeto e Noticia
	var strConteudoEmp = '<?xml version="1.0" encoding="ISO-8859-1"?><recordsets ><recordset ID="1" NomeEmpresa="'+ strNomeEmp +'" LogoEmpresa="" FotoEmpresa="" Responsabilidade="" Investimento="" Porcentagem="" SiteResp="" EmailResp="" Destacar="" SiteOpciona="" Cotacoes=""/></recordsets>' // Estrutura do xml Dados Cadastrais
	var strConteudoAtualizado = '<?xml version="1.0" encoding="ISO-8859-1"?><recordsets><recordset ID="1" Data=""/></recordsets>'// Estrutura do xml Data Atualização
	var objTexto // objeto conteudo file
	MontaNomeEmp(strNomeArquivo)
	
	if (objFso.FileExists(PATH+strNomeArquivo+strNome)==false)
	{
		alert('O arquivo do Projeto foi criado em seu computador, no diretório' + PATH)
		
		if (objFso.FolderExists(PATH))
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strNome);
			Texto.Write(strConteudo);
		}
		else
		{
			objFso.CreateFolder(PATH);
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strNome);
			Texto.Write(strConteudo);
		}
	}
	if (objFso.FileExists(PATH+strNomeArquivo+strNomeDados)==false)
	{
		alert('O arquivo da Empresa foi criado em seu computador, no diretório' + PATH)
		
		if (objFso.FolderExists(PATH))
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strNomeDados);
			Texto.Write(strConteudoEmp);
		}
		else
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strNomeDados);
			Texto.Write(strConteudo);
		}
	}
	if (objFso.FileExists(PATH+strNomeArquivo+strNoticias)==false)
	{
		alert('O arquivo da Notícia foi criado em seu computador, no diretório' + PATH)

		if (objFso.FolderExists(PATH))
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strNoticias);
			Texto.Write(strConteudo);
		}
		else
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strNoticias);
			Texto.Write(strConteudo);
		}
	}
	if (objFso.FileExists(PATH+strNomeArquivo+strDataXML)==false)
	{
		if (objFso.FolderExists(PATH))
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strDataXML);
			Texto.Write(strConteudoAtualizado);
		}
		else
		{
			Texto = objFso.CreateTextFile(PATH + strNomeArquivo + strDataXML);
			Texto.Write(strConteudoAtualizado);
		}
	}
}
// --------------------------------	--------------------------------------------
// Objetivo  : Consultar o próximo código do projeto
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarXmlProjeto()
{
	var objDocXmlDom	// Objeto xml
	var strLogin		// Login
	var strSenha		// Senha		
	var objElement		// Recebe um unico elemento recordset do arquivo login.xml 
	var intTotal		// Variavel utilizada no laço for
	var intRecuperaID	// Recebe o valor do próximo ID
	
	MontaNomeEmp(strNomeArquivo)
	
	objDocXmlDom =new ActiveXObject("Microsoft.XMLDOM")
	objDocXmlDom.async = false
	objDocXmlDom.load(PATH + strNomeArquivo + strNome)
	
	objElement = objDocXmlDom.getElementsByTagName("recordset")
	
	intTotal = objElement.length -1
	
	if (intTotal==-1)
	{
 		document.frmProjeto.hdnID.value =  1
 	}
 	else
 	{
 		intRecuperaID = objElement(intTotal).getAttribute("ID")
 		document.frmProjeto.hdnID.value =  parseInt(intRecuperaID) + 1
 	}
}
// --------------------------------	--------------------------------------------
// Objetivo  : Consultar o próximo código de Notícia
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarXmlNoticia()
{
	var objDocXmlDom	// Objeto xml
	var strLogin		// Login
	var strSenha		// Senha		
	var objElement		// Recebe um unico elemento recordset do arquivo login.xml 
	var intTotal		// Variavel utilizada no laço for
	var intRecuperaID	// Recebe o valor do próximo ID
	
	MontaNomeEmp(strNomeArquivo)
	
	objDocXmlDom =new ActiveXObject("Microsoft.XMLDOM")
	objDocXmlDom.async = false
	objDocXmlDom.load(PATH + strNomeArquivo + strNoticias)
	
	objElement = objDocXmlDom.getElementsByTagName("recordset")
	
	intTotal = objElement.length -1
	
	if (intTotal==-1)
	{
 		document.frmProjeto.hdnID.value =  1
 	}
 	else
 	{
 		intRecuperaID = objElement(intTotal).getAttribute("ID")
 		document.frmProjeto.hdnID.value =  parseInt(intRecuperaID) + 1
 	}
}
/******************************************************************************
/ Objetivo  : Inserir linha para inclusão de novos campos para imagens da galeria
/ Premissas : Nenhuma
/ Entradas  : strIdTable - Id da tabela que receberá as novas linhas
/...........: strValueP - Valor do da foto preview
/...........: strValueF - Valor do da foto full
/...........: intJaux	- posição
/...........: strValueLeg - Valor do da Legenda
/ Retorno   : Nenhum
/******************************************************************************/
function InsereLinha(strIdTable,strValueP,strValueF,intJaux,strValueLeg)
{
	var objTable = document.getElementById(strIdTable);		//Objeto
	var strClasseLinha;										//Nome da classe da linha da tabela
	var strClasseCelula;									//Nome da classe da célula da tabela
	var objTr;												//Objeto linha
	var objTd;												//Objeto célula
	
	if (strValueP=='')
	{
		strValueP = ''
	}
	if (strValueF=='')
	{
		strValueF = ''
	}
	
	if (intIndice == 0){intIndice = objTable.rows.length-1}
	else (intIndice += 1)
	
	if(intIndice<7)
	{
		if(intIndice % 2 == 0)
		{
			strClasseLinha = "LinhaValores2";
			strClasseCelula = "TabLinha2c";
		}
		else
		{
			strClasseLinha = "LinhaValores1";
			strClasseCelula = "TabLinha1c";	
		}
	
		//Insere a linha e as células
		objTr = objTable.insertRow();
		objTr.id = 'tbImg' + intIndice;
		objTr.className = '';
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = 'Foto Preview ' + intIndice ;
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		
		objTd.innerHTML = "<input name=txtImgMin"+ intJaux +" type=text id=txtImgMin"+ intJaux +" size=30 class=FormTxt value="+ strValueP+"> <span class=btoEnviar style=cursor:hand id=spanAltMin" + intJaux +" onclick=window.open('FormConsultaProcurarFile.asp?strID=txtImgMin"+intJaux+"','ProcurarArquivo','height=20px,width=340px')>Procurar</span><br><span  style='color:gray;font-size:9px;font-weight: normal;'><em> (86 x 57 pixels - arquivo .jpeg - tamanho máximo: 10 kb)</em></span>"
		objTr = objTable.insertRow();
		objTr.id = 'tbImg' + intIndice +1
		objTr.className = '';
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = 'Foto Full ' + intIndice;
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		//objTd.innerHTML = '<input type=\"file\" id=\"txtImgFull' + intIndice + '\" name=\"txtImgFull' + intIndice + '\" class=\"FormTxt\" size=\"30\"\/>';
		objTd.innerHTML = "<input name=txtImgFull"+ intJaux+" type=text id=txtImgFull"+intJaux+" size=\'30\' class=\'FormTxt\' value='"+strValueF +"'> <span class='btoEnviar' style='cursor:hand' id=spanAltFull"+intJaux+" onclick=\"window.open('FormConsultaProcurarFile.asp?strID=txtImgFull"+intJaux+"','ProcurarArquivo','height=20px,width=340px')\">Procurar</span><br><span  style='color:gray;font-size:9px;font-weight: normal;'><em> (350x250 pixels - arquivo .jpeg - Tamanho máximo: 60 kb)</em></span>"
		
		objTr = objTable.insertRow();
		objTr.id = 'tbImg' + intIndice +2
		objTr.className = '';
		
		
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = 'Legenda ' + intIndice;
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';

		objTd.innerHTML = "<input name=txtLegenda"+ intJaux+" type=text id=txtLegenda"+intJaux+" size=\'42\' class=\'FormTxt\' value='"+strValueLeg +"'> "
	}	
	else
	{
		document.getElementById('trMaisImg').style.display = 'none';
		alert("Chegou ao número máximo de imagens.")
	}
}
/******************************************************************************
/ Objetivo  : Excluir linha que contém registro para posterior exclusão
/ Premissas : Nenhuma
/ Entradas  : strIdTr - Id da linha a ser excluída
/			: strIdTable - Id da tabela que terá a linha excluída
/ Retorno   : Nenhum
/******************************************************************************/
function ExcluiLinha(strIdTable)
{
	var objTable = document.getElementById(strIdTable);					//Objeto
	var intRowIndex = 0;												//Indice da linha
	var intCont = 0;													//Contador auxiliar

	for (intCont = 3; intCont < objTable.rows.length; intCont++)
	{
		intRowIndex = objTable.rows[intCont].rowIndex;
		objTable.rows[intCont].style.display = 'none';
	}
}		
/******************************************************************************
/ Objetivo  : Inserir linha para inclusão de nova imagens de galerias
/ Premissas : Nenhuma
/ Entradas  : strIdTable - Id da tabela que receberá as novas linhas
/ Retorno   : Nenhum
/******************************************************************************/
function InsereLinhaGrupoDestinatario(strIdTable)
{
	var objTable = document.getElementById(strIdTable);		//Objeto
	var strClasseLinha;										//Nome da classe da linha da tabela
	var strClasseCelula;									//Nome da classe da célula da tabela
	var objTr;												//Objeto linha
	var objTd;												//Objeto célula
	var intQtd;                                          // Quantidade
	
	
	intQtd = objTable.rows.length-1
	
	switch (intQtd)
	{
	    case 2:
	        intQtd = intQtd;
	        break;
	    case 5:
	        intQtd = intQtd -2;
	        break;
	     case 8:
	        intQtd = intQtd -4;
	        break;
	    case 11:
	        intQtd = intQtd -6;
	        break;
        case 14:
	        intQtd = intQtd -8;
	        break;
	
	}
	document.frmProjeto.hdnQtd.value = intQtd
	if (intIndice == 0){intIndice = intQtd}
	else (intIndice += 1)
	
	if(intIndice<7)
	{
		if(intIndice % 2 == 0)
		{
			strClasseLinha = "LinhaValores2";
			strClasseCelula = "TabLinha2c";
		}
		else
		{
			strClasseLinha = "LinhaValores1";
			strClasseCelula = "TabLinha1c";	
		}
	
		//Insere a linha e as células
		objTr = objTable.insertRow();
		objTr.id = 'tbImg' + intIndice;
		objTr.className = '';
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = 'Foto Preview ' + intIndice ;
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = '<input type=\"file\" id=\"txtImgMin' + intIndice + '\" name=\"txtImgMin' + intIndice + '\" class=\"FormTxt\" size=\"30\"\/><br><span  style="color:gray;font-size:9px;font-weight: normal;"><em> (86 x 57 pixels - arquivo .jpeg - tamanho máximo: 10 kb) </em></span>';
	
		objTr = objTable.insertRow();
		objTr.id = 'tbImg' + intIndice +1
		objTr.className = '';
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = 'Foto Full ' + intIndice;
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = '<input type=\"file\" id=\"txtImgFull' + intIndice + '\" name=\"txtImgFull' + intIndice + '\" class=\"FormTxt\" size=\"30\"\/><br><span  style="color:gray;font-size:9px;font-weight: normal;"><em> (350x250 pixels - arquivo .jpeg - Tamanho máximo: 60 kb) </em>';
		
		objTr = objTable.insertRow();
		objTr.id = 'tbImg' + intIndice +2
		objTr.className = '';
		
		
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';
		objTd.innerHTML = 'Legenda ' + intIndice;
	
		objTd = objTr.insertCell();
		objTd.className = 'TxtCinza';

		objTd.innerHTML = "<input name=txtLegenda"+ intIndice+" type=text id=txtLegenda"+intIndice+" size=\'42\' maxlength=\'100\' class=\'FormTxt\'>"
		
		if(intIndice==6)
		{
		    document.getElementById('trMaisImg').style.display = 'none';
		}
	}	
	else
	{
		document.getElementById('trMaisImg').style.display = 'none';
		alert("Este projeto atingiu o número máximo de imagens (seis fotos).")
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Display d objetos
// Premissas : strID - id do objeto
//           : strDisplay - display none or block
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function Fdisplay(strID,strDisplay)
{
    try
    {
        var arrID =  strID.split("|")
        var intIaux
        var intTotal = arrID.length
        
        alert(intTotal)
        for (intIaux=0;intIaux<intTotal;intIaux++)
        {
          document.getElementById(arrID[intIaux]).style.display=strDisplay  
        }
        //
    }
    catch(objEx)
    {
        alert(objEx.message)
    }
}
// ----------------------------------------------------------------------------
// Objetivo  : Listar todos projetos cadastrados
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ListarProjetos()
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for
	var strProjetosListados =  new String('') // Projeto listados
	MontaNomeEmp(strNomeArquivo)
	try
	{
		objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
		objDocXmlDom.async = false;
		objDocXmlDom.load(PATH+strNomeArquivo+strNome);
		CarregaXMLAtualizado = objDocXmlDom.getElementsByTagName("recordset");
		
		for(intIaux=0;intIaux<CarregaXMLAtualizado.length;intIaux++)
		{
			strProjetosListados = strProjetosListados + "<a href="+CarregaXMLAtualizado(intIaux).getAttribute('ID')+">" + CarregaXMLAtualizado(intIaux).getAttribute('Projeto') + "</a><br><br>"
		}
		return strProjetosListados
	}
	catch(objEx)
	{
		alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Sair
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function Sair()
{
	document.frmProjeto.hdnEnviar.value='';
	document.frmProjeto.action = "FormConsultaAdmin.asp";
	alert('ATENÇÃO: as alterações realizadas foram salvas neste computador, no diretório C:\BovRespSocial. \n Agora você deve enviar todos os arquivos do diretório "C:\BovRespSocial" para os e-mails \n - rmartins@bovespa.com.br \n - elopes@bovespa.com.br \n - mapacheco@bovespa.com.br')
	document.frmProjeto.submit();
}
// ----------------------------------------------------------------------------
// Objetivo  : Monta nome do Arquivo para pesquisa
// Premissas : Nenhuma
// Entradas  : strNome - Nome do arquivo
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function MontaNomeEmp(strNome)
{
	if (strNome.indexOf(' ') !=-1  && strNome.indexOf(' ') > 0)
	{
		strNome = strNome.substring(0,strNome.indexOf(' '))
	}
	else
	{
		strNome = strNome 
	}
	
	return strNome
}
// ----------------------------------------------------------------------------
// Objetivo  : Consultar dados no arquivo xml xxxDadosCadastrais.xml
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarXmlDadosEmp()
{
	var objDocXmlDom			// Objeto xml dom
	var CarregaXMLAtualizado	// Objeto xml dom (elemento)
	var intIaux					// Variavel utilisada no laço for

	MontaNomeEmp(strNomeArquivo)
	
	try
	{
		objDocXmlDom = new ActiveXObject("Microsoft.XMLDOM");
		objDocXmlDom.async = false;
		objDocXmlDom.load(PATH+strNomeArquivo+strNomeDados);
		CarregaXMLAtualizado = objDocXmlDom.getElementsByTagName("recordset");
		if (CarregaXMLAtualizado.length>0)
		{
			document.frmProjeto.txtNomeEmpresa.value = CarregaXMLAtualizado(0).getAttribute("NomeEmpresa");
			//document.frmProjeto.txtLogo.value = CarregaXMLAtualizado(0).getAttribute("LogoEmpresa");
			//document.frmProjeto.txtFotoEmp.value = CarregaXMLAtualizado(0).getAttribute("FotoEmpresa");
			
			if(CarregaXMLAtualizado(0).getAttribute("Responsabilidade")!='')
			{
				document.frmProjeto.txtResponsabilidade.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Responsabilidade"),1);
			}
			else
			{
				document.frmProjeto.txtResponsabilidade.value = 'Máximo de 700 caracteres';
			}
						
			document.frmProjeto.txtInvestimento.value = TrocarCaracter(CarregaXMLAtualizado(0).getAttribute("Investimento"),1);
			document.frmProjeto.txtfaturamento.value = CarregaXMLAtualizado(0).getAttribute("Porcentagem");
			document.frmProjeto.txtSiteEmpresa.value = CarregaXMLAtualizado(0).getAttribute("SiteResp");
			document.frmProjeto.txtEmailEmpresa.value = CarregaXMLAtualizado(0).getAttribute("EmailResp");
			if (CarregaXMLAtualizado(0).getAttribute("Destacar")==0 || CarregaXMLAtualizado(0).getAttribute("Destacar")=='')
			{
				document.frmProjeto.chkDestacar.checked = false;
			}
			else
			{
				document.frmProjeto.chkDestacar.checked = true;
			}
			
			document.frmProjeto.txtSiteEmpresaRes.value = CarregaXMLAtualizado(0).getAttribute("SiteOpciona");
			document.frmProjeto.txtCotacoes.value = CarregaXMLAtualizado(0).getAttribute("Cotacoes");
		}
	}
	catch(objEx)
	{
		alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Cadastrar dados da Empresa
// Premissas : Nenhuma
// Entradas  : 
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function CadastrarDadosEmp()
{
	var objXml		// Objeto xml
	var objRaiz		// Aponta para a raiz do xml	
	var objRegistro	// Define um registro
	var objExiste	// Carrega o xml para verificar existencia do registro
	MontaNomeEmp(strNomeArquivo)
	
	try
	{
		
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNomeDados)
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='1']")
		
		objRegistro = objXml.createElement("recordset");
			
		objRaiz.appendChild(objRegistro);
		
		AlterarDadosEmpresa(objRegistro)
			
		objXml.save(PATH+strNomeArquivo+strNomeDados);
			
		alert("Dados alterados com Sucesso.");
			
		document.frmProjeto.action = "FormConsultaHomeAdmin.asp"
		document.frmProjeto.submit();
	}
	catch(objEx)
	{
		alert(objEx.message);
		//alert(objEx);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar dados da Empresa
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarDadosEmp()
{	
	var objXml			// Objeto xml
	var objRaiz			// Aponta para a raiz do xml	
	var objRegistro		// Define um registro
	var objExiste		// Carrega o xml para verificar existencia do registro
	var objRegistro1	// Define um registro Antigo
	MontaNomeEmp(strNomeArquivo)
	
	try
	{	
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strNomeDados)
	
		objRaiz = objXml.documentElement
		objExiste = objRaiz.getElementsByTagName("recordset[@ID='1']")
	
		if (objExiste.length > 0)
		{ 
			if (confirm("Deseja realmente Alterar os Dados da Empresa? " ))
			{
				objRegistro = objXml.createElement("recordset")
				objRaiz.appendChild(objRegistro)
	
				AlterarDadosEmpresa(objRegistro)
	
				objRegistro1 = objRaiz.selectSingleNode("recordset[@ID='1']")
	
				objRaiz.replaceChild(objRegistro,objRegistro1)
	
				objXml.save(PATH+strNomeArquivo+strNomeDados)
				alert("Empresa Alterada com Sucesso.")
				document.frmProjeto.submit();
			}
			else
			{
				alert('Alteração cancelada.')
			}
		}
		else
		{
			CadastrarDadosEmp()
		}
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Validar dados da Empresa
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ValidarDadosEmp()
{
	try
	{
		var strDiretorioImg = PATH 			// Diretório destino das imagens
		var objForm = document.frmProjeto	//objeto de formulário
		var intJaux							// Variavel utilizada no laço for
		var intQtdPapel						// Recebe a quantidade de papel 	
		for(intJaux=0;intJaux<objForm.length;intJaux++)
		{
			if(objForm[intJaux].type=='text'  )
			{
				if (objForm[intJaux].value=='' )
				{
					if (objForm[intJaux].name=='txtNomeEmpresa')
					{
						objForm[intJaux].focus();
						throw "O campo Nome da Empresa é Obrigatório.";	
					}
					else if (objForm[intJaux].name=='txtResponsabilidade')
					{
						objForm[intJaux].focus();
						throw "O campo 'Conceito de Responsabilidade Social para sua Empresa' é Obrigatório.";	
					}
				}
				else if (objForm[intJaux].name=='txtInvestimento')
				{
					
					if (ValidaCampoMonetario(objForm[intJaux].value)==false)
					{
						objForm[intJaux].focus();
						throw "No campo \"Valor do Investimento\" não utilize pontuação; apenas números.";
					}
				}
				else if (objForm[intJaux].name=='txtCotacoes')
				{
					
					intQtdPapel = objForm[intJaux].value.split(";")
					if (intQtdPapel.length>4)
					{
						objForm[intJaux].focus();
						throw "No campo Cotações insira o código de até quatro papéis, no máximo.";
					}
				}
				else if (objForm[intJaux].name=='txtEmailEmpresa')
				{
					
					if (objForm[intJaux].value.indexOf("@")==-1)
					{
						objForm[intJaux].focus();
						throw "O campo \"E-mail de contato da área de Responsabilidade Social\" está incorreto.";
					}
				}
			}
			if(objForm[intJaux].type=='textarea')
			{
				if (objForm[intJaux].value=='' || objForm[intJaux].value=='Máximo de 700 caracteres')
				{
					if (objForm[intJaux].name=='txtResponsabilidade')
					{
						objForm[intJaux].focus();
						throw "O campo \"Conceito de Responsabilidade para sua Empresa\" é Obrigatório."	
					}
				}
				else if(objForm[intJaux].name=='txtResponsabilidade')
				{
					if (ContarCaracter(document.frmProjeto[intJaux].value)>700)
					{
						document.frmProjeto[intJaux].focus();
						throw "Campo Conceito de Responsabilidade para sua empresa ultrapassa o número máximo de caracterres (700), \n Está com " +ContarCaracter(document.frmProjeto[intJaux].value) + " Caracteres."
						
					}
						
				}
			}
			if(objForm[intJaux].type=='checkbox')
			{
				if(objForm[intJaux].checked)
				{
					if (objForm[intJaux+1].value=='')
					{
						throw "O campo \"Site de Responsabilidade Social\" não pode estar vazio quando o link estiver habilitado."
					
					}
				}
			}
			/*if(objForm[intJaux].type=='text')
			{
				if (objForm[intJaux].value!='')
				{
					if (objForm[intJaux].name=='txtLogo' || objForm[intJaux].name=='txtFotoEmp') 
					{
						var objFsoLogo
						objFsoLogo = new ActiveXObject("Scripting.FileSystemObject")
						if (objFsoLogo.FileExists(document.frmProjeto[intJaux].value))
						{
							
							if (objForm[intJaux].name=='txtLogo')
							{
								if(objForm[intJaux].value.substr(objForm[intJaux].value.lastIndexOf(".")).toUpperCase()!=".GIF")
								{
									throw "O tipo de arquivo do Logo da Empresa é .gif"
								}
							}
							if (objForm[intJaux].name=='txtFotoEmp')
							{
								if(objForm[intJaux].value.substr(objForm[intJaux].value.lastIndexOf(".")).toUpperCase()!=".JPG")
								{
									throw "O tipo de arquivo do Foto da página da Empresa é .jpg"
								}
							}
							
							if(objFsoLogo.GetFile(document.frmProjeto[intJaux].value).Size>12000)
							{
								document.frmProjeto[intJaux].focus();
								throw "A imagem não pode ser maior que 12K."
							}
							else
							{
								
								if(objForm[intJaux].value.indexOf('BovRespSocial')==-1)
								{
									
									objFsoLogo.CopyFile(document.frmProjeto[intJaux].value,strDiretorioImg,true)
									if (objFsoLogo.FileExists(strDiretorioImg+ strNomeArquivo + document.frmProjeto[intJaux].value.substr(document.frmProjeto[intJaux].value.lastIndexOf('\\')+1)))
									{
										objFsoLogo.DeleteFile(strDiretorioImg+ strNomeArquivo + document.frmProjeto[intJaux].value.substr(document.frmProjeto[intJaux].value.lastIndexOf('\\')+1))
									}
									objFsoLogo.GetFile(strDiretorioImg+ document.frmProjeto[intJaux].value.substr(document.frmProjeto[intJaux].value.lastIndexOf('\\')+1)).Name = strNomeArquivo + document.frmProjeto[intJaux].value.substr(document.frmProjeto[intJaux].value.lastIndexOf('\\')+1)
								}
								
							}
						}
						else
						{
							document.frmProjeto[intJaux].focus();
							throw "O arquivo da Imagem não foi encontrado."
						}
					}
				}
			}*/
		}
		AlterarDadosEmp()
	}
	catch(objEx)
	{
		alert(objEx.toString());
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Valida formulário de Projetos
// Premissas : Nenhuma
// Entradas  : intStatus - Determina se ´pe inserção ou alteração
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ValidaFormProjeto(intStatus)
{
	var objFso	// Objeto file system object
	var intTotaObjetoFrm // Recebe a quantidade de objrto do formulário
	var intCont			// Variavel utilizada no laço for
	var strDiretorioImg = PATH	// Caminho diretório
	var strImgP = ''	// Imagem Preview
	var strImgF = ''	// Imagem Full
	var strData = ''	// Data 1	
	var strData1 = ''	//Data 2
	var strLegenda=''		// Legenda
	
	try
	{
		intTotaObjetoFrm = document.frmProjeto.length
		intCont = 0
		
		for(intCont==0;intCont<intTotaObjetoFrm;intCont++)
		{
			if(document.frmProjeto[intCont].type=='text')
			{
				if(document.frmProjeto[intCont].value=='' || document.frmProjeto[intCont].value=='Máximo de 150 caracteres' || document.frmProjeto[intCont].value=='Máximo de 50 caracteres')
				{
					if(document.frmProjeto[intCont].name.indexOf('txtLegenda')==-1 && document.frmProjeto[intCont].name.indexOf('txtPeriodo')==-1 && document.frmProjeto[intCont].name.indexOf('txtPeriodo1')==-1 &&  document.frmProjeto[intCont].name.indexOf('Site')==-1 && document.frmProjeto[intCont].name.indexOf('mail')==-1 && document.frmProjeto[intCont].name.indexOf('Investimento')==-1 )//&& document.frmProjeto[intCont].name.indexOf('Img')==-1
					{
						
						if(document.frmProjeto[intCont].name.indexOf('txtAlvo')!=-1)
						{
						    if(document.frmProjeto.cboAtuacao.value!='Ambiental')
						    {
						        document.frmProjeto[intCont].focus();
						        throw "Campo de Preenchimento Obrigatório. \n Clique \"OK\" e preencha-o."
						    } 
						}
						else
						{
						    document.frmProjeto[intCont].focus();
						    throw "Campo de Preenchimento Obrigatório. \n Clique \"OK\" e preencha-o."
						}
					}
				}
				/*else if (document.frmProjeto[intCont].name=='txtInvestimento')
				{
					if (ValidaCampoMonetario(document.frmProjeto[intCont].value)==false)
					{
						document.frmProjeto[intCont].focus();
						throw "No campo \"Valor do Investimento\" não utilize pontuação; apenas números.";
					}
				}*/
				else if (document.frmProjeto[intCont].name=='txtEmail')
				{
						
					if (document.frmProjeto[intCont].value.indexOf("@")==-1)
					{
						document.frmProjeto[intCont].focus();
						throw "O campo \"E-mail para Contato\" está incorreto.";
					}
				}
				if (document.frmProjeto[intCont].name=='txtPeriodo' || document.frmProjeto[intCont].name=='txtPeriodo1')
				{
					if(document.frmProjeto.optPeriodoPer.checked==false)
					{
						if (document.frmProjeto[intCont].value =="")
						{
							document.frmProjeto[intCont].focus();
							throw "Campo de Preenchimento Obrigatório. \n Clique \"OK\" e preencha-o."
						}
						else if (ValidaPeriodoProjeto(document.frmProjeto[intCont].value)==false)
						{
							document.frmProjeto[intCont].focus();
							throw "1"
						}
						if(document.frmProjeto[intCont].name=='txtPeriodo')
						{
							strData = document.frmProjeto[intCont].value
						}
						if(document.frmProjeto[intCont].name=='txtPeriodo1')
						{
							strData1 = document.frmProjeto[intCont].value
						}
						if(strData1!='' && strData !='')
						{
							if(ValidaPeriodo(strData,strData1)==false)
							{
								document.frmProjeto[intCont].focus();
								throw "1";
							}
						}
					}
				}
			}
			if(document.frmProjeto[intCont].type=='textarea')
			{
				if(document.frmProjeto[intCont].value=='' || document.frmProjeto[intCont].value=='Máximo de 200 caracteres' || document.frmProjeto[intCont].value=='Máximo de 2.000 caracteres')
				{
					if(document.frmProjeto[intCont].name.indexOf('Resultados')==-1)
					{
						document.frmProjeto[intCont].focus();
						throw "Campo de Preenchimento Obrigatório. \n Clique \"OK\" e preencha-o."
						
					}
				}
				else if(document.frmProjeto[intCont].name.indexOf('Objetivo')!=-1)
				{
					if (ContarCaracter(document.frmProjeto[intCont].value)>200)
					{
						document.frmProjeto[intCont].focus();
						throw "Campo Objetivo ultrapassa o número máximo de caracterres (200), \n Está com " +ContarCaracter(document.frmProjeto[intCont].value)+ " Caracteres."
						
					}
						
				}
				else if(document.frmProjeto[intCont].name.indexOf('Descritivo')!=-1)
				{
					if (ContarCaracter(document.frmProjeto[intCont].value)>2000)
					{
						document.frmProjeto[intCont].focus();
						throw "Campo Descritivo do Projeto ultrapassa o número máximo de caracterres (2000), \n Está com " +ContarCaracter(document.frmProjeto[intCont].value) + " Caracteres."
					}
				}
				else if(document.frmProjeto[intCont].name.indexOf('Resultados')!=-1)
				{
					if (ContarCaracter(document.frmProjeto[intCont].value)>1500)
					{
						document.frmProjeto[intCont].focus();
						throw "Campo \"Principais Resultados\" ultrapassa o número máximo de caracterres (1500), \n Está com " +ContarCaracter(document.frmProjeto[intCont].value) + " Caracteres."
					}
				}
			}
		}
		
		if (intStatus==0)
		{	
			if (ConsultarXmlQdadeProj() < 15 )
			{
				
				CadastrarDados(document.frmProjeto.hdnID.value)
			}
			else
			{
				throw "O número de projeto não pode ultrapassar 15 projetos."
			}
		}
		else if (intStatus==1)
		{
			AlterarDados(document.frmProjeto.cboProjeto.value)
		}
	}
	catch(objEx)
	{
		if(objEx.toString()!='1')
			alert(objEx.toString());
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Valida formulário de Notícias
// Premissas : Nenhuma
// Entradas  : intSatus Determina se uma insersão ou alteração
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ValidaFormNoticias(intSatus)
{
	var intTotaObjetoFrm // Recebe a quantidade de objrto do formulário
	var intCont			// Variavel utilizada no laço for
	try
	{
		intTotaObjetoFrm = document.frmProjeto.length
		intCont = 0
		
		for(intCont==0;intCont<intTotaObjetoFrm;intCont++)
		{
			if(document.frmProjeto[intCont].type=='text')
			{
				if(document.frmProjeto[intCont].value=='' || document.frmProjeto[intCont].value=='Máximo de 35 caracteres' || document.frmProjeto[intCont].value=='Máximo de 80 caracteres')
				{
					document.frmProjeto[intCont].focus();
					
					switch (document.frmProjeto[intCont].name)
					{
					    case "txtChapeu":
					        throw 'O campo \"Título\" é Obrigatório.';
					        break;
					    case "txtNoticia":
					        throw 'O campo \"Título principal\" é Obrigatório.';
					        break;
					    case "txtIntegra":
					        throw 'O campo \"Notícia\" é Obrigatório.';
					        break;
					}
					
					
				}
			}
			
			if(document.frmProjeto[intCont].type=='textarea')
			{
				if(document.frmProjeto[intCont].value=='' || document.frmProjeto[intCont].value=='Máximo de 3000 caracteres')
				{
					document.frmProjeto[intCont].focus();
					throw "O campo \"Íntegra da Notícia\" é Obrigatório.";
				}
				if(ContarCaracter(document.frmProjeto[intCont].value) > 3000)
				{
					document.frmProjeto[intCont].focus();
					throw "O campo \"Íntegra da Notícia\" esta com mais do que 3000 caracteres. " + "Quantidade = " + ContarCaracter(document.frmProjeto[intCont].value);
				}
			}
		}
		if (intSatus==0)
		{
			CadastrarNoticia(document.frmProjeto.hdnID.value);
		}
		else if (intSatus==1)
		{
			AlterarNoticia(document.frmProjeto.cboNoticias.value)
		}
		
	}
	catch(objEx)
	{
		alert(objEx)
		//alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Submeter informações para Consuta de Projetos
// Premissas : Nenhuma
// Entradas  :objForm - Objeto Formulário
//..........:strDestino	- Destino para submeter os dados do form
//..........:strNomeArquivo	Nome do Arquivo
//..........:strIdProjeto	código do projeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarProjeto(objForm,strDestino,strNomeArquivo,strIdProjeto)
{
	try
	{
		
		document.frmRS.action= strDestino;
		document.frmRS.hdnArqProjeto.value = strNomeArquivo;
		document.frmRS.hdnIDProjeto.value = strIdProjeto;
		document.frmRS.submit();
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Submeter informações para Consuta de Notícias
// Premissas : Nenhuma
// Entradas  :objForm - Objeto Formulário
//..........:strDestino	- Destino para submeter os dados do form
//..........:strNomeArquivo	Nome do Arquivo
//..........:strIdProjeto	código do projeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function ConsultarNoticia(objForm,strDestino,strNomeArquivo,strIdNoticia)
{
	try
	{
		document.frmRS.action= strDestino;
		document.frmRS.hdnArqProjeto.value = strNomeArquivo;
		document.frmRS.hdnIDNoticia.value = strIdNoticia;
		document.frmRS.submit();
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Limpa Campos do Formulário de Projetos
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function LimpaCampo(strId)
{

	var strValor = document.getElementById(strId).value.substring(0,7)
	var strCaracter = document.getElementById(strId).value.substr(10)

	if(strValor=='Máximo ' && strCaracter.indexOf('caracteres')!=-1)
	{
		document.getElementById(strId).value = "";
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Marca opção de |Período no formulário de Projetos escolhida pelo usuário
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function MarcaOpcao()
{
	if(document.frmProjeto.optPeriodoPer.checked==true)
	{
		document.frmProjeto.txtPeriodo.value = "";
		document.frmProjeto.txtPeriodo1.value = "";
		document.frmProjeto.txtDurante.value = "";
	}
	else if (document.frmProjeto.optPeriodoData.checked==true)
	{
		document.frmProjeto.txtDurante.value = "";
	}
	else if (document.frmProjeto.optDurante.checked==true)
	{
        document.frmProjeto.txtPeriodo.value = "";
		document.frmProjeto.txtPeriodo1.value = "";
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Marca opção de |Período no formulário de Projetos escolhida pelo usuário
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function MarcaOpcaoPeriodo(intStatus)
{
	
	if (intStatus==0)
	{
        
    }
    else if (intStatus==1)
    {
        document.frmProjeto.optPeriodoData.checked=true
    }
    else if (intStatus==2)
    {
        document.frmProjeto.optDurante.checked=true
    }
    
										
}
// ----------------------------------------------------------------------------
// Objetivo  : Valida O periodo escolhido pelo usuário no formulário de projetos
// Premissas : Nenhuma
// Entradas  :	strValor valor do período
// Retorno   : retorna  true se a data for válida, caso contrário retorna falso
// ----------------------------------------------------------------------------
function ValidaPeriodoProjeto(strValor)
{
	var intIaux // Variavel utilizada no laço for
	try
	{
		if (strValor.length == 7)
		{
			for(intIaux=0;intIaux<strValor.length;intIaux++)
			{
				if(intIaux!=2)
				{
					if(strValor.charCodeAt(intIaux)<48 || strValor.charCodeAt(intIaux)>57)
					{
						throw "Período Inválido";
					}
				}
				else if(intIaux==2)
				{
					if(strValor.charCodeAt(intIaux)!=47)
					{
						throw "Período Inválido";
					}
				}
			}
		}
		else
		{
			throw "Período Inválido";
		}
		return true
	}
	catch(objEx)
	{
		
		alert(objEx.toString());
		return false
		
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Valida O periodo escolhido pelo usuário no formulário de projetos
// Premissas : Nenhuma
// Entradas  :strValor1 data inicial
//..........: strValor2 data Final
// Retorno   : retorna  true se a data for válida, caso contrário retorna falso
// ----------------------------------------------------------------------------
function ValidaPeriodo(strVal1,strVal2)
{
	var strMes1 = strVal1.substring(0,2); // Recupera o mes da data inicial
	var strMes2 = strVal2.substring(0,2); // Recupera o mes da data Final
	var strAno1 = strVal1.substring(3,7); // Recupera o ano da data inicial
	var strAno2 = strVal2.substring(3,7); // Recupera o ano da data Final
	
	try
	{       
		
		if((strMes1 >=1 &&  strMes1 <= 12) && (strMes2 >=1 && strMes2 <=12))
		{
			if(strMes1 == strMes2)
			{
				if(strAno2 < strAno1)
				{
					throw "A data final não pode ser menor que a data Inicial"
				}
				else if(strAno2 == strAno1)
				{
					throw "A data final não pode ser igual que a data Inicial"
				}
			}
			else if(strMes2 < strMes1)
			{
				if(strAno2 <= strAno1)
				{
					throw "A data final não pode ser menor que a data Inicial"
				}
				
			}
			else if(strMes2 > strMes1)
			{
				if(strAno2 < strAno1)
				{
					throw "A data final não pode ser menor que a data Inicial"
				}
				
			}
		}
		else
		{
			throw "Período Inválido"
		}
	}
	catch(objEx)
	{
		alert(objEx.toString());
		return false
		
	}
	
}
// ----------------------------------------------------------------------------
// Objetivo  : Valida campo monetário
// Premissas : Nenhuma
// Entradas  :strValor valor monetário
// Retorno   : retorna  true se o valor for válido, caso contrário retorna falso
// ----------------------------------------------------------------------------
function ValidaCampoMonetario(strValor)
	{
		var intPosVirgula = -1 // recebe a posição do caracter virgula se houver
		try
		{
			if (strValor.indexOf(',')!=-1)
			{
				intPosVirgula = strValor.indexOf(',');	
				if(strValor.substr(intPosVirgula+1).length!=2)
				{
					throw "Campo Inválido."
				}
			}
			 for(intIaux=0;intIaux<strValor.length;intIaux++)
				{
					if(intIaux!= intPosVirgula)
					{
						if(strValor.charCodeAt(intIaux)<48 || strValor.charCodeAt(intIaux)>57)
						{
							throw "O campo é numérico";
						}
					}
					else if(intIaux==intPosVirgula)
					{
						if(strValor.charCodeAt(intIaux)!=44)
						{
							throw "O campo é numérico";
						}
					}
						
				}		
		}
		catch(objEx)
		{
			return false
			
		}
	}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar dados da Empresa
// Premissas : Nenhuma
// Entradas  :
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AlterarDataAtualizacao()
{	
	var objXml			// Objeto xml
	var objRaiz			// Aponta para a raiz do xml	
	var objRegistro		// Define um registro
	var objExiste		// Carrega o xml para verificar existencia do registro
	var objRegistro1	// Define um registro Antigo
	MontaNomeEmp(strNomeArquivo)
	
	try
	{	
	
		objXml = new ActiveXObject("Microsoft.XMLDOM")
		objXml.load(PATH+strNomeArquivo+strDataXML)
	
		objRaiz = objXml.documentElement

		objRegistro = objXml.createElement("recordset")
		objRaiz.appendChild(objRegistro)

		objRegistro.setAttribute ("ID",1);
		objRegistro.setAttribute ("Data",TrocarCaracter(document.frmProjeto.hdnDate.value,0));

		objRegistro1 = objRaiz.selectSingleNode("recordset[@ID='1']")
		objRaiz.replaceChild(objRegistro,objRegistro1)
		objXml.save(PATH+strNomeArquivo+strDataXML)
	}
	catch(objEx)
	{
		alert(objEx.message);
	}
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar Imagem na galeria de foto
// Premissas : Nenhuma
// Entradas  : strFoto nome da foto ,strLegenda legenda da foto.
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function GaleriaFoto(strFoto,strLegenda)
{
	var objFrame = parent.frames["ifrGaleriaG"];
	objFrame.document.getElementById('imgMostraFoto').src=strFoto;
	objFrame.document.getElementById('tdMostraLegenda').innerHTML=strLegenda;
}
// ----------------------------------------------------------------------------
// Objetivo  : Alterar Imagem no objjeto
// Premissas : Nenhuma
// Entradas  : strID id do objeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function AtualizarImg(strID)
{
	window.opener.document.getElementById(strID).value = document.frmProjeto.txtFile.value;
	this.close();
}
// ----------------------------------------------------------------------------
// Objetivo  : Quebra de Linha
// Premissas : Nenhuma
// Entradas  : strValor texto para insersão do parágrafo
//...........: strID id do objeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function QuebrarLinha(strValor,strId)
{
	var strParagrafoIni = '<p>'; // Determina a tag inicial do parágrafo
	var strParagrafoFim = '</p>';// Determina a tag Final do parágrafo
	var strTextoIni = '';		// Recebe texto inicial
	var strTextoFim = '';		// Recebe texto Final
	var objText = document.getElementById(strId)
	var objPosicao = objText.createTextRange();

	
	if (strValor.lastIndexOf('</p>')!=-1)
	{
		strTextoIni = strValor.substr(0,strValor.lastIndexOf('</p>')+4);
		strTextoFim = strValor.substr(strValor.lastIndexOf('</p>')+4);
		
		if(strTextoFim.length!=0)
		{
			strTextoFim = strTextoIni + strParagrafoIni + strTextoFim + strParagrafoFim;
		}
		else
		{
			strTextoFim = strTextoIni;
		}
	}
	else
	{
		strTextoFim = strTextoIni +  strParagrafoIni + strValor + strParagrafoFim;
	}
	document.getElementById(strId).value = strTextoFim;
	
	document.getElementById(strId).focus();
	objPosicao.move("character",strTextoFim.length);
}
// ----------------------------------------------------------------------------
// Objetivo  : Tirar Aspas
// Premissas : Nenhuma
// Entradas  : strValor texto 
//...........: intstatus id do objeto
// Retorno   : Nenhum
// ----------------------------------------------------------------------------
function TrocarCaracter(strValor,intStatus)
{
	try
	{
		var arrValor
		var intIaux
		var strResult = ''
		var srtTextIni
		var srtTextFim
		var arrQuot
		var arrCodigoInvalido = new Array(8220,8221,34)
		
		if(intStatus==0)
		{
			for(intJaux=0;intJaux<strValor.length;intJaux++)
			{
				for (intIaux=0;intIaux<arrCodigoInvalido.length;intIaux++)
				{
					if(strValor.charCodeAt(intJaux)==arrCodigoInvalido[intIaux])
					{
						srtTextIni = strValor.substr(0,intJaux)
						srtTextFim = strValor.substr(intJaux+1)
						strValor = srtTextIni + "&quot;" + srtTextFim
					}
				}
			}
		}
		else if(intStatus==1)
		{
			
			
			arrQuot = strValor.split('&quot;')
			for(intIaux=0;intIaux<arrQuot.length;intIaux++)
			{
				if(intIaux==0)
				{
					srtTextIni =  arrQuot[intIaux]
					strValor = srtTextIni
				}
				else
				{
					srtTextIni =  srtTextIni + '\"' +  arrQuot[intIaux]
					strValor = srtTextIni		
				}
			
			}
		}
		
		return strValor
	}
	catch(objEx)
	{
		alert(objEx.message)
	}

}

function ContarCaracter(strValor)
{
	
	var strValorTratado = strValor.toLowerCase()
	var arrBr		// Array da tag <br>
	var arrItIni	// Array da tag <i>
	var arrItFim	// Array da tag </i>
	var arrNegIni	// Array da tag <b>
	var arrNegFim	// Array da tag </b>
	
	var intTotal	// Total de Caracteres
	var intTotalBr	// Tota de br
	var intTotalIt	// Total de Italico
	var intTotalNeg	// Total de Negrito
	
	arrBr = strValorTratado.split('<br>')
	
	arrNegIni = strValorTratado.split('<b>')
	arrNegFim = strValorTratado.split('</b>')
	
	arrItIni = strValorTratado.split('<i>')
	arrItFim = strValorTratado.split('</i>')
	
	arrNegIni = strValorTratado.split('<b>')
	arrNegFim = strValorTratado.split('</b>')
	
	
	intTotal = strValor.length
	intTotalBr = (arrBr.length-1)*4
	intTotalIt = (((arrItIni.length-1)*3) + ((arrItFim.length-1)*4) )
	intTotalNeg = (((arrNegIni.length-1)*3) + ((arrNegFim.length-1)*4) )
	
	
	return(intTotal - (intTotalBr + intTotalIt + intTotalNeg))
	

}

// ----------------------------------------------------------------------------
// Objetivo  : MouseOver do botão
// Premissas : 
// Entradas  : 
// Retorno   : 
// ----------------------------------------------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// ----------------------------------------------------------------------------
// Objetivo  : MouseOver do botão
// Premissas : 
// Entradas  :
// Retorno   : 
// ----------------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


// ----------------------------------------------------------------------------
// Objetivo  : MouseOver do botão
// Premissas : 
// Entradas  :
// Retorno   : 
// ----------------------------------------------------------------------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// ----------------------------------------------------------------------------
// Objetivo  : MouseOver do botão
// Premissas : 
// Entradas  :
// Retorno   : 
// ----------------------------------------------------------------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
