function eduReset() {
	//----Reset
	$('#cuatro1, #tres1, #dos1, #uno1').remove();
	$('#cuatro, #tres, #dos, #uno').css({paddingTop:'0px'});
	$('#edu h1').css({paddingLeft:'0%',width:'100%'});
	$('#amarillo').css({width:'0%'},750);
	//----End reset

}

function educacion() {
	$('.triger').hover(
		function(){
			$(this).find('.slider').slideDown(200);
			$(this).find('.logo').slideUp(200);
		},
		function(){
			$(this).find('.slider').slideUp(200);
			$(this).find('.logo').slideDown(200);	
		}
	).stop();
	$('#edu h1').delay(500).animate({paddingLeft:'90%',width:'10.2%'},1000);
	$('#amarillo').delay(500).animate({width:'100%'},750);
	$('#uno').delay(500).animate({paddingTop: '190px'},750, 'easeInOutElastic', function(){$('<div id="uno1"></div>').insertBefore('#uno h2').hide().fadeIn(250,function(){$('#dos').animate({paddingTop: '190px'},750, 'easeInOutElastic', function(){$('<div id="dos1"></div>').insertBefore('#dos h2').hide().fadeIn(250,function(){$('#tres').animate({paddingTop: '190px'},750, 'easeInOutElastic', function(){$('<div id="tres1"></div>').insertBefore('#tres h2').hide().fadeIn(250,function(){$('#cuatro').animate({paddingTop: '190px'},750, 'easeInOutElastic', function(){$('<div id="cuatro1"></div>').insertBefore('#cuatro h2').hide().fadeIn(250)})})})})})})});
}

function bioReset() {
	//----Reset
	$('#bio h1').css({paddingLeft:'0%',width:'100%'});
	$('#amarillo').css({width:'0%'},750);
	//----End reset
}

function biografia() {
	$('#bio h1').delay(500).animate({paddingLeft:'86%',width:'14.2%'},1000);
	$('#amarillo').delay(500).animate({width:'100%'},750);
}

function agreReset() {
	//----Reset
	$('#ingles1, #coche1, #disposicion1').remove()
	$('#ingles, #coche').css({marginLeft:'-1500px'});
	$('#disposicion').css({marginTop:'900px'});
	$('#oral, #escrito, #comprension').css({height:'0px'});
	$('#alto, #medio, #bajo, #disposicion h2, #valor aside').hide();
	$('#oral p, #escrito p, #comprension p').hide();
	$('#valor h1').css({paddingLeft:'0%',width:'100%'});
	$('#amarillo').css({width:'0%'},750);
	//----End reset
}

function agregado() {
	$('#valor h1').delay(500).animate({paddingLeft:'83%',width:'17.2%'},1000);
	$('#amarillo').delay(500).animate({width:'100%'},750);
	$('#ingles').delay(500).animate({marginLeft: '5px'},1000, 'easeInOutElastic', function(){$('<div id="ingles1"></div>').insertAfter('#ingles h2').hide().fadeIn(500,function(){$('#oral').animate({height:'142px'},500,function(){$('#escrito').animate({height:'190px'},500,function(){$('#comprension').animate({height:'142px'},500,function(){$('#alto').fadeIn(500,function(){$('#medio').fadeIn(500,function(){$('#bajo').fadeIn(500)})})})})})})});
	$('#oral p, #escrito p, #comprension p').delay(3500).fadeIn(1000);
	$('#coche').delay(3500).animate({marginLeft: '5px'},1000, 'easeInOutElastic', function(){$('<div id="coche1"></div>').insertBefore('#coche h2').hide().fadeIn(500)});
	$('#disposicion').delay(3750).animate({marginTop: '210px'},1000, 'easeInOutElastic', function(){$('<div id="disposicion1"></div>').insertAfter('#disposicion h2').hide().fadeIn(500)});
	$('#disposicion h2').delay(4000).fadeIn(1000);
	$('#valor aside').delay(2500).fadeIn(1500);
}

function saberReset() {
	//----Reset
	$('#saber h1').css({paddingLeft:'0%',width:'100%'});
	$('#amarillo').css({width:'0%'},750);
	$('#name').val('');
	$('#email').val('');
	$('#message').val('');
	$('#enviado').css({display:'none'},(function(){$('#enviado p').css({display:'none'})}));
	//----End reset
}

function saber() {
	$('#saber h1').delay(500).animate({paddingLeft:'88%',width:'12.2%'},1000);
	$('#amarillo').delay(500).animate({width:'100%'},750);
}

function inicio() {
	educacion();
	$("#up").tooltip({ effect: 'slide', relative: 'true', position: 'center right', offset: [87, -13]});
	$("#down").tooltip({ effect: 'slide', relative: 'true', position: 'center right', offset: [19, -13]});
	$('#twitter a').hover(function(){
		$(this).stop().hide();
		$(this).stop().fadeIn(500,(
			function(){
				$(this).css({opacity:'1'})
				}
			)
		)
		}
	);
$('#linkedIn a').hover(function(){$(this).stop(true).hide();$(this).fadeIn(500,(function(){$(this).css({opacity:'1'})}));});
}

function correo() {
	$('#contact').submit(function(){
			var name = $('input#name').val();
			var email = $('input#email').val();
			var message = $('textarea#message').val();
			var mensaje = 'name=' + name + '&email=' + email + '&message=' + message;
			$.ajax({
				type: "POST",
				data: mensaje,
				url: ('library/enviar-formulario.php'),
				success: function(){ 
							$('#enviado').fadeIn(500,
								(function(){
									$('#enviado p').fadeIn(1000)
										}))
							}
			});
		return false;
	});
	return false;
}

// remap jQuery to $
(function($){})(window.jQuery);

/* trigger when page is ready */
$(document).ready(function (){
	Height = $(window).height();
	//$('section').css({height:Height-'65'});
	$('#saber').css({height:Height-'164'});
	$("a.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
	});
	$('h1, h2').css({textIndent: '0px'});
	correo();
	inicio();
	$('#aedu').click(function(){
		eduReset();
		educacion();
	});
	$('#abio').click(function(){
		bioReset();
		biografia();
	});
	$('#avalor').click(function(){
		agreReset();
		agregado();
	});
	$('#asaber').click(function(){
		saberReset();
		saber();
	});
	$('#easaber').click(function(){
		saberReset();
		saber();
	});
});


//optional triggers
$(window).load(function() {
	$('nav').onePageNav({
		currentClass: 'selec',
		scrollSpeed: 750
		});
	$('.toggleContainer').hide();
//Google +1
  window.___gcfg = {lang: 'es'};
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
//Fin Google +1
//Facebook
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
//Fin Facebook
});

$(window).resize(function() {
	Height = $(window).height();
	//$('section').css({height:Height-'65'});
	$('#saber').css({height:Height-'164'});
});




