/* smartRollover */

//smartRollOver

function smartOver() {
var bodyID = document.getElementsByTagName("body")[0].id;

wrapID = $('wrapper');
buttonID = $('button');

if (wrapID) {
	smartRollover('wrapper');	//ロールオーバーを適用させたい箇所のIDを指定
}
if (buttonID) {
	smartRollover2('buttonr');	//ロールオーバーを適用させたい箇所のIDを指定
}

}

function smartRollover(idName) {
if(document.getElementsByTagName) {
var images = document.getElementById(idName).getElementsByTagName("img");
for(var i=0; i < images.length; i++) {

if(images[i].getAttribute("src").match(/_off\./))
{
fileName = new Array(images[i].getAttribute("src").replace("_off.", "_on."));
preImages = new Array();
for (j=0; j<fileName.length; j++)
{
preImages[j] = new Image();
preImages[j].src = fileName[j];		//「_on」の画像をプリロード
}

images[i].onmouseover = function() {
this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));	//マウスオーバーで_off→_on
}
images[i].onmouseout = function() {
this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));	//マウスが離れたら_on→_off
}
}
}
}
}

function smartRollover2(idName2) {
if(document.getElementsByTagName) {
var images2 = document.getElementById(idName2).getElementsByTagName("input");
for(var ii=0; ii < images2.length; ii++) {

if(images2[ii].getAttribute("src").match(/_off\./))
{
fileName2 = new Array(images2[ii].getAttribute("src").replace("_off.", "_on."));
preImages2 = new Array();
for (jj=0; jj<fileName2.length; jj++)
{
preImages2[jj] = new Image();
preImages2[jj].src = fileName2[jj];		//「_on」の画像をプリロード
}

images2[ii].onmouseover = function() {
this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));	//マウスオーバーで_off→_on
}
images2[ii].onmouseout = function() {
this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));	//マウスが離れたら_on→_off
}
}
}
}
}

Event.observe(window, 'load', smartOver, false);