var imagesNormal = new Object();
var imagesHilite = new Object();
function SwapImage (name,normalSrc,hiliteSrc) {
   this.name = name;
   this.normalSrc = normalSrc;
   this.hiliteSrc = hiliteSrc;
}
function setupSwapImages(swapImages) {
    preloadSwapImages(swapImages);
    setupSwapEvent(swapImages);
}


function preloadSwapImages (a) {
    for (var i=0; i < a.length; i++){
        imagesNormal[a[i].name] = new Image();
        imagesNormal[a[i].name].src = a[i].normalSrc;
        imagesHilite[a[i].name] = new Image();
        imagesHilite[a[i].name].src = a[i].hiliteSrc;
    }
}
function setupSwapEvent (a) {
    for (var i=0; i<a.length; i++){
        var images = getElementsByClass(a[i].name);
        for (var j=0; j<images.length; j++){
            var image = images[j];
            if (image.getAttribute("src")){
               image.onmouseover = function () {swapImage( this, "hilite" );}
               image.onmouseout  = function () {swapImage( this, "normal" );}
            }
        }
    }
}
function swapImage(image,type){
    if (type=="hilite") {
       image.src = imagesHilite[image.className].src;
    } else if (type=="normal") {
       image.src = imagesNormal[image.className].src;
    }
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

var swapImages = [new SwapImage('cart','/design/tigre/common/header_cart.gif','/design/tigre/common/header_cart2.gif'),new SwapImage('mypage','/design/tigre/common/header_mypage.gif','/design/tigre/common/header_mypage2.gif'),new SwapImage('help','/design/tigre/common/header_help.gif','/design/tigre/common/header_help2.gif'),new SwapImage('regi','/design/tigre/common/header_regi.gif','/design/tigre/common/header_regi2.gif'),new SwapImage('login','/design/tigre/common/header_login.gif','/design/tigre/common/header_login2.gif'),new SwapImage('tops','/design/tigre/common/left_tops.gif','/design/tigre/common/left_tops2.gif'),new SwapImage('tshirts','/design/tigre/common/left_tshirts.gif','/design/tigre/common/left_tshirts2.gif'),new SwapImage('longtshirts','/design/tigre/common/left_longtshirts.gif','/design/tigre/common/left_longtshirts2.gif'),new SwapImage('shirts','/design/tigre/common/left_shirts.gif','/design/tigre/common/left_shirts2.gif'),new SwapImage('parka','/design/tigre/common/left_parka.gif','/design/tigre/common/left_parka2.gif'),new SwapImage('outer','/design/tigre/common/left_outer.gif','/design/tigre/common/left_outer2.gif'),new SwapImage('bottoms','/design/tigre/common/left_bottoms.gif','/design/tigre/common/left_bottoms2.gif'),new SwapImage('other','/design/tigre/common/left_other.gif','/design/tigre/common/left_other2.gif'),new SwapImage('pants','/design/tigre/common/left_pants.gif','/design/tigre/common/left_pants2.gif'),new SwapImage('accessories','/design/tigre/common/left_accessories.gif','/design/tigre/common/left_accessories2.gif'),new SwapImage('bag','/design/tigre/common/left_bag.gif','/design/tigre/common/left_bag2.gif'),new SwapImage('wallet','/design/tigre/common/left_wallet.gif','/design/tigre/common/left_wallet2.gif'),new SwapImage('accessoriessub','/design/tigre/common/left_accessoriessub.gif','/design/tigre/common/left_accessoriessub2.gif'),new SwapImage('cap','/design/tigre/common/left_cap.gif','/design/tigre/common/left_cap2.gif'),new SwapImage('mens','/design/tigre/common/left_mens.gif','/design/tigre/common/left_mens2.gif'),new SwapImage('ladies','/design/tigre/common/left_ladies.gif','/design/tigre/common/left_ladies2.gif'),new SwapImage('tigre','/design/tigre/common/left_tigre.gif','/design/tigre/common/left_tigre2.gif'),new SwapImage('reserveditems','/design/tigre/common/left_reserveditems.gif','/design/tigre/common/left_reserveditems2.gif'),new SwapImage('hustle','/design/tigre/common/left_hustle.gif','/design/tigre/common/left_hustle2.gif'),new SwapImage('addtocart','/design/tigre/common/detail_addtocart.gif','/design/tigre/common/detail_addtocart2.gif'),new SwapImage('reservation','/design/tigre/common/detail_reservation.gif','/design/tigre/common/detail_reservation2.gif'),new SwapImage('cart_order','/design/tigre/common/cart_order.gif','/design/tigre/common/cart_order2.gif'),new SwapImage('cart_shopping','/design/tigre/common/cart_shopping.gif','/design/tigre/common/cart_shopping2.gif'),new SwapImage('member_agree','/design/tigre/common/member_agree.gif','/design/tigre/common/member_agree2.gif'),new SwapImage('member_disagree','/design/tigre/common/member_disagree.gif','/design/tigre/common/member_disagree2.gif'),new SwapImage('member_submit','/design/tigre/common/member_submit.gif','/design/tigre/common/member_submit2.gif'),new SwapImage('member_kakunin','/design/tigre/common/member_kakunin.gif','/design/tigre/common/member_kakunin2.gif'),new SwapImage('member_passwords','/design/tigre/common/member_passwords.gif','/design/tigre/common/member_passwords2.gif'),new SwapImage('member_ordercheck','/design/tigre/common/member_ordercheck.gif','/design/tigre/common/member_ordercheck2.gif'),new SwapImage('nonmember_order','/design/tigre/common/nonmember_order.gif','/design/tigre/common/nonmember_order2.gif'),new SwapImage('member_login','/design/tigre/common/member_login.gif','/design/tigre/common/member_login2.gif'),new SwapImage('member_regi','/design/tigre/common/member_regi.gif','/design/tigre/common/member_regi2.gif'),new SwapImage('ladies_tlink','/design/tigre/common/ladies_tlink.gif','/design/tigre/common/ladies_tlink2.gif'),new SwapImage('mens_tlink','/design/tigre/common/mens_tlink.gif','/design/tigre/common/mens_tlink2.gif')];
window.onload = function () {setupSwapImages(swapImages);};