var loginCarrinho = false;

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


//Mudança de cor do campo input da extranet
function modify_input(ref,color)
{
    ref.style.background=color;
}

/*Menu Drop Down para IE6
jQuery(document).ready(function()
{
    jQuery('li.headlink').hover(
	function() { jQuery('ul', this).css('display', 'block'); },
	function() { jQuery('ul', this).css('display', 'none'); });
}); */

//Zerar input ao clicar
function reset_fields(id)
{
	var Fid = document.getElementById(id);
	var TheDefaultValue = Fid.defaultValue;
	var TheValue = Fid.value;
	if(TheDefaultValue == TheValue)
	{
		Fid.value = '';
	}
}

/*Mudança de Abas*/
jQuery(document).ready(function()
{
    jQuery("body.content_ab2 #make_assessment #content_tab > div").hide();
	jQuery("body.content_ab2 #make_assessment #content_tab > div:eq(0)").show();
	jQuery("body.content_ab2 #make_assessment #tabs > a:eq(0)").css("background", "url(../images/bg_make_tab1.png) no-repeat");
});

function opentab(num)
{
    jQuery("body.content_ab2 #make_assessment #content_tab > div").hide();
	jQuery("body.content_ab2 #make_assessment #content_tab > div:eq(" + (num-1) + ")").fadeIn();
	jQuery("body.content_ab2 #make_assessment #tabs > a").css("background", "url(../images/bg_make_tab2.png) no-repeat");
	jQuery("body.content_ab2 #make_assessment #tabs > a:eq(" + (num-1) + ")").css("background", "url(../images/bg_make_tab1.png) no-repeat");
}

//Banners rotativos
var featuredcontentglider={
	csszindex: 100,
	ajaxloadingmsg: '<b>Buscando conteúdo. Aguarde ...</b>',
	glide:function(config, showpage, isprev){
		var selected=parseInt(showpage)
		if (selected>=config.$contentdivs.length){
			selected=0
		}
		var $target=config.$contentdivs.eq(selected)

		if (config.$togglerdiv.attr('lastselected')==null || parseInt(config.$togglerdiv.attr('lastselected'))!=selected){
			var $selectedlink=config.$toc.eq(selected)
			config.$next.attr('loadpage', (selected<config.$contentdivs.length-1)? selected+1+'pg' : 0+'pg')
			config.$prev.attr('loadpage', (selected==0)? config.$contentdivs.length-1+'pg' : selected-1+'pg')
			var startpoint=(isprev=="previous")? -config.startpoint : config.startpoint
			$target.css(config.leftortop, startpoint).css("zIndex", this.csszindex++)
			var endpoint=(config.leftortop=="left")? {left:0} : {top:0}
			$target.animate(endpoint, config.speed)
			config.$toc.removeClass('selected')
			$selectedlink.addClass('selected')
			config.$togglerdiv.attr('lastselected', selected+'pg')
		}
	},

	getremotecontent:function(config){
		config.$glider.html(this.ajaxloadingmsg)
		jQuery.ajax({
			url: config.remotecontent,
			error:function(ajaxrequest){
				config.$glider.html('Erro ao buscar o conteúdo. <br /> Resposta do servidor: '+ajaxrequest.responseText)
			},
			success:function(content){
				config.$glider.html(content)
				featuredcontentglider.setuptoggler(config)
			}
		})
	},

	aligncontents:function(config){
		config.$contentdivs=jQuery("#"+config.gliderid+" ."+config.contentclass)
		config.$contentdivs.css(config.leftortop, config.startpoint).css({height: config.$glider.height(), visibility: 'visible'}) //position content divs so they're out of view:
	},

	setuptoggler:function(config){
		this.aligncontents(config)
		config.$togglerdiv.hide()
		config.$toc.each(function(index){
				jQuery(this).attr('pagenumber', index+'pg')
				if (index > (config.$contentdivs.length-1))
					jQuery(this).css({display: 'none'})
		})
		var $nextandprev=jQuery("#"+config.togglerid+" .next, #"+config.togglerid+" .prev")
		$nextandprev.click(function(event){
			featuredcontentglider.glide(config, this.getAttribute('loadpage'), this.getAttribute('buttontype'))
			event.preventDefault()
		})
		config.$toc.click(function(event){
			featuredcontentglider.glide(config, this.getAttribute('pagenumber'))
			event.preventDefault()
		})
		config.$togglerdiv.fadeIn(1000, function(){
			featuredcontentglider.glide(config, config.selected)
			if (config.autorotate==true){
				config.stepcount=0
				config.totalsteps=config.$contentdivs.length*config.autorotateconfig[1]
				featuredcontentglider.autorotate(config)
			}
		})
		config.$togglerdiv.click(function(){
			featuredcontentglider.cancelautorotate(config.togglerid)
		})
	},

	autorotate:function(config){
		var rotatespeed=config.speed+config.autorotateconfig[0]
		window[config.togglerid+"timer"]=setInterval(function(){
			if (config.totalsteps>0 && config.stepcount>=config.totalsteps){
				clearInterval(window[config.togglerid+"timer"])
			}
			else{
				config.$next.click()
				config.stepcount++
			}
		}, rotatespeed)
	},

	cancelautorotate:function(togglerid){
		if (window[togglerid+"timer"])
			clearInterval(window[togglerid+"timer"])
	},

	getCookie:function(Name){
		var re=new RegExp(Name+"=[^;]+", "i")
		if (document.cookie.match(re))
			return document.cookie.match(re)[0].split("=")[1]
		return null
	},

	setCookie:function(name, value){
		document.cookie = name+"="+value
	},

	init:function(config){
		jQuery(document).ready(function(){
			config.$glider=jQuery("#"+config.gliderid)
			config.$togglerdiv=jQuery("#"+config.togglerid)
			config.$toc=config.$togglerdiv.find('.toc')
			config.$next=config.$togglerdiv.find('.next')
			config.$prev=config.$togglerdiv.find('.prev')
			config.$prev.attr('buttontype', 'previous')
			var selected=(config.persiststate)? featuredcontentglider.getCookie(config.gliderid) : config.selected
			config.selected=(isNaN(parseInt(selected))) ? config.selected : selected
			config.leftortop=(/up/i.test(config.direction))? "top" : "left"
			config.heightorwidth=(/up/i.test(config.direction))? config.$glider.height() : config.$glider.width()
			config.startpoint=(/^(left|up)/i.test(config.direction))? -config.heightorwidth : config.heightorwidth
			if (typeof config.remotecontent!="undefined" && config.remotecontent.length>0)
				featuredcontentglider.getremotecontent(config)
			else
				featuredcontentglider.setuptoggler(config)
			jQuery(window).bind('unload', function(){
				config.$togglerdiv.unbind('click')
				config.$toc.unbind('click')
				config.$next.unbind('click')
				config.$prev.unbind('click')
				if (config.persiststate)
					featuredcontentglider.setCookie(config.gliderid, config.$togglerdiv.attr('lastselected'))
				config=null

			})
		})
	}
}

var imagemProdutoAtual = "";
function exibirImagemProduto(imagem)
{
	jQuery("#"+imagemProdutoAtual).hide();
	jQuery("#"+imagem).show();
	imagemProdutoAtual = imagem;
}

function verificaEmail(email)
{
	var achou_ponto=false;
	var achou_arroba=false;
	var achou_caracter=false;

	for (var i=0; i<email.length; i++)
	{
		if (email.charAt(i)=="@") achou_arroba=true;
		else if (email.charAt(i)==".") achou_ponto=true;
		else if (email.charAt(i)!=" ") achou_caracter=true;
	}
	return (achou_ponto & achou_arroba & achou_caracter);
}


function validarSoliciteProduto()
{
	var erros = Array();

	if(!trim(jQuery('#nome_solicitacao').val()))
	{
		erros.push("O campo 'nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#email_solicitacao').val()))
	{
		erros.push("O campo 'e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email_solicitacao').val()))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}
	return false;
}

function validarEnvieAmigo()
{
	var erros = Array();

	if(!trim(jQuery('#seu_nome').val()))
	{
		erros.push("O campo 'seu nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#seu_email').val()))
	{
		erros.push("O campo 'seu e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#seu_email').val()))
		{
			erros.push("O campo 'seu e-mail' não contém um e-mail válido.");
		}
	}

	if(!trim(jQuery('#nome_amigo').val()))
	{
		erros.push("O campo 'nome amigo' deve ser preenchido.");
	}

	if(!trim(jQuery('#email_amigo').val()))
	{
		erros.push("O campo 'e-mail amigo' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email_amigo').val()))
		{
			erros.push("O campo 'e-mail amigo' não contém um e-mail válido.");
		}
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}
	return false;
}

function validarOpiniao()
{
	var erros = Array();

	if(!trim(jQuery('#nome_opniao').val()))
	{
		erros.push("O campo 'nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#email_opniao').val()))
	{
		erros.push("O campo 'e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email_opniao').val()))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!trim(jQuery('#opniao').val()))
	{
		erros.push("O campo 'opinião' deve ser preenchido.");
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}
	return false;
}

function notaProduto(nota)
{
	jQuery('#nota_produto').val(nota);
}

function acenderEstrelas(valor)
{
	jQuery('#estrela_nota_produto_1').removeClass("ativa");
	jQuery('#estrela_nota_produto_2').removeClass("ativa");
	jQuery('#estrela_nota_produto_3').removeClass("ativa");
	jQuery('#estrela_nota_produto_4').removeClass("ativa");
	jQuery('#estrela_nota_produto_5').removeClass("ativa");
	for(i=0;i<valor;i++)
	{
		var aux = i+1;
		jQuery('#estrela_nota_produto_'+aux).addClass('ativa');
	}
	notaProduto(valor);
}

function validarAvaliarProduto()
{
	var erros = Array();

	if(!trim(jQuery('#nome_avaliar').val()))
	{
		erros.push("O campo 'nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#email_avaliar').val()))
	{
		erros.push("O campo 'e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email_avaliar').val()))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}

	return false;
}

var boxVideoAtual = 1;
var qtdBoxVideo = 0;
function avancarVideosProduto()
{
	jQuery('#box_video_produtos_'+boxVideoAtual).hide();
	boxVideoAtual++;
	jQuery('#box_video_produtos_'+boxVideoAtual).show();
	jQuery('#produtos_videos_anterior').show();
	if(boxVideoAtual==qtdBoxVideo)
	{
		jQuery('#produtos_videos_proximo').hide();
	}
}

function voltarVideosProduto()
{
	jQuery('#box_video_produtos_'+boxVideoAtual).hide();
	boxVideoAtual--;
	jQuery('#box_video_produtos_'+boxVideoAtual).show();
	jQuery('#produtos_videos_proximo').show();
	if(boxVideoAtual==1)
	{
		jQuery('#produtos_videos_anterior').hide();
	}
}

jQuery(document).ready(function() {
	jQuery('a[name=modal]').click(function (e) {
		var id = jQuery(this).attr('href');
		openModal(e, id);
	});

	jQuery('.container-modal .close').click(function (e) {
		e.preventDefault();
		loginCarrinho = false;
		jQuery('#mask').hide();
		jQuery('.container-modal').hide();
	});

	jQuery('#mask').click(function () {
		jQuery(this).hide();
		jQuery('.container-modal').hide();
	});

});

function openModal(e, id) {
	if (e) e.preventDefault();
	var maskHeight = jQuery(document).height();
	var maskWidth = jQuery(window).width();

	if(id.indexOf("video")>=0)
	{
		var idVideo = id.split("_");
		idVideo = idVideo[1];
		aumentarVideo(idVideo);
	}

	jQuery('#mask').css({'width':maskWidth,'height':maskHeight});
	jQuery('#mask').fadeIn(500);
	jQuery('#mask').fadeTo("slow",0.8);

	//Get the window height and width
	var winH = jQuery(window).height();
	var winW = jQuery(window).width();

	jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
	jQuery(id).css('left', winW/2-jQuery(id).width()/2);

	jQuery(id).fadeIn(1000);
}

var idUltimoVideo = "";
function aumentarVideo(idVideo)
{
	if(idUltimoVideo)
	{
		jQuery('#video_produto_zoom_'+idUltimoVideo).hide();
	}
	jQuery('#video_produto_zoom_'+idVideo).show();
	idUltimoVideo = idVideo;
}

function validaFaleConosco()
{
	var erros = Array();

	if(!trim(jQuery('#departamento_contato').val()))
	{
		erros.push("O campo 'setor' deve ser preenchido.");
	}

	if(!trim(jQuery('#nome_contato').val()))
	{
		erros.push("O campo 'nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#email_contato').val()))
	{
		erros.push("O campo 'e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email_contato').val()))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!trim(jQuery('#cidade_contato').val()))
	{
		erros.push("O campo 'cidade' deve ser preenchido.");
	}

	if(!trim(jQuery('#estado_contato').val()))
	{
		erros.push("O campo 'estado' deve ser preenchido.");
	}

	if(!trim(jQuery('#ddd_contato').val() || !jQuery('#telefone_contato').val()))
	{
		erros.push("O campo 'telefone' deve ser preenchido com DDD.");
	}

	if(!trim(jQuery('#mensagem_contato').val()))
	{
		erros.push("O campo 'mensagem_contato' deve ser preenchido.");
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}

	return false;
}

function validaContatoSuporte()
{
	var erros = Array();

	if(!trim(jQuery('#nome').val()))
	{
		erros.push("O campo 'nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#email').val()))
	{
		erros.push("O campo 'e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email').val()))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!trim(jQuery('#mensagem').val()))
	{
		erros.push("O campo 'mensagem' deve ser preenchido.");
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}

	return false;
}


function validaNewsleter()
{
	var erros = Array();

	if(!trim(jQuery('#nome_newsletter').val()))
	{
		erros.push("O campo 'nome' deve ser preenchido.");
	}

	if(!trim(jQuery('#email_newsletter').val()))
	{
		erros.push("O campo 'e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail(jQuery('#email_newsletter').val()))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!erros.length)
	{
		return true;
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}

	return false;
}

function loginUsuario()
{
	var erros = Array();

	if(!trim($('email_login').value))
	{
		erros.push("O campo 'seu e-mail' deve ser preenchido.");
	}
	/*else
	{
		//valida o email
		if(!verificaEmail($('email_login').value))
		{
			erros.push("E-mail inválido.");
		}
	}*/

	if(!trim($('senha_login').value))
	{
		erros.push("O campo 'sua senha' deve ser preenchido.");
	}

	if(!erros.length)
	{
		//ajax para efetuar o login
		var dadosFormulario = $('frm_tenho-conta').serialize();
		new Ajax.Request(urlSite+"ajaxLogin.php",
		{
			method: 'post',
			postBody: dadosFormulario,
			onLoading : function()
			{
				$('conteudo_modal_autenticacao').hide();
				$('loading_modal_autenticacao').show();
			},

			onComplete : function(req)
			{
				if(req.responseText=="OK")
				{
					if(loginCarrinho==false)
					{
						document.location.reload();
					}
					else
					{
						jQuery('#mask').hide();
						jQuery('.container-modal').hide();
						loginCarrinho = false;
						openModal(null,"#shopping_cart");
						log=1;
						checkout();
					}
				}
				else
				{
					$('loading_modal_autenticacao').hide();
					$('conteudo_modal_autenticacao').show();
					alert(req.responseText);
					$('email_login').focus();
				}
			},

			onFailure : function()
			{
				alert("Ops! ocorreu um erro na transacao AJAX!");
			}

		});
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}

	return false;
}

function novoUsuario()
{
	var erros = Array();

	if(!trim($('nome_novo_usuario').value))
	{
		erros.push("O campo 'seu nome' deve ser preenchido.");
	}

	if(!trim($('email_novo_usuario').value))
	{
		erros.push("O campo 'seu e-mail' deve ser preenchido.");
	}
	else
	{
		//valida o email
		if(!verificaEmail($('email_novo_usuario').value))
		{
			erros.push("E-mail inválido.");
		}
	}

	if(!erros.length)
	{
		//ajax para efetuar o login
		var dadosFormulario = $('frm_novo_usuario').serialize();
		new Ajax.Request(urlSite+"ajaxLogin.php",
		{
			method: 'post',
			postBody: dadosFormulario,
			onLoading : function()
			{
				$('conteudo_modal_autenticacao').hide();
				$('loading_modal_autenticacao').show();
			},

			onComplete : function(req)
			{
				$('loading_modal_autenticacao').hide();
				$('conteudo_modal_autenticacao').show();
				if(req.responseText=="OK")
				{
					$('nome_novo_usuario').value = "";
					$('email_novo_usuario').value = "";
					$('receber_news').checked = "";
					alert("Seu usuário foi adicionado com sucesso!\n\nVocê receberá um e-mail confirmando seu cadastro e contendo seus dados de acesso com sua senha provisória.");
				}
				else
				{
					alert(req.responseText);
					$('email_login').focus();
				}
			},

			onFailure : function()
			{
				alert("Ops! ocorreu um erro na transacao AJAX!");
			}

		});
	}
	else
	{
		var msg = "Os seguintes erros foram encontrados:\n\n";
		msg += erros.join("\n");
		msg += "\n\n por favor, verifique e tente novamente.";
		alert(msg);
	}

	return false;
}

function recuperarSenha()
{
	$('email_recuperar_senha').value = "";
	$('conteudo_modal_autenticacao').hide();
	$('recuperar_senha_modal_autenticacao').show();
}

function voltarRecuperarSenha()
{
	$('email_recuperar_senha').value = "";
	$('recuperar_senha_modal_autenticacao').hide();
	$('conteudo_modal_autenticacao').show();
}

function envioRecuperarSenha()
{
	if(!trim($('email_recuperar_senha').value))
	{
		alert("Digite o seu e-mail!");
	}
	else
	{
		if(!verificaEmail($('email_recuperar_senha').value))
		{
			alert("E-mail inválido.");
		}
		else
		{
			//efetua ajax para recuperar senha
			var dadosFormulario = $('frm_recuperar_senha').serialize();
			new Ajax.Request(urlSite+"ajaxLogin.php",
			{
				method: 'post',
				postBody: dadosFormulario,
				onLoading : function()
				{
					$('recuperar_senha_modal_autenticacao').hide();
					$('loading_modal_autenticacao').show();
				},

				onComplete : function(req)
				{
					$('loading_modal_autenticacao').hide();
					$('recuperar_senha_modal_autenticacao').show();
					if(req.responseText=="OK")
					{
						voltarRecuperarSenha();
						alert("Um e-mail foi enviado a você com os procedimentos para a recuperação de sua senha.");
					}
					else
					{
						alert(req.responseText);
						$('email_recuperar_senha').focus();
					}
				},

				onFailure : function()
				{
					alert("Ops! ocorreu um erro na transacao AJAX!");
				}

			});

		}
	}
	return false;
}

var size = 0;
function fontInc() {
	if (size < 4) {
		size++;
		fontChange(+2);
	}
}

function fontDec() {
	if (size > -1) {
		size--;
		fontChange(-2);
	}
}



function fontChange(change) {
	var fontSize = parseInt(jQuery('div#conteudo_single').css('font-size').replace(/[^0-9]+/i, ''));
	jQuery('div#conteudo_single p').css('font-size', (fontSize + change) + 'px');
}

var tagAlvo = new Array('p','strong');
var tamanhos = new Array( '12px','14px','16px','18px','20px','22px','24px' );
var tamanhoInicial = 0;

function mudaTamanho(idAlvo,acao)
{
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  selecionados.style.fontSize = tamanhos[ tamanho ];
  selecionados.style.lineHeight = tamanhos[ tamanho ];

  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) {tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ]; tagsAlvo[ j ].style.lineHeight = '24px';}
  }
}

var removeAddThisSpan = window.setInterval(function () {
	if (jQuery('a.addthis_button_compact span').size() > 0) {
		jQuery('a.addthis_button_compact span').remove();
		window.clearInterval(removeAddThisSpan);
	}
}, 1000);

jQuery(document).ready(function () {
	jQuery('.input-cursos, .input-newsletter').focus(function () {
		jQuery(this).val('');
	});
});


var abaSuporteAtual = 1;
function alterarAbaSuporte(numeroAba)
{
	$('li_tab_'+abaSuporteAtual).className = "";
	$('li_tab_'+numeroAba).className = "ativo";
	$('tabs').className = "item-"+numeroAba+"-ativo";
	$('ul-container-tab-'+abaSuporteAtual).hide();
	$('ul-container-tab-'+numeroAba).show();
	abaSuporteAtual = numeroAba;
}

function removeFromCart(id) {
	jQuery.get(ajaxurl, 'action=catalog_shopping&removefromcart=' + id, function (data) {
		jQuery('#shopping_cart .container-modal-box').html(data);
		openModal(null, '#shopping_cart');
	});
}

function addToCart(id) {
	jQuery.get(ajaxurl, 'action=catalog_shopping&addtocart=' + id, function (data) {
		jQuery('#shopping_cart .container-modal-box').html(data);
		openModal(null, '#shopping_cart');
	});
}

function changeQt(id, qt) {
	jQuery.get(ajaxurl, 'action=catalog_shopping&changeqt=' + id + '&qt=' + qt);
}

function checkout() {
	if (log) {
		jQuery.post(ajaxurl + '?action=catalog_shopping&checkout=1', { 'enviar' : "S" }, function (data) {
			//if(!jQuery('.container-modal').visible()) { openModal(null, '#shopping_cart'); }
			//jQuery('#shopping_cart .container-modal-box').html(data);
			if(data=="OK")
			{
				clearCart();
				alert("A sua solicitação de produtos foi enviada com sucesso!");
			}
			else
			{
				alert(data);
			}
		});
	} else {
		alert("Para finalizar sua solicitação de produtos \nvocê deve ser cadastrado e estar logado no sistema.");
		jQuery('#mask').hide();
		jQuery('.container-modal').hide();
		loginCarrinho = true;
		openModal(null, '#dialog');
	}
}


/*function checkout() {
	if (typeof step == 'undefined') {
		step = 0;
	}
	if (step == 1) {
		alert("ENVIAR FORMULARIO");
		/*jQuery.post(ajaxurl + '?action=catalog_shopping&checkout=1', { 'name_' : jQuery('#checkout_name').val(), 'email' : jQuery('#checkout_email').val() }, function (data) {
			jQuery('#shopping_cart .container-modal-box').html(data);
			openModal(null, '#shopping_cart');
		});
	} else {
		alert("Para finalizar seu pedido você deve ser cadastrado e estar logado no sistema.");
		jQuery('#mask').hide();
		jQuery('.container-modal').hide();
		loginCarrinho = true;
		openModal(null, '#dialog');
		/*jQuery.get(ajaxurl, 'action=catalog_shopping&checkout=1', function (data) {
			jQuery('#shopping_cart .container-modal-box').html(data);
			openModal(null, '#shopping_cart');
		});
	}
}*/

function clearCart() {
	jQuery.get(ajaxurl, 'action=catalog_shopping&clearcart=1', function (data) {
		jQuery('#shopping_cart .container-modal-box').html(data);
		openModal(null, '#shopping_cart');
	});
}

function updateCart() {
	jQuery.get(ajaxurl, 'action=catalog_shopping', function (data) {
		jQuery('#shopping_cart .container-modal-box').html(data);
		openModal(null, '#shopping_cart');
	});
}

var submenuAtual = "";
var submenuSair = "";
function exibirSubmenu(idMenu)
{
	if(submenuAtual && submenuAtual!=idMenu) { $(submenuAtual).hide(); }
	if(idMenu==submenuSair) { submenuSair = ""; }else if(submenuSair) { $(submenuSair).hide(); }
	if(idMenu!="submenu_produtos") { $('submenu_produtos').hide(); }
	if(idMenu!="submenu_rede-de-vendas") { $('submenu_rede-de-vendas').hide(); }
	if(idMenu!="submenu_suporte") { $('submenu_suporte').hide(); }

	submenuAtual = idMenu;

	if(!$(idMenu).visible())
	{	jQuery('#'+idMenu).slideToggle(); }
}

function esconderSubmenu(etapa)
{
	if(!etapa || etapa=='1')
	{
		submenuSair = submenuAtual;
		setTimeout("sairSubMenu('2')", 50)
	}
	else if(etapa=='2')
	{
		if(submenuSair)
		{
			sairSubMenu();
		}
	}
}

function sairSubMenu()
{
	if(submenuSair)
	{
		$(submenuSair).hide();
		submenuSair = "";
	}
}
