var ie6 = false;
if(navigator.userAgent.toUpperCase().indexOf('MSIE 6') > -1 || navigator.userAgent.toUpperCase().indexOf('MSIE 7') > -1 || (navigator.userAgent.toUpperCase().indexOf('SAFARI') > -1 && navigator.userAgent.toUpperCase().indexOf('CHROME') == -1))
	ie6 = true;
	
var isIphone = false;
if(navigator.userAgent.toUpperCase().indexOf('IPHONE') > -1) 
	isIphone = true;

// var regioes = ['Acre#ac','Alagoas#al','Amapá#ap','Amazonas#am','Bahia#ba','Ceará#ce','Distrito Federal#df','Espírito Santo#es','Goiás#go','Maranhão#ma','Mato Grosso#mt','Mato Grosso do Sul#ms','Minas Gerais#mg','Pará#pa','Paraíba#pb','Paraná#pr','Pernambuco#pe','Piauí#pi','Rio de Janeiro#rj','Rio Grande do Norte#rn','Rio Grande do Sul#rs','Rondônia#ro','Roraima#rr','Santa Catarina#sc','São Paulo#sp','Sergipe#se','Tocantins#to'];

$(document).ready(function(){
	/* Animação do menu personalizado */
	$('#slide-home-boxAcordeon .botao .botaoContent').click(function(){
		if($(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').css('display') != 'block'){
			//-- Faz uma animação caso o browser não seja IE6
			if(ie6 != true)
				$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').find('.personalize_item').css('display','none');
			
			$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').slideDown(150);
			// $(this).find('p.titulo').html('fechar');
			$(this).find('.seta').addClass('on');
			
			//-- Faz uma animação caso o browser não seja IE6
			if(ie6 != true)
				$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').find('.personalize_item').fadeIn('fast');
			else
				$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').find('.personalize_item').show();
				
		}else{
			//-- Faz uma animação caso o browser não seja IE6
			if(ie6 != true)
				$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').find('.personalize_item').fadeOut('fast');
			else
				$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').find('.personalize_item').hide();
			
			$(this).parents('#slide-home-boxAcordeon').find('.content').find('.conteudo').slideUp(300);
			//$(this).find('p.titulo').html('Eu Sou 50 Milh&otilde;es');
			// $(this).find('p.titulo').html('Novidades');
			$(this).find('.seta').removeClass('on');
		}
	});
	

	
	/* Elimina a sombra no IE6 */
/* 	if(ie6 == true){
		$('.addSombra').css('background','none');
	} */
	
/* 	$('.sombra').ready(function(){
		//-- Remove a sombras da direita se a janela estiver em um tamanho menor que (1024 + tamanho da sombra)
		if($(window).width() <= 1049)
			$('.sombra .on_right').hide();
		else
			$('.sombra .on_right').show();
	
		//-- Remove a sombras do IE6
		if(ie6 == true){
			$('.sombra .on_left').hide();
			$('.sombra .on_right').hide();
		}else{
			fnAjustaSombra();
			$('.sombra').each(function(){
				$(this).find('.on_left').css('margin-left','-35px');
				$(this).find('.on_right').css('margin-left', $(this).find('.context').width() + 16 + 'px');
			});
		}
	}); */
	
	//-- Remove a sombras da direita se a janela estiver em um tamanho menor que (1024 + tamanho da sombra)
/* 	$(window).resize(function(){
		if($(window).width() <= 1049)
			$('.sombra .on_right').hide();
		else
			$('.sombra .on_right').show();
		
		
		//-- Ajusta o tamanho do lightbox e posicionamento
		if($('.lightbox').css('display') == 'block'){
			$('.lightbox .lb_background').css('width',$('.content_geral').width());
			$('.lightbox .lb_box').css('left',($(window).width() / 2) - ($('.lightbox .lb_box').width() / 2));
			$('.lightbox .lb_box').css('top',($(window).height() / 2) - ($('.lightbox .lb_box').height() / 2));
		}
	}); */
	
	//-- Fecha todas as categorias do menu lateral
	 // $('dl.lateral_categorias dl dd').hide();
	//-- Function: onClick do menu lateral para abrir as categorias
	/* $('dl.lateral_categorias a.menuTitulo').click(function(){
		$(this).blur();
		if($(this).parent().parent().find('dd').css('display') != 'block'){
			$(this).parent().addClass('on');
			$(this).parent().parent().find('dd').show();
		}else{
			$(this).parent().removeClass('on');
			$(this).parent().parent().find('dd').hide();
		}
		fnAjustaSombra();
	}); */
	
	//-- Montando o breadcrumb a partir das paginas selecionadas
/* 	window.setTimeout(function(){
		var html = '';
		if($('.header_geral .menu li a.on').html() != null)
			html += '<a href="' + $('.header_geral .menu li a.on').attr('href') + '" >' + $('.header_geral .menu li a.on').html() + '</a>';
		
		if($('.header_geral .submenu li.on a').html() != null)
			html += ' &gt; <a href="' + $('.header_geral .submenu li.on a').attr('href') + '" >' + $('.header_geral .submenu li.on a').html() + '</a>';
			
		if($('dl.lateral_categorias h2#newSection').html() != null){
			html += ' &gt; <a href="' + $('dl.lateral_categorias h2#newSection a').attr('href') + '" >' + $('dl.lateral_categorias h2#newSection a').html() + '</a>';			
		}				
		
		if($('dl.lateral_categorias dd dt.on a').html() != null){
			html += ' &gt; <a href="' + ($('dl.lateral_categorias dd dt.on a').attr('href').indexOf('void(0)') == -1 ? $('dl.lateral_categorias dd dt.on a').attr('href') : $('.header_geral .submenu li.on a').attr('href')) + '" >' + $('dl.lateral_categorias dd dt.on a').html() + '</a>';
		}		
		
		if($('dl.lateral_categorias a.on').html() != null)
			html += ' &gt; <a href="' + $('dl.lateral_categorias a.on').attr('href') + '" >' + $('dl.lateral_categorias a.on').html() + '</a>';			
		
		if(html.length > 0)
			$('#breadcrumb_content').html(html);
		else
			$('#breadcrumb_content').parent().hide();
	},1); */
	
	//-- Function: Internas de Duvidas - Show and Hide nas respostas
/* 	$('fieldset#box_duvidas div.description > dl > dd').hide();
	$('fieldset#box_duvidas div.description > dl:first').addClass('sem_border');
	$('fieldset#box_duvidas div.description > dl > dt').click(function(){
		if($(this).parent().find('dd').css('display') == 'block'){
			$(this).removeClass('on');
			$(this).parent().find('dd').hide();
		}else{
			$(this).addClass('on');
			$('fieldset#box_duvidas div.description > dl > dd').hide();
			$(this).parent().find('dd').show();
		}
	}); */
	
	//-- Ao carregar a pagina, ajusta o tamanho das sombras dos conteudos
	// fnAjustaSombra();
});

function getCookie(c_name){
	if (document.cookie.length>0){
  		c_start=document.cookie.indexOf(c_name + "=");
  		if (c_start!=-1){
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
    		return unescape(document.cookie.substring(c_start,c_end));
    	}
  	}
	return "";
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function in_array(needle,haystack) {
	return new RegExp('(^|\,)'+needle+'(\,|$)','gi').test(haystack);
}

/***
** Lightbox v1.0
** Author: Marcus Vinicius Corrêa
** Parameters: 	id = ID do elemento (apenas o nome do id, sem #)
**				width = largura do elemento (apenas o valor numerico)
**				height = altura do elemento (apenas o valor numerico)
**				condition = elemento ira abrir ou fechar (boolean 1 ou 0)
**				content = ID do conteudo que ira dentro do lightbox
***/
function fnLightBox(id, width, height, condition, content){
	if(ie6){
		$('select').hide();
		$('.lightbox_content').find('select').show();
	}
	
	//-- se a condition for definida como ZERO, entao o elemento com o ID selecionado sera fechado
	if(condition == 0){
		//-- esconde o box do conteudo
		$('#' + id).find('.lb_box').animate({
			opacity:0
		//-- esconde o background do lightbox
		},350).parent().find('.lb_background').delay(200).animate({
			opacity:0
		},350);
		
		//-- esconde a div principal do lightbox
		window.setTimeout(function(){
			$('#' + id).hide();
		},800);
		
		if(ie6){
			$('select').show();
		}
		
		return;
	}else if(condition == -1){
		//-- deleta o box do conteudo
		$('#' + id).remove();
		
		if(ie6){
			$('select').show();
		}
		
		return;
	}
	
	//-- se o elemento ainda nao existir na pagina, o trecho abaixo sera lido
	if($('body').find('#' + id).length == 0){
		//-- cria os elementos por javascript
		var lightbox = document.createElement('div');
		var lb_background = document.createElement('div');
		var lb_box = document.createElement('div');
		var lb_box_content = document.createElement('div');
		
		var lb_sombra = document.createElement('div');
		var lb_s_top = document.createElement('div');
		var lb_s_bottom = document.createElement('div');
		
		lightbox.setAttribute('class','lightbox');
		lightbox.className = 'lightbox';
		lightbox.setAttribute('id',id);
		
		lb_background.setAttribute('class','lb_background');
		lb_background.className = 'lb_background';
		lb_background.setAttribute('onclick','fnLightBox(\''+ id +'\',\'' + width + '\',\''+ height +'\',0,\''+ content +'\');');
		lb_background.onclick = function(){ fnLightBox(id, width, height, 0, content); };
		lightbox.appendChild(lb_background);
		
		lb_box.setAttribute('class','lb_box');
		lb_box.className = 'lb_box';
		lightbox.appendChild(lb_box);
		
		lb_box_content.setAttribute('class','lb_box_content');
		lb_box_content.className = 'lb_box_content';
		lb_box.appendChild(lb_box_content);
		
		//-- monta a estrutura do conteudo dentro do lightbox
		var box_html = '';
		box_html +=	'	<div class="bgRight">';
		box_html +=	'	<div class="bgLeft">';
		box_html +=	'		<div class="btn_fechar"><a class="lb_btn_fechar" href="javascript:void(0);" onclick="fnLightBox(\''+ id +'\',\'' + width + '\',\''+ height +'\','+ (condition == '-2' ? '-1' : '0') +',\''+ content +'\');" title="Fechar"><img src="../sys/img/2010/06/btn_fechar.gif" alt="" /> fechar</a></div>';
		box_html +=	'		<div class="lb_content"></div>';
		box_html +=	'	</div>';
		box_html +=	'	</div>';
		
		lb_box_content.innerHTML = box_html;
		
		//-- insere os elementos no corpo da pagina
		$('body').append(lightbox);
		
		//-- insere o conteudo real* que esta no html dentro do lightbox
		$('#' + id).find('.lb_content').append($('#' + content));
		$('#' + id).find('.lb_content').find('.lightbox_content').show();
		
		//--  * O que é o conteudo real?
		//-- 	Esse conteudo é uma DIV contendo um ID que sera passado como parametro ("content") nessa função.
		//--	Geralmente, esse conteudo fica alocado no arquivo da lateral direita, contendo um ID e uma classe ("lightbox_content").
		//-- 	Essa DIV ira conter todo o html que o lightbox ira mostrar na tela no momento do click.
		//--	O css dessa DIV podera ficar no css da própria área em que e encontra.
		//-- 	Essa função javascript apenas se encarrega de pegar essa DIV e jogar para dentro do lightbox, evitando ter N lightboxs diferentes.
		
	}
	
	//-- define altura e largura para o background e o box com conteudo
	$('#' + id).find('.lb_background').css('width',$('.content_geral').width() + 'px');
	$('#' + id).find('.lb_background').css('height',$(document).height() + 'px');
	$('#' + id).find('.lb_box_content').css('width',(width == 'auto' ? 'auto' : width + 'px'));
	$('#' + id).find('.lb_box_content').css('height',(height == 'auto' ? 'auto' : height + 'px'));
	$('#' + id).find('.lb_box').css('left',($(window).width() / 2) - (width / 2) + 'px');
	
	if(isNaN(height))
		$('#' + id).find('.lb_box').css('top','150px');
	else
		$('#' + id).find('.lb_box').css('top',($(window).height() / 2) - (height / 2) > 10 ? ($(window).height() / 2) - (height / 2) : 10);
	
	//-- mostra a div principal do lightbox
	$('#' + id).show();
	
	//-- faz o efeito de fadeIn no background do lightbox
	$('#' + id).find('.lb_background').css('opacity',0);
	$('#' + id).find('.lb_background').animate({
		opacity:0.7
	},350);
	
	//-- faz o efeito de fadeIn no box do conteudo
	$('#' + id).find('.lb_box').css('opacity',0);
	$('#' + id).find('.lb_box').delay(450).animate({
		opacity:1
	},350);
	
	//-- realiza o scroll para o topo da pagina
	$('html,body').animate({
		scrollTop: 0
	},200);
}

function fnLightBox_Video(id, width, height, condition, w, h, swf, variaveis){
	//-- se a condition for definida como ZERO, entao o elemento com o ID selecionado sera deletado
	if(condition == 0){
		$('#' + id).find('.lb_box').animate({
			opacity:0
		//-- esconde o background do lightbox
		},350).parent().find('.lb_background').delay(200).animate({
			opacity:0
		},350);
		
		//-- esconde a div principal do lightbox
		window.setTimeout(function(){
			$('#' + id).remove();
		},800);
		
		return;
	}
	
	//-- se o elemento ainda nao existir na pagina, o trecho abaixo sera lido
	if($('body').find('#' + id).length == 0){
		//-- cria os elementos por javascript
		var lightbox = document.createElement('div');
		var lb_background = document.createElement('div');
		var lb_box = document.createElement('div');
		var lb_box_content = document.createElement('div');
		
		var lb_sombra = document.createElement('div');
		var lb_s_top = document.createElement('div');
		var lb_s_bottom = document.createElement('div');
		
		lightbox.setAttribute('class','lightbox');
		lightbox.className = 'lightbox';
		lightbox.setAttribute('id',id);
		
		lb_background.setAttribute('class','lb_background');
		lb_background.className = 'lb_background';
		lb_background.setAttribute('onclick','fnLightBox_Video(\''+ id +'\',\'' + width + '\',\''+ height +'\',0,'+ w +','+ h +',\''+ swf +'\',\''+ variaveis +'\');');
		lb_background.onclick = function(){ fnLightBox_Video(id, width, height, 0, w, h, swf, variaveis); };
		lightbox.appendChild(lb_background);
		
		lb_box.setAttribute('class','lb_box');
		lb_box.className = 'lb_box';
		lightbox.appendChild(lb_box);
		
		lb_box_content.setAttribute('class','lb_box_content');
		lb_box_content.className = 'lb_box_content';
		lb_box.appendChild(lb_box_content);
		
		//-- monta a estrutura do conteudo dentro do lightbox
		var box_html = '';
		box_html +=	'	<div class="bgRight">';
		box_html +=	'	<div class="bgLeft">';
		box_html +=	'		<div class="btn_fechar"><a class="lb_btn_fechar" href="javascript:void(0);" onclick="fnLightBox_Video(\''+ id +'\',\'' + width + '\',\''+ height +'\',0);" title="Fechar"><img src="../sys/img/2010/06/btn_fechar.gif" alt="" /> fechar</a></div>';
		box_html +=	'		<div class="lb_content"></div>';
		
		box_html +=	'		<div class="video_content">';
		box_html +=	'		<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ w +'" height="'+ h +'" id="CodeFlash" align="middle">';
		box_html +=	'		<param name="FlashVars" value="'+ variaveis +'">';
		box_html +=	'		<param name="allowScriptAccess" value="sameDomain" />';
		box_html +=	'		<param name="wmode" value="transparent" />';
		box_html +=	'		<param name="movie" value="'+ swf +'" /><param name="quality" value="hight" /><param name="bgcolor" value="#ffffff" />';
		box_html +=	'		<embed src="'+ swf +'" flashvars="'+ variaveis +'" wmode="transparent" quality="high" bgcolor="#ffffff" width="'+ w +'" height="'+ h +'" id="CodeFlash1" name="CodeFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		box_html +=	'		</object>';
		box_html +=	'		</div>';
		
		box_html +=	'	</div>';
		box_html +=	'	</div>';
		
		lb_box_content.innerHTML = box_html;
		
		//-- insere os elementos no corpo da pagina
		$('body').append(lightbox);
	}
	
	//-- define altura e largura para o background e o box com conteudo
	$('#' + id).find('.lb_background').css('width',$('.content_geral').width() + 'px');
	$('#' + id).find('.lb_background').css('height',$(document).height() + 'px');
	$('#' + id).find('.lb_box_content').css('width',width + 'px');
	$('#' + id).find('.lb_box_content').css('height',height + 'px');
	$('#' + id).find('.lb_box').css('left',($(window).width() / 2) - (width / 2));
	$('#' + id).find('.lb_box').css('top',($(window).height() / 2) - (height / 2) > 10 ? ($(window).height() / 2) - (height / 2) : 10);
	
	//-- mostra a div principal do lightbox
	$('#' + id).show();
	
	//-- faz o efeito de fadeIn no background do lightbox
	$('#' + id).find('.lb_background').css('opacity',0);
	$('#' + id).find('.lb_background').animate({
		opacity:0.7
	},350);
	
	//-- faz o efeito de fadeIn no box do conteudo
	$('#' + id).find('.lb_box').css('opacity',0);
	$('#' + id).find('.lb_box').delay(450).animate({
		opacity:1
	},350);
	
	//-- realiza o scroll para o topo da pagina
	$('html,body').animate({
		scrollTop: 0
	},200);
}

function fnPacotesDesconto_MudaAba(idLightbox,idAba){
	$('#'+ idLightbox +' .subitens .subitens_menu li a#' + idAba).click();
}



function xmlLoader(url){
	if(window.XMLHttpRequest) {
		var Loader = new XMLHttpRequest();
		try{
			Loader.open("GET", url ,false);
			Loader.send(null);
			return Loader.responseXML;
		}
			catch(e){
			return null;
		}
	}else if(window.ActiveXObject){
		var Loader = new ActiveXObject("Msxml2.DOMDocument.3.0");
		Loader.async = false;
		try{
			Loader.load(url);
			return Loader;
		} catch(e){
			return null;
		}
	}
}

function getParameter(pParam,pTipo){
	var wl = window.location.href;
	var params = urlDecode(wl.substring(wl.indexOf("?")+1));
	var param = params[pParam];
	
	if(param.length <= 0) return;
	
	//-- Tratando o parametro recebido, impedindo o uso de XSS
	switch(pTipo){
		case 'regional':
			var aUF = regioes;
			var vParam = param.toString().toLowerCase();
			if (in_array(vParam, aUF))
				return vParam;
			break;
			
		case 'numero':
			var numero = (parseInt(param) != undefined ? parseInt(param) : 0);
			if (!isNaN(numero))
				return numero;
			break;
			
		case 'string':
			if (param.toString().toLowerCase().indexOf('script') == -1){
				var vParam = param.replaceAll('<','&lt;').replaceAll('>','&gt;').replaceAll('/','&frasl;');
				return vParam;
			}
			break;
	}
	return '';
}

function urlDecode(string, overwrite){
    if(!string || !string.length){
        return {};
    }
    var obj = {};
    var pairs = string.split('&');
    var pair, name, value;
    var lsRegExp = /\+/g;
    for(var i = 0, len = pairs.length; i < len; i++){
        pair = pairs[i].split('=');
        name = unescape(pair[0]);
        value = unescape(pair[1]).replace(lsRegExp, " ");
        //value = decodeURIComponent(pair[1]).replace(lsRegExp, " ");
        if(overwrite !== true){
            if(typeof obj[name] == "undefined"){
                obj[name] = value;
            }else if(typeof obj[name] == "string"){
                obj[name] = [obj[name]];
                obj[name].push(value);
            }else{
                obj[name].push(value);
            }
        }else{
            obj[name] = value;
        }
    }
    return obj;
}

String.prototype.replaceAll = function(de, para){
    var str = this;
    var pos = str.indexOf(de);
    while (pos > -1){
		str = str.replace(de, para);
		pos = str.indexOf(de);
	}
    return (str);
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, "");
}

String.prototype.ltrim = function() {
	return this.replace(/^\s+/, "");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/, "");
}

//-- AJAX INICIO
function fnHttpRequest(file){
	var xmlHttp = getXMLHttp();
	
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			fnHttpResponse(xmlHttp.responseText);
		}
	}
	xmlHttp.open("GET", file, true);
	xmlHttp.send(null);
}

function getXMLHttp(){
	var xmlHttp;
	
	try{
		xmlHttp = new XMLHttpRequest();
	}catch(e){
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function fnHttpResponse(response){
	document.getElementById('faq_ajaxContent').innerHTML = response;
}
//-- AJAX FIM


function validarCPF(valor){
	var cpf = valor.replaceAll('.','').replaceAll('-','');
	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;
	}
	soma = 0;
	for(i = 0; i < 9; i++)
	 soma += parseInt(cpf.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if(resto == 10 || resto == 11)
	 resto = 0;
	if(resto != parseInt(cpf.charAt(9))){
	 return false;
	}
	soma = 0;
	for(i = 0; i < 10; i ++)
	 soma += parseInt(cpf.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if(resto == 10 || resto == 11)
	 resto = 0;
	if(resto != parseInt(cpf.charAt(10))){
	 return false;
	}
	return true;
}

function validarCNPJ(valor) {
	  var cnpj = valor.replaceAll('.','').replaceAll('-','').replaceAll('/','');
      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 validarEmail(pEmail){
	var regex_email = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
	if (pEmail == null || pEmail == '')
		return false;
	
	if (regex_email.exec(pEmail))
		return true;
	
	return false;
}

/* function acessoMeuVivo(ddd,celular){
	if(isNaN(ddd.value) || ddd.value.length < 2){
		$(ddd).focus();
		return false;
	}else if(isNaN(celular.value) || celular.value.length < 8){
		$(celular).focus();
		return false;
	}
	
	return true;
} */

function validarData(value){
	var regDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
	if (regDate.test(value)){
		return true;
	}
	return false;
}

function removeAcento(text) {
	text = text.replace(new RegExp('[ÁÀÂÃ]','g'), 'A')
  		.replace('&Aacute;', 'A')
		.replace('&Agrave;', 'A')
		.replace('&Acirc;', 'A')
		.replace('&Atilde;', 'A')
  		.replace(new RegExp('[áàâã]','g'), 'a')
		.replace('&aacute;', 'a')
		.replace('&agrave;', 'a')
		.replace('&acirc;', 'a')
		.replace('&atilde;', 'a')
		.replace(new RegExp('[ÉÈÊ]','g'), 'E')
		.replace('&Eacute;', 'E')
		.replace('&Egrave;', 'E')
		.replace('&Ecirc;', 'E')
		.replace(new RegExp('[éèê]','g'), 'e')
		.replace('&eacute;', 'e')
		.replace('&egrave;', 'e')
		.replace('&ecirc;', 'e')
		.replace(new RegExp('[ÍÌÎ]','g'), 'I')
		.replace('&Iacute;', 'I')
		.replace('&Igrave;', 'I')
		.replace('&Icirc;', 'I')
		.replace(new RegExp('[íìî]','g'), 'i')
		.replace('&iacute;', 'i')
		.replace('&igrave;', 'i')
		.replace('&icirc;', 'i')
		.replace(new RegExp('[ÓÒÔÕ]','g'), 'O')
		.replace('&Oacute;', 'O')
		.replace('&Ograve;', 'O')
		.replace('&Ocirc;', 'O')
		.replace('&Otilde;', 'O')
		.replace(new RegExp('[óòôõ]','g'), 'o')
		.replace('&oacute;', 'o')
		.replace('&ograve;', 'o')
		.replace('&ocirc;', 'o')
		.replace('&otilde;', 'o')
		.replace(new RegExp('[ÚÙÛ]','g'), 'U')
		.replace('&Uacute;', 'U')
		.replace('&Ugrave;', 'U')
		.replace('&Ucirc;', 'U')
		.replace(new RegExp('[úùû]','g'), 'u')
		.replace('&uacute;', 'u')
		.replace('&ugrave;', 'u')
		.replace('&ucirc;', 'u')
		.replace(new RegExp('[Ç]','g'), 'C')
		.replace('&Ccedil;', 'C')
		.replace(new RegExp('[ç]','g'), 'c')
		.replace('&ccedil;', 'c');
		
  return text;
}

/* Inicio */
//Funções para as métricas do portal
function retirarAcento(objResp) {  
	 var varString = new String(objResp);  
	 var stringAcentos = new String('àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜ -,');
	 var stringSemAcento = new String('aaeouaoaeioucuAAEOUAOAEIOUCU');  
		 
	 var i = new Number();  
	 var j = new Number();  
	 var cString = new String();  
	 var varRes = '';  
		 
	 for (i = 0; i < varString.length; i++) {  
		 cString = varString.substring(i, i + 1);  
		 for (j = 0; j < stringAcentos.length; j++) {  
			 if (stringAcentos.substring(j, j + 1) == cString){  
				 cString = stringSemAcento.substring(j, j + 1);  
			 }  
		 }  
		 varRes += cString;  
	 }  
	 
	 return varRes.toLowerCase();
}  


/* function fnMetrica(texto){
	$.post('/metrica/metrica.php?WT.ac='+texto, function(){});
} */
/* Final - Métrica do HotSite */

