');
var imgDiv = jQuery('
');
colaTooltip.append(imgDiv)
var tooltipHeader = jQuery('
');
colaTooltip.append(tooltipHeader)
colaTooltip.mouseout(function(ev) {
// the mouseout event seems to be semi-unstable embedded
//colaTooltip.hide();
});
jQuery('body').append(colaTooltip);
};
// add a mouseover to each of the amazon links
function colaEventHandlers() {
var anchors = document.links;
for (var i= 0; i < anchors.length; i++) {
// check each of the links for anchor text that has a
// valid ISBN number (i.e. is a book)
//TODO use bn.com and other book store links
//TODO create better ISBN regex (with 9 or 10 digits, dashes, etc)
//TODO make sure the ISBN is normalized into a 10 digit colapub ISBN
var matched = anchors[i].href.match(/amazon\.com.*(\d{10})/)
if (matched != null && matched.length == 2) {
var isbn = matched[1];
// add the isbn to the anchor
jQuery.data(anchors[i],"isbn", isbn)
jQuery(anchors[i]).mouseover(function(ev) {
jQuery(anchors[i]).css('opacity','0.2');
// since the mouseout handlers are so wonky in jquery 1.2 check the offset before re-showing the div
if (jQuery("#cola-tooltip").css('display') == 'none' ||
(Math.abs(parseInt(jQuery('#cola-tooltip').css('top'))-ev.pageY) > 40) ||
(Math.abs(parseInt(jQuery('#cola-tooltip').css('left'))-ev.pageX) > 100)) {
jQuery('#cola-tooltip').css({'top':ev.pageY-10,'left':ev.pageX-5}).show();
}
colaFillTooltip(jQuery.data(this,"isbn"));
}).mouseout(function(ev) {
jQuery(anchors[i]).css("opacity",'1.0');
});
}
}
}
function colaFillTooltip(isbn) {
//TODO use image webservice
// image http://www.syndetics.com/index.aspx?client=claplib&type=xw12&upc=&oclc=&isbn=1565922824/LC.GIF
//TODO:
// use isbndb for better flavor text (e.g. title, desc, etc.)
jQuery("#cola-tooltip img").attr("src","http://catalog.colapl.org/WebCat_Images/English/Other/MiscD/LOGO.jpg");
var colaURL = "http://catalog.colapl.org/uhtbin/cgisirsi/x/0/0/5?search_type=search&library=ALL&searchdata1="+isbn;
jQuery("#cola-tooltip a").attr('href', colaURL)
}
colaCreateTooltip();
colaEventHandlers();