/**
 * Copyright Notice
 * This file contains proprietary information of Valspar Corporation
 * Copying or reproduction without prior written approval is prohibited.
 * Copyright (c) 2007
 *
 */



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// initialize all the functions
//addLoadEvent();
addLoadEvent(function() {
/* more code to run on page load */
initButtonRollovers('input');
initButtonRollovers('img');
});



// set and preload the button 'on' state images
function initButtonRollovers(el) {
	if (!document.getElementsByTagName) return;

	var oPreLoad = new Array();
	var oTempSrc;
	var obj = document.getElementsByTagName(el);

	for (var i = 0; i < obj.length; i++) {
		// only look for elements with class of 'rollover'
		if (obj[i].className == 'rollover') {
			// get the image source
			var src = obj[i].getAttribute('src');
			// get the over state by replacing 'off' with 'on'
			var osrc = src.replace(/_off(\.[a-z0-9]+)$/i,'_on$1');

			obj[i].setAttribute('osrc', osrc);

			// preload 'on' state images
			oPreLoad[i] = new Image();
			oPreLoad[i].src = osrc;

			// set image to on state
			obj[i].onmouseover = function() {
				oTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('osrc'));
			}

			// set image to off state
			obj[i].onmouseout = function() {
				if (!oTempSrc) oTempSrc = this.getAttribute('src').replace(/-on(\.[a-z0-9]+)$/i,'_off$1');
				this.setAttribute('src', oTempSrc);
			}
		}
	}
}

