$(document).ready(function(){

/* Delay */
	jQuery.fn.delay = function(time,func){
		return this.each(function(){
			setTimeout(func,time);
		});
	};

/* Header Animaciones Elementos */
//Animación Menú, Logo, Botones Redes
	$("#hldr-mnu ul li").mouseover(function(){
		$(this).stop().animate({marginTop:'-5px'},{queue:false, duration:100, easing: 'easeInOutBounce'});
	});	
	$("#hldr-mnu ul li").mouseout(function(){
		$(this).stop().animate({marginTop:'0px'},{queue:false, duration:200, easing: 'easeInOutBounce'});
	});
	$(this).delay(200,function(){
		$("#hldr-mnu").stop().animate({top:'89px'},{queue:false, duration:1500, easing: 'easeInOutBounce'});
	});
	$("#hldr-header #social li").mouseover(function(){
		$(this).animate({'marginTop':'-2px'},{queue:false, duration:300, easing: 'easeInOutCirc'});
	});
	$("#hldr-header #social li").mouseout(function(){
		$(this).animate({'marginTop':'-7px'},{queue:false, duration:300, easing: 'easeInOutCirc'});
	});
	$("#hldr-header ul#mnu li").mouseover(function(){
		$(this).animate({scale: [1.06, 1.06]},{queue:false, duration:500, easing: 'easeInOutSine'});
	});
	$("#hldr-header ul#mnu li").mouseout(function(){
		$(this).animate({scale: [1.0, 1.0]},{queue:false, duration:500, easing: 'easeInOutSine'});
	});

/*Fadings INPUT BUSCAR HEADER*/
$('.buscarb-label').animate({ opacity: "0.4" })  
    .click(function() {  
        var thisFor = $(this).attr('for');  
        $('.'+thisFor).focus();  
});   
$('.buscarb').focus(function() {  
    $('.buscarb-label').animate({ opacity: "0" }, "fast");  
        if($(this).val() == "¿Qué quieres encontrar?")  
            $(this).val() == "";  
    }).blur(function() {  
        if($(this).val() == "") {  
            $(this).val() == "¿Qué quieres encontrar?";  
            $('.buscarb-label').animate({ opacity: "0.4" }, "fast");  
        }  
    });
	if($('.buscarb').val() == "") {
		}else{
		$('.buscarb-label').hide();
	}
	
/*Tooltip General*/
var tip = null;
	$(".tip-rn").hover(function(){
		tip = $(this).find('.tip');
		$('body').append(tip);
		tip.fadeIn('fast').show();

	}, function() {
		tip.hide();
		$(this).append(tip);

	}).mousemove(function(e) {
	if ( tip == null ) return;
		  var mousex = e.pageX + 20;
		  var mousey = e.pageY - 20;
		  var tipAncho = tip.width();
		  var tipAlto = tip.height();

		  var tipVisX = $(window).width() - (mousex + tipAncho);
		  var tipVisY = $(window).height() - (mousey + tipAlto);

		if ( tipVisX < 20 ) {
			mousex = e.pageX - tipAncho - 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) {
			mousey = e.pageY - tipAlto + 20;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});	
																									
});

