/*
 * サイト全体共通のjavascript
 */

//IE6のBackgroundImageCacheを有効にする
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


jQuery.noConflict();//jQueryと他ライブラリの競合回避
jQuery(document).ready(function($){
	// ここでは、$はjQueryとして使えます。


//文字サイズ
	$('#switch-style-ctr').show();

	// H1タグにアイコン付加
	$("#main-content h1").not(".news-details-heading").wrapInner('<span class="heading-h1"></span>');
	
	// 角丸
	$('#main-content h2').corners("5px");
	$('#related-links').corners("4px");
	
	//shadow
	//$('#main-content h1').dropShadow({left:0,top:1,opacity:0.3,blur: 2,color:'#7C7F5F'});
	
	
	//ローカル：メニュー現在地表示
	// #breadcrumbsの文字列から判別
	
	//var dir_array =['学科・附属施設案内' ,'地域フィールド科学教育研究センター','森林生態系部門'];
	
	var dir_array =[];

	$('#breadcrumbs a:gt(1)').each(function(){
		var txt = $.trim($(this).text());							
		dir_array.push(txt);	  												  
	});
		//console.log(dir_array);	
	
	var curr_dir = $('#breadcrumbs em:last').text() || $('#breadcrumbs *:last').text() ;	
		//console.log(curr_dir);
	curr_dir = $.trim(curr_dir);	
	dir_array.push(curr_dir);
		//console.log(dir_array);	
		//console.log(dir_array.length);
	
	
	var dir_flag = false;

	var aaa = $('#nav-menu li li a:contains("'+ dir_array[0] +'")')
				.not('#nav-menu li li li *').parent();
		//console.log(aaa);
	
	var bbb = $('li a:contains("'+ dir_array[1] +'")', aaa)
				.not('#nav-menu li li li li *').parent();
		//console.log(bbb);
	
	
	if(dir_array.length == 2) {
		bbb.addClass("current-page");
	}else if(dir_array.length == 1){
		
		aaa.addClass("current-page");
	
	}
	



	//吹き出し
	$('*[title]').qtip({
					style:	 {	
							  name: 'cream',
							  tip: true,
							  title: { 'font-weight': 'bold', 'overflow': 'hidden' }
					}
					
			   ,	position: { 
							 adjust: { screen: true , mouse : false }
					}
				,	show: { delay: 650 }
					
				/*	,content: {
							   text: '***',
							   title: { text: '***' }
					}
				  */
	});
	
	



	// ページtopへのアンカータグの表示・非表示設定
	if($("#content")){
		if($("#content").height() < 700){ //ページheightが～以下だったら非表示
			$(".go-pagetop").css('visibility','hidden');
		}
	}
	
	// アンカータグのスムーススクロール
	$.localScroll({duration:500}); //全てのanchor




});

