//swfobject.embedSWF(baseUrl+"flash/player.swf", "video-empresa", "320", "225", "9.0.0", baseUrl+"flash/expressInstall.swf");

$(document).ready(function() {
    $('a[rel=external]').attr('target', '_blank');

    $("#main-menu > ul > li").hover(
        function () {
            $(this).addClass('hover');
        },
        function () {
            $(this).removeClass('hover');
        }
    );

    $("#main-menu > ul > li > ul").prev('a').click(function(e){
        e.preventDefault();
    });



    $('#main-menu > ul > li > a')
    .append('<span class="hover"></span>')
    .each(function () {
        var $span = $('> span.hover', this);

        $(this).hover(
            function () {
                $span.stop().fadeTo(500, 1);
            }, function () {
                $span.stop().fadeTo(500, 0);
            }
        );
    });


    $("#gallery-list-draggable").disableSelection().sortable({
      update: function(event, ui) {
        var x = 1;
        $("#gallery-list-draggable div.gallery").each(function(){
          $(this).find('input').val(x);
          x++;
        });
      }
    });

    $("#galley-view-images").disableSelection().sortable({
      update: function(event, ui) {
        var x = 1;
        $("#galley-view-images input[type=hidden]").each(function(){
          $(this).val(x);
          x++;
        });
      }
    });


    if(redimensionaPaginaInicial)
        $('#middle').animate({ height: $('#page-home').height() }, 0);


    $('#logo').fadeTo(0, 0);
    $('#logo').fadeTo(1000, 1);


    var loadItem = function(id) {
        $('#main-menu ul li.item-'+id).show().animate({opacity: 1, marginTop:'0'}, 300, function() {
            if(id+1 <= 3) {
                loadItem(id+1);
            }
        });
    }

    $('#main-menu ul li').animate({opacity: 0, marginTop:'50px'}, 0, function() {
        loadItem(0);
    });

    $("#video-empresa").click(function() {
        $.fancybox({
            'padding'         : 0
            ,'autoScale'      : false
            ,'transitionIn'   : 'elastic'
            ,'transitionOut'  : 'elastic'
            ,'title'          : false
            ,'width'          : 680
            ,'height'         : 495
            ,'href'           : this.href
            ,'type'           : 'swf'
            ,'swf'            : {
                'wmode' : 'transparent',
                'allowfullscreen' : 'true'
            }
            ,'orig'           : this
        });

        return false;
    });

    $("#mapaLocalizacao").click(function() {
        $.fancybox({
            'padding'         : 10
            ,'autoScale'      : false
            ,'transitionIn'   : 'elastic'
            ,'transitionOut'  : 'elastic'
            ,'title'          : false
            ,'width'          : 800
            ,'height'         : 400
            ,'href'           : this.href
            ,'type'           : 'iframe'
            ,'orig'           : this
        });

        return false;
    });

    $("#galleriesList li a").click(function() {
        $.fancybox({
            'padding'         : 0
            ,'autoScale'      : false
            ,'transitionIn'   : 'elastic'
            ,'transitionOut'  : 'elastic'
            ,'title'          : false
            ,'width'          : 735
            ,'height'         : 605
            ,'href'           : this.href
            ,'type'           : 'iframe'
            ,'orig'           : this
        });

        return false;
    });

    $("#trabalhe-conosco-button").fancybox({
        showTitle: false,
        centerOnScroll: true,
        width: 725,
        height: 600,
        padding: 0,
        autoDimensions: false
    });

    $('#trabalheConoscoForm').live('submit', function(e) {
        var errors = '';

        if($('#TrabalheName').val() == '')
            errors += 'Preencha seu Nome Completo\n\r';

        if($('#TrabalheCpf').val() == '')
            errors += 'Preencha seu CPF\n\r';

        if($('#TrabalheEmail').val() == '')
            errors += 'Preencha seu Email\n\r';

        if($('#TrabalheNascimento').val() == '')
            errors += 'Preencha sua Data de Nascimento\n\r';

        if($('#TrabalheEndereco').val() == '')
            errors += 'Preencha seu Endereço\n\r';

        if($('#TrabalheBairro').val() == '')
            errors += 'Preencha seu Bairro\n\r';

        if($('#TrabalheCidade').val() == '')
            errors += 'Preencha sua Cidade\n\r';

        if($('#TrabalheEmpresa').val() == '')
            errors += 'Preencha o nome da Empresa do seu emprego anterior\n\r';

        if($('#TrabalheEscolaridade').val() == '')
            errors += 'Preencha sua Escolaridade\n\r';

        if(
            $('#TrabalheWord').val() == ''
            || $('#TrabalhePowerPoint').val() == ''
            || $('#TrabalheExcel').val() == ''
            || $('#TrabalheInternet').val() == ''
        )
            errors += 'Preencha os conhecimentos em informática\n\r';

        if(errors != '') {
            e.preventDefault();
            alert(errors);
        }
    });
});

jQuery.fn.extend({
    placeHolder: function(value){
        jQuery(this).focus(function(){
            if(jQuery(this).val() == value)
                jQuery(this).val('');
        });
        jQuery(this).blur(function(){
            if(jQuery(this).val() == '')
                jQuery(this).val(value);
        });
    }
});

