/* vim:set ts=2 sw=2 sts=2 ai si nu et ft=javascript ff=dos:

  Last Change: 05-April-2010 09:26:12.
  Author: Technical team.
  Copyright: (C)Anchor Group K.K.

  URL: http://www.anchor-gr.jp/labo.html
  EMAIL: info@anchor-gr.jp

  Filename: smartrollover.js

 ---------------------------------------------------------*/
var smartRolloverVersion = "1.2.2";
function smartRollover(out, on, onclass) { var auto = false; if (!out) { out = "_0"; }; if (!on) { on = "_1"; } if (typeof(onclass) == "boolean") { if (onclass === true) { auto = true; }else{ onclass = ""; } } var PATH = location.protocol + "//" + location.hostname + location.pathname; var REG_EXT = new RegExp(out + "(\.(gif|jpe?g|png))$", "i"); var REG_HTTP = new RegExp("^http"); var REG_DOCROOT = new RegExp("^[\/]"); var mouseover, mouseout; var images = document.images; var length = images.length; var attach = function(img, mouseout, mouseover) { var preload = new Image(); preload.src = mouseover; var mouseOver = function(e) { img.src = mouseover; }; var mouseOut = function(e) { img.src = mouseout; }; try { img.addEventListener('mouseover', mouseOver, false); img.addEventListener('mouseout', mouseOut, false); } catch (e) { img.attachEvent('onmouseover', mouseOver); img.attachEvent('onmouseout', mouseOut); } }; function __autoOnCheck(p) { var result = false; if (p.tagName.toLowerCase() == "a") { var href = p.getAttribute('href'); if (href != "") { href = href.replace("./", ""); if (! href.match(REG_HTTP)) { if (! href.match(REG_DOCROOT)) { href = "/" + href; } href = location.protocol + "//" + location.hostname + href; } if (href == PATH) { result = true; } } } return result; } function __manualOnCheck(obj, onclass) { if (! onclass) onclass = ""; var result = false; var cl = (obj.getAttribute('class')||obj.getAttribute('className')||"").split(" "); for (var j=0; j<cl.length; j++) { if (cl[j] == onclass) { result = true; continue; } } return result; } for (var i=0; i<length; i++) { if (images[i].src.match(REG_EXT)) { var onflag = false; if (auto) { onflag = __autoOnCheck(images[i].parentNode); }else if (typeof(onclass) == "string" && onclass != "") { onflag = __manualOnCheck(images[i], onclass); } mouseover = images[i].src.replace(REG_EXT, on + "$1"); if (! onflag) { mouseout = images[i].src; attach(images[i], mouseout, mouseover); }else{ images[i].src = mouseover; } } } } 
function smartRolloverA(out, on) { smartRollover(out, on, true); }

