/*  透過PNGで使用する透過gif　本番サーバーに引っ越したときにパスを変更する  */
var PNG_BLANK_IMAGE = '/living/common/image/spacer.gif';

/*  ロールオーバーする要素  */
var ROLL_OVER_ELMS = '#globalNav img, #utility img, #tokutoku img,#feature img,#specs img';

/*  PNGでロールオーバー画像の接頭辞  */
var SUFFIX = '_over';


$(function () {
    
	/*  ページトップボタン  */
    $('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var target = $(this.hash);
			target = target.length && target;
			if (target.length) {
				var targetOffset = target.offset().top;
				$('html,body')
					.animate({scrollTop: targetOffset}, {duration: 1000, easing: "easeOutExpo"});
				return false;
			}
		}
	});
    
    /*  ロールオーバー&透過PNG  */
    if($.browser.msie && $.browser.version<7){
    	
    	/*  IEで透過PNGを表示  */
    	$('img[src$=.png]').each(function(){
            $(this)
                .data('src',$(this).attr('src'))
                .attr('src',PNG_BLANK_IMAGE)
                .css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+$(this).data('src')+'",sizingMethod="scale")');
        });
		
		/*  ロールオーバー  */
        $(ROLL_OVER_ELMS)
            .bind({
                mouseover: function(){
					if($(this).data('src') == null) {
						if($(this).parent().attr('class').indexOf('this') == -1) $(this).attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1'+SUFFIX+'$2'));
					} else {
                    	if($(this).parent().attr('class').indexOf('this') == -1) $(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+$(this).data('src').replace(/^(.+)(\.[a-z]+)$/, '$1'+SUFFIX+'$2')+'",sizingMethod="scale")');
					}
                },
                mouseout: function(){
					if($(this).data('src') == null) {
						if($(this).parent().attr('class').indexOf('this') == -1) $(this).attr('src',$(this).attr('src').replace(/^(.+)_over(\.[a-z]+)$/, '$1$2'));
					} else {
                    	if($(this).parent().attr('class').indexOf('this') == -1) $(this).css('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+$(this).data('src')+'",sizingMethod="scale")');
					}
                }
            })
            .each(function(){
                if($(this).attr('src').indexOf('over') == -1) $('<img>').attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1'+SUFFIX+'$2'));
            });
    }else{
        $(ROLL_OVER_ELMS)
            .bind({
                mouseover:function(){
                    if($(this).parent().attr('class').indexOf('this') == -1) $(this).attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1'+SUFFIX+'$2'));
                },
                mouseout:function(){
                    if($(this).parent().attr('class').indexOf('this') == -1) $(this).attr('src',$(this).attr('src').replace(/^(.+)_over(\.[a-z]+)$/, '$1$2'));
                }
            })
            .each(function(){
                if($(this).attr('src').indexOf('over') == -1) $('<img>').attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1'+SUFFIX+'$2'));
            });
    };
	
	$('#closeBtn')
		.click(function(){
			window.close();
		});
		
	$('#merit a, ul.merit a, a.merit')
		.each(function(){
			$(this)
				.click(function(){
					window.open($(this).attr('href'),'function','width=600,height=779,menubar=yes,resizable=no,toolbar=yes,scrollbars=yes');
					return false;
				});
		});
	    
	
});
