$(document).ready(function(){

    $(document).pngFix();

	$('a[rel*=facebox]').facebox({
		loading_image : 'loading.gif',
    close_image   : 'closelabel.gif'
	 }); 	


$("input:text").addClass("input");
$("input:submit").addClass("submit");


$("#nome").focus(function(){
				if($(this).val() == 'nome'){
					$(this).attr('value','');
					}
					}).blur(function(){
						if($(this).val() == ''){
							$(this).attr('value','nome');
							}
						});
$("#email").focus(function(){
				 if($(this).val() == 'email'){
					 $(this).attr('value','');
					 }
				 }).blur(function(){
					if($(this).val() == '' ){
						$(this).attr('value','email');
						} 
					});

$('#telefone').mask('(99) 9999.9999').attr('value','telefone');


$("#telefone").focus(function(){
					if($(this).val() == 'telefone'){
						$(this).attr('value','');
						}
						}).blur(function(){
							if($(this).val() == '' ){
								$(this).attr('value','telefone');
								}
});



	$('form#form-contato').validate({
								rules:{
									nome:{
										required:true
										},
									email:{
										required:true,
										email:true
										},
									mensagem:{
										required:true
										}
									},
								messages:{
										nome:{
											required: "Preencha o nome, por favor!"
											},
										email:{
											required: "Preencha o email, por favor!",
											email: "Preencha um email válido!"
											},
										mensagem:{
											required: "Preencha com sua mensagem por favor."
											}
										},
								
								errorLabelContainer:$('#recebe-erro')
									
									
								});

  //IMAGE-REPLACE NO SLIDE DA HOME
  $('ul#ultimostrabalhos > li > a > img:odd').hide();
  $('ul#ultimostrabalhos > li > a').hover(
    function(){
      $(this).find('img:first').hide();
      $(this).find('img:last').show();
    },
    function(){
      $(this).find('img:last').hide();
      $(this).find('img:first').show();
    }
  );

  //BORDAS EM PORTFOLIO
  $('ul.trabalho').hover(
    function(){
      $('div.foto-trabalho img').removeClass('trabhover');
      $(this).find('div:first img').addClass('trabhover');
    },
    function(){
      $(this).find('div:first img').removeClass('trabhover');
    }
  );
  //IMAGE-REPLACE EM TRABALHOS-VER
  $('ul.nav > li > a > img:odd').hide();
  $('ul.nav > li > a').hover(
    function(){
      $(this).find('img:first').hide();
      $(this).find('img:last').show();
    },
    function(){
      $(this).find('img:last').hide();
      $(this).find('img:first').show();
    }
  );

  //IMAGE-REPLACE NA PAGINAÇÃO
  $('div.pg > a > img:odd').hide();
  $('div.pg > a').hover(
    function(){
      $(this).find('img:first').hide();
      $(this).find('img:last').show();
    },
    function(){
      $(this).find('img:last').hide();
      $(this).find('img:first').show();
    }
  );

  //CROP
  $('div.crop').each(function(){
    var div = $(this),
        dim = div.attr('title'),
        size = dim.split('x'),
        w = size[0],
        h = size[1];
    div.css({width:w,height:h}).removeAttr('title');
  });

  $('.conteudo-slide').cycle({
    next: "#next",
    prev: "#prev",
    timeout: 0
  });


});


DD_roundies.addRule('.ver,.ver2', '4px', true);
DD_roundies.addRule('#recebe-erro', '5px', true);
DD_roundies.addRule('fieldset.form label input,fieldset.form label input,.submit', '4px', true);
