<!--
//Configurações
//*******************************************
var PRIVATE_ROOT = "/CSJ/";

//=====================================================================================================================================================================

/*-----------------------------------------------------------------------------*/


var QntdJanelaAlert = 0;

function addEvent(obj, evType, fn)
{
	try
	{
		obj.addEventListener(evType, fn, false);
	}
	catch(e){}
	try
	{
		obj.attachEvent("on"+evType, fn);
	}
	catch(e){}
}


/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
function fsAlerta(conteudo,variavel,posy2)
{
	
	var posy2 = 300;
	
	if(QntdJanelaAlert>0)
	{
		var a = document.body;
		var t = a.removeChild(document.getElementById('divPaiAlerta'));
		var d = a.removeChild(document.getElementById('divFundoAlerta'));
		var r = a.removeChild(document.getElementById('divIframeAlerta'));
	}
	
	QntdJanelaAlert++;
	
	var largura_tela = (document.body.clientWidth/2)-20;
	var altura_tela = (document.body.clientHeight/2);
	var alerta_tamanho = 316;
	var alerta_altura = 115;
	var alerta_x = alerta_tamanho/2;
	var alerta_y;
  
  	if (posy2 > 125)
  	{
		alerta_y = document.documentElement.scrollTop + posy2 - 80;
  	}
  	if((document.body.clientHeight - posy2) < 125)
  	{
  		alerta_y = document.documentElement.scrollTop + 20;
  	}
  	else
  	{
		alerta_y = document.documentElement.scrollTop + posy2-80;
  	}

	
	var divPai = document.createElement("div");
	divPai.style.position = "absolute";
	divPai.style.border = "0px solid black";
	divPai.style.left = (largura_tela - alerta_x)+"px";
	divPai.style.top = alerta_y+"px";
	divPai.style.width = "316px";
	divPai.style.height = "115px";
	divPai.style.padding = "15px";
	divPai.style.zIndex = "1000";
	divPai.style.overflow = "hidden";
	divPai.style.cursor = "pointer";
	divPai.id = "divPaiAlerta";
	divPai.setAttribute("title","Clique para fechar o popup.");
	
	var divConteudo = document.createElement("div");
	divConteudo.style.border = "0px";
	divConteudo.style.width = "290px";
	divConteudo.style.height = "80px";
	divConteudo.style.textAlign = "center";
	divConteudo.style.overflow = "auto";
	divConteudo.style.cursor = "pointer";
	divConteudo.innerHTML = conteudo + "";
	
	var Botao = document.createElement("input");
	Botao.type = 'image';
	Botao.src = "img/bt_ok.gif";
	Botao.id = "botao";
	Botao.name = "botao";
	Botao.value = "";
	
	var iframePopup = document.createElement("iframe");
	iframePopup.style.position = "absolute";
	iframePopup.style.border = "0px solid black";
	iframePopup.style.left = (largura_tela - alerta_x)+"px";
	iframePopup.style.top = alerta_y+"px";
	iframePopup.style.width = "316px";
	iframePopup.style.height = "115px";
	iframePopup.style.padding = "20px";
	iframePopup.style.zIndex = "999";
	iframePopup.style.overflow = "hidden";
	iframePopup.src = "nada.html";
	iframePopup.style.opacity = ".0";
	iframePopup.style.filter = "alpha(opacity=0)";
	iframePopup.id = "divIframeAlerta";
	
	var divFundo = document.createElement("img");
	divFundo.style.position = "absolute";
	divFundo.style.left = (largura_tela - alerta_x)+"px";
	divFundo.style.top = alerta_y+"px";
	divFundo.style.width = "316px";
	divFundo.style.height = "115px";
	divFundo.style.zIndex = "998";
	divFundo.style.overflow = "hidden";
	divFundo.id = "divFundoAlerta";
	divFundo.style.border = "0px";
	divFundo.src = "img/fundo_alert.gif";
	
	a = function()
	{
		var a = document.body;
		var t = a.removeChild(document.getElementById('divPaiAlerta'));
		var r = a.removeChild(document.getElementById('divIframeAlerta'));
		var d = a.removeChild(document.getElementById('divFundoAlerta'));
		document.getElementById(variavel).focus();
		QntdJanelaAlert = 0;
	}
	
	addEvent(divPai, "click", a);
	addEvent(divConteudo, "click", a);
	
	divConteudo.appendChild(Botao);
	divPai.appendChild(divConteudo);
	document.body.appendChild(divPai);
	document.body.appendChild(divFundo);
	document.body.appendChild(iframePopup);
	document.getElementById('botao').focus();	
}


/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/

function iniciarAjax()
{ //instancia um novo xmlhttprequest
	//baseado na getXMLHttpObj que possui muitas cópias na net e eu nao sei quem é o autor original	
	
    if(typeof(XMLHttpRequest)!='undefined')
	{
		return new XMLHttpRequest();
	}
	
    var axO=['Microsoft.XMLHTTP','Msxml2.XMLHTTP','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0'];
    for(var i=0;i<axO.length;i++)
	{ 
		try
		{ 
			return new ActiveXObject(axO[i]);
		}
		catch(e)
		{
		} 
	}
	return false;
}



function ajaxInit()
{
	var req;
	try
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex)
		{
			try
			{
				req = new XMLHttpRequest();
			}
			catch(exc)
			{
				alert("Esse browser não tem recursos para uso do Ajax");
				req = null;
			}
		}
	}
	return req;
	//alert(req);
}

/*-----------------------------------------------------------------------------*/





/*-----------------------------------------------------------------------------*/

somar = 0;
function BuscarAlunos()
{
	var idcurso = document.getElementById('idcurso');
	var turma	= document.getElementById('turma');
	
	//document.getElementById('alunos_comunicado').style.display = "none";
	//document.getElementById('envio_comunicado').style.display = "none";
		
	var ajax = ajaxInit();
	var Path = "js/ajexe.asp?LC=buscar_alunos";
		Path += "&idcurso="+idcurso.value;
		Path += "&turma="+turma.value;
		
	if(ajax)
	{
		var Resp;
		ajax.open("GET", Path, true);
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 1)
			{	
				document.body.style.cursor = 'wait';
			}				
			
			if(ajax.readyState == 4)
			{	
				//alert(ajax.status);
				if(ajax.status != 200)
				{
					Resp = "0///|---Problema no serviço".split('///|---');
					alert(ajax.responseText);
				}
					
				if(ajax.status == 200)
				{
					Resp = ajax.responseText.split('///|---');
						
					if (Resp.length <= 3)
					{
						//fsAlerta('<div style="font-family:Arial, Helvetica, sans-serif; font-size:12px; padding-top:0px; padding-bottom:3px; color:#222222;"><b>AVISO</b></div><div style="width:250px; margin:auto auto; text-align:center; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#222222; padding-bottom:12px;">'+Resp[1]+'</div>',Resp[2],300);
						alert(Resp[1]);
						document.body.style.cursor = 'default';
						document.getElementById(Resp[2]).focus();
						return false;
					}
					else
					{	
						document.location = 'boletim_comunicados_professor_inclui.asp?idcurso='+Resp[1]+'&turma='+Resp[2];
					}
				}
			}
		}
		ajax.send(null);
	}
}


	
/*-----------------------------------------------------------------------------*/
























function popup_up(pagina,targ,largura,altura){
	esquerda = (screen.width - largura - 10)/2;
	topo = screen.height - 59;
	topo = (topo - altura)/2;
	param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	window.open(pagina,targ,param);
}

function popup(pagina,targ,largura,altura,esquerda,topo,scrollbars){
	if (scrollbars == null || scrollbars == ''){
		scrollbars = '0';
	}
	if (esquerda == null || esquerda == ''){
		esquerda = (screen.width - largura - 10)/2;
	}
	if (topo == null || topo == ''){
		topo = (screen.height - altura - 57)/2;
	}
//	param = "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
//	win = window.open("",targ,param);
//	win.moveTo(esquerda,topo);
//	win.resizeTo(largura,altura);
//	param = "fullscreen=1"
	param = "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",resizable=0,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	win = window.open(pagina,targ,param);
	return win;
}

function Money_2_Java(num){
	novo_num = num;
	for(z=0;novo_num.lastIndexOf(".")>-1;z++){
		ult_ponto = novo_num.lastIndexOf(".");
		novo_num = novo_num.substring(0,ult_ponto) + novo_num.substring(ult_ponto+1,novo_num.length);
	}
	ult_virg = novo_num.lastIndexOf(",");
	if (ult_virg > -1){
		novo_num = novo_num.substring(0,ult_virg) + "." + novo_num.substring(ult_virg+1,novo_num.length);
	}
	return novo_num
}

function NumJava_2_Money(num){
	virg = false;
	novo_num = "";
	num = "" + num
	if (num.lastIndexOf(".") == -1){
		virg = true;
		ponto = 0
	}
	for(i=0;i<num.length;i++){
		if(num.substring(num.length-i-1,num.length-i) == "."){
			if (!virg){
				virg = true;
				ponto = 0;
				novo_num = "," + novo_num;
			}
		}else{
			if(virg){
				if (ponto == 3 && num.substring(num.length-i-1,num.length-i) != "-"){
					ponto = 0
					novo_num = "." + novo_num
				}
				ponto = ponto + 1
			}
			novo_num = num.substring(num.length-i-1,num.length-i) + novo_num;
		}
	}
	if (novo_num.lastIndexOf(",") == -1){
		novo_num = novo_num + ",00";
	}else if(novo_num.lastIndexOf(",") == novo_num.length - 2){
		novo_num = novo_num + "0";
//	}else{
//		novo_num = novo_num.substring(0,novo_num.lastIndexOf(",")) + novo_num.substring(novo_num.lastIndexOf(",") + 1,2);
	}
	return novo_num
}

function mascaradata(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=8) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
		}
	}
    campo.value = temp;
}

function mascaracep(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=6) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "-" + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." + S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascarafone(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<10) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"-"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"-"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +"-"+ S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + ") " + S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4) +"-"+ S.charAt(5) + S.charAt(6) + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) +"-"+ S.charAt(6) + S.charAt(7) + S.charAt(8)+ S.charAt(9)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaranumero(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0"){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	if (S.length == 1){
		temp = "0.0" + S
		temp = NumJava_2_Money(temp);
	}else if (S.length == 2){
		temp = "0." + S
		temp = NumJava_2_Money(temp);
	}else if (S.length > 2){
		temp = a_virg + "." + S.charAt(S.length-2) + S.charAt(S.length-1);
		temp = NumJava_2_Money(temp);
	}else{
		temp = S;
	}
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
	if(temp=="")
	{temp = "0,00"}
    campo.value = temp;
}

function mascaranumero2(S,campo){
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++){
		if (ini_z == true || S.charAt(i) != "0"){
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	temp = S;
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
    campo.value = temp;
}

function mascaracpfcnpj(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=13) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) + "-" + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) + "-" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7) + "-" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8) + "-" + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9) + "-" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10) +"-"+ S.charAt(11) + S.charAt(12)}}
			if (numero == 14){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11) +"-"+ S.charAt(12) + S.charAt(13)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}



function mascaracpf(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=10) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) + "-" + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) + "-" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7) + "-" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8) + "-" + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9) + "-" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10) +"-"+ S.charAt(11) + S.charAt(12)}}
			if (numero == 14){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11) +"-"+ S.charAt(12) + S.charAt(13)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}


function mascaracnpjcol(S,campo){
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++){
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=11) {
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 8){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++){
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}

function limpa_string_virg(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789,.";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++){
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}

function valida_CPF(s){
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++){
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++){
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
		return false;
	}
   return true;
}
function valida_CGC(s){
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);

	var d1 = 0;
	for (i = 0; i < 12; i++){
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++){
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
		return false;
	}
        return true;
}
function ltrim(string){
	inicio = false;
	nova_string = "";
	for (x=0;x<string.length;x++){
		if (string.charAt(x) != " "){
			inicio = true;
			nova_string = nova_string + string.charAt(x);
		}else if(inicio){
			nova_string = nova_string + string.charAt(x);
		}
	}
	return nova_string
}

function rtrim(string){
	inicio = false;
	nova_string = "";
	for (x = string.length - 1;x>=0;x--){
		if (string.charAt(x) != " "){
			inicio = true;
			nova_string = string.charAt(x) + nova_string;
		}else if(inicio){
			nova_string = string.charAt(x) + nova_string;
		}
	}
	return nova_string
}

function trim(string){
	return ltrim(rtrim(string))
}
function logout() {
	if(confirm('Deseja sair e fazer logout do HelpDesk Online?')){
		popup_up('logout.asp?x=unload','logout',50,10)
	}
}
function checa(nform) {
	if (nform.email.value == "") {
		alert("Informe seu e-mail.");
		nform.email.focus();
		nform.email.select();
		return false;
	} else {
		prim = nform.email.value.indexOf("@")
		if(prim < 2) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("@",prim + 1) != -1) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".") < 1) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(" ") != -1) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("zipmeil.com") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("hotmeil.com") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".@") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("@.") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".com.br.") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("/") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("[") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("]") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("(") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(")") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("..") > 0) {
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
	}
		return true;
}
function sair(){
	if(confirm("Deseja Realmente Sair do Sistema?"))
	{
		location = "logout.asp"
	}
	else
	{
		return false;
	}
}

function altera_menu(pg,valor){
	formulario.action = 'cadastro'+pg+'.asp?acao=alterar&voltar='+valor;
	formulario.submit();
}
	
-->