$( document ).ready( function () {
  $( '#personal a' ).click( function() {
    showToolTip(this, $(this).next());
    return true;
  });
   $( '.popup' ).click( function() {
    showToolTip($(this).prev(), this);
  });
  $("#tabs a").hover(
      function () {
        $(this).css("background-position","0% -31px");
      }, 
      function () {
        $(this).css("background-position","top left");
      }
    );
  $("#idea_tabs > ul").tabs();
 
});

function swapABg(mode) {
  if(mode == 'over') {
    //
  } else if(mode == 'out') {
    //
  }
}

function showToolTip(what,target) {
  //alert($( '.popup' ).css('display'));

  if ( $( target ).css('display') == 'block')	{
    $( '.popup' ).hide();
    if(is.ie6) {
      $('#myIFrame').hide();
    }
    $(what).children('img').attr('src','./images/btn_question.gif');
    return false;

  }	else {
    $( '.popup' ).hide();

    var offset = $( what ).offset();
    //    alert('Left: ' + offset.left + ' top:' + offset.top);
    //    alert('Left: ' + offset.left + ' top:' + offset.top);

    // do some math.
    var divWidth = $( target ).width();
    var divHeight = $( target ).height();

    var divLeft = (offset.left - divWidth);
    var divTop = (offset.top + 10);

    $( target ).css('top',divTop).css('left',divLeft);
    
    if (is.ie6) {
      var targetHeight = $(target).height() + 30;
      var targetWidth = $(target).width() + 25;
      
      var targetTop = divTop;
      var targetLeft = divLeft;
      
      $( '#myIFrame' ).show();
      $( '#myIFrame' ).css('top',targetTop).css('left',targetLeft);
      
      $( 'iframe' ).css('height', targetHeight).css('width',targetWidth);
      $( 'iframe' ).css('z-index','1000');
      $( '#myIFrame' ).css('z-index','1000');
      
    }
    $( target ).css('z-index','2000');
    $( target ).fadeIn();
    //$( what ).html('Close Tooltip');
    $( what ).children('img').attr('src','./images/btn_minus.gif');
    return false;
  }
}
function Is() {
  agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla') != -1) &&
  (agent.indexOf('spoofer') == -1) &&
  (agent.indexOf('compatible') == -1) &&
  (agent.indexOf('opera') == -1) &&
  (agent.indexOf('webtv') == -1) &&
  (agent.indexOf('hotjava') == -1));
  this.ns2 = (this.ns && (this.major == 2));
  this.ns3 = (this.ns && (this.major == 3));
  this.ns4 = (this.ns && (this.major == 4));
  this.ns6 = (this.ns && (this.major >= 5));
  this.ie = ((agent.indexOf("msie") != -1) &&
  (agent.indexOf("opera") == -1));
  this.ie3 = (this.ie && (this.major < 4));
  this.ie4 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 4") != -1));
  this.ie5 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 5.") != -1) &&
  (agent.indexOf("msie 5.5") == -1) &&
  (agent.indexOf("mac") == -1));
  this.iem5 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 5.") != -1) &&
  (agent.indexOf("mac") != -1));
  this.ie55 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 5.5") != -1));
  this.ie6 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 6.") != -1));
  this.ie7 = (this.ie && (this.major == 4) &&
  (agent.indexOf("msie 7.0b") != -1));
  this.nsdom = (this.ns4 || this.ns6);
  this.ie5dom = (this.ie5 || this.iem5 || this.ie55);
  this.iedom = (this.ie4 || this.ie5dom || this.ie6);
  this.w3dom = (this.ns6 || this.ie6 ||this.ie7);
}
var is = new Is();