// JavaScript Document
var imageList = new Array();
//Add this line to add image swapping
imageList.push({'def':'../gimg/cart_default.gif', 'swap':'../gimg/cart_default_02.gif'});
imageList.push({'def':'../gimg/infomail.png', 'swap':'../gimg/infomail_02.png'});
imageList.push({'def':'../gimg/gb_home.png', 'swap':'../gimg/gb_home_02.png'});
imageList.push({'def':'../gimg/gb_shopping.png', 'swap':'../gimg/gb_shopping_02.png'});
imageList.push({'def':'../gimg/gb_guide.png', 'swap':'../gimg/gb_guide_02.png'});
imageList.push({'def':'../gimg/gb_flow.png', 'swap':'../gimg/gb_flow_02.png'});
imageList.push({'def':'../gimg/gb_blog.png', 'swap':'../gimg/gb_blog_02.png'});
imageList.push({'def':'../gimg/gb_staff.png', 'swap':'../gimg/gb_staff_02.png'});
imageList.push({'def':'../gimg/gb_link.png', 'swap':'../gimg/gb_link_02.png'});
imageList.push({'def':'../gimg/gb_store.png', 'swap':'../gimg/gb_store_02.png'});
imageList.push({'def':'../gimg/gb_company.png', 'swap':'../gimg/gb_company_02.png'});
imageList.push({'def':'../gimg/gb_poli.png', 'swap':'../gimg/gb_poli_02.png'});
var imageObjs = new Array();
window.onload = function() {
	setImages();
};

function setImages() {
	var allImages = document.getElementsByTagName("img");
	for(i=0;i<imageList.length;i++) {
		var imgObj = document.createElement("img");
		imgObj.setAttribute("src", imageList[i].swap);
		for(j=0;j<allImages.length;j++) {
			if(allImages[j].getAttribute("src").indexOf(imageList[i].def, 0) != -1) {
				imageObjs.push({'def':allImages[j], 'defsrc':imageList[i].def, 'swap':imgObj, 'flag':false});
				Event.observe(allImages[j], 'mouseover', swapImage, false);
				Event.observe(allImages[j], 'mouseout', swapImage, false);
			}
		}
	}
}

function swapImage(e) {
	var target;
	if(e.target) {
		target = e.target;
	}else {
		target = event.srcElement;
	}
	for(i=0;i<imageObjs.length;i++) {
		if(target == imageObjs[i].def) {
			if(imageObjs[i].flag != true) {
				target.setAttribute("src", imageObjs[i].swap.getAttribute("src"));
				imageObjs[i].flag = true;
			}else {
				target.setAttribute("src", imageObjs[i].defsrc);
				imageObjs[i].flag = false;
			}
		}
	}
}