$(function() {

	// bot›es sociais (top)
	$(".social div img").hover(function() {
		$(this).attr("src", $(this).attr("src").split(".png").join("-hover.png"));  // adds -hover to the name of the image
	}, function() {
		$(this).stop(true,false); // prevents the creation of stacked actions
		$(this).attr("src", $(this).attr("src").split("-hover.png").join(".png"));  // removes -hover from the name of the image
	});
	
	// botÍes sociais hover (tipsy)
	$('.social img').tipsy({gravity: 'e'});
	  
	// google reader
	$( '.googlereader-click' ).click(function() {
		$( ".googlereader" ).fadeIn();
		return false;
	});

	// projetos (mosaic - hover)
	$('.bar2').mosaic({
		animation	:'slide'
	});
	  
	// posterous
	$('.headlines').rssfeed('http://jvitor.posterous.com/rss.xml', {
		limit: 1,
		date:false,
		content:false,
		header:false,
		linktarget:'_blank',
		titletag:'h3'
		 }, function() {
		 	Cufon.refresh();
	});
  	 
	// form hint
	$('input[title!=""]').hint();
  	 
  	// email antispam
	$('a.email').each(function(){
			e = this.rel.replace('/','@');
			e = e.replace('-','.');
			e +=  '.com.br';
			this.href = 'mailto:' + e;
			$(this).text(e);
	});
	
	$( "#slider" ).slider({
	
		slide: function( event, ui ) {
			$("input[name='slider']").val(ui.value);
		}
	});
	
	// form contact submit()
	$('input, textarea').keyup(function(){
		if ( $(this).val() != "" )
			$(this).removeClass('required');
	})
	$("#formContact").submit(function(){
	
		error = false;
		contactName = $("input[name='contactName']");
		contactMail = $("input[name='contactMail']");
		contactMessage = $("textarea[name='contactMessage']");
		slider = $("input[name='slider']");
		
		if ( $(contactName).val() == "" || $(contactName).val() == $(contactName).attr('title') ) {
			$(contactName).addClass('required');
			error = true;
		}
		if ( $(contactMail).val() == "" || $(contactMail).val() == $(contactMail).attr('title') ) {
			$(contactMail).addClass('required');
			error = true;
		}
		if ( $(contactMessage).val() == "" ) {
			$(contactMessage).addClass('required');
			error = true;
		}
		
		if ( slider.val() < 90 ) {
			error = true;
		}

		if ( error == true ) return false;
		else return true;
	});
	
	$('.showmore').hide();
	
	$(".clickShowMore").click(function(){
		$(".clickShowMore").fadeOut();
		$('.showmore').fadeIn('slow');
	});
	
});



Cufon.replace("h1",{ fontFamily : "texgp", textShadow: '#999 1px 0px'});
Cufon.replace("h2",{ fontFamily : "Colaborate-Bold", textShadow: '#333 1px 1px, #000 1px 1px' });
Cufon.replace("h3",{ fontFamily : "texgp", textShadow: '#999 1px 0px' });
Cufon.replace(".menu .tab",{ fontFamily : "Colaborate-Bold", textShadow: '#333 1px 1px, #000 1px 1px' });

