//but script behind the body
var W3CDOM = (document.createElement && document.getElementsByTagName);

var mouseOvers = new Array();
var mouseOuts = new Array();



function mouseGoesOver()
{
	  if (typeof mouseOvers != 'undefined' && mouseOvers.length > 0) this.src = mouseOvers[this.number].src;
}

function mouseGoesOut()
{
	 if (typeof mouseOuts != 'undefined' && mouseOuts.length > 0) this.src = mouseOuts[this.number].src;
}


function init()
{
	if (!W3CDOM) return;
	var imgs = document.getElementsByTagName('img');
	for (var i=0;i<imgs.length;i++)
	{
		if (imgs[i].id.indexOf("mo_") == 0 ) //img should have an id starting with mo_
		{
			imgs[i].onmouseover = mouseGoesOver;
			imgs[i].onmouseout = mouseGoesOut;
			var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
			mouseOuts[i] = new Image();
			mouseOuts[i].src = imgs[i].src;
			mouseOvers[i] = new Image();
			if (imgs[i].src.lastIndexOf("_o")+2 == imgs[i].src.lastIndexOf('.') || imgs[i].src.lastIndexOf("_s")+2 == imgs[i].src.lastIndexOf('.')  )
			{
				mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')-2) + "_o" + suffix;
			}
			else
			{
				mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "_o" + suffix;
			}
			imgs[i].number = i;
		}
	}
}


addLoadEvent(function() {
    init();
})

