// JavaScript Document


// document ready
$(document).ready(function(){

	// cufon
	Cufon.replace('	#menu ul li a', {fontFamily: 'Verdana', hover: true, textShadow: '#ffffff 1px 1px' });
	Cufon.replace('	#header #atendimento p em,\
					#header #atendimento p strong,\
					#header #atendimento p strong em,\
					#header #newsletters strong,\
					#cep p\
					', {fontFamily: 'Adobe Garamond Pro'});
	
	// share
	/*$('#footer #wrap ul li p a.facebook').click(function(){
		
		u = location.href;
		t = document.title;
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent('http://www.revestwall.com.br/')+'&t='+encodeURIComponent('Revest Wall - Um novo conceito em decoração - Papel de parede com textura em alto relevo'),'sharer','toolbar=0,status=0,width=626,height=436');
		
		return false;
		
	});*/
	
	
	// form newsletter
	
	$('#cep input[name="cep"]').mask('99999-999');
	
	$('#newsletters form input[name="btnsubmit"]').click(function(){
		
		var nome = $('#newsletters form input[name="camponome"]').val();
		var email = $('#newsletters form input[name="campoemail"]').val();
		
		if(email != "" && email != "Email:" && nome != "" && nome != "Nome:"){
			
			$("#cep").animate({top: '130px'}, 400, "easeOutQuint");
			$("#fade").fadeIn(300);
						
		}else{
			
			$('#newsletters #status').html('').html('<p>Preencha todos os campos!</p>');
			$('#newsletters #status').fadeIn();
			$('#newsletters #status').delay(5000).fadeOut();
			
		};

	});
	
	$("#cep form input[name='enviarcep']").click(function(){
		
		var cep = $('#cep form input[name="cep"]').val();
		var nome = $('#newsletters form input[name="camponome"]').val();
		var email = $('#newsletters form input[name="campoemail"]').val();
		
		if(cep != ""){
			
			$('#cep #status').html('').html('<span>Cadastrando...</span>');
			
			$.ajax({
				type: 'POST',
				url: 'php/salvarEmail.php',
				data: 'nome='+nome+'&email='+email+'&cep='+cep,
				dataType: "html",
				success: function(msg){
					
					$('#cep #status')
						.delay(1500)
						.html('')
						.html('<span>'+msg+'</span>');
					
					$('#cep').delay(1000).stop(true, true).animate({top: '-240px'}, 400, "easeOutQuint");
					$('#fade').fadeOut(400);
				}
			})
		
		}else{
			
			$('#cep form input[name="cep"]').focus();
			$('#cep #status').html('').html('<span>Por favor, preencha o campo acima.</span>');
		
		};
	});
	
	$('#cep div.close').click(function(){
		
		$('#cep').delay(1000).stop(true, true).animate({top: '-240px'}, 400, "easeOutQuint");
		$('#fade').fadeOut(400);
		
	});
	
	$('#newsletters form input[name="campoemail"]')
		.focus(function(){
			
			$(this).stop(true, true).animate({backgroundColor: '#ffcc00'}, 300);
			
			if ($(this).val() == "Email:"){ 
				$(this).val('');
			}
		})
		.blur(function(){
			
			$(this).stop(true, true).animate({backgroundColor: '#ededed'}, 300);
			
			if ($(this).val() == ''){  
				$(this).val('Email:');
			} 
		});
		
	$('#newsletters form input[name="camponome"]')
		.focus(function(){
			
			$(this).stop(true, true).animate({backgroundColor: '#ffcc00'}, 300);
			
			if ($(this).val() == "Nome:"){ 
				$(this).val('');
			}
		})
		.blur(function(){
			
			$(this).stop(true, true).animate({backgroundColor: '#ededed'}, 300);
			
			if ($(this).val() == ''){  
				$(this).val('Nome:');
			} 
		});
	
	/* -- */
	
});
