/** * * Copyright (C) 2005 Matsuda Shota * http://sgssweb.com/ * sgss@mac.com * * ------------------------------------------------------------------------ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ------------------------------------------------------------------------ */ /* 2005-4-23 - Event are no longer automatically assigned 2005-4-23 - Now many replacements can be set. 2005-4-17 - Packaged. */ /** * @param object obj */ function RolloverController_activate(obj) { if(RolloverController_validate(obj)) { obj.src = obj.activeimg.src; } } /** * @param object obj */ function RolloverController_inactivate(obj) { if(RolloverController_validate(obj)) { obj.src = obj.initsrc; } } function RolloverController_validate(obj) { return (obj.initsrc != undefined && obj.activeimg != undefined && obj.activeimg.src != undefined)? true : false; } /** * @param object obj * @param string regexp * @param string replacement */ function RolloverController_preloadImages(obj, regexp, replacement) { //avoid duplication of preload obj.onload = function() {}; //store initial image src obj.initsrc = obj.src; //preload var replaced_str = obj.src; for(var i = 1; i < arguments.length - 1; i += 2) { replaced_str = replaced_str.replace(arguments[i], arguments[i + 1]); } obj.activeimg = new Image(); obj.activeimg.src = replaced_str; } function RolloverController() { } RolloverController.prototype.load = RolloverController_preloadImages; RolloverController.prototype.activate = RolloverController_activate; RolloverController.prototype.inactivate = RolloverController_inactivate;