//Rollover
function smartOver() {
	smartRollover('gm');
}
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.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];
				}
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}
if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

// swap
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
function initSwapImage(){
	if(!document.getElementsByTagName) return;
	var imgs = document.getElementsByTagName('img');
	for (var i=0; i<imgs.length; i++){
		if(imgs[i].className == "swap"){
			var tmp = new Image();
			tmp.src = imgs[i].src.replace('_on\.', "_off.");
			tmp.src  = imgs[i].src.replace('_off\.', "_on.");
			imgs[i].onmouseover = function(){ action(this, 1) }
			imgs[i].onmouseout  = function(){ action(this, 0) }
		}
	}
	if(!document.getElementsByTagName) return;
	var imgs = document.getElementsByTagName('input');
	for (var i=0; i<imgs.length; i++){
		if(imgs[i].className == "swap"){
			var tmp = new Image();
			tmp.src = imgs[i].src.replace('_on\.', "_off.");
			tmp.src  = imgs[i].src.replace('_off\.', "_on.");
			imgs[i].onmouseover = function(){ action(this, 1) }
			imgs[i].onmouseout  = function(){ action(this, 0) }
		}
	}
}
function action(imgObj, EventType){
	imgObj.src = (EventType) ? imgObj.src.replace('_off\.', "_on.") : imgObj.src.replace('_on\.', "_off.");
	return true;
}
addLoadEvent(initSwapImage);

