(function(){
    if (window['swfobject']) swfobject.registerObject("main-flash", "10.0.0.0", "expressInstall.swf");
    var preloads = [];
    var mapImage = false;
    jQuery.fn.extend({
        popup:function(){
            return $(this).each(function(){
                $(this).click(function(){
                    var size = $(this).attr('rel')?$(this).attr('rel').split('x'):[200,200];
                    window.open($(this).attr('href'), null, 'width='+size[0]+',height='+size[1]+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
                    return false;
                });
            });
        },
        rollover:function(){
            return $(this).each(function(){
                var src = $(this).attr('src');
                if (!src.match(/_on\./)) {
                    var tmp = src.split('.');
                    var ext = tmp.pop();
                    var oSrc = tmp.join('.') + '_on.' + ext;
                }
                else {
                    oSrc = src;
                }
                var img = new Image();
                img.src = oSrc;
                preloads.push(img);
                $(this).hover(
                    function(){
                        $(this).attr('src', oSrc);
                    },
                    function(){
                        $(this).attr('src', src);
                    }
                );
            });
        },
        floorMapLocator:function(){
            if (!mapImage) {
                mapImage = $('.map-image');
                $('#floor_map').css({
                    background: 'url(' + mapImage.attr('src') + ') no-repeat left top'
                }).width(mapImage.width());
                var baseMap = mapImage.attr('src');
            }
            var currentShop = false;
            return $(this).each(function(){
                var tId = $(this).is('area')?$(this).attr('rel'):$(this).attr('href').substr(1);
                var altMap = baseMap.split('_')[0]+'_'+tId+'1.jpg';
                var img = new Image();
                img.src = altMap;
                preloads.push(img);
                $(this).hoverIntent(
                    function(){
                        if (!currentShop || currentShop.attr('id') != tId) {
                            mapImage.stop().attr('src', altMap).fadeTo(0, 0).fadeTo(300, 1);
                            if (currentShop) currentShop.hide();
                            currentShop = $('#' + tId);
                            currentShop.show().fadeTo(0, 0).fadeTo(300, 1);
                        }
                    },
                    function(){
                    }
                ).click(function(){
                    location.href = $('#'+tId+" a").attr('href');
                    return false
                });
            });
        },
		flip:function(){
			return $(this).each(function(){
				$(this).mouseover(function(){
					var src = $(this).children('img').attr('src').replace(/_thumb/, '_img');
					$('.shop1_left1 .hw1 img').attr('src', src);
					return false;
				});
			});
		}
    });
    jQuery(function($){
        $('.floor_right').hide();
        $('a.popup').popup();
        $('img.rollover').rollover();
        $('area,#floor_left a').floorMapLocator();
        $('<span id="flash-overlay-bg"></span>').appendTo('#flash').fadeTo(0,0.7);
        $('#floor_hw1 a').click(function(){
            location.href='/genre.html';
            return false;
        });
		$('.shop1_thumb a').flip();
    	$('.selector-target').children().css('display','none');
    	$('.genre-selector a').click(function() {
                    $('.selector-target').children().css('display', 'none');
                    $($(this).attr('href')).fadeIn();
                    return false;
    	});
        if (location.pathname == '/genre.html') {
            $(location.hash).fadeIn();
        }
    });
})();
