var W3CDOM = (document.createElement && document.getElementsByTagName);

var mouseOver = new Array();
var mouseOut = new Array();

var z = 0;

function init() {
	if (!W3CDOM) return;
	attachjs('menuitems');
}

function attachjs(element) {
	var menu = document.getElementById(element);
	var img = menu.getElementsByTagName('img');
	
	for (i=0; i<img.length; i++) {
		if (!img[i].src.match("_over") && !img[i].src.match("_selected") && !img[i].src.match("blank") && !img[i].src.match("seperator")) {
			img[i].onmouseover = swapon;
			img[i].onmouseout = swapoff;
			
			var suffix = img[i].src.substring(img[i].src.lastIndexOf('.'));
			mouseOut[z] = new Image();
			mouseOut[z].src = img[i].src;
			mouseOver[z] = new Image();
			mouseOver[z].src = img[i].src.substring(0,img[i].src.lastIndexOf('.')) + "_over" + suffix;
			img[i].number = z;
			z++;
		}
	}
}

function swapon() {
	this.src = mouseOver[this.number].src;
}

function swapoff() {
	this.src = mouseOut[this.number].src;
}

function replaceimg() {
	var img = document.getElementById('selected');
	
	if (img) {
		var sourc = img.src.substring(0,img.src.lastIndexOf('.')) + "_selected.png";
		alert(sourc);
		img.src = sourc;
	}
}

var helvetica= {
 src: 'gfx/helvetica.swf'
 ,ratios: [7, 1.32, 8, 1.31, 12, 1.27, 19, 1.23, 22, 1.2, 29, 1.19, 36, 1.18, 49, 1.17, 50, 1.16, 51, 1.17, 81, 1.16, 85, 1.15, 86, 1.16, 92, 1.15, 93, 1.16, 1.15]
 ,wmode: "transparent"
};


// You probably want to switch this on, but read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad> first.
// sIFR.useStyleCheck = true;
sIFR.activate(helvetica);

sIFR.replace(helvetica, {
 selector: 'h1'
 ,css: [
   '.sIFR-root { font-style: italic; font-size:28px;color: #af1f30; }'
 ]
});

sIFR.replace(helvetica, {
 selector: 'h2'
 ,css: [
   '.sIFR-root { font-style: italic; font-size:28px;color: #af1f30; }'
 ]
});

window.onload = init;
