﻿// JavaScript Document

//font-size.js//
/*

===========================================================

フォントサイズ変更スクリプト（タイプC）



Last Updated:09/21/2001



insomnia!Web Labo.

http://www3.airnet.ne.jp/insomnia/

http://www3.airnet.ne.jp/insomnia/labo/fsc/fscC.html

===========================================================

*/



/*

========== ::: 初期設定 ::: ==========

*/



// 値の単位を設定（必ずダブルクオートかクオートで括る）

var fontSizeUnit = "%";



// 一回の操作で変化させる値を設定（ダブルクオートやクオートで括らない）

var perOrder = 10;



// 初期状態の値を設定（ダブルクオートやクオートで括らない）

var defaultSize = 80;



// クッキーの名前（必ずダブルクオートかクオートで括る）

var ckName = "FSC";



// クッキーの有効期限（日）（ダブルクオートやクオートで括らない）

var ckDays = 2;



// クッキーのパス（必ずダブルクオートかクオートで括る。指定が不要の場合は"/"にする）

var ckPath = "/"





/*

========== ::: ページ読み込み時の値を設定 ::: ==========

*/



// クッキー読み出し

var fsCK = GetCookie( ckName );



if ( fsCK == null ){

  var currentSize = defaultSize;          //クッキーが無ければ現在の値を初期状態の値に設定

}

else{

  var currentSize = eval( fsCK );          //クッキーがあれば現在の値をクッキーの値に設定

}





/*

========== ::: head内にstyle要素を出力 ::: ==========

*/

document.writeln( '<style type="text/css">' );

document.write( 'body{font-size:' + currentSize + fontSizeUnit+ '}' );

document.writeln( '</style>' );





/*===================================

  [関数 fsc]

  引数CMDに渡される値に応じて

  変更後の値を算出しクッキーに書き込む。

====================================*/



function fsc( CMD ){



  // 拡大：現時点の値に一回の操作で変化させる値を加えて操作後の値"newSize"に代入

  if ( CMD == "larger" ){

    var newSize = Number( currentSize + perOrder );

    SetCookie( ckName , newSize );          //クッキー書き込み

  }



  // 縮小：現時点の値から一回の操作で変化させる値を引き操作後の値に代入

  // 現時点のサイズの値が一回の操作で変化させる値と同じならそのまま操作後の値に代入

  if ( CMD == "smaller" ){

    if ( currentSize != perOrder ){

      var newSize = Number( currentSize - perOrder );

      SetCookie( ckName , newSize );          //クッキー書き込み

    }

    else{

      var newSize = Number( currentSize );

    }

  }



  // 元に戻す：操作後の値を初期値にする

  if ( CMD == "default" ){

    DeleteCookie( ckName );          //クッキー削除

  }



  // ページの再読み込み

  // 再読み込みをすることで変更後の値を反映したstyle要素が出力される

  location.reload();

}



// _______________________________________ end of function fsc() ___ 





/*===================================

  [関数 SetCookie]

  クッキーに値を書き込む

====================================*/

function SetCookie( name , value ){

  var dobj = new Date();

  dobj.setTime(dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);

  var expiryDate = dobj.toGMTString();

  document.cookie = name + '=' + escape(value) + ';expires=' + expiryDate + ';path=' + ckPath;

}



/*===================================

  [関数 GetCookie]

  クッキーを取得する

====================================*/

function GetCookie (name){

  var arg  = name + "=";

  var alen = arg.length;

  var clen = document.cookie.length;

  var i = 0;

  while (i < clen){

    var j = i + alen;

    if (document.cookie.substring(i, j) == arg)

    return getCookieVal (j);

    i = document.cookie.indexOf(" ", i) + 1;

    if (i == 0) break;

  }

  return null;

}



/*===================================

  [関数 getCookieVal]

  クッキーの値を抽出する

====================================*/

function getCookieVal (offset){

  var endstr = document.cookie.indexOf (";", offset);

  if (endstr == -1)

  endstr = document.cookie.length;

  return unescape(document.cookie.substring(offset,endstr));

}



/*===================================

  [関数 DeleteCookie]

  クッキーを削除する

====================================*/

function DeleteCookie(name){

  if (GetCookie(name)){

    document.cookie = name + '=' +

    '; expires=Thu, 01-Jan-70 00:00:01 GMT;path='+ckPath;

  }

}

//toTop.js//
function backToTop() {
var x1 = x2 = x3 = 0;
var y1 = y2 = y3 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
x3 = window.scrollX || 0;
y3 = window.scrollY || 0;
var x = Math.max(x1, Math.max(x2, x3));
var y = Math.max(y1, Math.max(y2, y3));
window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
if (x > 0 || y > 0) {
window.setTimeout("backToTop()", 25);
}
}

//news_tab.js//

$(function(){
	$("ul.panel li:not("+$("ul.tab li a.selected").attr("href")+")").hide();
	$("ul.tab li a").click(function(){
									 
		$("ul.tab li a").removeClass("selected");
		$(this).addClass("selected");
		$("ul.panel li").hide();
		//$("ul.panel li").slideUp("fast");//スライドアップしながら切り替わるスクリプト
		//$($(this).attr("href")).slideDown("fast");//スライドダウンしながら切り替わるスクリプト
		$($(this).attr("href")).show();
		
		return false;
	});
	
});


//データベースサーチ//

$(function(){
	$("ul.panel_lib li:not("+$("ul.tab_lib li a.selected_lib").attr("href")+")").hide();
	$("ul.tab_lib li a").click(function(){
									 
		$("ul.tab_lib li a").removeClass("selected_lib");
		$(this).addClass("selected_lib");
		$("ul.panel_lib li").hide();

		$($(this).attr("href")).show();
		
		return false;
	});
	
});


//蔵書検索//

function GoCARIN(pram)
{
	var str="";
	if (pram=='') {
		var obj;
		if (document.all) {
        	obj = document.all["CARINData"];
    	}else if (document.getElementById) {
        	obj = document.getElementById("CARINData");
    	}
		if (!obj) return false;
		var v = obj.value;
		if (v=="") return false;
		str="AL="+v;
		obj.value="";
	} else str=pram;
	if (str=="") return false;
	var URL="http://carinweb.adm.nagoya-cu.ac.jp/intrasite/CARINOPACLINK.HTM?"+str;
	window.open(URL+"&EXIT=2");
//	location.href=URL;
	return false;
}


/*tree01*/
/*
 * Treeview 1.3 - jQuery plugin to hide and show branches of a tree
 * 
 * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
 *
 * Copyright (c) 2006 Jörn Zaefferer, Myles Angell
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.treeview.js 3506 2007-10-02 18:15:21Z joern.zaefferer $
 *
 */

(function($) {

	// classes used by the plugin
	// need to be styled via external stylesheet, see first example
	var CLASSES = {
		open: "open",
		closed: "closed",
		expandable: "expandable",
		collapsable: "collapsable",
		lastCollapsable: "lastCollapsable",
		lastExpandable: "lastExpandable",
		last: "last",
		hitarea: "hitarea"
	};
	
	$.extend($.fn, {
		swapClass: function(c1, c2) {
			return this.each(function() {
				var $this = $(this);
				if ( $.className.has(this, c1) )
					$this.removeClass(c1).addClass(c2);
				else if ( $.className.has(this, c2) )
					$this.removeClass(c2).addClass(c1);
			});
		},
		replaceClass: function(c1, c2) {
			return this.each(function() {
				var $this = $(this);
				if ( $.className.has(this, c1) )
					$this.removeClass(c1).addClass(c2);
			});
		},
		hoverClass: function(className) {
			className = className || "hover";
			return this.hover(function() {
				$(this).addClass(className);
			}, function() {
				$(this).removeClass(className);
			});
		},
		heightToggle: function(animated, callback) {
			animated ?
				this.animate({ height: "toggle" }, animated, callback) :
				this.each(function(){
					jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
					if(callback)
						callback.apply(this, arguments);
				});
		},
		heightHide: function(animated, callback) {
			if (animated) {
				this.animate({ height: "hide" }, animated, callback)
			} else {
				this.hide();
				if (callback)
					this.each(callback);				
			}
		},
		prepareBranches: function(settings) {
			// mark last tree items
			this.filter(":last-child").addClass(CLASSES.last);
			// collapse whole tree, or only those marked as closed, anyway except those marked as open
			this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
			// return all items with sublists
			return this.filter(":has(>ul)");
		},
		applyClasses: function(settings, toggler) {
			this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
				if ( this == event.target ) {
					toggler.apply($(this).next());
				}
			}).add( $("a", this) ).hoverClass();
			
			// handle closed ones first
			this.filter(":has(>ul:hidden)")
					.addClass(CLASSES.expandable)
					.replaceClass(CLASSES.last, CLASSES.lastExpandable);
					
			// handle open ones
			this.not(":has(>ul:hidden)")
					.addClass(CLASSES.collapsable)
					.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
					
            // create hitarea
			this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>")
				.find("div." + CLASSES.hitarea).click( toggler )
		},
		treeview: function(settings) {
			
			// currently no defaults necessary, all implicit
			settings = $.extend({}, settings);
			
			if (settings.add) {
				return this.trigger("add", [settings.add]);
			}
			
			if (settings.toggle ) {
				var callback = settings.toggle;
				settings.toggle = function() {
					return callback.apply($(this).parent()[0], arguments);
				}
			}
		
			// factory for treecontroller
			function treeController(tree, control) {
				// factory for click handlers
				function handler(filter) {
					return function() {
						// reuse toggle event handler, applying the elements to toggle
						// start searching for all hitareas
						toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
							// for plain toggle, no filter is provided, otherwise we need to check the parent element
							return filter ? $(this).parent("." + filter).length : true;
						}) );
						return false;
					}
				}
				// click on first element to collapse tree
				$(":eq(0)", control).click( handler(CLASSES.collapsable) );
				// click on second to expand tree
				$(":eq(1)", control).click( handler(CLASSES.expandable) );
				// click on third to toggle tree
				$(":eq(2)", control).click( handler() ); 
			}
		
			// handle toggle event
			function toggler() {
				// this refers to hitareas, we need to find the parent lis first
				$(this).parent()
					// swap classes
					.swapClass( CLASSES.collapsable, CLASSES.expandable )
					.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
					// find child lists
					.find( ">ul" )
					// toggle them
					.heightToggle( settings.animated, settings.toggle );
				if ( settings.unique ) {
					$(this).parent()
						.siblings()
						.replaceClass( CLASSES.collapsable, CLASSES.expandable )
						.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
						.find( ">ul" )
						.heightHide( settings.animated, settings.toggle );
				}
			}
			
			function serialize() {
				function binary(arg) {
					return arg ? 1 : 0;
				}
				var data = [];
				branches.each(function(i, e) {
					data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
				});
				$.cookie("treeview", data.join("") );
			}
			
			function deserialize() {
				var stored = $.cookie("treeview");
				if ( stored ) {
					var data = stored.split("");
					branches.each(function(i, e) {
						$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
					});
				}
			}
			
			// add treeview class to activate styles
			this.addClass("treeview");
			
			// prepare branches and find all tree items with child lists
			var branches = this.find("li").prepareBranches(settings);
			
			switch(settings.persist) {
			case "cookie":
				var toggleCallback = settings.toggle;
				settings.toggle = function() {
					serialize();
					if (toggleCallback) {
						toggleCallback.apply(this, arguments);
					}
				};
				deserialize();
				break;
			case "location":
				var current = this.find("a").filter(function() { return this.href == location.href; });
				if ( current.length ) {
					current.addClass("selected").parents("ul, li").add( current.next() ).show();
				}
				break;
			}
			
			branches.applyClasses(settings, toggler);
				
			// if control option is set, create the treecontroller
			if ( settings.control )
				treeController(this, settings.control);
			
			return this.bind("add", function(event, branches) {
				$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable);
				$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
			});
		}
	});
	
	// provide backwards compability
	$.fn.Treeview = $.fn.treeview;
})(jQuery);

/*tree02*/
			//$(function(){
				//$("#siteMap").treeview({
					//collapsed: false,
					//animated: "fast"
				//});
			//});
