/*
 * jQuery Hoverbox 1.0
 * http://koteako.com/hoverbox/
 *
 * Copyright (c) 2009 Eugeniy Kalinin
 * Dual licensed under the MIT and GPL licenses.
 * http://koteako.com/hoverbox/license/
 */
jQuery.fn.hoverbox = function(options) {
    var settings = jQuery.extend({
        id: 'tooltip',
        top: 190,
        left: -75
    }, options);

    var handle;

    function tooltip(event) {
        if ( ! handle) {
            // Create an empty div to hold the tooltip
            handle = $('<div style="position:absolute" id="'+settings.id+'"></div>').appendTo(document.body).hide();
        }

        if (event) {
            // Make the tooltip follow a cursor
            handle.css({
                top: (event.pageY - settings.top) + "px",
                left: (event.pageX + settings.left) + "px"
            });
        }

        return handle;
    }

    this.each(function() {
        $(this).hover(
            function(e) {
                if (this.title) {
                    // Remove default browser tooltips
                    this.t = this.title;
                    this.title = '';
                    this.alt = '';

                    tooltip(e).html(this.t).fadeIn('fast');
                }
            },
            function() {
                if (this.t) {
                    this.title = this.t;
                    tooltip().hide();
                }
            }
        );

        $(this).mousemove(tooltip);
    });
};
$(function(){
    $('.tip').hoverbox();
});






// zoomi - A zoom for images ~ Sean Catchpole - Version 0.9 stolen from http://www.sunsean.com/zoomi/
(function($){

$.fn.zoomi = function() {
  $(this).filter("img").each(function(){
    if(!this.z) {
      $(this).zoom1().mouseover(function(){$(this).zoom2().show();});
      $(this.z).mouseout(function(){$(this).hide();}); }
  });
 return this;
}

$.fn.zoom1 = function() {
  $(this).each(function(){
    var e = this;
    $(e).css({'position':'relative','z-index':'8'}).after('<img class="'+e.className+'">');
    e.z = e.nextSibling;
    //$(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.alt || e.src)
    $(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.src)
    .css({'position':'absolute','z-index':'10'});
    $(e.z).hide();
  });
  return this;
}

$.fn.zoom2 = function() {
  var s = [];
  this.each(function(){
    var e = this;
    if(!e.z) e = $(e).zoom1()[0]; s.push(e.z);
    if(!e.z.complete) return;
    if(!e.z.width) { $(e.z).show(); e.z.width=e.z.width; $(e.z).hide(); }
    $(e.z).css({left:$(e).offsetLeft()-(e.z.width-e.scrollWidth)/2+'px',
    top:$(e).offsetTop()-(e.z.height-e.scrollHeight)/2+'px'});
  });
  return this.pushStack(s);
}

$.fn.offsetLeft = function() {
  var e = this[0];
  if(!e.offsetParent) return e.offsetLeft;
  return e.offsetLeft + $(e.offsetParent).offsetLeft(); }

$.fn.offsetTop = function() {
  var e = this[0];
  if(!e.offsetParent) return e.offsetTop;
  return e.offsetTop + $(e.offsetParent).offsetTop(); }

$(function(){ $('img.zoomi').zoomi(); });

})(jQuery);
