/////////////////////////
// COOKIEに値をセット //
////////////////////////
function setCookie(theName, theValue, theDay){
	if((theName != null) && (theValue != null)){
		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";
		if(theDay != null){
			theDay = eval(theDay);
			setDay = new Date();
			setDay.setTime(setDay.getTime() + (theDay * 1000 * 60 * 60 * 24));
			expDay = setDay.toGMTString();
		}
		document.cookie = theName + "=" + escape(theValue) + ";expires=" + expDay;
		alert(theName + "=" + escape(theValue) + ";expires=" + expDay);
		return true;
	}
	return false;
}

//サブウインドを画面の中央に表示する-------------------------------------
//引数：　サブウインドに表示するファイルのURL
//引数：　サブウインド名
//引数：　サブウインドの横幅
//引数：　サブウインドの縦幅
//引数：　スクロールバーの有無
//帰値：　サブウインドobj
//-----------------------------------------------------------------------
function ShwSubWinC( strURL, strName, nWx, nWy, UseScrlBar ) {
	var x = ( screen.width - nWx ) / 2;
	var y = ( screen.height - nWy ) / 2;
	if( UseScrlBar == 1 ) var ScrlBar = "yes";
	else var ScrlBar = "no";
	var ScrlBar = UseScrlBar;
	return window.open( strURL, strName,
								"left="+x+",top="+y+",width="+nWx+",height="+nWy+
								",scrollbars="+ScrlBar );
}

//サブウインドを画面の中央に表示する-------------------------------------
//引数：　サブウインドに表示するファイルのURL
//引数：　サブウインド名
//引数：　サブウインドの横幅
//引数：　サブウインドの縦幅
//引数：　ウィンドウの性質
//帰値：　サブウインドobj
//-----------------------------------------------------------------------
function ShwSubWinC2( strURL, strName, nWx, nWy, WinStatus ) {
	var x = ( screen.width - nWx ) / 2;
	var y = ( screen.height - nWy ) / 2;
	hWin = window.open( strURL, strName,
								"left="+x+",top="+y+",width="+nWx+",height="+nWy+
								","+WinStatus );
	hWin.focus();
}

// すべてのフォーム部品をdisabledにする
function setDiabledAll(){
	var i, j;
	
	/*
	for(i = 0; i < document.forms.length; i++){
		for(j = 0; j < document.forms[i].elements.length; j++){
			alert(document.forms[i].elements[j].name);
			document.forms[i].elements[j].disabled = "true";
		}
	}
	*/
	
	var eleAry = document.getElementsByTagName("INPUT");
	
	for(i = 0; i < eleAry.length; i++){
		if(eleAry[i].type == "button" || eleAry[i].type == "submit"){
			eleAry[i].disabled = "true";
		}
	}
}

function openOpener(url){
	var hWin;
	
	if(sj_isObjNull(window.opener)){
		hWin = window.open(url);
		hWin.focus();
	}else{
		window.opener.document.location.href = url;
		window.opener.focus();
	}
}

function cbClick(id)
{
	var o = document.getElementById(id);
	var i = o.getElementsByTagName('input')[0];
	var s = o.getElementsByTagName('select')[0];
	
	if (s.style.display != 'block') {
		s.style.display = 'block';
		s.focus();
	} else {
		s.style.display = 'none';
	}
}

function cbInput(id)
{
	var o = document.getElementById(id);
	var s = o.getElementsByTagName('select')[0];
	s.style.display = 'none';
}

function cbSelect(id)
{
	var o = document.getElementById(id);
	var i = o.getElementsByTagName('input')[0];
	var s = o.getElementsByTagName('select')[0];
	s.style.display = 'none';
	//i.value = s.value;
	if(s.selectedIndex >= 0){
		i.value = s.options[s.selectedIndex].text;
	}else{
		i.value = "";
	}
}
