
jQuery(document).ready(function($){

	//------------------------------------------------------------
	// グローバルサブナビゲーションの制御
	//------------------------------------------------------------
	//不具合がある為
	//ドロップシャドウエフェクトはIE6以外で付ける事とする。
	
	$(".subNavi").css("opacity","0.9");
	
	$("ul.subNavi:empty").remove();
	//サブナビ中に現在見ているページがある場合の処理
	$(".subNavi:has(.current)").show();
	if ( !$.browser.msie ) {
		$(".subNavi:has(.current)").removeShadow().dropShadow({left:0, top:2, blur:2, opacity:0.5 ,color: "black"});
	}
	var timerId;
	timerId = setTimeout(function(){
		$(".subNavi:has(.current)").hide("fast");
		if ( !$.browser.msie ) {
			$(".subNavi:has(.current)").removeShadow();
		}
	},1500);
	
	//基本的なサブナビの表示制御
	$("#gNavi .inner > ul > li").hover(function(){
		clearTimeout(timerId); //タイマー解除
		var id = $(this).attr("id").replace("gNavi","");
		$("#subNavi" + id).show();
		if ( !$.browser.msie ) { 
			$("#subNavi" + id).removeShadow().dropShadow({left:0, top:2, blur:2, opacity:0.5 ,color: "black"});
		}
	},function(){
	
		var id = $(this).attr("id").replace("gNavi","");
		$("#subNavi" + id).hide();
		if ( !$.browser.msie ) {
			$("#subNavi" + id).removeShadow();
		}
	});
	
	
	
	//------------------------------------------------------------
	// ヘッダーサブナビゲーションの制御
	//------------------------------------------------------------
	//不具合がある為
	//ドロップシャドウエフェクトはIE6以外で付ける事とする。
	
	$("ul.hSubNavi:empty").remove();
	//サブナビ中に現在見ているページがある場合の処理
	$(".hSubNavi:has(.current)").show();
	if ( !$.browser.msie ) {
		$(".hSubNavi:has(.current)").dropShadow({left:0, top:2, blur:2, opacity:0.5 ,color: "black"});
	}
	
	var hTimerId
	hTimerId = setTimeout(function(){
		$(".hSubNavi:has(.current)").hide("fast");
		if ( !$.browser.msie ) {
			$(".hSubNavi:has(.current)").removeShadow();
		}
	},1500);
	
	//基本的なサブナビの表示制御
	$("#headerNavi > ul > li").hover(function(){

		clearTimeout(hTimerId); //タイマー解除
		var id = $(this).attr("id").replace("headerNavi","");
		$("#hSubNavi" + id).show();
		if ( !$.browser.msie ) { 
			$("#hSubNavi" + id).dropShadow({left:0, top:2, blur:2, opacity:0.5 ,color: "black"});
		}
		
	},function(){
		var id = $(this).attr("id").replace("headerNavi","");
		$("#hSubNavi" + id).hide();
		if ( !$.browser.msie ) {
			$("#hSubNavi" + id).removeShadow();
		}
	});
	
	
	
	//------------------------------------------------------------
	// サブナビゲーション全開／全閉
	//------------------------------------------------------------
	$("#subNaviToggle").toggle(function(){
		$("#headerNavi > ul > li, #gNavi .inner > ul > li").each(function(){
			$(this).trigger("mouseover");
		});
	},function(){
		$("#headerNavi > ul > li, #gNavi .inner > ul > li").each(function(){
			$(this).trigger("mouseout");
		});
	});
	
	
	//------------------------------------------------------------
	// カテゴリ内ウェブページ一覧の表示
	//------------------------------------------------------------
	//$("#contentsArea").append( $("#sideNavi") );
	
	
	
	
	//------------------------------------------------------------
	// 画像の疑似ロールオーバー処理
	//------------------------------------------------------------
	$("#header a img, #gNavi img a, #sideArea a img, #newsHead a img, #footerNavi a img, #gNavi a img").hover(
		function () {
			$(this).css("opacity","0.6");
		},
		function () {
			$(this).animate({"opacity":"1"}, "fast");
		}
	);
	
	//------------------------------------------------------------
	// 子ページ閲覧時、親ページのグローバルナビゲーション画像をON
	//------------------------------------------------------------
	if ( $("#sideNavi h2 a").attr("href") ) {
	
		//gNaviの画像をON
		var gNaviParentUrl = $("img", "#gNavi a[href='" + $("#sideNavi h2 a").attr("href") + "']").attr("src");
		if ( gNaviParentUrl != null ) {
			//alert( parentUrl );
			var replaceUrl = gNaviParentUrl.replace(".","_on.");
			var replaceUrl = replaceUrl.replace("_on_on.","_on.");
			$("img", "#gNavi a[href='" + $("#sideNavi h2 a").attr("href") + "']").attr("src", replaceUrl );
		}
		
		//headerNaviの画像をON
		var headerNaviParentUrl = $("img", "#headerNavi a[href='" + $("#sideNavi h2 a").attr("href") + "']").attr("src");
		if ( headerNaviParentUrl != null ) {
			//alert( parentUrl );
			var replaceUrl = headerNaviParentUrl.replace(".","_on.");
			var replaceUrl = replaceUrl.replace("_on_on.","_on.");
			$("img", "#headerNavi a[href='" + $("#sideNavi h2 a").attr("href") + "']").attr("src", replaceUrl );
		}
		
	}
	
	//------------------------------------------------------------
	// 検索フォームの文字列制御
	//------------------------------------------------------------
	$("#gNavi #searchForm input#q").attr("title","キーワード検索");
	$("#gNavi #searchForm input#q")
		.blur(function(){
			var $$=$(this);
			if($$.val()=='' || $$.val()==$$.attr('title')){
				$$.css('color', '#cccccc').val($$.attr('title'));
			}
		})
		.focus(function(){
			var $$=$(this);
			if($$.val()==$$.attr('title')){
				$(this).css('color', '#000').val('');
			}
		})
		.parents('form:first').submit(function(){
			var $$=$('#text');
			if($$.val()==$$.attr('title')){
				$$.triggerHandler('focus');
			}
		}).end()
		.blur();
	
	
	//------------------------------------------------------------
	// トップページの更新情報タブ化
	//------------------------------------------------------------
	$("#newsAllBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsAllBtn_on.gif");
	$("#newsHead .newsBtns").click(function(e){
		
		$("#newsAllBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsAllBtn.gif");
		$("#newsRewriteBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsRewriteBtn.gif");
		$("#newsOshiraseBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsOshiraseBtn.gif");
		$("#newsJitureiBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsJitureiBtn.gif");
		
		$(".newsInner").hide();
		
		switch ( $(this).attr("id") ) {
			case "newsAllBtn":
				$("#newsAllBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsAllBtn_on.gif");
				$("#newsAll").show();
				break;
				
			case "newsRewriteBtn":
				$("#newsRewriteBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsRewriteBtn_on.gif");
				$("#newsRewrite").html(" 読込中... ").load("/wp-content/themes/wordpress_default/ajax.php?mode=news&type=newsRewrite").show();
				
				break;
				
			case "newsOshiraseBtn":
				$("#newsOshiraseBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsOshiraseBtn_on.gif");
				$("#newsOshirase").html(" 読込中... ").load("/wp-content/themes/wordpress_default/ajax.php?mode=news&type=newsOshirase").show();
				break;
				
			case "newsJitureiBtn":
				$("#newsJitureiBtn img").attr("src","/wp-content/themes/wordpress_default/img/newsJitureiBtn_on.gif");
				$("#newsJiturei").html(" 読込中... ").load("/wp-content/themes/wordpress_default/ajax.php?mode=news&type=newsJiturei").show();
				break;
		}
		
	});
	
	
	//------------------------------------------------------------
	// 管理者ログイン時のページ編集可能ボタン
	//------------------------------------------------------------
	$(".post-edit-link").closest("p").addClass("editLink");
	
});

