// popup __________________________________________________
var MacIe = navigator.userAgent.indexOf( "Mac" ) > -1 && navigator.userAgent.indexOf( "MSIE" ) > -1;
var JsWin;

function commonpop( JsUrl, JsWinName, JSWidth, JSHeight ){
JSWidth = parseInt( JSWidth );
JSHeight = parseInt( JSHeight );
if( !MacIe ){ JSWidth = JSWidth + 17; }
if( MacIe ){ JSWidth = JSWidth - 1 ; }
JsProperty = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=" + JSWidth + ",height=" + JSHeight;
JsWin = window.open( JsUrl, JsWinName, JsProperty );
if( MacIe ){ return; }
JsWin.focus();
}

function commonpop2( JsUrl, JsWinName, JSWidth, JSHeight ){
JSWidth = parseInt( JSWidth );
JSHeight = parseInt( JSHeight );
JsProperty = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + JSWidth + ",height=" + JSHeight;
JsWin = window.open( JsUrl, JsWinName, JsProperty );
if( MacIe ){ return; }
JsWin.focus();
}



// Rollover __________________________________________________
$(document).ready(function(){
function rollover_img(selector, suffix){
$(selector).each(function(i){
var defaultImg = $(this).attr("src");
if (!defaultImg.match((suffix))) {
var point = defaultImg.lastIndexOf(".")
var rolloverImg = defaultImg.slice(0, point) + suffix + defaultImg.slice(point);
var preloadImg = new Image();
preloadImg.src = rolloverImg;
$(this).hover(
function(){
$(this).attr("src", rolloverImg);
},
function(){
$(this).attr("src", defaultImg);
}
)
}
})
}
rollover_img("img.rollover", "_ov");
});



// include __________________________________________________
var include = new Include();
include.init('common/js/common.js');

function Include() {
	// 初期化
	this.init = function(base) {
		var scripts = document.getElementsByTagName('script');
		for (var i = 0, l = scripts.length; i < l; i++) {
			if (scripts[i].src.match(base + '([\?].*|$)')) {
				this.root = scripts[i].src.split(base)[0] + './';
				break;
			}
		}
	}

	// 出力
	this.write = function(src) {
		src = src.join('\n');
		while(src.match('__path__')) {
			src = src.replace('__path__', this.root);
		}
		document.open();
		document.write(src);
		document.close();
	}
}



// SHOW or HIDE OBJECT __________________________________________________
function showObj(id){
	document.getElementById(id).style.display = "block";
}
function hideObj(id){
	document.getElementById(id).style.display = "none";
}



/*---------------------------------------------------------------

 jQuery.slideScroll.js
 
 jQuery required (tested on version 1.2.6)
 encoding UTF-8

 Copyright (c) 2008 nori (norimania@gmail.com)
 http://moto-mono.net
 Licensed under the MIT

 $Update: 2008-12-24 20:00
 $Date: 2008-12-22 23:30
 
 ----------------------------------------------------------------

$(function(){
		$("a[href*='#']").slideScroll();
});

$.fn.slideScroll = function(options){
	var c = $.extend({
		interval: 20, // 変化はあんまりないかも
		easing: 0.6, // 0.4 ~ 2.0 くらいまで
		comeLink: false
	},options);
	var d = document;
	var timer;
	var pos;
	
	function currentPoint(){
		var current = {
			x: d.body.scrollLeft || d.documentElement.scrollLeft,
			y: d.body.scrollTop || d.documentElement.scrollTop
		}
		return current;
	}
	
	function setPoint(){
		var h = d.documentElement.clientHeight;
		var w = d.documentElement.clientWidth;
		var maxH = d.documentElement.scrollHeight;
		var maxW = d.documentElement.scrollWidth;
		pos.top = ((maxH-h)<pos.top && pos.top<maxH) ? maxH-h : pos.top;
		pos.left = ((maxW-w)<pos.left && pos.left<maxW) ? maxW-w : pos.left;
	}
	
	function nextPoint(){
		var x = currentPoint().x;
		var y = currentPoint().y;
		var sx = Math.ceil((x - pos.left)/(5*c.easing));
		var sy = Math.ceil((y - pos.top)/(5*c.easing));
		var next = {
			x: x - sx,
			y: y - sy,
			ax: sx,
			ay: sy
		}
		return next;
	}
	
	function scroll(href){
		var movedHash = href;
		timer = setInterval(function(){
			nextPoint();
			if(Math.abs(nextPoint().ax)<1 && Math.abs(nextPoint().ay)<1){
				clearInterval(timer);
				window.scroll(pos.left,pos.top);
				location.href = movedHash;
			}
			window.scroll(nextPoint().x,nextPoint().y);
		},c.interval);
	}
	
	function comeLink(){
		if(location.hash){
			if($(location.hash) && $(location.hash).length>0){
				pos = $(location.hash).offset();
				setPoint();
				window.scroll(0,0);
				if($.browser.msie){
					setTimeout(function(){
						scroll(location.hash);
					},50);
				}else{
					scroll(location.hash);
				}
			}
		}
	}
	if(c.comeLink) comeLink();
	
	$(this).each(function(){
		if(this.hash && $(this.hash).length>0 
			&& this.href.match(new RegExp(location.href.split("#")[0]))){
			var hash = this.hash;
			$(this).click(function(){
				pos = $(hash).offset();
				clearInterval(timer);
				setPoint();
				scroll(this.href);
				return false;
			});
		}
	});
}

*/



/*--------------------------------------------------------------------------*
 *  
 *  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);
}