/**
 * @name main.js
 * @fileOverview
 * @version 1.0
 * @description
 * <p>(c) FOURDIGIT Inc. Licensed <a href="http://ja.wikipedia.org/wiki/GNU_General_Public_License">GNU General Public License</a>.</p>
 */
//他ライブラリと共存する場合、下の一行削除($無効化)
//jQuery.noConflict();
(function($){
	var config = function () {
	//bodyのクラスにブラウザ情報を追加
		$.addClassUA();
	//easyOverのターゲット設定
		$("img.ahover, .ahoverArea img, #searchBt, .RFBtn").easyOver();
	//IE5,6にてPNG有効化 (pngfixの読み込みが必要)
		$("img[src$=png],p.png, #RFBody").enablePNG();
	//Flash
		//$("object, embed").enableFlash();
	//ポップアップリンクに置換
		$(".commonPop").easyPop();
	//アンカーリンクをスムージング
		$("a[href^=#][class!='tab']").smoothScroll();
	//他ドメインリンク時にpageTracker有効化
		//$("a,area").blankLogToGoogle();
	//対象の要素をスクロールに追従するようにする
		//$("#fixBox").fixPosition("stopperID","normal");
	}
	
	//shadowbox
	Shadowbox.loadSkin('classic', '/common/js/shadowbox/skin');
	Shadowbox.loadLanguage('en', '/common/js/shadowbox/lang');
	Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '/common/js/shadowbox/player');

	//onload 追記
	$(function() {
		config();
		switch (jQuery(".page").attr("id")) {
			case "index":
				$('#topPlan dl').autoHeight({column:2});
				//TOP最新情報タブ
				$('#topInfo').each(function(){
					$('#infoTab a.tab:first').addClass('current');
					$('.infoList').hide();
					$('.infoList:first').show();
					$('#infoTab a.tab').click(function(){
						var tabAnc = $(this).attr('href');
						$('#infoTab a.tab').removeClass('current');
						$(this).addClass('current');
						$('.infoList').hide();
						$(tabAnc).show();
						return false;
					});
				});
			break;
		}
		//Language選択
		$('select#selectLanguage').change(function(){
			if(this.value != ""){
				window.open(this.value);
			}
		});
		//Google検索
		$('input#searchText').val('サイト内検索').css("color", "#999");
		$('input#searchText').focus(function(){
			if(this.value == 'サイト内検索'){
				$(this).val("").css("color", "#000");
			}
		});
		$('input#searchText').blur(function(){
			if(this.value == ''){
				$(this).val('サイト内検索').css("color", "#999");
			}
		});
		$('.tableStyle').each(function(){
			$('.tableStyle tr:odd').addClass('odd');
		});
		$('#searchBt').click(function(){
			$('#hdrSearch').submit();
		});
		//ssNav
		$('.ssNav').each(function(){
			$(this).find('li:first').addClass('firstChild');
		});
		//indexList
		$('.indexList').each(function(){
			$(this).find('dd').autoHeight({column:2});
		});
		//indexList
		$('.planList').each(function(){
			$(this).find('dl').autoHeight({column:2});
			$(this).find('dl:odd').css('margin-left', '20px');
		});
		//shadowbox
		Shadowbox.init({});
		$('a.photoLink').each(function(){
			$(this).width($(this).find('img').width()+2);
			$(this).append('<img src="/common/imgs/icon-photo.gif" style="position:absolute;right:0;bottom:0;" />');
			$(this).hover(
				function(){
					$(this).css("opacity",0.6);
				},
				function(){
					$(this).css("opacity",1);
				}
			);
		});
		//fairGallery
		$('#fairGallery').each(function(){
			$(this).find('li').autoHeight({column:3});
		});
		//foodGallery
		$('#foodGallery').each(function(){
			$('#galleryNav a').click(function(){
				$('#galleryNav a').removeClass('current');
				$(this).addClass('current');
				$('#mainGallery').hide().attr("src", $(this).attr("href")).fadeIn();
				return false;
			});
		});
	});

})(jQuery);
