function sendme() {
	/************** CONTACT FORM */
	$("#formContact").submit();	
}

function emailme() {
	
	
	$('a.email').each(function(){
		e = this.rel;
		e = e.replace('[+]','@'); //Remplaza el texto '(arroba)' por '@'.
		e = e.replace('[-]','.'); //Remplaza el texto '(punto)' por '.'.
		$(this).attr('href','mailto:' + e);
		$(this).text(e);
	});
	
}



/********** READ STATE FOR JQUERY */
$(document).ready(function() {
	
	/************* FUNCIONES */
	externalLinks();
	emailme();
	
	/************* RANDOM BACKGROUND */
	/*
	$('body').randombg({
	    directory: "app/public/img/site/backgrounds/", //directory to image folder
	    howmany: 5 //how many images are in this folder
	});
	*/
	
	/************** FADE IN EFFECT */
	$('body').css('display','none');
	$('body').fadeIn(2000);
	
	/************** FIX HEIGHT PANELS */
	$('#scroll').css('height', $('#myperfil').height());

	/************* NAV BAR */
	
	/// wrap inner content of each anchor with first layer and append background layer
	$("#navbar li a").wrapInner( '<span class="out"></span>' ).append( '<span class="bg"></span>' );
	 
	// loop each anchor and add copy of text content
	$("#navbar li a").each(function() {
		$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
	});
	 
	$("#navbar li a").hover(function() {
		// this function is fired when the mouse is moved over
		$(".out",	this).stop().animate({'top':	'45px'},	250); // move down - hide
		$(".over",	this).stop().animate({'top':	'0px'},		250); // move down - show
		$(".bg",	this).stop().animate({'top':	'0px'},		130); // move down - show
	 
	}, function() {
		// this function is fired when the mouse is moved off
		$(".out",	this).stop().animate({'top':	'0px'},		250); // move up - show
		$(".over",	this).stop().animate({'top':	'-45px'},	250); // move up - hide
		$(".bg",	this).stop().animate({'top':	'-45px'},	130); // move up - hide
	});
	
	/************ SLIDES */

	var width = -($('.panel').width() + 83);
	$('#perfil').click(function(){
		$('#scroll').animate({marginLeft:0}, { "duration": "1000", "easing": "easeInOutCubic" });
		$('#scroll').css('height', $('#myperfil').height());
	});
	
	$('#trabajos').click(function(){		
		$('#scroll').animate({marginLeft:width-1000}, { "duration": "1000", "easing": "easeInOutCubic" });
		$('#scroll').css('height', $('#myworks').height());
	});
	
	$('#contactar').click(function(){
		$('#scroll').animate({marginLeft:(width-1000)*2}, { "duration": "1000", "easing": "easeInOutCubic" });
		$('#scroll').css('height', $('#mycontact').height()+50);
	});	
	
	
	/************* PORTAFOLIO ITEM EFFECT */
	
	$(".thumb").hover(
		function(){
			$(this).children("div.preview").fadeTo("fast", 0);
			$(this).children("div.info").fadeTo("slow", 1);
		},
		function(){
			$(this).children("div.preview").fadeTo("slow", 1);
			$(this).children("div.info").fadeTo("fast", 0);
		}
	);
	
	/************* FORM */
	if ($("#formContact").length > 0) {
		$("#formContact").validate();
	}
		

});
