<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -31,6 +31,8 @@ Simpltry.Tooltip.Base = Class.create({
     this.setPopupPosition();
     $$(&quot;body&quot;)[0].appendChild(this.popup);
     this.attachEvents();
+    this.element.observe(&quot;tooltip:displayed&quot;, this.hideSelectBoxes.bind(this));
+    this.element.observe(&quot;tooltip:closed&quot;, this.showSelectBoxes.bind(this));
     if(this.options.relative == &quot;cursor&quot;) {
       Event.observe(document, &quot;mousemove&quot;, this.setMouse.bindAsEventListener(this));
     }
@@ -64,12 +66,12 @@ Simpltry.Tooltip.Base = Class.create({
     topPosition += this.options.offsetTop;
 
     if(this.options.direction == &quot;right&quot;){
-      if(($(document.body).getDimensions().width - ((offset[0] + elementDimentions.width + this.popup.getDimensions().width) + 8)) &lt; 0) {
+      if($(document.body).getDimensions().width - (offset[0] + this.popup.getDimensions().width) + 8 &lt; 0) {
         leftPosition = offset[0] + elementDimentions.width - this.popup.getDimensions().width;
         topPosition = offset[1] + elementDimentions.height + 8;
       }
     } else if(this.options.direction == &quot;below&quot;) {
-      var distanceFromScreenTop = $(document.body).getDimensions().height - (offset[1] + this.popup.getDimensions().height) + 8;
+      var distanceFromScreenTop = document.body.getDimensions().height - (offset[1] + this.popup.getDimensions().height) + 8;
       if(distanceFromScreenTop &lt; 0) topPosition += distanceFromScreenTop;
     }
     this.popup.setStyle({position: 'absolute', left: leftPosition + &quot;px&quot;, top: topPosition + &quot;px&quot;});
@@ -77,8 +79,8 @@ Simpltry.Tooltip.Base = Class.create({
   },
   attachEvents: Prototype.emptyFunction,
   display: function() {
-    this.element.fire(&quot;tooltip:displayed&quot;);
     this.setPopupPosition();
+    this.element.fire(&quot;tooltip:displayed&quot;);
     this.popup.show();
   },
   close: function() {
@@ -88,6 +90,35 @@ Simpltry.Tooltip.Base = Class.create({
   setMouse: function(event) {
     this.lastX = Event.pointerX(event);
     this.lastY = Event.pointerY(event);
+  },
+  hideSelectBoxes: function() {
+    var tooltip_offsets = {top: parseInt(this.popup.getStyle(&quot;top&quot;), 10), left: parseInt(this.popup.getStyle(&quot;left&quot;), 10)};
+    var tooltip_info = {left: tooltip_offsets.left, top: tooltip_offsets.top, right: tooltip_offsets.left + this.popup.getWidth(), bottom: tooltip_offsets.top + this.popup.getHeight()};
+
+    this.popup.select_boxes = $$(&quot;select&quot;).findAll(function(box) {
+      var box_offsets = box.cumulativeOffset();
+      var box_info = {left: box_offsets.left, top: box_offsets.top, right: box_offsets.left + box.getWidth(), bottom: box_offsets.top + box.getHeight()};
+
+      // if any of box is between tooltip left + right, and any of box is between tooltip top + bottom 
+      // and which have no visibility or visibility: &quot;visible&quot;
+      if(box_info.top &gt; tooltip_info.bottom || box_info.bottom &lt; tooltip_info.top ||
+        box_info.left &gt; tooltip_info.right || box_info.right &lt; tooltip_info.left)
+        return false;
+
+      //else
+      if(box.getStyle(&quot;visibility&quot;) == undefined || box.getStyle(&quot;visibility&quot;) == &quot;visible&quot;)
+        return true;
+    });
+
+    this.popup.select_boxes.each(function(box) {
+      box.setStyle({visibility: &quot;hidden&quot;});
+    });
+  },
+  showSelectBoxes: function() {
+    if(this.popup.select_boxes)
+      this.popup.select_boxes.each(function(box) {
+        box.setStyle({visibility: &quot;visible&quot;});
+      });
   }
 });
 Simpltry.ClickTooltip = Class.create(Simpltry.Tooltip.Base, {</diff>
      <filename>src/tooltip.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fc2f0f26439a693843373207fe2e0bb9e2145da2</id>
    </parent>
  </parents>
  <author>
    <name>Nicholas Schlueter</name>
    <email>schlueter@gmail.com</email>
  </author>
  <url>http://github.com/schlueter/simpltryjs/commit/d9e78112e9878157a1411a37fb7b63035c8122d1</url>
  <id>d9e78112e9878157a1411a37fb7b63035c8122d1</id>
  <committed-date>2008-04-04T21:59:49-07:00</committed-date>
  <authored-date>2008-04-04T21:59:49-07:00</authored-date>
  <message>in IE6 select boxes bleed through higher z layers so you need to hide conflicting select boxes</message>
  <tree>956299866eb170b23ca12ce51796cee50c68ae33</tree>
  <committer>
    <name>Nicholas Schlueter</name>
    <email>schlueter@gmail.com</email>
  </committer>
</commit>
