// JavaScript Document

$(document).ready(function()
{
    $("#elLogoMDP").fadeIn(150).animate({top:"-=-20px"},150).animate({top:"+=-20px"},150).animate({top:"-=-20px"},150)
	.animate({top:"+=-20px"},150).animate({top:"-=-20px"},150).animate({top:"-=80px"},150);

	//hide the object with blink effect  
	$("#button2").click(function()
    {
		$("#elLogoMDP").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100);
	});
	//show the object with blink effect  
	$("#button4").click(function()
    {
		$("#elLogoMDP").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
	});
	//bounce an object
	$("#elLogoMDP").click(function()
    {
		$("#elLogoMDP").fadeIn(100).animate({top:"-=50px"},200).animate({top:"+=20px"},100).animate({top:"-=5px"},150)
		.animate({top:"+=70px"},100).animate({top:"-=120px"},250).animate({top:"+=20px"},100);

	});
	
	scrollDiv("#especialidadesDesplebagles");
	scrollDiv("#enlacesPatrocinados");
});

function scrollDiv(cualDiv){
     $(function() {
       var offset = $(cualDiv).offset();
       var topPadding = 15;
       $(window).scroll(function() {
          if ($(window).scrollTop() > offset.top){
             $(cualDiv).stop().animate({
                 marginTop: $(window).scrollTop() - offset.top + topPadding
              });
          } else {
             $(cualDiv).stop().animate({
                 marginTop: 0
              });
          };
       });
     });
}

