// 新しいウィンドウを開く
// "openurl" onclick="openMod(this.href,wsize,hsize);return false;" onkeypress="openMod(this.href,wsize,hsize);return false;"
// 外部ドメインには使用しないでください
function openMod (openurl, wsize, hsize) {
var myMod;
	if (openurl) {
		mywin = window.open (openurl, 'window', 'toolbar=0,locationbar=0,status=0,directories=0,menubar=0,scrollbars=1,resizable=1');
		w = wsize;
		if(wsize<=1){
				w = screen.width/5*4;
			}else{
				w = wsize
		}
		if(hsize<=1){
				h = screen.height/5*4;
			}else{
				h = hsize
		}
		x = (screen.width - w) / 2;
		y = (screen.height - h) / 2;
		with (mywin) {
			resizeTo (w, h);
			window.moveTo (x, y);
			focus ();
		}
	}
return(false);
}

// "targeturl" onclick="targetMod(this.href);return false;" onkeypress="targetMod(this.href);return false;"
function targetMod (targeturl) {	
	if (targeturl) {
		mytargetwin = window.open (targeturl);
		mytargetwin.focus();
	}
return(false);
}


function autoPOP()
{
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('className') == 'popup' || x[i].getAttribute('class') == 'popup')
		{
			x[i].onclick = function () {
			return openMod (this.href,750,600)
			}
			x[i].title += '(Popup)';
		}
	}
};

function autoTarget()
{
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('className') == 'target' || x[i].getAttribute('class') == 'target')
		{
			x[i].onclick = function () {
			return targetMod (this.href)
			}
			x[i].title += '(Target)';
		}
	}
};


//テキストフォームのフォーカス
$(function(){
	var aleatMsg='サイト内検索';
	var initClr='#969696';
	var inputClr='#333';
	$(".textfield").val(aleatMsg)
	   .css("color",initClr);
	$(".textfield").focus(function(){
		if(this.value == aleatMsg){
			$(this).val("").css("color",inputClr);
		}
	});
	$(".textfield").blur(function(){
		if(this.value == ""){
			$(this).val(aleatMsg)
			     .css("color",initClr);
		}
		if(this.value != aleatMsg){
			$(this).css("color",inputClr);
		}
	});
});


/*--------------------------------------------------------------------------*
 *  
 *  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);
}


/*--------------------------------------------------------------------------*
 *
 *  2011.2
 *  add a function of
 *  http://faq.sompo-japan.dga.jp/
 *  for /covenanter/index.html
 *
 *--------------------------------------------------------------------------*/
function purposeOC(n, flg){
  if(flg == 2){
    var purpose     = '#purpose2_'+ n;
    var purposelist = 'purpose_list2_'+ n;
    var purposeImg  = 'purpose_img2_'+ n;
  }else{
    var purpose     = '#purpose1_'+ n;
    var purposelist = 'purpose_list1_'+ n;
    var purposeImg  = 'purpose_img1_'+ n;
  }
  if(document.getElementById(purposelist)){
    purposeObj  = document.getElementById(purposelist);
    purposeImgObj = document.getElementById(purposeImg);
    if(purposeObj.style.display == 'block'){
      purposeObj.style.display = 'none';
      purposeImgObj.src = '/images/common/module/icon/bullet_arrow_02.gif';
    }else{
      purposeObj.style.display = 'block';
      purposeImgObj.src = '/images/common/module/icon/bullet_arrow_01.gif';
    }
    $(purpose).toggleClass("visible-menu");
    $(purpose).toggleClass("hidden-menu-01");
  }
}

function listOpenAll(flg){
  if(flg == 2){
    $('div[@id*="purpose_list2_"]').css("display", "block");
    $('table[@id*="purpose2_"]').removeClass("visible-menu");
    $('table[@id*="purpose2_"]').removeClass("hidden-menu-01");
    $('table[@id*="purpose2_"]').addClass("hidden-menu-01");
    $('img[@id*="purpose_img2_"]').attr("src","/images/common/module/icon/bullet_arrow_01.gif");
    $('#purpose_open2').css("display", "none");
    $('#purpose_close2').css("display", "");
  }else{
    $('div[@id*="purpose_list1_"]').css("display", "block");
    $('table[@id*="purpose1_"]').removeClass("visible-menu");
    $('table[@id*="purpose1_"]').removeClass("hidden-menu-01");
    $('table[@id*="purpose1_"]').addClass("hidden-menu-01");
    $('img[@id*="purpose_img1_"]').attr("src","/images/common/module/icon/bullet_arrow_01.gif");
    $('#purpose_open1').css("display", "none");
    $('#purpose_close1').css("display", "");
  }
}

function listCloseAll(flg){
  if(flg == 2){
    $('div[@id*="purpose_list2_"]').css("display", "none");
    $('table[@id*="purpose2_"]').removeClass("visible-menu");
    $('table[@id*="purpose2_"]').removeClass("hidden-menu-01");
    $('table[@id*="purpose2_"]').addClass("visible-menu");
    $('img[@id*="purpose_img2_"]').attr("src","/images/common/module/icon/bullet_arrow_02.gif");
    $('#purpose_close2').css("display", "none");
    $('#purpose_open2').css("display", "");
  }else{
    $('div[@id*="purpose_list1_"]').css("display", "none");
    $('table[@id*="purpose1_"]').removeClass("visible-menu");
    $('table[@id*="purpose1_"]').removeClass("hidden-menu-01");
    $('table[@id*="purpose1_"]').addClass("visible-menu");
    $('img[@id*="purpose_img1_"]').attr("src","/images/common/module/icon/bullet_arrow_02.gif");
    $('#purpose_close1').css("display", "none");
    $('#purpose_open1').css("display", "");
  }
}



/**/



