//=====================================================================
// DOM Image Rollover v3
//=====================================================================
// copyright Chris Poole
// http://chrispoole.com
// domroll@chrispoole.com
// demo: http://chrispoole.com/scripts/dom_image_rollover/
//=====================================================================

function domRollover(imgpath)
{
	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion <7) return;
	function makeFunctions(imgarr) {
		var imgPreload=new Array();
		var imgSrc=new Array();
		var imgClass=new Array();
		for (i=0;i<imgarr.length;i++){
			if (imgarr[i].className.indexOf('domroll')!=-1){
				if (!imgarr[i].getAttribute('src')) continue;
				imgSrc[i]=imgarr[i].getAttribute('src');
				imgClass[i]=imgarr[i].className;
				imgPreload[i]=new Image();
				if (imgClass[i].match(/domroll (\S+)/)) {
					imgPreload[i].src = imgpath+imgClass[i].match(/domroll (\S+)/)[1]
				}
				imgarr[i].setAttribute('xsrc', imgSrc[i]);
				imgarr[i].onmouseover=function(){
					this.setAttribute('src',imgpath+this.className.match(/domroll (\S+)/)[1])
				}
				imgarr[i].onmouseout=function(){
					this.setAttribute('src',this.getAttribute('xsrc'))
				}
			}
		}
	}
	makeFunctions(document.getElementsByTagName('img'));
	makeFunctions(document.getElementsByTagName('input'));
}