/* ---

R-co.ltd
jquery1.4 common file.

--------------------------------------- */

/* ---
flash 
--------------------------------------- */

$(document).ready(function(){

	// table hover background color change.
	$(function(){
		$('.basicTable table tbody tr').hover(function(){
			$(this).addClass("select");
		},function(){
			$(this).removeClass("select");
		});
	});

	// open new window.
	$(function() {
		$('a[href^="http://"]').not('a[href^="http://jigsaw.w3.org/"]').not('a[href^="http://validator.w3.org/"]').click(function() {
			if (!(location.hostname == this.hostname)) {
				this.target = "_blank";
				//window.open(this.href, '');
				//return false;
			}
		});
		$('a[href^="../pdf"]').click(function() {
			window.open(this.href, '');
			return false;
		});
		$('a[href^="pdf/"]').click(function() {
			window.open(this.href, '');
			return false;
		});
		$('a[href^="../blog"]').click(function() {
			window.open(this.href, '');
			return false;
		});
		$('a[href^="blog/"]').click(function() {
			window.open(this.href, '');
			return false;
		});
		$('a[href^="../nzoom"]').click(function() {
			window.open(this.href, '');
			return false;
		});
	});

	// easing
	$(function() {
		$('area[href*=#], a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
				var target = $(this.hash);
				target = target.length && target;

				//もし、class="select"があれば削除、リンク先の要素にclass="select"を入れる
				if( $('#serviceStationList div ol li').hasClass("select") ) {
					$('#serviceStationList div ol li').removeClass("select");
				}
				$(target).addClass("select");

				if (target.length) {
					var sclpos = 24;	//スクロール後のtopからの距離　初期値：30
					var scldurat = 2400;	//スクロールスピードの調整ミリ秒　初期値：1200
					var targetOffset = target.offset().top - sclpos;
					//$('html,body')
					$($.browser.opera ? $.support.boxModel == false ? 'body' : 'html' :'html,body')
						//.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
						.animate({scrollTop: targetOffset});
					return false;
				}
			}
		});
	});

	// web catalog image change
	$(document).ready(function(){
		$(function(){
			$(".catNavi li").click(function(){
				if( $('.catNavi li').hasClass("select") ) {
					$('.catNavi li').removeClass("select");
				}
				$(this).addClass("select")
				
				$("#main img").attr("src",$(".catNavi li.select a").attr("href"));
				return false;
			});
		});
	});
	
	//メニューの高さをそろえる
    $(function() {
        var tallest = 0;
        var thisheight = 0;
        $(".AutoHeight>li>div").each(function() {
            thisheight = $(this).height();
            if(thisheight > tallest){
                tallest = thisheight;
            }
        });
        $(".AutoHeight>li>div").height(tallest);
    });

});
