$(function(){
	mov.start();
	texto.init();
	flecha.init()
})

var mov={
	start:function(area){
		//$("#"+area).animate({marginTop: '-=10'},200,'easeOutQuad');
		$("#face").bind({mouseover:function(){
										   $(this).animate({marginTop: '-=6'},800,'easeInOutBack');
										   $("#face_sombra").css({'opacity':0});
										  	$("#face_sombra").animate({opacity:0.8,width:'+=0'},800);
										   },
										   mouseout:function(){
											$(this).animate({marginTop: '+=6'},800,'easeInOutBack'); 
											$("#face_sombra").animate({width:'-=0',opacity:0},800,function(){$(this).css({'display':'none'})});
										   }});
		$("#in").bind({mouseover:function(){
										   $(this).animate({marginTop: '-=6'},800,'easeInOutBack');
										   $("#in_sombra").css({'opacity':0});
										  	$("#in_sombra").animate({opacity:0.8,width:'+=0'},800);
										   },
										   mouseout:function(){
											$(this).animate({marginTop: '+=6'},800,'easeInOutBack'); 
											$("#in_sombra").animate({width:'-=0',opacity:0},800,function(){$(this).css({'display':'none'})});
										   }});
		$("#twitter").bind({mouseover:function(){
										   $(this).animate({marginTop: '-=6'},800,'easeInOutBack');
										   $("#tw_sombra").css({'opacity':0});
										  	$("#tw_sombra").animate({opacity:0.8,width:'+=0'},800);
										   },
										   mouseout:function(){
											$(this).animate({marginTop: '+=6'},800,'easeInOutBack'); 
											$("#tw_sombra").animate({width:'-=0',opacity:0},800,function(){$(this).css({'display':'none'})});
										   }});
	}
};

var	texto={
	vars:{
		cant_p:'',
		pos_actual:1
	},
	init:function(){
			texto.vars.cant_p=$(".cont_text p");
			if(texto.vars.pos_actual==1){
				var flecha_right=$(".arrow_right");
				flecha_right.show().bind('click',function(){
														  	texto.vars.pos_actual++;
														  	$(".cont_text").animate({marginLeft: '-=476'},2000);	
															
															flecha_right.hide();
															flecha_right.unbind('click');
															texto.init();
														  });
			}else if(texto.vars.cant_p.length==texto.vars.pos_actual){
				var flecha_left=$(".arrow_left a");
				flecha_left.show().bind('click',function(){
														 	texto.vars.pos_actual--;
														  	$(".cont_text").animate({marginLeft: '+=476'},2000);	
															
															flecha_left.hide();
															flecha_left.unbind('click');
															texto.init();
														  });	
			}else{
				var flecha_right=$(".arrow_right");
				flecha_right.show().bind('click',function(){
														  	texto.vars.pos_actual++;
														  	$(".cont_text").animate({marginLeft: '-=476'},2000);	
															
															flecha_right.hide();
															flecha_right.unbind('click');
															flecha_left.unbind('click');
															texto.init();
														  });
				var flecha_left=$(".arrow_left a");
				flecha_left.show().bind('click',function(){
														 	texto.vars.pos_actual--;
														  	$(".cont_text").animate({marginLeft: '+=476'},2000);	
															
															flecha_left.hide();
															flecha_left.unbind('click');
															flecha_right.unbind('click');
															texto.init();
														  });	
			}
	}
}

var flecha={
	init:function(){
		setInterval(flecha.animacion,3000);
	},
	animacion:function(){
		var flecha_right=$(".arrow_right");
		var flecha_left=$(".arrow_left");
		flecha_right.animate({opacity:'0.3'},1500,function(){
														   $(this).animate({opacity:'1'},1500)
														   });
		flecha_left.animate({opacity:'0.3'},1300,function(){
														   $(this).animate({opacity:'1'},1300)
														   });
	}
}

