﻿// JavaScript Document
function visualiza(cam)
{ 
	window.open(cam,'Anexo','scrollbars=yes,top=0,left=0,width=800,heigth=600');
}

//deleta arquivo anexo
function deletar(arq)
{
	if (confirm("Deseja deletar o arquivo '"+arq+"'"))
	{
		document.location.href = "anexardocumento.asp?del="+arq;
	}
}

//div compromissos recebiados não lidos
function MontaDivNaoLidos(id, total, qm)
{
	//alert(id);
	setTimeout('MovimentaDiv("'+id+'", 3,'+total+','+qm+')',100);
}
function FecharMontaDivNaoLidos(id)
{
	//alert("oiiiiiiiiiiiiiiii "+id);
	document.getElementById(id).style.visibility = "hidden";
}

function MovimentaDiv(id, top1, total, qm)
{
	//alert(qm);
	//234
	var width = 350;
	var height = 50;
	var left = ((document.body.clientWidth)/2)-(350/2);
	var top = ((document.body.clientHeight)/2)-(50/2);
	//alert(top);
	//alert(document.getElementById(id).style.top);
	str = document.getElementById(id).style.top;
	re = "px";
	top_1 = str.replace(re,"");
	//alert(top_1);
	if(parseInt(top_1) <= 200)
	{
		//alert("oi");
		document.getElementById(id).style.top = parseInt(top_1) + top1;
		document.getElementById(id).style.left = left;
		document.getElementById(id).style.width = width;
		document.getElementById(id).style.height = height;
		document.getElementById(id).style.visibility = "visible";
		var html = "<div style='text-align:right;'>";
		html=html+"<img id='fechar' name='fechar' src='images/fechar2.gif' style='cursor:pointer;' onClick='FecharMontaDivNaoLidos(\""+id+"\");' onMouseOver='MouseOver();' onMouseOut='MouserOut();'>";
		html=html+"</div>";
		html=html+"<fieldset style='border-color:#000000; background-color:#a87fcf;'><legend class='link'>Recebidos Não Lidos</legend><font class='link'></BR>";
		html=html+"&nbsp;&nbsp;&nbsp;Total de Compromissos e Mensagens não lidas por você [ "+total+" ]</BR></BR>";
		html=html+"&nbsp;&nbsp;&nbsp;<a href='mensagens.asp?cp=-1&np=Recebidos&qm="+qm+"' class='link2'>Clique aqui para visualizar</a></BR></BR></font></fieldset>";
		document.getElementById(id).innerHTML = html;
		MontaDivNaoLidos(id, total, qm);
	}
}
function MouseOver()
{
	document.getElementById("fechar").src = "images/fechar1.gif";
}
function MouserOut()
{
	document.getElementById("fechar").src = "images/fechar2.gif";
}
///fim div compromissos recebiados não lidos

function FecharErro()
{
	document.getElementById("LErro").style.display = "none";
}
function AbreErro(erro)
{
	var width = 300;
	var height = 100;
	var left = ((document.body.clientWidth)/2)-(width/2);
	var top = ((document.body.clientHeight)/2)-(height/2);
	document.getElementById("LErro").style.top = String(top+"px");
	document.getElementById("LErro").style.left = String(left+"px");
	document.getElementById("LErro").style.display = "block";
	var texto = "<div style='text-align:right;'><span onclick='javascript:FecharErro();' class='XLErro'>&nbsp;[ X ]&nbsp;</span></div>";
	texto = texto + "<span style='color:#FF0000; font:Arial; font-size:12px;'>&nbsp;" + erro + "</span>";
	document.getElementById("LErro").innerHTML = "";
    document.getElementById("LErro").innerHTML = texto;
    document.getElementById("LErro").focus();
}

function AbreErroParent(erro)
{
	var width = 300;
	var height = 100;
	var left = ((parent.document.body.clientWidth)/2)-(width/2);
	var top = ((parent.document.body.clientHeight)/2)-(height/2);
	parent.document.getElementById("LErro").style.top = String(top+"px");
	parent.document.getElementById("LErro").style.left = String(left+"px");
	parent.document.getElementById("LErro").style.display = "block";
	var texto = "<div style='text-align:right;'><span onclick='javascript:FecharErro();' class='XLErro'>&nbsp;[ X ]&nbsp;</span></div>";
	texto = texto + "<span style='color:#FF0000; font:Arial; font-size:12px;'>&nbsp;" + erro + "</span>";
	parent.document.getElementById("LErro").innerHTML = "";
    parent.document.getElementById("LErro").innerHTML = texto;
}

function relogio()
{
  var now = new Date();
  var hours = now.getHours();
  var minutes = now.getMinutes();
  var seconds = now.getSeconds()
	
  if(hours <=9)
    hours="0"+hours;
  if(minutes<=9)
    minutes="0"+minutes;
  if(seconds<=9)
    seconds="0"+seconds;
	
  var cdate=hours+":"+minutes+":"+seconds ;
  document.getElementById('lblRelogio').innerHTML= cdate ;
  
  setTimeout("relogio()",1000);
}

function CancelPostBack()
{
    var objMan = Sys.WebForms.PageRequestManager.getInstance();
    if (objMan.get_isInAsyncPostBack())
        objMan.abortPostBack();
}  

function MOver(id)
{
	document.getElementById(id).style.backgroundImage = "url(../imagens/LnkAtivo.jpg)";
}
function MOut(id)
{
	document.getElementById(id).style.backgroundImage = "url(../imagens/LnkInativo.jpg)";
}

function excluir(id,descricao,titulo,url)
{
    if(id!="")
    {
        var texto = '\nDeseja excluir este ['+titulo+']?\n\nDescrição: '+ descricao;
        if(confirm(texto))
            window.location = url+'?operacao=excluir&id='+id;
    }
}

function AlertaGrupos(qtd)
{
    alert('Grupo Vinculado a ' + qtd + ' Usuarios.\n\nExclusao cancelada.');
    return false;
}

function MouseOverLinks(id)
{
	document.getElementById(id).style.color = "#C15B06";
	document.getElementById(id).style.fontSize = "11px";
}
function MouserOutLinks(id)
{
	document.getElementById(id).style.color = "#0269C4";
	document.getElementById(id).style.fontSize = "10px";
}

function POPUP(id)
{
	var width = 408;
	var height = 250;
	var left = ((screen.width)/2)-(408/2);
	var top = ((screen.height)/2)-(250/2);
	window.open("relatorio.aspx?id="+id,"Relatorio","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top="+top+",left="+left+",width="+width+"px, height="+height+"px");
}

function ModalRelatorio(id) 
{
	window.showModalDialog('relatorio.aspx?id='+id,'Relatorio','dialogWidth:410px;dialogHeight:250px,scroll:no,center:yes,status:no');
}

function PosicaoDiv(nome, altura)
{
    var alturaPagina = document.getElementById("Corpo").clientHeight;
    var alturaScroll = document.getElementById("Corpo").scrollTop;
    document.getElementById(nome).style.top = (alturaPagina + alturaScroll - altura ) + "px";
}

function ComboBox()
{
    if (typeof "ctl00_CPHConteudo_cmboxContatos_OptionList" != "string") {
        document.getElementById("ctl00_CPHConteudo_cmboxContatos_OptionList").style.top = "160px";
        document.getElementById("ctl00_CPHConteudo_cmboxContatos_OptionList").style.left = "320px";   
    }
}

function ComboBoxMOver(id)
{
	document.getElementById(id).style.backgroundImage = "url(../imagens/windows-arrow2.gif)";
}

function ComboBoxMOut(id)
{
	document.getElementById(id).style.backgroundImage = "url(../imagens/windows-arrow.gif)";
}

function MovaParaTopo()
{
    document.body.scrollTop = 0;
}

function ConfirmaSenha(pSenha, pConfirmaSenha) 
{
    if (document.getElementById(pSenha).value != '') {
        if (document.getElementById(pSenha).value != document.getElementById(pConfirmaSenha).value) {
            alert('Senha não confere! Digite novamente');
            document.getElementById(pConfirmaSenha).focus();
        }
    }
}

function formatar(src, mask, e) {
    var i = src.value.length;
    var saida = mask.substring(0, 1);
    var texto = mask.substring(i);

    var Key = '';
    var strCheck = '0123456789';

    if (navigator.appName == "Microsoft Internet Explorer")
        var whichCode = e.keyCode;
    else
        var whichCode = e.which;

    if ((whichCode == 13) || (whichCode == 8) || (whichCode == 0))
        return true;

    key = String.fromCharCode(whichCode);

    if (strCheck.indexOf(key) == -1)
        return false;

    if (src.value.length < mask.length) {
        if (texto.substring(0, 1) != saida) {
            src.value += texto.substring(0, 1);
            return true;
        }
    }
    else {
        return false;
    }
}

function ConfirmaExclusao(nome) {
    if (nome != null)
        return (confirm('Deseja excluir ' + nome + '?'));
    else
        return (confirm('Deseja excluir o item selecionado?'));
}