/*======================================================================
ドロップダウン
======================================================================
*/

$(function(){
  $("ul#submenu").hide();
  $("ul#gnavi > li").hover(function(){
        $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(0);
		},
		function(){  
        $(this).find('ul:first').css({visibility: "hidden"});  
        });  
});


/*
======================================================================
	$.changeLetterSize.addHandler(func)
	文字の大きさが変化した時に実行する処理を追加
======================================================================
*/

jQuery.changeLetterSize = {
	handlers : [],
	interval : 1000,
	currentSize: 0
};

(function($) {

	var self = $.changeLetterSize;

	/* 文字の大きさを確認するためのins要素 */
	var ins = $('<ins>M</ins>').css({
		display: 'block',
		visibility: 'hidden',
		position: 'absolute',
		padding: '0',
		top: '0'
	});

	/* 文字の大きさが変わったか */
	var isChanged = function() {
		ins.appendTo('body');
		var size = ins[0].offsetHeight;
		ins.remove();
		if (self.currentSize == size) return false;
		self.currentSize = size;
		return true;
	};

	/* 文書を読み込んだ時点で
	   文字の大きさを確認しておく */
	$(isChanged);

	/* 文字の大きさが変わっていたら、
	   handlers中の関数を順に実行 */
	var observer = function() {
		if (!isChanged()) return;
		$.each(self.handlers, function(i, handler) {
			handler();
		});
	};

	/* ハンドラを登録し、
	   最初の登録であれば、定期処理を開始 */
	self.addHandler = function(func) {
		self.handlers.push(func);
		if (self.handlers.length == 1) {
			setInterval(observer, self.interval);
		}
	};

})(jQuery);

/*
======================================================================
	$(expr).flatHeights()
	$(expr)で選択した複数の要素について、それぞれ高さを
	一番高いものに揃える
======================================================================
*/

(function($) {

	/* 対象となる要素群の集合 */
	var sets = [];

	/* 高さ揃えの処理本体 */
	var flatHeights = function(set) {
		var maxHeight = 0;
		set.each(function(){
			var height = this.offsetHeight;
			if (height > maxHeight) maxHeight = height;
		});
		set.css('height', maxHeight + 'px');
	};

	/* 要素群の高さを揃え、setsに追加 */
	jQuery.fn.flatHeights = function() {
		if (this.length > 1) {
			flatHeights(this);
			sets.push(this);
		}
		return this;
	};

	/* 高さ揃えを再実行する処理 */
	var reflatting = function() {
		$.each(sets, function() {
			this.height('auto');
			flatHeights(this);
		});
	};

	/* 文字の大きさが変わった時に高さ揃えを再実行 */
	$.changeLetterSize.addHandler(reflatting);

	/* ウィンドウの大きさが変わった時に高さ揃えを再実行 */
	$(window).resize(reflatting);

})(jQuery);

$(function(){
    $('#top ul#service li dl dd > .txt').flatHeights();
});




/*　トップ
===========================================*/
$(function(){
	$("body#top dl#concept dd ul li:last-child").css("margin-right", "0")
});

$(function(){
	$("body#top ul#service li:last-child").css("margin-right", "0")
});

$(function(){
	$("body#top #main #news ul li:last-child").css("margin-bottom", "0")
});

/*　会社概要
===========================================*/

$(function(){
	$(".table tr td:odd").css("background", "#f6f6f6")
});

/*　午前中チャーター便
===========================================*/

$(function(){
	$(".chaterprice tr:even td").css("background", "#f6f6f6")
});

/*　配車代行サービス
===========================================*/

$(function(){
	$("ul#agencyflow li:last-child").css("padding-right", "0px")
});
