	$(function() {
		var accordion = $("#accordion");
		var index = $.cookie("accordion");
		var active;
		if (index !== null) {
			active = accordion.find("h3:eq(" + index + ")");
		} else {
			active = 0;
		} 

		$("#accordion").accordion({
			autoHeight: false,
			collapsible: true,
			//active: false,
			active: active,
			icons: {
			header: "ui-icon-circle-plus",
			headerSelected: "ui-icon-circle-minus"
			},
			change: function(event, ui) {
                var index = $(this).find("h3").index ( ui.newHeader[0] );
                $.cookie("accordion", index, {
                        path: "/"
                });
			} 
			});
			$("#slider").easySlider({
				auto: true, 
				continuous: true,
				controlsShow:false,
				speed:2500,
				pause:10000,
				continuous: true
			});
		$("#dialog").dialog({
			bgiframe: true,
			width: 400,
			modal: true
		});

		$('flag_empresa').click(function() {
			alert('Handler for .click() called.');
			$('#mostra_empresa').slideDown('slow');
			
		});	

		$('#faqs h5').each(function() {
				var tis = $(this), state = false, answer = tis.next('div').hide().css('height','auto').slideUp();
				tis.click(function() {
					state = !state;
					answer.slideToggle(state);
					tis.toggleClass('active',state);
				});
			});

		
		
	});

function stats_browser(){
	var caminho = window.location.pathname;
	$.post('/stats_browser.asp', {ua: navigator.userAgent, pg: caminho});
	//$("#resposta").load("/stats_browser.asp", {ua: navigator.userAgent, pg: caminho});
}

function gera_stats(tipo, mes, ano){
//	$.post('/testes/stats_browser/dados.asp', {tp: tipo, ms: mes, an: ano});	
//	$.getScript('/testes/stats_browser/dados.asp', {tp: tipo, ms: mes, an: ano});
	$.getScript('/testes/stats_browser/teste_in.html');
//	$("#grafico").load('/testes/stats_browser/teste_in.html');
	//drawVisualization();
}

function verificacpf (cpf){
	if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") 
		return false;
	add = 0;
	for (i=0; i < 9; i ++)
		add += parseInt(cpf.charAt(i)) * (10 - i);
	rev = 11 - (add % 11);
	if (rev == 10 || rev == 11)
		rev = 0;
	if (rev != parseInt(cpf.charAt(9)))
		return false;
	add = 0;
	for (i = 0; i < 10; i ++)
		add += parseInt(cpf.charAt(i)) * (11 - i);
	rev = 11 - (add % 11);
	if (rev == 10 || rev == 11)
		rev = 0;
	if (rev != parseInt(cpf.charAt(10)))
		return false;
	return true;
}

function digitoNire(nire){
	var Soma = 0;
	var Ind2 = 2;
	var temp = 0;
	var TamValor = nire.length;

	for(i=TamValor-1; i>=0; i--){
		if(Ind2 == 11){
			temp = parseInt(nire.substr(i,1))*2;
		}else{
			temp = parseInt(nire.substr(i,1))*Ind2;
		}
		Soma = Soma + temp;
		Ind2 = Ind2 + 1;
	}
	Resto = Soma - (parseInt(Soma / 11) * 11);
	Resto = Soma%11;
	Digito = 11 - Resto;
	if(Digito == 11)
		Digito = 1;
	else
		if(Digito == 10) Digito = 0;
   
   return Digito;
}
function nireValido(nire){
	var saida=false;
	if (nire.length==11){
		if(digitoNire(nire.substr(0,10))==nire.substr(10,1))
			saida=true;
		else
			saida=false;
	}else{
		saida=false;
	}
	return saida;
}
function verificacnpj(cnpj){
	var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
	digitos_iguais = 1;
	if (cnpj.length < 14 && cnpj.length < 15)
		  return false;
	for (i = 0; i < cnpj.length - 1; i++)
		  if (cnpj.charAt(i) != cnpj.charAt(i + 1))
				{
				digitos_iguais = 0;
				break;
				}
	if (!digitos_iguais)
		  {
		  tamanho = cnpj.length - 2
		  numeros = cnpj.substring(0,tamanho);
		  digitos = cnpj.substring(tamanho);
		  soma = 0;
		  pos = tamanho - 7;
		  for (i = tamanho; i >= 1; i--)
				{
				soma += numeros.charAt(tamanho - i) * pos--;
				if (pos < 2)
					  pos = 9;
				}
		  resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
		  if (resultado != digitos.charAt(0))
				return false;
		  tamanho = tamanho + 1;
		  numeros = cnpj.substring(0,tamanho);
		  soma = 0;
		  pos = tamanho - 7;
		  for (i = tamanho; i >= 1; i--)
				{
				soma += numeros.charAt(tamanho - i) * pos--;
				if (pos < 2)
					  pos = 9;
				}
		  resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
		  if (resultado != digitos.charAt(1))
				return false;
		  return true;
		  }
	else
		  return false;
} 
function getInternetExplorerVersion(){
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function checkVersion(){
  var msg = "";
  var ver = getInternetExplorerVersion();
  if ( ver > -1 )
  {
    if ( ver < 7.0 ){
      msg = "Atualize seu navegador para o Internet Explorer 8.";
	  alert(msg);
	}
  }
}
String.prototype.capitalize = function(){
	return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
};
  
