$.fn.raise = function(depth, callback, force, forcebounce){

    if(typeof(depth) !== "string") var depth = -depth;
    var goingDown = parseInt($(this).css("top")) < depth;
    if (typeof(forcebounce) !== "undefined") goingDown = true;
    
    $(this).stop(true, true).animate({top: depth+"px"}, {
      duration: goingDown ? 700 : 100,
      easing: goingDown ? "easeOutBounce" : "easeOutQuad",
      complete: function(){
        }
    });
  if (typeof(callback) !== "undefined") callback();
  return $(this);
}

$.fn.softRaise = function(depth, radius, callback, force, forcebounce){
  var index = $(this).index();
  $(this).raise(depth, callback, undefined, forcebounce);
  // $(this).siblings().eq(index-limit).raise(depth/2);
  return $(this);
}

$.fn.randomize = function(){
  $(this).each(function(){
    var random = Math.random()*60;
    $(this).raise(random, undefined, true);
  });
}

$("area").live({
  mouseover: function(){
    var index = $(this).index();
    var modulo = $(".modulo").eq(index);
    if(locked[index] == false){
      modulo.raise("-=30", function(){
        $(".modulo").eq(index).showTooltip();
      });
    }
  },
  mouseleave: function(){
    var index = $(this).index();
    var modulo = $(".modulo").eq(index);
    if(locked[index] == false){
        modulo.raise("+=30", function(){
          modulo.hideTooltip();
      }, undefined, true);
    }
  },
  click: function(){
    var index = $(this).index();
    var modulo = $(".modulo").not(".dummy").eq(index);
    if(locked[index] == false){
      lock("all");
      modulo.moduloShow();
      projetoSelecionado = projetosReais[index];
    }
  }
});

function setTampoes(){
     $(".break").add(".modulo:gt(23)").each(function(){
      var tampao = $('<img src="images/losango_back.png"  class="tampao" alt="" />');
      var terminal = $(".modulo").eq($(this).index()-1);
      tampao.clone().appendTo(".background").css({
        left: terminal.offset()['left']+200,
        top: terminal.offset()['top']+100,
        zIndex: $(this).css('z-index')
      });
    });
    mouseListener();
  }
