jQuery(document).bind("contextmenu",function(e) {return false;});

jQuery(document).ready(function() {
    
    $('#mycarousel').jcarousel();
    
    $('#mycarousel img').click(function(){
        
        var $this = $(this);
        var $m = $this.attr('img-media');
        var $g = $this.attr('img-grande');
        
        $('#mostra-img').find("a").attr({href: $g});
        $('#mostra-img').find("img").attr({src: $g}).fadeIn(100);

    });
    
    $("div#modelo ul").cycle({
        fx: 'fade',
        pause: 1
    });
    
    $("input").placeholder();
    $("textarea").placeholder();
    
    $('input[type=text]').setMask();

    $("a[rel=video]").click(function() {
	$.fancybox({
            'padding'               : 10,
            'autoScale'             : false,
            'transitionIn'          : 'none',
            'transitionOut'         : 'none',
            'width'                 : 680,
            'height'                : 495,
            'href'                  : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'                  : 'swf',
            'swf'                   : {
                'wmode'             : 'transparent', 
                'allowfullscreen'   : 'true'
            }
        });

        return false;
    });
    
    
    $("#formContato").valida({
        redireciona: false,
        onValida: function() {
            $(this).removeClass('erro');
        },
        onErro: function() {
            $(this).addClass('erro');
        },
        onPassa: function() {

            $("#loading").hide();
            $.post(URLBASE+'contato/send', $(this).serialize(), function(data) {
                $("#loading").show();
                if(data.result) {
                    alert('Seu contato foi enviado com sucesso.');
                } else {
                    alert('Não foi possível enviar seu contato, por favor tente mais tarde.');
                }
            }, 'json' );

        }
    });
    
});
