/* ---------------------------------------------------
 * 
 * common.js
 * + Rollover Setting
 * + Smooth Scroll
 * + heightLine
 * + Popup Menu
 * + Wrap Scroll
 * 
 --------------------------------------------------- */










/* ---------------------------------------------------
 * 
 * Rollover Setting
 * 
 --------------------------------------------------- */
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
			
			aImages[i].onclick = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

try{
	window.addEventListener("load",initRollovers,false);
}catch(e){
	window.attachEvent("onload",initRollovers);
}










/*  ================================================================================
 *
 *  JavaScript -Default version 3.0.6
 *  (c) 2004-2009 coliss.com
 *
 *  この作品は、クリエイティブ・コモンズの表示 2.1 日本ライセンスの下で
 *  ライセンスされています。
 *  この使用許諾条件を見るには、http://creativecommons.org/licenses/by/2.1/jp/を
 *  チェックするか、クリエイティブ･コモンズに郵便にてお問い合わせください。
 *  住所は：559 Nathan Abbott Way, Stanford, California 94305, USA です。
 *
================================================================================  */


/*  ================================================================================
TOC
============================================================
Set Adjustment
Page Scroller
============================================================
this script requires jQuery 1.3(http://jquery.com/)
================================================================================  */


/*  ================================================================================
Set Adjustment
================================================================================  */
var virtualTopId = "wrapper",
    virtualTop,
    adjTraverser,
    adjPosition,
    callExternal = "pSc",
    delayExternal= 500;

/* example
======================================================================  */
//    virtualTop = 0;    // virtual top's left position = 0
//    virtualTop = 1;    // virtual top's left position = vertical movement
//    adjTraverser = 0;  // left position = 0
//    adjTraverser = 1;  // horizontal movement.
//    adjPosition = -26;

/*  ================================================================================
Page Scroller
================================================================================  */
(function($){var height=$.fn.height,width=$.fn.width,left=$.fn.left,top=$.fn.top;
$.fn.extend({width:function(){if(!this[0])error();
if(this[0]==window)return self.innerWidth||$.boxModel&&document.documentElement.clientWidth||document.body.clientWidth;
if(this[0]==document)return((document.documentElement&&document.compatMode=="CSS1Compat")?document.documentElement.scrollWidth:document.body.scrollWidth);
return width.apply(this,arguments)},height:function(){if(!this[0])error();
if(this[0]==window)return self.innerHeight||$.boxModel&&document.documentElement.clientHeight||document.body.clientHeight;
if(this[0]==document)return((document.documentElement&&document.compatMode=="CSS1Compat")?document.documentElement.scrollHeight:document.body.scrollHeight);
return height.apply(this,arguments)},left:function(){if(!this[0])return true;
var obj=document.getElementById?document.getElementById(this[0].id):document.all(this[0].id);
var tagCoords=new Object();
tagCoords.x=obj.offsetLeft;
while((obj=obj.offsetParent)!=null){tagCoords.x+=obj.offsetLeft}if((tagCoords.x*0)==0)return(tagCoords.x);
else return(this[0].id)},top:function(){if(!this[0])return true;
var obj=document.getElementById?document.getElementById(this[0].id):document.all(this[0].id);
var tagCoords=new Object();
tagCoords.y=obj.offsetTop;
while((obj=obj.offsetParent)!=null){tagCoords.y+=obj.offsetTop}if((tagCoords.y*0)==0)return(tagCoords.y);
else return(this[0].id)}})})(jQuery);
$(function(){$('a[href^="#"]').click(function(){var usrUrl=location.hostname+location.pathname;
var anchorPath=((this.href).substring(0,(((this.href).length)-((this.hash).length)))).slice((this.href).indexOf("//")+2);
if(usrUrl.lastIndexOf("?")!=-1)usrUrlOmitQ=usrUrl.slice(0,(usrUrl.lastIndexOf("?")));
else usrUrlOmitQ=usrUrl;
if(anchorPath.lastIndexOf("?")!=-1)anchorPathOmitQ=anchorPath.slice(0,(anchorPath.lastIndexOf("?")));
else anchorPathOmitQ=anchorPath;
if(anchorPathOmitQ==usrUrlOmitQ){coliss.toAnchor((this.hash).substr(1));
return false}});
$("body").click(function(){coliss.stopScroll()})});
$(function(){$('area[href^="#"]').click(function(){var usrUrl=location.hostname+location.pathname;
var anchorPath=((this.href).substring(0,(((this.href).length)-((this.hash).length)))).slice((this.href).indexOf("//")+2);
if(usrUrl.lastIndexOf("?")!=-1)usrUrlOmitQ=usrUrl.slice(0,(usrUrl.lastIndexOf("?")));
else usrUrlOmitQ=usrUrl;
if(anchorPath.lastIndexOf("?")!=-1)anchorPathOmitQ=anchorPath.slice(0,(anchorPath.lastIndexOf("?")));
else anchorPathOmitQ=anchorPath;
if(anchorPathOmitQ==usrUrlOmitQ){coliss.toAnchor((this.hash).substr(1));
return false}});
$("body").click(function(){coliss.stopScroll()})});
this.pageScrollTimer=null;
var coliss={getScrollRange:function(type){if(type=="x")return(($(document).width())-($(window).width()));
else if(type=="y")return(($(document).height())-($(window).height()))},getWindowOffset:function(type){if(type=="x")return(window.pageXOffset||document.body.scrollLeft||document.body.parentNode.scrollLeft);
else if(type=="y")return(window.pageYOffset||document.body.scrollTop||document.body.parentNode.scrollTop)},pageScroll:function(toX,toY,frms,frX,frY){var pageScrollTimer;
if(pageScrollTimer)clearTimeout(pageScrollTimer);
var spd=16;
var actX=coliss.getWindowOffset('x');
var actY=coliss.getWindowOffset('y');
if(!toX||toX<0)toX=0;
if(!toY||toY<0)toY=0;
if(!frms)frms=$.browser.mozilla?10:$.browser.opera?8:9;
if(!frX)frX=0+actX;
if(!frY)frY=0+actY;
frX+=(toX-actX)/frms;
if(frX<0)frX=0;
frY+=(toY-actY)/frms;
if(frY<0)frY=0;
var posX=Math.ceil(frX);
var posY=Math.ceil(frY);
window.scrollTo(posX,posY);
if((Math.floor(Math.abs(actX-toX))<1)&&(Math.floor(Math.abs(actY-toY))<1)){clearTimeout(this.pageScrollTimer);
window.scroll(toX,toY)}else if((posX!=toX)||(posY!=toY))this.pageScrollTimer=setTimeout("coliss.pageScroll("+toX+","+toY+","+frms+","+frX+","+frY+")",spd);
else clearTimeout(this.pageScrollTimer)},stopScroll:function(){clearTimeout(this.pageScrollTimer)},cancelScroll:function(e){coliss.stopScroll()},toAnchor:function(idName){coliss.stopScroll();
var anchorX,anchorY;
if(!!idName){if(idName==virtualTopId){anchorX=(virtualTop==0)?0:(virtualTop==1)?window.pageXOffset||document.body.scrollLeft||document.body.parentNode.scrollLeft:$('#'+idName).left();
anchorY=((virtualTop==0)||(virtualTop==1))?0:$('#'+idName).top()}else{anchorX=(adjTraverser==0)?0:(adjTraverser==1)?($('#'+idName).left()):window.pageXOffset||document.body.scrollLeft||document.body.parentNode.scrollLeft;
anchorY=adjPosition?($('#'+idName).top())+adjPosition:($('#'+idName).top())}var dMaxX=coliss.getScrollRange('x');
var dMaxY=coliss.getScrollRange('y');
if(((anchorX*0)==0)||((anchorY*0)==0)){var setX=(anchorX<1)?0:(anchorX>dMaxX)?dMaxX:anchorX;
var setY=(anchorY<1)?0:(anchorY>dMaxY)?dMaxY:anchorY;
coliss.pageScroll(setX,setY)}else location.hash=idName}else coliss.pageScroll(0,0)},initPageScroller:function(){var usrUrl=location.href;
var checkAnchor=usrUrl.indexOf("#",0);
var checkPageScroller=usrUrl.match(callExternal);
if(!!checkPageScroller){anchorId=usrUrl.slice(usrUrl.lastIndexOf("?"+callExternal)+4,usrUrl.length);
timerID=setTimeout("coliss.toAnchor(anchorId)",delayExternal)}if(!checkAnchor)window.scroll(0,0);
else return true}};
$(coliss.initPageScroller);











/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		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);
}










/* ---------------------------------------------------
 * 
 * Style Switcher
 * 
 --------------------------------------------------- */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);









/* ---------------------------------------------------
 * 
 * Popup
 * 
 --------------------------------------------------- */
function openSubWin(path, w, h){
newWindow = window.open(path, "popup", "width=" + w + ",height=" + h + ",scrollbars=no");
win.focus();
win.resizeTo(screen.availWidth,screen.availHeight);
}









/* 
 * wrapScroll
 */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=10};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 m=2(){1.B.C(1,D)};m.E={X:\'0.9.6\',F:Y,h:Z,n:0,G:0,i:0,q:H,B:2(e,p,r){1.I(11,\'12\',1.u(1.J,D))},J:2(e,p,r){3(o=8.w(e)){1.q={\'e\':o,\'p\':(p)?8.w(p):o.13,\'r\':(r)?8.w(r):H};o.4.K=\'L\';3((c=o.g)!=(v=((o.4.j=o.g+\'x\')!=\'\')?o.g:0)){o.4.n=0;o.4.j=c+(v-c)+\'x\'}1.z()}},z:2(){f=1.M.N(1,1.q);14(1.u(1.z),(f)?10:1.F)},u:2(a,b){7 c=1;7 d=(b)?b:[];5 2(){a.C(c,d)}},I:2(e,a,b,c){3(e.O){e.O(a,b,c)}15 3(e.P){e.P(\'16\'+a,b)}},17:2(f,d){3(f){1.A=f}3(d){1.h=d}},A:2(t,b,c,d){5 c*(t/=d)*t+b}};m.E.M={N:2(t,o){7 a=Q.18(1.R(),(o.r)?1.k(o.r)+1.l(o.r):1.k(o.p));7 b=(1.k(o.p)+1.l(o.p))-(1.l(o.e)+t.G);7 s=19(o.e.4.j);7 e=Q.1a(b,a+t.n);3((t.S!=e)||(t.i>t.h)){t.i=0}3((t.S=e)!=s){o.e.4.j=t.A(t.i++,s,e-s,t.h,o.e.4)+\'x\';5 1b}5 1c},R:2(){5 8.T.U||8.V.U},l:2(o){5 o.1d||8.V.W||8.T.W},k:2(o){y=o.g;3(o.4.K==\'L\'){5 y};1e(o=o.1f){y+=o.g}5 y}};',62,78,'|this|function|if|style|return||var|document||||||||offsetTop|Duration|_timer|top|offset|height|wrapScroll|marginTop|||_obj||||bind||getElementById|px||callback|tween|initialize|apply|arguments|prototype|Interval|marginBottom|null|attach|prepare|position|absolute|event|update|addEventListener|attachEvent|Math|scroll|_prev|documentElement|scrollTop|body|scrollHeight|Version|500|60||window|load|parentNode|setTimeout|else|on|setTween|max|parseInt|min|true|false|offsetHeight|while|offsetParent'.split('|'),0,{}))


new wrapScroll('wrapScroll','main');
