//window.addEventListener?window.addEventListener("load",createGradient,false):window.attachEvent("onload",createGradient);
function popup(){

	largura = "652";
	altura = "391";
	w = screen.width;
	h = screen.height;
	meio_w = w/2;
	meio_h = h/2;
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;

	
	window.open ("video/media/mediaplayer.htm","janela","location=0,status=0,scrollbars=0,width=" + largura + ",height=" + altura + ",resizable=0,toolbar=0,titlebar=0, top="+meio1+", left="+meio2+"");
 } 
 
function popup2(){

	largura = "480";
	altura = "295";
	w = screen.width;
	h = screen.height;
	meio_w = w/2;
	meio_h = h/2;
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;

	
	window.open ("http://www.tracegp.com.br/video/video-instituciona-comercial-trace-agosto-2009.htm","janela","location=0,status=0,scrollbars=0,width=" + largura + ",height=" + altura + ",resizable=0,toolbar=0,titlebar=0, top="+meio1+", left="+meio2+"");
 } 
 
function abreSistema(){
	var wide = window.screen.width-6;
	var high = window.screen.height-80;
	window.open("http://tracegp.trace.com.br:8080/TraceGP/indexPopup.jsp","tracegpClientePopup","left=0,top=0,height="+high+",width="+wide+",directories=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes");
}

function mostraOcultaCamada(acao, nomeCamada){
	if (acao == 'mostra'){
		document.getElementById(nomeCamada).style.visibility = "visible";
		document.getElementById('iconeAtendimento').style.cursor = "hand";
	} else if(acao == 'esconde' && document.formMain.situacao.value != "S"){
		document.getElementById(nomeCamada).style.visibility = "hidden";
	}	
}

function mostraOcultaFixa(nomeCamada){
		document.getElementById(nomeCamada).style.visibility = "visible";
		document.getElementById('iconeAtendimento').style.cursor = "hand";
		document.formMain.situacao.value = "S";
}

function fecharCamada(nomeCamada){
		document.getElementById(nomeCamada).style.visibility = "hidden";
		document.getElementById('close').style.cursor = "hand";
		document.formMain.situacao.value = "N";
}

function montaCamadaAtendimento(){
	var bannerAtendimento = '<div style="text-align:center;width:181px;">';
		bannerAtendimento += '<a href="javascript:void(window.open(\'http://200.213.60.167/livezilla_tracegp/livezilla.php\',\'\',\'width=600,height=550,left=0,top=0,resizable=yes,menubar=no,location=yes,status=yes,scrollbars=yes\'))">';
		bannerAtendimento += '<img id="bannerAt" src="http://200.213.60.167/livezilla_tracegp/image.php?id=03" width="181" height="50" border="0" alt="Atendimento TraceGP">';
		bannerAtendimento += '</a><noscript>';
		bannerAtendimento += '<div>';
		bannerAtendimento += '<a href="http://200.213.60.167/livezilla_tracegp/livezilla.php" target="_blank">';
		bannerAtendimento += 'Contate nossos atendentes';
		bannerAtendimento += '</a>';
		bannerAtendimento += '</div>';
		bannerAtendimento += '</noscript>';
		bannerAtendimento += '<div style="margin-top:2px;">';
		//bannerAtendimento += '<a href="http://www.tracegp.com.br" target="_blank" title="http://www.tracegp.com.br" style="font-size:10px;color:#bfbfbf;text-decoration:none;font-family:verdana,arial,tahoma;">';
		//bannerAtendimento += 'TraceGP';
		//bannerAtendimento += '</a>';
		bannerAtendimento += '</div>';
		bannerAtendimento += '</div>';
		bannerAtendimento += '<div id="livezilla_tracking" style="display:none"></div>';
		bannerAtendimento += '<script language="JavaScript" type="text/javascript">';
		bannerAtendimento += 'var script = document.createElement("script");script.type="text/javascript";var src = "http://200.213.60.167/livezilla_tracegp/server.php?request=track&output=jscript&nse="+Math.random();setTimeout("script.src=src;document.getElementById(\'livezilla_tracking\').appendChild(script)",1);';
		bannerAtendimento += '</script>';

	// testa se for FF ou IE, e se for IE 7 ou 6 para tratamento de possíveis erros
	if (document.all){
		var camadaAtendimento = '<!--[if !IE 6]><form name="formMain"><input name="situacao" type="hidden" value="N" /></form><![endif]-->';
		camadaAtendimento = '<div id="camadaAtendimento">';
		camadaAtendimento += '<img id="close" src="images/close_tooltip.png" alt="Fechar" width="19" height="19" onclick="fecharCamada(\'camadaAtendimento\');fecharCamada(\'seta\')"/>';
		camadaAtendimento += '<h4>Suporte TraceGP</h4>';
		camadaAtendimento += '<h3>+55 51 2101.6914<br />';
		camadaAtendimento += '+55 11 3020.6914</h3>';
		/*camadaAtendimento += bannerAtendimento;*/
		camadaAtendimento += '<p><a href="mailto:suporte@tracesistemas.com.br">suporte@tracesistemas.com.br</a>';
		camadaAtendimento += '<br>Segunda a Sexta-feira, das 8hs às 18hs</p>';
		camadaAtendimento += '<h4>Contato Comercial</h4>';
		camadaAtendimento += '<h3>+55 51 2101.6900</h3>';
		camadaAtendimento += '<p><a href="mailto:comercial@tracesistemas.com.br">comercial@tracesistemas.com.br</a></p>';
		camadaAtendimento += '</div>';
		//camadaAtendimento += '<!--[if !(IE 6)]>';
		camadaAtendimento += '<div id="seta">';
		camadaAtendimento += '<img src="images/setaAtendimento.gif" width="61" height="29" border="0" />	';
		camadaAtendimento += '</div>';
		//camadaAtendimento += '<![endif]-->';
		camadaAtendimento += '<div id="iconeAtendimento">';
		camadaAtendimento += '<img onmouseover="mostraOcultaCamada(\'mostra\',\'camadaAtendimento\');mostraOcultaCamada(\'mostra\',\'seta\')" onmouseout="mostraOcultaCamada(\'esconde\',\'camadaAtendimento\');mostraOcultaCamada(\'esconde\',\'seta\')"  onclick="mostraOcultaFixa(\'camadaAtendimento\');mostraOcultaFixa(\'seta\')" src="images/icone_atendimento.gif" alt="Contatos" width="45" height="40" border="0" title="Contatos"  /> ';
		camadaAtendimento += '</div>';
		//document.write(camadaAtendimento);
	
	} else {
		var camadaAtendimento = '<form name="formMain"><input name="situacao" type="hidden" value="N" /></form>';
		camadaAtendimento = '<div id="camadaAtendimento">';
		camadaAtendimento += '<img id="close" src="images/close_tooltip.png" alt="Fechar" width="19" height="19" onclick="fecharCamada(\'camadaAtendimento\');fecharCamada(\'seta\')"/>';
		camadaAtendimento += '<h4>Suporte TraceGP</h4>';
		camadaAtendimento += '<h3>+55 51 2101.6914<br />';
		camadaAtendimento += '+55 11 3020.6914';
		/*camadaAtendimento += bannerAtendimento;*/
		camadaAtendimento += '<p><a href="mailto:suporte@tracesistemas.com.br">suporte@tracesistemas.com.br</a>';
		camadaAtendimento += '<br>Segunda a Sexta-feira, das 8hs às 18hs</p></h3>';
		camadaAtendimento += '<h4>Contato Comercial</h4>';
		camadaAtendimento += '<h3>+55 51 2101.6900';
		camadaAtendimento += '<p><a href="mailto:comercial@tracesistemas.com.br">comercial@tracesistemas.com.br</a></p></h3>';
		camadaAtendimento += '</div>';
		//camadaAtendimento += '<!--[if !(IE 6)]>';
		camadaAtendimento += '<div id="seta">';
		camadaAtendimento += '<img src="images/setaAtendimento.gif" width="61" height="29" border="0" />	';	
		camadaAtendimento += '</div>';
		//camadaAtendimento += '<![endif]-->';
		camadaAtendimento += '<div id="iconeAtendimento">';
		camadaAtendimento += '<img onmouseover="mostraOcultaCamada(\'mostra\',\'camadaAtendimento\');mostraOcultaCamada(\'mostra\',\'seta\')" onmouseout="mostraOcultaCamada(\'esconde\',\'camadaAtendimento\');mostraOcultaCamada(\'esconde\',\'seta\')"  onclick="mostraOcultaFixa(\'camadaAtendimento\');mostraOcultaFixa(\'seta\')" src="images/icone_atendimento.gif" alt="Contatos" width="45" height="40" border="0" title="Contatos"  /> ';		
		camadaAtendimento += '</div>';
		//document.write(camadaAtendimento);
	}
	
}

function toTrim(param) {
  if (param == "") {
    return "";
  } else {
    brancos = true;
    while (brancos == true) {
      if (param.substring(0,1) == " ") {
        param = param.substring(1);
        brancos = true;
      } else {
        if (param.substring(param.length-1) == " ") {
          param = param.substring(0,param.length-1);
          brancos = true;
        }else {
          brancos = false;
        }
      }
      if (param == "") {
        brancos = false;
      }
    }
    return param;
  }
}

function verify() {
	var themessage = "Antes de prosseguir, por favor preencha corretamente os seguintes campos:\n";

	document.contato.nome.value = toTrim(document.contato.nome.value);
	document.contato.cidade.value = toTrim(document.contato.cidade.value);
	document.contato.estado.value = toTrim(document.contato.estado.value);
	document.contato.comments.value = toTrim(document.contato.comments.value);

if (document.contato.nome.value=="") {
	themessage = themessage + "\n - Nome";
}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.contato.email.value)) {
	themessage = themessage + "\n - E-mail";
}
if (document.contato.cidade.value=="") {
	themessage = themessage + "\n - Cidade";
}
if (document.contato.estado.value=="") {
	themessage = themessage + "\n - Estado";
}
if (document.contato.comments.value=="") {
	themessage = themessage + "\n - Seus comentários";
}
if (document.getElementById('comparacao').value==""){
	themessage = themessage + "\n - Informe o valor da soma";
} else {
	var d = document.getElementById('comparacao').value;
	if (d != c) {
		themessage = themessage + "\n - A soma está incorreta";
	}
}
if (themessage == "Antes de prosseguir, por favor preencha corretamente os seguintes campos:\n") {
	// chamada da página pai com a finalidade de registrar os cliques no botão enviar
	monitoraClique();
	document.contato.submit();
} else {
	alert(themessage);
	return false;
}
}

function verifyRecomenda() {
var themessage = "Antes de prosseguir, por favor preencha corretamente os seguintes campos:\n";
if (document.contato.nome.value=="") {
	themessage = themessage + "\n - Seu nome";
}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.contato.email.value)) {
	themessage = themessage + "\n - Seu e-mail";
}
if (document.contato.nome_amigo.value=="") {
	themessage = themessage + "\n - Nome do amigo";
}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.contato.email_amigo.value)) {
	themessage = themessage + "\n - E-mail do amigo";
}
if (document.contato.comments.value=="") {
	themessage = themessage + "\n - Seus comentários";
}
if (themessage == "Antes de prosseguir, por favor preencha corretamente os seguintes campos:\n") {
	document.contato.submit();
	//
	//document.getElementById("MENSAGEM_ENVIO_SUCESSO").style.display = "";
	//
} else {
	alert(themessage);
	return false;
}
}

function verifyIndicaLink() {
	var themessage = "Antes de prosseguir, por favor preencha corretamente os seguintes campos:\n";
	if (document.contato.para.value=="") {
		themessage = themessage + "\n - Para";
	}
	if (document.contato.de.value=="") {
		themessage = themessage + "\n - De";
	}
	if (document.contato.assunto.value=="") {
		themessage = themessage + "\n - Assunto";
	}	
	if (document.contato.mensagem.value=="") {
		themessage = themessage + "\n - Mensagem";
	}
		
	if (themessage == "Antes de prosseguir, por favor preencha corretamente os seguintes campos:\n") {
		document.contato.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
}

var URLSite = window.location.href;
var TituloSite = document.title;

function adicionarFavoritos(){
	//if (document.all) window.external.AddFavorite(URLSite,TituloSite);
    var url        = "http://www.tracegp.com.br";
    var title    = "TraceGP :: Sistema Executivo de Governança e Gestão de Projetos";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);       
var c = a + b;
function DrawBotBoot(){
	document.write("Quanto é "+ a + " + " + b +"? ");
	document.write("&nbsp;&nbsp;<input id='comparacao' class='inputCaptcha' style='width: 50; height: 18' type='text' maxlength='2' size='2'/>");
} 