<!--
function valida_senha() {
	var s;
	s = document.form.senha;
	var i;
	var num = 0, carac = 0;
	if (document.form.senha.value.length == 0) {
	  alert('Por favor entre com sua senha!');
	  document.form.senha.focus();
	  return false;
	}
	
	if (s.length >= 8 && s.length <= 14 && '4' == '-' && '2' == '-' && s.value == document.form.confirmar.value) {
	  return true;
	}
	
	for (i = 0; i < s.value.length; i++) {
	  var c = s.value.charAt(i);
	  // ha um numero 
	  if (((c >= '0') && (c <= '9'))) {
		num++;
	  }
	  if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) ||
		   (c == '.') || (c == '!') || (c == '@') || (c == '#') || (c == '$') ||
		   (c == '*') || (c == ',') || (c == '-') || (c == '{') || (c == '}')) {
		carac++;
	  }
	  if (c == "'" || c == '`' || c == '~' || c == '"' || c == '^') {
		alert('');
		document.form.senha.focus();
		return false;
	  }
	}
	if ((num < '2' || carac < '6' || (num > 0 && '2' == 0) || (carac > 0 && '6' == 0))) {
	  if ('6' == 0) {
		msg = 'Somente números';
	  }
	
	  if ('2' == 0) {
		msg = 'Somente letras';
	  }
	
	  if ('2' > 0 && '6' > 0) {
		msg = '6 letras e 2 números';
	  }
	  alert('Senha Inválida! Senha deve conter ' + msg + '!!');
	  document.form.senha.focus();
	  return false;
	}
	if (document.form.senha.value.length == 0 || document.form.confirmar.value.length == 0) {
	  alert('As senhas são obrigatórias !');
	  document.form.senha.focus();
	  return false;
	}
	if (document.form.senha.value.length < 8) {
	  alert('Sua nova senha deve conter no mínimo 6 caracteres !');
	  document.form.senha.focus();
	  return false;
	}
	if (document.form.senha.value.length > 14) {
	  alert('A senha deve ter no máximo 14 caracteres !');
	  document.form.senha.focus();
	  return false;
	}
	if (document.form.senha.value != document.form.confirmar.value) {
	  alert('As senhas não são iguais!');
	  document.form.senha.focus();
	  return false;
	}
	s = document.form.senha.value
	hoje = new Date()
	ano = hoje.getYear()
	for (f=-2; f<=2; f++) {
	  n = s.indexOf(ano + f,0)
	  if (n > -1) {
		alert('Não é permitido colocar o ano como senha.');
		document.form.senha.focus();
		return false;
	  }
	}
  return true;
}
function Mascarar_Hora(keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + ':';
		}
		if (campo.value.length == 5 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + ':';
		}
	}
}

function Compara_Data()
{
	datai =  document.form.dt_inicial.value;
	datai = datai.replace("/","");
	datai = datai.replace("/","");
	dataf =  document.form.dt_final.value;
	dataf = dataf.replace("/","");
	dataf = dataf.replace("/","");
	
	diai =  datai.substring(0,2);
	mesi =  datai.substring(4,2);
	anoi =  datai.substring(8,4);
	
	diaf =  dataf.substring(0,2);
	mesf =  dataf.substring(4,2);
	anof =  dataf.substring(8,4);
	
	
	datai = anoi + "" + mesi + "" + diai;
	dataf = anof + "" + mesf + "" + diaf;

	if (datai == dataf) {
		return 0;
	}
	else if (datai < dataf) {
		return 1;
	}
	else {
		return -1;
	}
}

function Limpa(S)
{
	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 Inverte(S)
{
	var temp = "";
	for (var i=0; i<S.length; i++) {
		temp = S.charAt(i) + temp;
	}
    return temp;
}

function Resto(S)
{
	var invertido = Inverte(Limpa(S));
	var soma = 0;
	for (var i=0; i<invertido.length; i++) {
		soma = soma + (i+2) * eval(invertido.charAt(i));
	}
	soma *= 10;
	return ((soma % 11) % 10);
}

function Testar_Cnpj(cnpj,g)
{
	var vercnpj = 0;
	var ind = 2;
	var tam;
	for(f=g;f>0;f--) {
		vercnpj += parseInt(cnpj.charAt(f-1))*ind;
		if(ind>8) {
			ind = 2;
		}
		else {
			ind++;
		}
	}
	vercnpj %= 11;
	if(vercnpj == 0 || vercnpj == 1) {
		vercnpj = 0;
	}
	else {
		vercnpj = 11 - vercnpj;
	}
	if(vercnpj != parseInt(cnpj.charAt(g))) {
		return(0);
	}
	else {
		return(1);
	}
}

function Validar_CNPJ()
{
	cnpj = Limpa(document.form.cnpj.value);
	if(cnpj == 0) {
		return (false);
	}
	else {
		g = cnpj.length-2;
		if(Testar_Cnpj(cnpj,g) == 1) {
			g = cnpj.length-1;
			if(Testar_Cnpj(cnpj,g) == 1) {	
				return (true);
			}
			else {
				return (false);
			}
		}
		else {
			return (false);
		}
	}
}

function Validar_CPF()
{
	if ((document.form.cpf.value == "000.000.000-00") || (document.form.cpf.value == "111.111.111-11") || (document.form.cpf.value == "222.222.222-22") || (document.form.cpf.value == "333.333.333-33") || (document.form.cpf.value == "444.444.444-44") || (document.form.cpf.value == "555.555.555-55") || (document.form.cpf.value == "666.666.666-66") || (document.form.cpf.value == "777.777.777-77") || (document.form.cpf.value == "888.888.888-88") || (document.form.cpf.value == "999.999.999-99")) {
		return (false);
	}
	var result = "";
	var OK = false;
	var temp = Limpa(document.form.cpf.value);
	if (temp.length>10) {
		var work = temp.substring(0,(temp.length)-2);
		var resto = Resto(work);
		OK = (resto == eval(temp.charAt((temp.length)-2)));
		if (OK){
			work = work + resto;
			resto = Resto(work);
			OK = (resto == eval(temp.charAt((temp.length)-1)));
		}
	}
	if (OK){
		return (true);
	}
	else 
	{
		return (false);
	}
}

function Validar_Email(email)
{
	if(email.length < 6) {
		return false;
	}
	var x = 0;
	for (var c=0;c<email.length;c++) {
		if (email.substring(c,c+1) == '@') {
			x = c;
		}
	}
	var y = 0;
	if (x > 0) {
		for (c=x;c<email.length;c++) {
			if (email.substring(c,c+1)=='.') {
				y = c;
				var valida = 1;
			}
		}
		if (y > 0) {
			var dominio = '';
			for (c=x;c<y;c++) {
				dominio = dominio + email.substring(1,c);
			}
		}
	}
	else {
		return false;
	}					
	if (y <= x+2){
		return false;
	}				
	if (valida == 1){
		return true;
	}
}

function Validar_Numero(keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
}

function Mascarar_CEP(keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 5 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + '-';
		}
	}
}

function Mascarar_CPF(keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 3 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '.';
		}
		if (campo.value.length == 7 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '.';
		}
		if (campo.value.length == 11 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '-';
		}
	}
}

function Mascarar_CNPJ(keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '.';
		}
		if (campo.value.length == 6 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '.';
		}
		if (campo.value.length == 10 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '/';
		}
		if (campo.value.length == 15 ) { 
			campo.value = campo.value;
			campo.value = campo.value + '-';
		}
	}
}

function Mascarar_Data(keypress, objeto)
{
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + '/';
		}
		if (campo.value.length == 5 ) { 
	 		campo.value = campo.value;
	 		campo.value = campo.value + '/';
		}
	}
}

function Mascarar_Telefone(objeto,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	if (tam < tammax && tecla != 8) {
		tam = vr.length + 1 ;
	}
	if (tecla == 8 ) {
		tam = tam - 1 ;
	}
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
		if ( tam <= 4 ) { 
	 		objeto.value = vr ;
		}
	 	if ( (tam > 4) && (tam <= 8) ) {
	 		objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
	 	if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;			
		}
	}		
}

function Getbox(parent)
{
	if (typeof(parent) == "undefined") {
		parent = 0;
	}
	this.top = 0;
	this.left = 0;
	this.width = screen.width;
	this.height = screen.height;
	if (parent == 2) {
		this.top = window.screenTop;
		this.left = window.screenLeft;
		this.width = document.body.offsetWidth;
		this.height = document.body.offsetHeight;
	}
	else if (parent == 1) {
		this.width = screen.availWidth;
		this.height = screen.availHeight;
	}
	else if(parent == 0) {
		this.width = screen.width;
		this.height = screen.height;
	}
	else {
		this.top = parent.screenTop;
		this.left = parent.screenLeft;
		this.width = parent.document.body.offsetWidth;
		this.height = parent.document.body.offsetHeight;
	}
}

POP_win = 2;
POP_client = 1;
POP_tot = 0;

function PopUp(url,width,height,halign,valign,parent)
{
	var top = 0;
	var left = 0;
	box = new Getbox(parent);
	switch(halign) {
		case "":
		case "left":
		left = 0;
		break;
		case "right":
		left = box.width - width;
		break;
		case "center":
		left = (box.width - width) / 2;
		break;
		default:
		if (typeof(halign) == "string") {
			if (halign.search(/%/g) != "-1") {
				left = (box.width - width) * parseInt(halign) / 100;
			}
			else {
				left = parseInt(halign);
			}
		}
		else if (typeof(halign) == "number") {
			left = halign;
		}
	}
	switch(valign){
		case "":
		case "top":
		top = 0;
		break;
		case "bottom":
		top = box.height - height;
		break;
		case "center":
		top = (box.height - height) / 2;
		break;
		default:
		if (typeof(valign) == "string") {
			if (valign.search(/%/g) != "-1") {
				top = (box.height - height) * parseInt(valign) / 100;
			}
			else {
				top = parseInt(valign);
			}
		}
		else if (typeof(valign) == "number"){
			top = valign;
		}
	}
	top += box.top;
	left += box.left;
	window.open(url,"","width="+width+",height="+height+",top="+top+",left="+left);
	return;
}

function PopUp_Barra(url,width,height,halign,valign,parent,scrollbars,resizable)
{
	var top = 0;
	var left = 0;
	box = new Getbox(parent);
	switch(halign) {
		case "":
		case "left":
		left = 0;
		break;
		case "right":
		left = box.width - width;
		break;
		case "center":
		left = (box.width - width) / 2;
		break;
		default:
		if (typeof(halign) == "string") {
			if (halign.search(/%/g) != "-1") {
				left = (box.width - width) * parseInt(halign) / 100;
			}
			else {
				left = parseInt(halign);
			}
		}
		else if (typeof(halign) == "number") {
			left = halign;
		}
	}
	switch(valign){
		case "":
		case "top":
		top = 0;
		break;
		case "bottom":
		top = box.height - height;
		break;
		case "center":
		top = (box.height - height) / 2;
		break;
		default:
		if (typeof(valign) == "string") {
			if (valign.search(/%/g) != "-1") {
				top = (box.height - height) * parseInt(valign) / 100;
			}
			else {
				top = parseInt(valign);
			}
		}
		else if (typeof(valign) == "number"){
			top = valign;
		}
	}
	top += box.top;
	left += box.left;
	
	var menubar = 0;
	var locationbar = 0;
	var directories = 0;
	var statusbar = 0;
	var toolbar = 0;
	
	windowprops = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;

	windowprops += (menubar ? ",menubars" : "") +
	(scrollbars ? ",scrollbars" : "") +
	(locationbar ? ",location" : "") +
	(directories ? ",directories" : "") +
	(resizable ? ",resizable" : "") +
	(statusbar ? ",status" : "") +
	(toolbar ? ",toolbar" : "");
	
	window.open(url,"",windowprops);
	return;
}

//somente para o sistema da spazio
function Compara_Data_Spazio()
{
	//data do formulario de projetos
	datai =  document.form.data_inicial.value;
	datai = datai.replace("/","");
	datai = datai.replace("/","");
	dataf =  document.form.data_final.value;
	dataf = dataf.replace("/","");
	dataf = dataf.replace("/","");
	
	diai =  datai.substring(0,2);
	mesi =  datai.substring(4,2);
	anoi =  datai.substring(8,4);
	
	diaf =  dataf.substring(0,2);
	mesf =  dataf.substring(4,2);
	anof =  dataf.substring(8,4);
	
	//datai = data inicial do projeto
	datai = anoi + "" + mesi + "" + diai;
	//dataf = data final do projeto
	dataf = anof + "" + mesf + "" + diaf;

	//data do formularioda de etapas
	dti =  document.form.dt_inicial.value;
	dti = dti.replace("/","");
	dti = dti.replace("/","");
	dtf =  document.form.dt_final.value;
	dtf = dtf.replace("/","");
	dtf = dtf.replace("/","");
	
	di =  dti.substring(0,2);
	mi =  dti.substring(4,2);
	yi =  dti.substring(8,4);
	
	df =  dtf.substring(0,2);
	mf =  dtf.substring(4,2);
	yf =  dtf.substring(8,4);
	
	//dti = data inicial da etapa
	dti = yi + "" + mi + "" + di;
	//dtf = data final da etapa
	dtf = yf + "" + mf + "" + df;
	
	if (dti < datai) {
		//data inicial da etapa nao pode ser menor que data inicial do projeto
		return 0;
	}
	else {
		if (dti > dataf) {
			//data inicial da etapa não pode ser maior que a data final do projeto
			return 1;
		}
		else {
			if (dtf > dataf) {
				//data final da etapa não pode ser maior que a data final do projeto
				return 2;
			}
			else {	
				if (dtf < datai) {
					//data final da etapa não pode ser menor que data inicial do projeto
					return 3;
				}
			}
		}
	}
}
-->