﻿var Site = {

    Init: function(Titulo, Imagem) {

        /* -- Header E Background -- */
        if (!Titulo) {
            $('#header h3').remove();
        } else {
            $('#header h3').text(Titulo);
            Site.Generics.ClearAccent(Titulo);
            $('#header').addClass('header-' + strLimpa);
            Cufon.replace('#header h3', { fontFamily: 'Caecilia LT Std', hover: true });
        }

        if (Imagem) {
            $('#header').css('background-image', 'url(' + Imagem + ')');
        }

        /* -- Menu e Busca -- */
        $('ul.sf-menu').superfish();
        $('#header fieldset #ctl00_header_TextBox1').focus(function() {
            v = document.getElementById('ctl00_header_TextBox1').value
            if (v == 'Busca') {
                $(this).attr({ value: '' });
            }
        });
        $('#header fieldset #ctl00_header_TextBox1').blur(function() {
            v = document.getElementById('ctl00_header_TextBox1').value
            if (v == '') {
                $(this).attr({ value: 'Busca' });
            }
        });
        $('#header fieldset #header_TextBox1').focus(function() {
            v = document.getElementById('header_TextBox1').value
            if (v == 'Busca') {
                $(this).attr({ value: '' });
            }
        });
        $('#header fieldset #header_TextBox1').blur(function() {
            v = document.getElementById('header_TextBox1').value
            if (v == '') {
                $(this).attr({ value: 'Busca' });
            }
        });

        Cufon.replace('#CrossContent li a', { fontFamily: 'Caecilia LT Std', hover: true });

    },

    Generics: {

        ClearAccent: function(keyword) {
            strLimpa = '';
            var comAcento = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ \'';
            var semAcento = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC-';
            keyword = keyword.split('(').join('-').split(')').join('-');

            for (i = 0; i < keyword.length; i++) {
                if (comAcento.search(keyword.substr(i, 1)) >= 0) {
                    strLimpa += semAcento.substr(comAcento.search(keyword.substr(i, 1)), 1);
                } else {
                    strLimpa += keyword.substr(i, 1);
                }
            }
            strLimpa = strLimpa.toLowerCase();
        },

        SideMenuPictures: function() {
            $('#picture ul li a').click(function() {
                $('#picture ul li a').removeClass('active');
                $(this).addClass('active');
                var foto = $(this).attr('href');

                $('#picture div img').fadeOut(700, function() {
                    $(this).attr({ src: foto });
                    $(this).fadeIn(700);
                });

                /*
                $('#picture div img').fadeOut(700, function() {
                $(this).attr({ src: foto });
                $(this).fadeIn(700);
                });
                */
                return false;
            });
        },

        Carousel: function() {
            $('.galeria2').anythingSlider({
                autoPlay: false,
                animationTime: 500,
                buildNavigation: false,
                pauseOnHover: false
            });
            $("a[rel=gallery]").fancybox({
                'transitionIn': 'none',
                'transitionOut': 'none',
                'titlePosition': 'over',
                'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
                    return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
                }
            });
        },
        ShowMenu: function() {
            $('.sf-menu').fadeIn(700);
        }
    },

    Home: function() {
        var flashvars = {};
        var params = {
            wmode: 'opaque'
            //bgcolor: '#285BB4'
        };
        var attributes = {};
        swfobject.embedSWF("swf/home_main.swf", "flash", "100%", "600", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
    },
    
    AmyrKlink: function() {
        if (!$.browser.msie) {
            $('.rounded').corners('2px');
        }
    },

    MarinaDoEngenho: function() {
        if (!$.browser.msie) {
            $('.rounded').corners('2px');
        }
        Cufon.replace('#main ul.links li a', { fontFamily: 'Caecilia LT Std', hover: true });
    },

    Barcos: function() {
        if (!$.browser.msie) {
            $('.rounded').corners('2px');
        }
    },

    Expedicoes: function() {
        if (!$.browser.msie) {
            $('.rounded').corners('2px');
        }
    },

    Galeria: function() {
        $('#ctl00_content_Busca').focus(function() {
            $(this).attr({ value: '' });
        });
        /*
        $('#ctl00_content_Busca').blur(function() {
        $(this).attr({ value: 'O que você está procurando?' });
        });
        */
        $('#sidebar #tags ul').tagcloud({ colormin: '#999' }, { colormax: '#333' });
    },

    SolicitarPalestras: function() {

        $('.calendario').anythingSlider({
            easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            delay: 3000,                    // How long between slide transitions in AutoPlay mode
            animationTime: 600,             // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
            pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
            startText: "Start",             // Start text
            stopText: "Stop",               // Stop text
            navigationFormatter: null       // Details at the top of the file on this use (advanced use)
        });

    }

}
