/// <reference path="lib/jquery/jquery-1.6.2.js" />
/// <reference path="lib/jquery/jquery.external.modal.js" />
/// <reference path="lib/jquery/jquery.internal.modal.js" />
/// <reference path="lib/jquery/jquery.maskedinput-1.3.min.js" />
/// <reference path="lib/cufon/cufon-1.09.js" />

var Site = {
    Init: function () {

        Cufon.replace('#header ul li a, #footer .hold div p:not(.no-cufon)', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });

        $('#header ul li:first').css('padding-left', 0);
        $('#header ul li:last').css('padding-right', 0).css('background', 'none');

        $('.email-despulga').focus(function () {
            if (this.value == this.defaultValue) {
                this.value = '';
            }
        }).blur(function () {
            if (this.value == '') {
                this.value = 'DIGITE SEU E-MAIL';
            }
        });
        
        //Busca por todos os links que possuem a classe '.external-modal' para abrir janela modal
        $('.external-modal').click(function () {
            var id = $(this).attr('id');
            var source = $(this).attr('href');
            var dimensoes = $(this).attr('rel');
            dimensoes = dimensoes.split('x');
            var w = dimensoes[0];
            var h = dimensoes[1];
            Site.Generics.OpenExternalModal(id, source, w, h);
            return false;
        });
    },
    Generics: {
        OpenExternalModal: function (id, source, w, h) {
            ModalWindow.windowId = id;
            ModalWindow.width = w;
            ModalWindow.height = h;
            ModalWindow.content = '<iframe width=\"' + w + '\" height=\"' + h + '\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\" src=\"' + source + '\"></iframe>';
            ModalWindow.Open();
        },
        FormsEffects: function () {
            $('input[type=text], textarea, select').focus(function () {
                $(this).addClass('on');
            });
            $('input[type=text], textarea, select').blur(function () {
                $(this).removeClass('on');
            });
        }
    },
    Home: function () {
        Cufon.replace('.home .destaques div.fr p', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
        $('#slider').anythingSlider({
            showMultiple: 1,
            changeBy: 1,
            theme: 'home',
            infiniteSlides: false,
            pauseOnHover: false,
            delay: 6000,
            autoPlay: true
        });
    },
    FaleConosco: function () {
        Cufon.replace('#content .page-title', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
        $('.telefone').mask("(99) 9999-9999");
    },
    Campanhas: function () {
        Cufon.replace('#content .page-title, #content .page-subtitle', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });

        $('.campanhas .hold div ul li a').click(function () {
            $('.campanhas .hold div ul li a').removeClass('on');
            $(this).addClass('on');
            var link = $(this).attr('href');
            link = link.split('=');
            $('#player iframe').attr('src', 'http://www.youtube.com/embed/' + link[1] + '?rel=0');
            return false;
        });

    },
    Concurso: function () {
        Cufon.replace('#content .page-title, #content .page-subtitle', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
    },
    ConcursoCadastro: function () {
        Cufon.replace('#content .page-title, #content .page-subtitle', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
        $('.telefone').mask("(99) 9999-9999");
        $('.data').mask("99/99/9999");
    },
    ConcursoComoParticipar: function () {
        Cufon.replace('#content .page-title, #content .page-subtitle', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
    },
    ConcursoVotar: function () {
        Cufon.replace('#content .page-title, #content .page-subtitle', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });

        $('.visualizar a:first').click(function () {
            if (!$(this).hasClass("open")) {
                $(this).addClass('open');
            } else {
                $(this).removeClass('open');
            }
            $(this).next('ul').slideToggle("medium");
            return false;
        });

    },
    Premios: function () {
        Cufon.replace('#content .page-title, #content .page-subtitle', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
    },
    Bichos: function () {
        Cufon.replace('.bichos .hold ul li a, .bichos .hold .text .bread-crumb span, #content .page-title, .bicho-bottom h2, .bicho-bottom p, .bicho-bottom a', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
        $('.bread-crumb span:eq(1)').remove();
    },
    Produtos: function () {
        Cufon.replace('#content .page-title, .produtos .highlights .aplicacao-ciclo-bulas .bulas h1', { fontFamily: 'Helvetica Neue Light Standard Bold', hover: true });
        $('#slider').anythingSlider({
            showMultiple: 1,
            changeBy: 1,
            theme: 'produtos',
            infiniteSlides: false,
            pauseOnHover: false
        });
    }
}
