			// Initially set opacity on thumbs and add
			// additional styling for hover effect on thumbs
			var onMouseOutOpacity = 0.67;
			$('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
				.hover(
					function () {
						$(this).not('.selected').fadeTo('fast', 1.0);
					}, 
					function () {
						$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
					}
				);

					$(document).ready(function() {

					    // Initialize Advanced Galleriffic Gallery
					    function isValidEmailAddress(emailAddress) {
					        var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
					        return pattern.test(emailAddress);
					    }

					    function validaCampo(id, marca) {
					        idCampo = "#" + id;
					        if (marca) {
					            $(idCampo).addClass("NaoValido");
					        } else {
					            $(idCampo).removeClass("NaoValido");
					        }

					    }

					    if (document.getElementById('contatos')) {

					        $(".IsAssoc").click(function() {
					            var num = $(".IsAssoc:checked").val();
					            if (num == 1) {
					                $('#numAssoc').show();
					            } else {
					                $('#numAssoc').hide();
					            }

					        });
					        $(".numerado").click(function() {

					            $("#Message").keypress(function(e) {
					                var total = 4000;
					                var restante = total - parseInt($("#Message").val().length);
					                $("#limite").text(restante);
					                if (restante <= 0 && (e.which != 8 && e.which != 0)) {
					                    return false;
					                }

					            });

					        });

					        $("#FormularioEmail").dialog({
					            autoOpen: false,
					            modal: true,
					            title: "Contato",
					            width: 620,
					            height: 475
					        });

					        $("#juridico").click(function() {
					            $("#FormularioEmail").dialog('option', 'title', 'Orienta&ccedil;&atilde;o Juridica');
					            $("#Subject").val("1");
					            $("#contadorNumero").show();
					            $("#FormularioEmail").dialog('open');
					            $("#TelefoneDepto").html("<p>Voc&ecirc; pode obter a resposta imediata para esta d&uacute;vida atrav&eacute;s do telefone <b>(21) 3906-3900</b></p><p><b>Hor&aacute;rio de atendimento:</b> 9h &agrave;s 18h</p><hr/>");
					            $("#ObsContato").html("");
					            return false;
					        });
					        $("#SAC").click(function() {
					            $("#FormularioEmail").dialog('option', 'title', 'Central de Relacionamento');
					            $("#Subject").val("4");
					            $("#contadorNumero").show();
					            $("#FormularioEmail").dialog('open');
					            $("#TelefoneDepto").html(" <p><b>Telefone(s):</b> (21) 3906-3800</p><p><b>Hor&aacute;rio de atendimento:</b> 9h &agrave;s 21h</p> <hr/>");
					            $("#ObsContato").html("");

					            return false;
					        });
					        $("#Imprensa").click(function() {
					            $("#FormularioEmail").dialog('option', 'title', 'Assessoria de Imprensa');
					            $("#Subject").val("3");
					            $("#contadorNumero").show();
					            $("#FormularioEmail").dialog('open');
					            $("#TelefoneDepto").html("<p><b>Telefone(s):</b> (11) 5085-3590 / (21) 9419-8852</p> <hr/>");
					            $("#ObsContato").html("");
					            return false;
					        });
					        $("#Adm").click(function() {
					            $("#FormularioEmail").dialog('option', 'title', 'Administra&ccedil;&atilde;o');
					            $("#Subject").val("2");
					            $("#contadorNumero").show();
					            $("#FormularioEmail").dialog('open');
					            $("#TelefoneDepto").html(" <p><b>Telefone(s):</b> (21) 3906-3800</p><p><b>Hor&aacute;rio de atendimento:</b> 9h &agrave;s 18h</p> <hr/>");
					            $("#ObsContato").html("");
					            return false;
					        });
					        $("#Revistas").click(function() {
					            $("#FormularioEmail").dialog('option', 'title', 'Fale com nossas revistas');
					            $("#Subject").val("5");
					            $("#contadorNumero").hide();
					            $("#Message").unbind();
					            $("#FormularioEmail").dialog('open');
					            $("#TelefoneDepto").html("");
					            $("#ObsContato").html("");
					            return false;
					        });

					        $("#esqueciCod").dialog({
					            autoOpen: false,
					            modal: true,
					            title: "Descobrindo seu codigo de associado",
					            width: 540,
					            height: 450
					        });
					        $("#esqueci").click(function() {
					            $("#esqueciCod").dialog('open');
					            return false;
					        });

					        $("#DDD, #Phone, #NumAssoc, #VerAssoc").keypress(function(e) {
					            if ((e.which < 48 || e.which > 57) && (e.which != 0 && e.which != 8)) {
					                return false
					            }
					        });

					        $(".ui-dialog-content .requerido").blur(function() {
					            var id = $(this).attr("id");

					            if ($(this).val() == "") {
					                validaCampo(id, true);
					            } else {
					                validaCampo(id, false);
					            }
					        });

					        $("#Email").blur(function() {
					            $("#erroEmail").remove();
					            if (isValidEmailAddress($("#Email").val())) {
					                validaCampo("Email", false);
					                $("#Email").after(' <img id="erroEmail" alt="E-mail valido" title="E-mail valido" src="/site_images/contatos/validyes.png">');
					            } else {
					                validaCampo("Email", true);
					                $("#Email").after(' <img id="erroEmail" alt="E-mail invalido" title="E-mail invalido" src="/site_images/contatos/validno.png">');
					            }
					        });

					        $("#VerAssoc").blur(function() {
					            var NumAssoc = jQuery.trim($("#NumAssoc").val());
					            var VerAssoc = jQuery.trim($("#VerAssoc").val());
					            $("#erroAssoc").remove();
					            if (NumAssoc % 97 == 0) {
					                checkCod = 97;
					            } else {
					                checkCod = NumAssoc % 97;
					            }
					            if (checkCod != VerAssoc) {
					                $("#VerAssoc").after(' <img id="erroAssoc" alt="Numero invalido" src="/site_images/contatos/validno.png">');
					                validaCampo("NumAssoc", true);
					                validaCampo("VerAssoc", true);
					            } else {
					                $("#VerAssoc").after(' <img id="erroAssoc" src="/site_images/contatos/validyes.png">');
					                validaCampo("NumAssoc", false);
					                validaCampo("VerAssoc", false);
					            }


					        });

					        $("#Submit").click(function() {

					            var Name = jQuery.trim($("#Name").val());
					            var Subject = $("#Subject").val();
					            var IsAssoc = $(".IsAssoc:checked").val();
					            var NumAssoc = jQuery.trim($("#NumAssoc").val());
					            var VerAssoc = jQuery.trim($("#VerAssoc").val());
					            var DDD = jQuery.trim($("#DDD").val());
					            var Phone = jQuery.trim($("#Phone").val());
					            var Email = jQuery.trim($("#Email").val());
					            var Message = jQuery.trim($("#Message").val());

					            erro = false;

					            var msgEspecial = "";

					            if (Name == "") {
					                erro = true;
					                validaCampo("Name", true);

					            } else {
					                validaCampo("Name", false);
					            }

					            if (IsAssoc != "0") {

					                var checkCod;
					                if (NumAssoc == "" || VerAssoc == "") {
					                    if (NumAssoc == "") {
					                        erro = true;
					                        validaCampo("NumAssoc", true);
					                    } else {
					                        validaCampo("NumAssoc", false);
					                    }
					                    if (VerAssoc == "") {
					                        erro = true;
					                        validaCampo("VerAssoc", true);
					                    } else {
					                        validaCampo("VerAssoc", false);
					                    }
					                } else {
					                    //Verificador do codigo de usuario.
					                    if (NumAssoc % 97 == 0) {
					                        checkCod = 97;
					                    } else {
					                        checkCod = NumAssoc % 97;
					                    }
					                    if (checkCod != VerAssoc) {

					                        erro = true;
					                        validaCampo("NumAssoc", true);
					                        validaCampo("VerAssoc", true);
					                    } else {
					                        validaCampo("NumAssoc", false);
					                        validaCampo("VerAssoc", false);
					                    }
					                }
					            }
					            if (Email == "") {
					                erro = true;
					                validaCampo("Email", true);
					            } else {
					                if (isValidEmailAddress(Email)) {
					                    validaCampo("Email", false);
					                } else {
					                    erro = true;
					                    validaCampo("Email", true);
					                }

					            }

					            if (DDD == "") {
					                erro = true;
					                validaCampo("DDD", true);
					            } else {
					                validaCampo("DDD", false);
					            }
					            if (Phone == "") {
					                erro = true;
					                validaCampo("Phone", true);
					            } else {
					                validaCampo("Phone", false);
					            }
					            if (Message == "") {
					                erro = true;
					                validaCampo("Message", true);
					            } else {
					                validaCampo("Message", false);
					            }

					            if (erro) {
					                $("#RetornoFormulario").addClass("Erro");
					                $("#RetornoFormulario").html("Verifique os campos marcados em <b>vermelho</b>.");
					                $("#RetornoFormulario").show("highlight", { color: "#ed5252" }, 2000);

					            } else {
					                $("#RetornoFormulario").show("highlight", 2000);
					                $("#RetornoFormulario").removeClass("Erro");
					                $("#RetornoFormulario").html("Enviando mensagem <img src='/site_images/contatos/ajax-loader.gif'/>");
					                $('#formularioContatos input, #formularioContatos select, #formularioContatos textarea').attr("disabled", true);
					                $("#formularioContatos").animate({
					                    opacity: 0.5
					                }, 1000);

					                $("#RetornoFormulario").load("/interactive/_contacts/ajaxContact.aspx", {
					                    Name: function() { return Name },
					                    Subject: function() { return Subject },
					                    IsAssoc: function() { return IsAssoc },
					                    NumAssoc: function() { return NumAssoc },
					                    VerAssoc: function() { return VerAssoc },
					                    Email: function() { return Email },
					                    DDD: function() { return DDD },
					                    Phone: function() { return Phone },
					                    Message: function() { return Message }

					                },
						function() {
						    $("#formularioContatos").animate({
						        opacity: 1
						    }, 1000);
						    $('#formularioContatos input[type=text], #formularioContatos select, #formularioContatos textarea').val("");
						    $('#formularioContatos input[type=text], #formularioContatos select, #formularioContatos textarea').removeClass("NaoValido");
						    $('#formularioContatos input, #formularioContatos select, #formularioContatos textarea').attr("disabled", false);
						}


						);
					            }
					        });
					        var aberto = false
					        $("#abreForm").click(function() {
					            if (!aberto) {
					                if ($.browser.msie) {
					                    $("#FormularioEmail").show("blind", 500);
					                } else {
					                    $("#FormularioEmail").show("blind", 500);
					                }
					                aberto = true;

					            }
					            return false
					        });
					    }


					    if (document.getElementById('gallery-adv')) {
					        var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
					            delay: 2000,
					            numThumbs: 7,
					            preloadAhead: 10,
					            enableTopPager: false,
					            enableBottomPager: true,
					            imageContainerSel: '#slideshow-adv',
					            controlsContainerSel: '#controls-adv',
					            captionContainerSel: '#caption-adv',
					            loadingContainerSel: '#loading-adv',
					            renderSSControls: true,
					            renderNavControls: true,
					            playLinkText: 'Exibir em serie',
					            pauseLinkText: 'Pausar',
					            prevLinkText: 'Anterior',
					            nextLinkText: 'Proxima',
					            nextPageLinkText: '>',
					            prevPageLinkText: '<',
					            enableHistory: true,
					            autoStart: false,
					            onChange: function(prevIndex, nextIndex) {
					                $('#thumbs-adv ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);
					            },
					            onTransitionOut: function(callback) {
					                $('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
					            },
					            onTransitionIn: function() {
					                $('#slideshow-adv, #caption-adv').fadeIn('fast');
					            },
					            onPageTransitionOut: function(callback) {
					                $('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
					            },
					            onPageTransitionIn: function() {
					                $('#thumbs-adv ul.thumbs').fadeIn('fast');
					            }
					        });
					    }
					    // Stop Page
					   
					    
					    

					});

	    function ShowSubscribe(){
			$("#StopPageDialog").dialog("open");	
		}
		
