












/* --------------------------------------------------------------------------
	1.smoothScroll.js
	2.rollover.js
	3.opendata.js
	4.heightLine.js
----------------------------------------------------------------------------- */













/* --------------------------------------------------------------------------
 1
-----------------------------------------------------------------------------
	[smoothScroll.js]
	Author  : mashimonator
	Create  : 2009/12/19
	Update  : 2010/02/16
	Description : smoothscroll
----------------------------------------------------------------------------- */

/*@cc_on 
var doc = document;
eval('var document = doc');
@*/
var smoothScroll = {
	//-----------------------------------------
	// 設定値
	//-----------------------------------------
	config : {
		speed : 25
	},
	storage : {
		url : location.href.replace(location.hash, ''),
		goal : null,
		working : false
	},
	//-----------------------------------------
	// 初期処理
	//-----------------------------------------
	initialize : function() {
		var elements = document.body.getElementsByTagName('a');
		for (var i = 0, len = elements.length; i < len; i++) {
			smoothScroll.set(elements[i]);
		}
		smoothScroll.addMouseScrollEvent(smoothScroll.cancel);
	},
	//-----------------------------------------
	// smoothScrollの設定
	//-----------------------------------------
	set : function( element ) {
		var href = element.getAttribute('href');
		if ( href && href != '' && href.match(/#[a-zA-Z0-9]+/) ) {
			var anchor = href.split('#');
			if ( anchor[0] == '' || anchor[0] == smoothScroll.storage.url ) {
				element.scrollTarget = anchor[1].replace(/^#/ ,'');
				element.href = 'javascript:void(0)';
				smoothScroll.addEvent( element, 'click', smoothScroll.scroll );
			}
		}
	},
	//-----------------------------------------
	// スクロール
	//-----------------------------------------
	scroll : function() {
		// 対象要素取得
		var target = document.getElementById(this.scrollTarget);
		if ( target ) {
			// 移動位置
			smoothScroll.storage.goal = smoothScroll.getElementPosition(target).top;
			//現在位置
			var start = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
			// スクロール開始
			smoothScroll.storage.working = true;
			if ( smoothScroll.storage.goal < start ) {
				// up
				smoothScroll.storage.goal -= 5;
				smoothScroll.up();
			} else {
				// down
				var ssize = smoothScroll.getScreenSize();
				var psize = smoothScroll.getPageSize();
				if ( ssize.height + smoothScroll.storage.goal > psize.height ) {
					smoothScroll.storage.goal = psize.height - ssize.height;
				}
				smoothScroll.down();
			}
		}
	},
	//-----------------------------------------
	// 上移動
	//-----------------------------------------
	up : function() {
		var currentTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
		var y = Math.floor( (currentTop - smoothScroll.storage.goal) * 0.2 );
		if ( y < 1 ) {
			y = 1;
		}
		window.scrollTo(0, currentTop - y);
		if ( currentTop > 1 && Math.abs(currentTop-smoothScroll.storage.goal) > 1 ) {
			window.setTimeout(smoothScroll.up, smoothScroll.config.speed);
		} else {
			window.scrollTo(0, smoothScroll.storage.goal);
			smoothScroll.storage.working = false;
		}
	},
	//-----------------------------------------
	// 下移動
	//-----------------------------------------
	down : function() {
		var currentTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
		var y = Math.floor( (smoothScroll.storage.goal - currentTop) * 0.2 );
		if ( y < 1 ) {
			y += 1;
		}
		window.scrollTo(0, y + currentTop);
		if ( Math.abs(smoothScroll.storage.goal-currentTop) > 1 ) {
			window.setTimeout(smoothScroll.down, smoothScroll.config.speed);
		} else {
			window.scrollTo(0, smoothScroll.storage.goal);
			smoothScroll.storage.working = false;
		}
	},
	//-----------------------------------------
	// スクロール中のマウスホイールキャンセル
	//-----------------------------------------
	cancel : function(event) {
		event = event || window.event;
		if ( smoothScroll.storage.working ) {
			if ( smoothScroll.isFirefox() ) {
				// for Firefox
				event.preventDefault();
				event.stopPropagation();
			} else {
				// for IE,Safari,Chrome,Opera
				event.returnValue = false;
				event.cancelBubble = true;
			}
		}
	},
	//-----------------------------------------
	// ブラウザの画面サイズを取得する
	//-----------------------------------------
	getScreenSize : function() {
		var w = 0;
		var h = 0;
		if ( window.innerWidth ) {
			w = window.innerWidth;
		} else if ( document.documentElement && document.documentElement.clientWidth != 0 ) {
			w = document.documentElement.clientWidth;
		} else if ( document.body ) {
			w = document.body.clientWidth;
		}
		if ( window.innerHeight ) {
			h = window.innerHeight;
		} else if ( document.documentElement && document.documentElement.clientHeight != 0 ) {
			h = document.documentElement.clientHeight;
		} else if ( document.body ) {
			h = document.body.clientHeight;
		}
		return ({ 'width': w, 'height': h });
	},
	//-----------------------------------------
	// ページのサイズを取得する
	//-----------------------------------------
	getPageSize : function() {
		var xScroll, yScroll;
		if ( window.innerHeight && window.scrollMaxY ) {
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if ( document.body.scrollHeight > document.body.offsetHeight ){
			// all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if ( self.innerHeight ) {
			// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			// Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			// other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		// for small pages with total height less then height of the viewport
		if ( yScroll < windowHeight ) {
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if ( xScroll < windowWidth ) {
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		//return [pageWidth,pageHeight];
		return ({ 'width' : pageWidth, 'height' : pageHeight });
	},
	//-----------------------------------------
	// 対象要素のポジションを取得する
	//-----------------------------------------
	getElementPosition : function( element ) {
		var offsetTrail = (typeof element == 'string') ? document.getElementById(element): element;
		var x = 0;
		var y = 0;
		while (offsetTrail) {
			x += offsetTrail.offsetLeft;
			y += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		if ( navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined' ) {
			x += document.body.leftMargin;
			y += document.body.topMargin;
		}
		return ({ 'left': x, 'top': y });
	},
	//-----------------------------------------
	// Firefox判定
	//-----------------------------------------
	isFirefox : function() {
		FF=/a/[-1]=='a';
		if(FF){
			return true;
		}else{
			return false;
		}
	},
	//-----------------------------------------
	// IE判定
	//-----------------------------------------
	isIE : function() {
		return IE='\v'=='v';
	},
	//-----------------------------------------
	// イベントに関数を付加する
	//-----------------------------------------
	addMouseScrollEvent : function( func ) {
		if ( smoothScroll.isFirefox() ) {
			// for Firefox
			window.addEventListener('DOMMouseScroll', func, false);
		} else if ( smoothScroll.isIE() ) {
			// for IE
			document.attachEvent('onmousewheel', (function(el){return function(){func.call(el);};})(document));
			window.attachEvent('onmousewheel', (function(el){return function(){func.call(el);};})(window));
		} else {
			// for Safari,Chrome,Opera
			window.addEventListener('mousewheel', func, false);
		}
	},
	//-----------------------------------------
	// イベントに関数を付加する
	//-----------------------------------------
	addEvent : function( target, event, func ) {
		try {
			target.addEventListener(event, func, false);
		} catch (e) {
			target.attachEvent('on' + event, (function(el){return function(){func.call(el);};})(target));
		}
	}
}
// 実行
smoothScroll.addEvent( window, 'load', smoothScroll.initialize );













/* --------------------------------------------------------------------------
 2
-----------------------------------------------------------------------------
	[rollover.js]
	last update: 09/06/16  created by edo.	
	This script attach the rollover effect to image on 'rollover' class.
	This is distributed by the MIT license.
	URL: http://css-eblog.com/
----------------------------------------------------------------------------- */

(function() {
var filename = 'rollover.js';
var _className = 'rob';

function getJsParam() {
	//get scripts list.
	var scripts = document.getElementsByTagName( 'script' );
	var script;
	var params = {};
	
	//pickup this file.
	for ( var i=0; i<scripts.length; i++ ) {
		var s = scripts.item( i );
		if( s.src.indexOf( filename ) !== -1 ) {
			script = s;
			break;
		}
	}
	
	if( script ) {
		script.src.match( /(.*)(\?)(.*)/ );
		if( RegExp.$3 ) {
			var a = RegExp.$3.split( '&' );
			if( a ) {
				for( var k=0; k<a.length; k++ ) {
					var p = a[ k ].split( '=' );
					if( p[0] ) {
						params[ p[0] ] = p[1];
					}
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	} else {
		return false;
	}
	
	return params;
}

function addEvent( node, evt, handler ) {
	try {
		if( node.addEventListener ) {
			node.addEventListener( evt, handler, false );
		} else {
			node.attachEvent( 'on' + evt, handler );
		}
	} catch( e ) {}
}

function setEvent( ele, ty ) {
	ele.originalSrc = ele.src;
	ele.originalSrc.match( /^(.*)(\.{1}.*)/g );
	ele.hoverSrc = RegExp.$1 + ty + RegExp.$2;
	addEvent( ele, 'mouseover', function( evt ) {
		var tar = evt.target || evt.srcElement;
		tar.src = tar.hoverSrc;
	});
	addEvent( ele, 'mouseout', function( evt ) {
		var tar = evt.target || evt.srcElement;
		tar.src = tar.originalSrc;
	});
}

function startRollover() {
	var jParam = getJsParam();
	var jType = jParam.type ? jParam.type : '-on';
	var imgs = document.getElementsByTagName( 'img' );
	for( var i=0; i<imgs.length; i++ ) {
		if( imgs[i].className.indexOf( _className ) !== -1 ) {
			setEvent( imgs[i], jType );
		}
	}
}

addEvent( window, 'load', startRollover );
})();













/* --------------------------------------------------------------------------
 3
-----------------------------------------------------------------------------
	[opendata.js]
----------------------------------------------------------------------------- */

function opendata(id){
	if(id){
		var ko = document.getElementById(id).style;
		if(ko) ko.display = (ko.display=="none")?"":"none";
	}
}














/* --------------------------------------------------------------------------
 4
-----------------------------------------------------------------------------
	[heightLine.js]
 heightLine JavaScript Library beta4
 MIT-style license. 
 2007 Kazuma Nishihata 
 http://www.webcreativepark.net
----------------------------------------------------------------------------- */

new function(){
	function heightLine(){
		this.className="hL";
		this.parentClassName="hLParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}

