	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;
	}

	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];}}
	}

	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;
	}

	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];}
	}

	function CarregarMenu() {
		MM_preloadImages('imagens/menu_hallbrasil_esc.jpg',
		                 'imagens/menu_galeria_esc.jpg',
		                 'imagens/menu_areaartista_esc.jpg',
		                 'imagens/menu_areacomprador_esc.jpg',
		                 'imagens/menu_maisvotados_esc.jpg',
		                 'imagens/menu_eventos_esc.jpg',
		                 'imagens/menu_atelier_esc.jpg',
		                 'imagens/menu_fegshui_esc.jpg',
		                 'imagens/menu_projetossociais_esc.jpg',
		                 'imagens/menu_duvidas_esc.jpg',
		                 'imagens/menu_faleconosco_esc.jpg',
		                 'imagens/menu_indique_esc.jpg',
		                 'imagens/menu_meucarrinho_esc.jpg',
		                 'imagens/menu_artistapatrocinado_esc.jpg',
		                 'imagens/menu_agentecultural_esc.jpg',
		                 'imagens/menu/menu_maisvotados.jpg',
                                 'imagens/menu/menu_eventos.jpg',
                                 'imagens/menu/menu_fegshui.jpg',
                                 'imagens/menu/menu_projetossociais.jpg',
                                 'imagens/menu/menu_indique.jpg',
                                 'imagens/menu/menu_duvidas.jpg');
	}

	function ValidaCPF(cpf){

		if (cpf.length != 11) {
			return(false);
		} else if ( ( cpf == '00000000000' ) ||
			    ( cpf == '11111111111' ) || 
			    ( cpf == '22222222222' ) || 
			    ( cpf == '33333333333' ) || 
			    ( cpf == '44444444444' ) || 
			    ( cpf == '55555555555' ) || 
			    ( cpf == '66666666666' ) || 
			    ( cpf == '77777777777' ) || 
			    ( cpf == '88888888888' ) || 
			    ( cpf == '99999999999' ) || 
			    ( cpf == '12345678909' ) ) {
			return(false);
		} else {
			total = 0;
			soma = 0;
			for (i=1; i<=9; ++i) {
				numero = cpf.charAt(i-1);
				total = total + (numero * (11 - i));
				soma = soma + numero;
			}

			resto = total % 11;

			if (resto > 1) {
				dv1 = 11 - resto;
			} else {
				dv1 = 0;
			}

			total = 0;
			soma = 0;

			for (i=1; i<=10; ++i) {
				numero = cpf.charAt(i-1);
				total = total + (numero * (12 - i));
				soma = soma + numero;
			}

			resto = total % 11;

			if (resto > 1) {
				dv2 = 11 - resto;
			} else {
				dv2 = 0;
			}

			if ((dv1 == cpf.charAt(9)) && (dv2 == cpf.charAt(10))) {
				return(true);
			} else {
				return(false);
			}
		}
	}

	function ValidaCNPJ(num) {
		var i
		var j
		var soma
		var aux
		var digito
		var ind
		var cnpj
		cnpj = num

		if (num.length != 14){
			// alert('Número do CNPJ Inválido !')
			return false;
		}

		if (num == "00000000000000" || num == "11111111111111" || num == "22222222222222" || num == "33333333333333" || num == "44444444444444"|| num == "55555555555555" || num == "66666666666666" || num == "77777777777777" || num == "88888888888888" || num == "99999999999999"){
			// alert('Número do CNPJ Inválido !')
			return false;
		}

		aux = num.substr(0, num.length-2);
		for (j=1; j<=2; j++){
			soma = 0;
			ind = 2
			for (i=0; i<=aux.length-1; i++){
				soma = soma + (aux.substr(aux.length - 1 - i, 1) * ind * 10);
				if (ind == 9) ind = 2; else ind++;
			}
			aux = aux + "01234567890".substr((soma % 11), 1);
		}

		if (aux != num){
			// alert('Número do CNPJ Inválido!')
			return false;}
		if (aux == num){
			return true;
		}

	}	


	function AbreDuvida(arquivo,largura,altura,rolagem) {
		data = new Date();
		numero = data.getSeconds();
		window.open(arquivo,'PopUp'+numero,'width='+largura+',height='+altura+',toolbar=no,location=no,directories=no,status=no,statusbar=no,menubar=no,scrollbars='+rolagem+',resizable=no');
	}


	function MostraContatoDetalhes(id_contato) {
		arquivo="popup.contato.php?id_contato="+id_contato;
		altura=200;
		largura=400;
		data = new Date();
		numero = data.getSeconds();
		window.open(arquivo,'PopUp'+numero,'width='+largura+',height='+altura+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}

	function toMoney(valor) {

		valor=valor*100;

		var inteiro 	= '';
		var decimal 	= '';

		valor = parseInt(valor);
		// alert('toMoney : 1 - '+valor);

		valor = valor.toString();
		// alert('toMoney : 2 - '+valor);

		tamanho = valor.length;
		// alert('toMoney : 3 - '+valor);

		decimal = valor.substr(tamanho-2,2);
		if (decimal.length == 1) { 
			decimal = decimal+'0'; 
		} else {
			if ( decimal.length == 0 ) { decimal = '00'; }
		}
		// alert('toMoney : 4 - '+valor);

		inteiro = valor.substr(0,tamanho-2);
		tamanho = inteiro.length;
		if ( tamanho == 0 ) {
			inteiro = '0';
		} else {
			if ( tamanho > 3 ) {
				variavel_inteiro = inteiro.substr(tamanho-3,3);
				tamanho_milhar = tamanho - variavel_inteiro.length;
				milhar = inteiro.substr(0,tamanho_milhar);
				// alert(' Tamanho : '+tamanho_milhar);
				inteiro = milhar+'.'+variavel_inteiro;
				// alert('toMoney : 5 '+inteiro);
			}
		}
		// alert('toMoney : 6 - '+inteiro+' , '+decimal);

		valor = inteiro+','+decimal;
		// alert('toMoney : 7 - '+inteiro+' , '+decimal);

		return valor;
	}
	
	function AbrePopUp(arquivo,largura,altura,scroll) {
		data = new Date();
		numero = data.getSeconds();
		window.open(arquivo,'PopUp'+numero,'width='+largura+',height='+altura+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no')
	}


	function toValue(valor) {
		valor = valor.replace('.','');
		valor = valor.replace(',','.');
		//valor.ParseFloat();
		return valor;
	}

	function ValidaEmail(email) {
		if (email.indexOf('@', 0) == -1
		|| email.indexOf('.', 0) == -1
		|| email.indexOf('"', 0) != -1
		|| email.indexOf("'", 0) != -1 ) {
			return false;
		} else {
			return true;
		}
		return true;
	}

	function MarcaLinha(objeto) {
		objeto.style.background='#D2D2D2';
	}

	function DesmarcaLinha(objeto) {
		objeto.style.background=document.body.style.background;
		objeto.style.color ='black'
	}

	function ValidaDia(v_dia) {
		v_dia = parseInt(v_dia);
		if ( ( v_dia > 31 ) || ( v_dia < 1 ) || ( isNaN(v_dia) ) ) {
			return(false);
		} else {
			return(true);
		}
	}

	function ValidaMes(v_mes) {
		v_mes = parseInt(v_mes);
		if ( ( v_mes > 12 ) || ( v_mes < 1 ) || ( isNaN(v_mes) ) ) {
			return(false);
		} else {
			return(true);
		}
	}

	function ValidaAno(v_ano) {
		v_ano = parseInt(v_ano);
		if ( ( v_ano > 2010 ) || ( v_ano < 1900 ) || ( isNaN(v_ano) ) ) {
			return(false);
		} else {
			return(true);
		}
	}

	function MostraMensagem(msg) {
		if ( msg != '' ) {
			alert(msg);
		}
	}

	function AbrirRelatorio(id_contrato,id) {
		AbrePopUp('contrato.relatorio.imprimir.php?id_contrato='+id_contrato+'&tmp_id='+id,'700','500','yes');
	}

	function AbrirFechamento(id_fechamento) {
		AbrePopUp('fechamento.detalhar.php?id_fechamento='+id_fechamento,'700','500','yes');
	}