$(document).ready(function() { function isset () { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: FremyCompany // + improved by: Onno Marsman var a=arguments, l=a.length, i=0; if (l===0) { throw new Error('Empty isset'); } while (i!==l) { if (typeof(a[i])=='undefined' || a[i]===null) { return false; } else { i++; } } return true; } var curr = ''; $(".rollover").hover( function() { curr = $(this).attr('src'); ext = curr.substr(curr.lastIndexOf('.'),4); overlen = curr.length; over = curr.substr(0, overlen-4); over = over+'_o'+ext; $(this).attr({ src: over}); }, function() { if (isset(curr)) { $(this).attr({ src: curr}); } } ); $(".rollover").each(function(i) { temp = this.src; ext = temp.substr(temp.lastIndexOf('.'),4); prelen = temp.length; pre = temp.substr(0, prelen-4); pre = pre+'_o'+ext; preload_image_object = new Image(); preload_image_object.src = pre; }); $('.alt_rollover').each(function() { var over = $(this).attr('longdesc'); preload_image_object = new Image(); preload_image_object.src = over; }); $(".alt_rollover").hover( function() { curr = $(this).attr('src'); var over = $(this).attr('longdesc'); $(this).attr({ src: over}); }, function() { if (isset(curr)) { $(this).attr({ src: curr}); } } ); });