/**
 *	@filename		lib.js
 *	@charset		utf-8
 *	@created		Augst 21, 2009
 *	@lastmodified	Augst 21, 2009
 *	@description	共通js
 */
(function(){



//
//	スクロール用
//
var moveObject = function(){
	var y = document.body.scrollTop || document.documentElement.scrollTop;
	var target = Math.max(Math.floor(y - (y / 8)));
	scrollTo(0, target);
	if(target > 0){
		setTimeout(moveObject,10);
	}
};



//
//	IE用objectタグ関係
//
var removeData = function(obj){
	var data = obj.getAttribute("data");
	if(data){
		obj.removeAttribute("data");
	}
};



//
//	リンクの点線を消す
//
var disableLinkOutline = function() {
	$(document.links).each(function(){
		$(this).focus(function(){
			this.blur();
		});
	});
};



////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	DOM読み込み完了後に実行
//
////////////////////////////////////////////////////////////////////////////////////////////////////
$(function(){



//
//	このページの先頭へボタン動作
//
$(".anchorTop a").click(function(){
	moveObject();
	return false;
});
$("#anchorTop a").click(function(){
	moveObject();
	return false;
});


//
//	リンクの点線を消す
//
disableLinkOutline();



//
//	ポップアップリンク用
//
$(".popup").click(function(){
	var url = this.href;
	if(url){
		var win = window.open(url);
		win.focus();
	}
	return false;
});


//
//バナー画像のマウスオーバー処理
//
$(".banners a").hover(function(){
							$(this).css({"width":$("img",this).attr("width"),"height":$("img",this).attr("height"),"display":"block","background-color":"#ffffff"});
							$("img",this).fadeTo(100,0.5);
						},
						function(){
							$("img",this).fadeTo(100,1);
						});



//
//	mainContent内の一番先頭のsectionContent内における先頭の子要素の上余白をトル
//
$("div#mainContent div.section:first div.sectionContent").each(function(){
	$("h2:first-child",this).addClass("firstChild");
});


//
//	店舗写真に影を付ける
//
if($("body#shop").length!=0){
	$("body#shop div.sectionContent img.shadow").wrap("<span class=\"shadow\"><span></span></span>");
}

//
//	ul.twoColList liの偶数番目にclass="even"を付与
//
$("ul.twoColList li:odd").addClass("even");


//
//	ul.twoColList liの高さ調整
//
if($("body#maintenance").length!=0){
	ajustLiHeight();
	
	var prevHeight = $("div#mainContent").height();
	
	setInterval(ajustLiHeight,100);
	
	$(window).unload(function(){
		clearInterval(ajustLiHeight);
	});
}

function ajustLiHeight(){
	curHeight = $("div#mainContent").height();
	
	if(curHeight != prevHeight){
		$("ul.twoColList li:even").each(function(){
			var next = $(this).next();
			$(this).height("auto");
			$(next).height("auto");
			
			var height1 = $(this).height();
			var height2 = $(next).height();
			
			var maxHeight = function(){
				if(height1 > height2){
					return height1;	
				}else{
					return height2;
				}
			}();
			
			var b = jQuery.browser;
			var v = jQuery.browser.version;
			var padding = function(){
				if(b.msie&&v=="6.0"){
					return 10;
				}else if(b.msie&&v=="8.0"){
					return 0;
				}else{
					return 0;
				}
			}();
			
			$(this).height(maxHeight + padding);
			$(next).height(maxHeight + padding);
		});
	}
	prevHeight = curHeight;
}


});
////////////////////////////////////////////////////////////////////////////////////////////////////



})();
