function menu_navigate(currentpage, targetpage, id) {

	f = document.cosmos;
	p = getscriptname(currentpage);
	if(f.d1 == null || f.d2 == null){
		f.action = targetpage;
		f.submit();
	}else if (submit_check(p,false) || p == 'messagelist') {
		f.id.value = id;
		f.tid.value = 0;
		f.action = targetpage;
//		setLongTypeDate();
		f.submit();
	}
}

function office_submit(){
	document.cosmos.everyset.value = 1;
	document.cosmos.submit();
}

function submenu_navigate(currentpage, id, tid) {
	f = document.cosmos;
	p = getscriptname(currentpage);
	if (submit_check(p,false)) {
		f.id.value = id;
		f.tid.value = tid;
		f.submit();
	}
}


function tab_navigate(currentpage, tid) {
	f = document.cosmos;
	p = getscriptname(currentpage);
	if (submit_check(p,false)) {
		f.tid.value = tid;
		f.action = currentpage;
		f.submit();
	}
}

function submit_check(page, issubmit) {
	if(displayflag == 0){
		displayflag = 1;
		switch(page)
		{
			case 'analyze': 
				if(analyze_submit_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;
				}
				break;
			case 'daily':
				if(daily_submit_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;
				}
				break;
			//掲示板履歴 insert by na on 2008/12/25
			case 'bbs':
				if(bulletin_board_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;
				}
				break;
			case 'weekly': 
				if(weekly_submit_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;				
				}
				break;
			case 'monthly': 
				if(monthly_submit_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;				
				}
				break;
			case 'dayofweek':
				if(dayofweek_submit_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;				
				}
				break;
			case 'yearly':
				if(yearly_submit_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;				
				}
				break;
			case 'mailsend':
				if(mailsend_check(issubmit)){
					return true;
				}else{
					displayflag = 0;
					return false;				
				}
				break;
			case 'officesetting': 
					displayflag = 0;
					return true;
				break;
			case 'progress':
					displayflag = 0; 
					return true;
				break;
			case 'report':
					displayflag = 0; 
					return true;
				break;
			default : displayflag = 0; return false;
		}
	}else{

	}
}

function getscriptname(str) {
	arr = str.toString().split("/");
	return arr[arr.length-1].toString().split(".")[0];
}

function mailsend_check(issubmit) {
	var f = document.fm;
	var who = trim(f.who.value);
	var address = trim(f.address.value);
	var content = trim(f.content.value);
	var error = false;
	var msg = '';
	if (who.length == 0) {
		msg += '名前は入力必要です！\n';
		error = f.who;
	}
	if (address.length == 0) {
		msg += 'メールアドレスは入力必要です！\n';
		if (!error) error = f.address;
	} else {
		emailReg = /^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!emailReg.test(address)) {
			msg += 'メールアドレスの書式が不正です！';
			if (!error) error = f.address;
		}
	}
	if (content.length == 0) {
		msg += '内容は入力必要です！\n';
		if (!error) error = f.content;
	}
	if(!error){
		f.who.value = who;
		f.address.value = address;
		if (issubmit) f.submit();
		return true
	} else {
		alert(msg);
		error.focus();
		return false
	}
}

function bbs_submit_check() {
	var f = document.cosmos;
	var d3 = trim(f.d3.value);
	var d3full = d3 + '/01';
	var error = false;
	var msg = '';
	if (!(isvaliddate(d3full) && isvaliddatescope(d3full))) {
		msg += '日付フォーマットが不正です！\n';
		if (!error) error = f.d3;
	}
	if(!error){
		f.d3.value = d3;
		return true;
	} else {
		alert(msg);
		error.focus();
		return false;
	}
}

function supportmemo_submit_check() {
	var f = document.cosmos;
	var supportmemo = f.supportmemo.value;
	var error = false;
	var msg = '';
	if (supportmemo.length == 0) {
		msg += '欄内に文字を入力してください。\n';
		error = f.supportmemo;
	}
	if(!error) {
		return true
	} else {
		alert(msg);
		error.focus();
		return false;
	}
}

function customermemo_submit_check() {
	var f = document.cosmos;
	var customermemo = f.customermemo.value;
	var error = false;
	var msg = '';
	if (customermemo.length == 0) {
		msg += '欄内に文字を入力してください。\n';
		error = f.customermemo;
	}
	if(!error) {
		return true
	} else {
		alert(msg);
		error.focus();
		return false;
	}
}

function monthly_submit_check(issubmit) {
	return daily_submit_check(issubmit);
}

function weekly_submit_check(issubmit) {
	return daily_submit_check(issubmit);
}

function dayofweek_submit_check(issubmit) {
	return daily_submit_check(issubmit);
}

function daily_submit_check(issubmit) {
	var f = document.cosmos;
	var d1 = trim(f.d1.value);
	var d2 = trim(f.d2.value);
	var error = false;
	var msg = '';
	if (!(isvaliddate(d1) && isvaliddatescope(d1))) {
		msg += '計測データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d1;
		}
	}
	if (!(isvaliddate(d2) && isvaliddatescope(d2))) {
		msg += '比較データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d2;
		}
	}
	if(!error){
		f.d1.value = d1;
		f.d2.value = d2;
		if (issubmit) f.submit();
		return true
	} else {
		alert(msg);
		error.focus();
		return false;
	}
}
function olddata(issubmit) {
	var f = document.cosmos;
	var dt3 = trim(f.dt3.value);

	if(dt3.length == 4){
		var d1full = dt3 + '/01/01';
	}else{
		var d1full = dt3;
	}
	
	var error = false;
	var msg = '';
	if (!(isvaliddate(d1full) && isvaliddatescope(d1full))) {
		msg += '日付フォーマットが不正です！\n';
		if (!error) {
			error = f.dt3;
		}
	}
	if(!error){
		f.dt3.value = dt3;
		if (issubmit) f.submit();
		return true
	} else {
		alert(msg);
		error.focus();
		return false
	}
}
function yearly_submit_check(issubmit) {
	var f = document.cosmos;
	var d1 = trim(f.d1.value);
	var d2 = trim(f.d2.value);

	if(d1.length == 4){
		var d1full = d1 + '/01/01';
	}else{
		var d1full = d1;
	}
	
	if(d2.length == 4){
		var d2full = d2 + '/01/01';
	}else{
		var d2full = d2;
	}
	
	var error = false;
	var msg = '';
	if (!(isvaliddate(d1full) && isvaliddatescope(d1full))) {
		msg += '計測データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d1;
		}
	}
	if (!(isvaliddate(d2full) && isvaliddatescope(d2full))) {
		msg += '比較データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d2;
		}
	}
	if(!error){
		f.d1.value = d1;
		f.d2.value = d2;
		if (issubmit) f.submit();
		return true
	} else {
		alert(msg);
		error.focus();
		return false
	}
}

function isvaliddatescope(str) {
	//日付の範囲は1970/01/01~2030/12/31
	var y = parseInt(str.split("/")[0]);
	if (y >= 1970 && y <= 2030) {
		//return true
	}else{
		alert('1970年から2030年の間で選択してください！');
	}
	return true
}

function isvaliddate(dateval){
	if (dateval.length != 10) {
		return false;
	}
	var arr = new Array();
	if(dateval.indexOf("/") != -1){
		arr = dateval.toString().split("/");
	}else{
		return false;
	}
	//書式はyyyy/mm/dd
	if(arr[0].length==4){
		var date = new Date(arr[0],arr[1]-1,arr[2]);
		if(date.getFullYear()==arr[0] && date.getMonth()==arr[1]-1 && date.getDate()==arr[2]){
			return true;
		}
	}
	return false;
}

function trim(str)
{
	return str.replace(/\s+$/,"").replace(/^\s+/,"");
}

//**************************************************************
//関数名 ：csv_download(..)
//機能　　： データダウンロード  	 
//引数　　：なし
//戻り値  ：なし  
//画面　　：週間詳細表、月間詳細表、曜日詳細表、年間詳細表
//作者　　：董俊 
//日付　　：2008/01/05
//**************************************************************
function csv_download(page,unitname) {
	f = document.cosmos;
	if (submit_check(page,false)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php?unitname=" + unitname;
		f.submit();
	}
}

function csv_download_weekly(page,data_show_flag,unitname) {
	f = document.cosmos;
	if (submit_check(page,false)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php?unitname=" + unitname + '&data_show_flag=' + data_show_flag;
		f.submit();
	}
}
function csv_download_yearly(page,data_show_flag,unitname) {
	f = document.cosmos;
	if (submit_check(page,false)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php?unitname=" + unitname + '&data_show_flag=' + data_show_flag;
		f.submit();
	}
}

function csv_download_monthly(page,data_show_flag,unitname) {
	f = document.cosmos;
	if (submit_check(page,false)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php?unitname=" + unitname + '&data_show_flag=' + data_show_flag;
		f.submit();
	}
}
//**************************************************************
//関数名 ：csv_download_daily(..)
//機能　　： データダウンロード  	 
//引数　　：なし
//戻り値  ：なし  
//画面　　： 一日詳細表
//作者　　：董俊 
//日付　　：2008/01/05
//**************************************************************
function csv_download_daily(page,cha,unitname) {
	f = document.cosmos;
	if (submit_check(page,false)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php?cha=" + cha + "&unitname=" + unitname;
		f.submit();
	}
}
//**************************************************************
//関数名 ：csv_download_bbs(..)
//機能　　： データダウンロード
//引数　　：なし
//戻り値  ：なし  
//画面　　： 掲示板履歴のデータダウンロード
//作者　　：那　宇峰 
//日付　　：2008/12/25
//**************************************************************
function csv_download_bbs(page) {
	f = document.cosmos;
	if (submit_check(page,true)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php";
		f.submit();
	}
}
//**************************************************************
//関数名 ：bbsnoterefresh(..)
//機能　　： ページの更新  	 
//引数　　：なし
//戻り値  ：なし  
//画面　　：一覧へ
//作者　　：董俊 
//日付　　：2008/01/04
//**************************************************************
function bbsnoterefresh(f) {
	f.page.value=0;
	if (bbs_submit_check()) {
		f.submit();
	}
}

//**************************************************************
//関数名 ：jumptonextpage(..)
//機能　　： 前のページの動作
//引数　　：なし
//戻り値  ：なし  
//画面　　：一覧へ
//作者　　： 董俊
//日付　　：2008/01/04
//**************************************************************
function jumptonextpage(f) {
	f.page.value = parseInt(f.page.value) + 1;
	if (bbs_submit_check()) {
		f.submit();
	}
}

//**************************************************************
//関数名 ：jumptoprevpage(..)
//機能　　：後ろページの動作
//引数　　：なし
//戻り値  ：なし  
//画面　　：一覧へ
//作者　　： 董俊
//日付　　：2008/01/04
//**************************************************************
function jumptoprevpage(f) {
	f.page.value = parseInt(f.page.value) - 1;
	if (bbs_submit_check()) {
		f.submit();
	}
}

//function parentsubmit(sid,co2,days) {
//	var count = days.length;
//	for(var i=0;i<count;i++ ){
//		alert(days[i]);
//	}
//	window.parent.document.forms["cosmos"].action = sid+".php?param_co2="+co2+"&abc="+days[1];
//	window.parent.document.forms["cosmos"].submit();
//}

function popuprevisionhistory(user_right_flag){
	var cn_cd= document.cosmos.cn_cd.value;
	var url = "editpopuprevisionhistory.php?cn_cd="+cn_cd+"&user_right_flag="+user_right_flag;
	var s = '<iframe src='+url+' width=380 height=300/>';
	return overlib(s, CAPTION, '契約履歴',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',RELX, -240);
}

function writesupportmemo(f, page){
	if (supportmemo_submit_check()) {
		res = submit_check(getscriptname(page), false);
		if (res) {
			f.action = 'writesupportmemo.php?frompage=' + page;
			f.submit();
		}
	}
}


function writecustomermemo(f, page){
	if (customermemo_submit_check()) {
		res = submit_check(getscriptname(page), false);
		if (res) {
			
			f.action = 'writecustomermemo.php?frompage=' + page;
			f.submit();
			
			
		}
	}
}

function popupinquiring(){
	s = '<iframe src=\'editpopupinquiring.php\' width=300 height=160/>';
	return overlib(s, CAPTION, 'test',STICKY, LEFT);
}
function popupeditchannel(number,measureno,channelno){
	
	c = '\'editpopupchannel.php?';
	c += '&number=' + number;
	c += '&sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&measureno=' + measureno;
	c += '&channelno=' + channelno;
	c += '\'';
	s = '<iframe src=' + c + ' width=350 height=350/>';

	return overlib(s, CAPTION, 'NO '+number,CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,LEFT);
}
function popupsetgraph(ElecAndTarget,Demand,ElecAll,gid){
	c = '\'setgraph.php?';
	c += 'ElecAndTarget=' + ElecAndTarget;
	c += '&Demand=' + Demand;
	c += '&ElecAll=' + ElecAll;
	c += '&gid=' + gid;
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;

	if(document.cosmos.co2.value != null){
		c += '&co2=' + document.cosmos.co2.value;
	}
	c += '\'';
	if(document.cosmos.form.value=='weekly' && document.cosmos.tid.value == '0'){
		s = '<iframe src=' + c + 'width=350 height=420 />';
		//alert("weekly");
	}else if(document.cosmos.form.value=='monthly' && document.cosmos.tid.value == '0'){
		s = '<iframe src=' + c + 'width=350 height=320 />';
		//alert("monthly")
	}else if(document.cosmos.form.value=='monthly' && document.cosmos.tid.value == '1'){
		s = '<iframe src=' + c + 'width=350 height=220 />';
		//alert("monthly")
	}else{
		s = '<iframe src=' + c + 'width=350 height=400 />';
		//alert("other")
	}
	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}

function popupsetgraph1(ElecAndTarget,Demand,ElecAll,gid,xWidth,yHeight,elec_show_flag){

	elec_show_flag = (elec_show_flag == 1 || elec_show_flag == 2)? 1 : 0;
	c = '\'setgraph.php?';
	c += 'ElecAndTarget=' + ElecAndTarget;
	c += '&Demand=' + Demand;
	c += '&ElecAll=' + ElecAll;
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&gid=' + gid;
	c += '&elec_show_flag=' + elec_show_flag;
	c += '\'';
	s = '<iframe src=' + c + ' width= ' + xWidth + ' height= '+ yHeight +' />';

	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}

function popupsetsumgraph(){
	c = '\'setsumgraph.php?';
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '\'';

	s = '<iframe src=' + c + 'width=350 height=420 />';

	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}
function popupsetsumgraph_SetSize(width,height){
	c = '\'setsumgraph.php?';
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '\'';

	//s = '<iframe src=' + c + 'width=350 height=420 />';
	s = '<iframe src=' + c + ' width= ' + width + ' height= ' + height + ' />';

	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}

//**************************************************************
//関数名 ：popupsetgraph_7day(..)
//日付　　：2007/11/15
//**************************************************************
function popupsetgraph_7day(ElecAndTarget,Demand,ElecAll,gid,xWidth,yHeight){
	c = '\'setgraph.php?';
	c += 'ElecAndTarget=' + ElecAndTarget;
	c += '&Demand=' + Demand;
	c += '&ElecAll=' + ElecAll;
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&gid=' + gid;
	c += '&day_7=1'
	c += '&day0=' + document.cosmos.day0.value;
	c += '&day1=' + document.cosmos.day1.value;
	c += '&day2=' + document.cosmos.day2.value;
	c += '&day3=' + document.cosmos.day3.value;
	c += '&day4=' + document.cosmos.day4.value;
	c += '&day5=' + document.cosmos.day5.value;
	c += '&day6=' + document.cosmos.day6.value;
	c += '&day00=' + document.cosmos.day00.value;
	c += '&day11=' + document.cosmos.day11.value;
	c += '&day22=' + document.cosmos.day22.value;
	c += '&day33=' + document.cosmos.day33.value;
	c += '&day44=' + document.cosmos.day44.value;
	c += '&day55=' + document.cosmos.day55.value;
	c += '&day66=' + document.cosmos.day66.value;
	
	c += '&date_1no1=' + document.cosmos.date_1no1.value;
	c += '&date_1no2=' + document.cosmos.date_1no2.value;
	c += '&date_1no3=' + document.cosmos.date_1no3.value;
	c += '&date_1no4=' + document.cosmos.date_1no4.value;
	c += '&date_1no5=' + document.cosmos.date_1no5.value;
	c += '&date_1no6=' + document.cosmos.date_1no6.value;
	c += '&date_1no7=' + document.cosmos.date_1no7.value;
	c += '&date_2no1=' + document.cosmos.date_2no1.value;
	c += '&date_2no2=' + document.cosmos.date_2no2.value;
	c += '&date_2no3=' + document.cosmos.date_2no3.value;
	c += '&date_2no4=' + document.cosmos.date_2no4.value;
	c += '&date_2no5=' + document.cosmos.date_2no5.value;
	c += '&date_2no6=' + document.cosmos.date_2no6.value;
	c += '&date_2no7=' + document.cosmos.date_2no7.value;
	c += '\'';
	//s = '<iframe src=' + c + 'width=350 height=600 />';
	s = '<iframe src=' + c + 'width= '+xWidth+ ' height= '+yHeight+' />';
							//,STICKY, LEFT
	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}
//gbl modify 20081210  start
function popupsetgraph_5day(ElecAndTarget,Demand,ElecAll,gid,xWidth,yHeight){
	//if(ElecAndTarget == 1){
		//alert('ElecAndTarget='+ElecAndTarget);
	//}
	c = '\'setgraph.php?';
	c += 'ElecAndTarget=' + ElecAndTarget;
	c += '&Demand=' + Demand;
	c += '&ElecAll=' + ElecAll;
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&gid=' + gid;
	c += '&day_5=1'
	c += '&data5_flag1=' + document.cosmos.data5_flag1.value;
	c += '&data5_flag2=' + document.cosmos.data5_flag2.value;
	c += '&day0=' + document.cosmos.day0.value;
	c += '&day1=' + document.cosmos.day1.value;
	c += '&day2=' + document.cosmos.day2.value;
	c += '&day3=' + document.cosmos.day3.value;
	c += '&day4=' + document.cosmos.day4.value;
	c += '&day00=' + document.cosmos.day00.value;
	c += '&day11=' + document.cosmos.day11.value;
	c += '&day22=' + document.cosmos.day22.value;
	c += '&day33=' + document.cosmos.day33.value;
	c += '&day44=' + document.cosmos.day44.value;
	c += '&set_avr1=' + document.cosmos.set_avr1.value;
	c += '&set_max1=' + document.cosmos.set_max1.value;
	c += '&set_min1=' + document.cosmos.set_min1.value;
	c += '&set_avr2=' + document.cosmos.set_avr2.value;
	c += '&set_max2=' + document.cosmos.set_max2.value;
	c += '&set_min2=' + document.cosmos.set_min2.value;
	
	c += '&date_1no1=' + document.cosmos.date_1no1.value;
	c += '&date_1no2=' + document.cosmos.date_1no2.value;
	c += '&date_1no3=' + document.cosmos.date_1no3.value;
	c += '&date_1no4=' + document.cosmos.date_1no4.value;
	c += '&date_1no5=' + document.cosmos.date_1no5.value;
	
	c += '&date_2no1=' + document.cosmos.date_2no1.value;
	c += '&date_2no2=' + document.cosmos.date_2no2.value;
	c += '&date_2no3=' + document.cosmos.date_2no3.value;
	c += '&date_2no4=' + document.cosmos.date_2no4.value;
	c += '&date_2no5=' + document.cosmos.date_2no5.value;
	
	c += '\'';
	//s = '<iframe src=' + c + 'width=340 height=590 />';
	s = '<iframe src=' + c + 'width='+xWidth+' height='+yHeight +'/>';
	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}

//gbl modify 20081210  end
function popupsetgraph_monthmaxmin(ElecAndTarget,Demand,ElecAll,gid,xWidth, yHeight){

	c = '\'setgraph.php?';
	c += 'ElecAndTarget=' + ElecAndTarget;
	c += '&Demand=' + Demand;
	c += '&ElecAll=' + ElecAll;
	c += '&sid=' + document.cosmos.form.value;
	c += '&kid=' + document.cosmos.id.value;
	c += '&tid=' + document.cosmos.tid.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&gid=' + gid;
	c += '&monthmaxmin=1'
	c += '&day0=' + document.cosmos.day0.value;
	c += '&day1=' + document.cosmos.day1.value;
	c += '&day2=' + document.cosmos.day2.value;
	c += '&day3=' + document.cosmos.day3.value;
	c += '&day4=' + document.cosmos.day4.value;
	c += '&day5=' + document.cosmos.day5.value;
	c += '&day6=' + document.cosmos.day6.value;
	c += '&day17=' + document.cosmos.day17.value;
	c += '\'';
	//s = '<iframe src=' + c + 'width=450 height=300 />';
	s = '<iframe src=' + c + 'width='+xWidth+' height='+yHeight+' />';

	return overlib(s, CAPTION, 'グラフの設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,ABOVE);
}

//*************************************************
//setgraph.tpl 
//*************************************************
function popjump(f){
	//alert(parent.document.cosmos.d1.value);
	if(popup_submit_check(f.sid.value,true)==true){
		var reg;   
		reg=/^\d{0,8}$/;   
		var r=f.tmax.value.match(reg);
		
		if(r==null){
			alert("もう一度入力してください！");
			return;    
		}  

		var v='';
		if(f.cbElec != null){
			if(f.cbElec.checked == true){
				f.elec.value = 1;
			}else{
				f.elec.value = 0;
			}
		}
		
		if(f.cbElecval != null){
			if(f.cbElecval.checked == true){
				f.elecval.value = 1;
			}else{
				f.elecval.value = 0;
			}
		}
		
		if(f.cbDelTarget != null){
			if(f.cbDelTarget.checked == true){
				f.deltarget.value = 1;
			}else{
				f.deltarget.value = 0;
			}		
		}
		
		if(f.cbDelTargetval != null){
			if(f.cbDelTargetval.checked == true){
				f.deltargetval.value = 1;
			}else{
				f.deltargetval.value = 0;
			}		
		}
		
		if(f.cbDemand != null){
			if(f.cbDemand.checked == true){
				f.demand.value = 1;
			}else{
				f.demand.value = 0;
			}
		}

		if(f.cbLine != null){
			if(f.cbLine.checked == true){
				f.st_line.value = 1;
			}else{
				f.st_line.value = 0;
			}
		}
		
		if(f.cbElecAll != null){
			if(f.cbElecAll.checked == true){
				f.allelec.value = 1;
			}else{
				f.allelec.value = 0;
			}
		}
			
		f.max.value = f.tmax.value;
		if(f.tmax1 != null){
			r=f.tmax1.value.match(reg);
			if(r==null){
				alert("もう一度入力してください！");
				return;
			} 	
			f.max1.value = f.tmax1.value;		
		}
		var path1 = document.getElementById('box1');
		var str="";
		if(path1 != null){
			for (var i = 0; i < path1.options.length; i++){
				str += path1.options[i].value + "&";
			}
		}
		f.line.value = str;
		
		v += 'sid=' + f.sid.value;
		v += '&kid=' + f.kid.value;
		v += '&tid=' + f.tid.value;
		v += '&cn_cd=' + f.cn_cd.value;
		v += '&gid=' + f.gid.value;
		v += '&elec=' + f.elec.value;
		v += '&elecval=' + f.elecval.value;
		v += '&deltarget=' + f.deltarget.value;
		v += '&deltargetval=' + f.deltargetval.value;
		v += '&demand=' + f.demand.value;
		v += '&st_line=' + f.st_line.value;
		v += '&line=' + f.line.value;
		v += '&allelec=' + f.allelec.value;
		v += '&max=' + f.max.value;
		v += '&max1=' + f.max1.value;
		v += '&co2=' + f.co2.value;
		v += '&day_7=' + f.day_7.value;
		v += '&day_5=' + f.day_5.value;
		v += '&monthmaxmin=' + f.monthmaxmin.value;
		if(f.day_7.value == 1){
			v += '&day0=' + f.day0.value;
			v += '&day1=' + f.day1.value;
			v += '&day2=' + f.day2.value;
			v += '&day3=' + f.day3.value;
			v += '&day4=' + f.day4.value;
			v += '&day5=' + f.day5.value;
			v += '&day6=' + f.day6.value;
			v += '&day00=' + f.day00.value;
			v += '&day11=' + f.day11.value;
			v += '&day22=' + f.day22.value;
			v += '&day33=' + f.day33.value;
			v += '&day44=' + f.day44.value;
			v += '&day55=' + f.day55.value;
			v += '&day66=' + f.day66.value;
		}else if(f.monthmaxmin.value == 1){
			v += '&day0=' + f.day0.value;
			v += '&day1=' + f.day1.value;
			v += '&day2=' + f.day2.value;
			v += '&day3=' + f.day3.value;
			v += '&day4=' + f.day4.value;
			v += '&day5=' + f.day5.value;
			v += '&day6=' + f.day6.value;	
			v += '&day17=' + f.day17.value;
		}else if(f.day_5.value == 1){
			v += '&day0=' + f.day0.value;
			v += '&day1=' + f.day1.value;
			v += '&day2=' + f.day2.value;
			v += '&day3=' + f.day3.value;
			v += '&day4=' + f.day4.value;	
			v += '&day00=' + f.day00.value;
			v += '&day11=' + f.day11.value;
			v += '&day22=' + f.day22.value;
			v += '&day33=' + f.day33.value;
			v += '&day44=' + f.day44.value;
		}
		f.action = 'setgraphparam.php?' + v;
		f.submit();
	}

}
function sum_subimit(f){
	var path1 = document.getElementById('box1');
	if(f.cbElecAll != null){
		if(f.cbElecAll.checked == true){
			f.allelec.value = 1;
		}else{
			f.allelec.value = 0;
		}
	}
	if(f.cbLine != null){
		if(f.cbLine.checked == true){
			f.st_line.value = 1;
		}else{
			f.st_line.value = 0;
		}
	}
	var str="";
	if(path1 != null){
		for (var i = 0; i < path1.options.length; i++){
			str += path1.options[i].value + "&";
		}
	}
	f.line.value = str;
	f.back_flag.value=1;
	f.submit();
}
function addItem(sid,tid){
	var txtLine = document.getElementById('txtLine');
	if(txtLine.value != ""){
		var path1 = document.getElementById('box1');
		if(sid == "analyze" || (sid == "monthly" && tid == 4) || sid == "daily" || 
									(sid == "weekly" && (tid == 1 || tid == 2))){
			var op = new Option(txtLine.value,txtLine.value);
		}else if(sid == "monthly" || (sid == "weekly" && (tid == 0 || tid == 3))){
			var op = new Option(txtLine.value + "日",txtLine.value);			
		}else if(sid == "yearly"){
			var op = new Option(txtLine.value + "月",txtLine.value);			
		}
		path1.options[path1.length] = op;
		txtLine.value="0:00";
	}else{
		alert("値を入力してください");
	}
}

function delItem(){
	var path1 = document.getElementById('box1');
	var j=0;
	for (var i = 0; i < path1.options.length; i++){
		if (path1.options[i].selected){
			path1.remove(i);
			j++;
		}
	}
	if(path1.options.length > 0 && j==0){
		alert("削除するデータを選択してください！");
	}
}

//**************************************************************
//関数名 ：detailsheetdisp(..)
//機能    ：詳細表の比較データ表を表示かどうか
//引数    ：checkboxname(checkboxの項目名)
//戻り値  ：なし  
//画面　　：一日詳細表、週間詳細表、月間詳細表、曜日詳細表、年間詳細表
//作者　　： 
//日付　　：2007/11/15
//**************************************************************
function detailsheetdisp(checkboxname){
	if(checkboxname.checked == true){
		detailsheet2.style.display='inline';
		detailsheet3.style.display='inline';
	}else{
		detailsheet2.style.display='none';
		detailsheet3.style.display='none';
	}
}

//**************************************************************
//関数名 ：demandgraphdisp(..)
//機能　　：デマンドグラフを表示かどうか
//引数　　：なし
//戻り値  ：なし  
//画面　　：
//作者　　： 
//日付　　：2007/11/15
//**************************************************************
function demandgraphdisp(){
	if(demandshowcheck.checked == true){
		demandgraph.style.display='inline'
	}else{
		demandgraph.style.display='none'
	}
}

//**************************************************************
//関数名 ：sheetdisp(..)
//機能    ：比較データ表を表示かどうか
//引数    ：なし
//戻り値  ：なし  
//画面     ：
//作者     ： 
//日付     ：2007/11/15
//**************************************************************
function sheetdisp(checkboxname,divname){
	if(checkboxname.checked==true){
		divname.style.display='inline';
	}else{
		divname.style.display='none';
	}
}

//**************************************************************
//関数名	：analyze_change_time(..)
//機能		：分析画面の日付、開始時間と終了時間の移動関係とフォマットチェック
//引数		：change_index	1: １時間が間として　小さくになる
//										2:　１時間が間として　大きくになる
//										3:　開始時間と終了時間の差が間として　小さくになる
//										4:　開始時間と終了時間の差が間として　多きくになる
//戻り値	：なし　　　　日付、開始時間と終了時間のフォマットが正しい場合
//			：false  日付、開始時間或いは終了時間のフォマットが不正の場合
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function analyze_change_time(change_index){/* 分析開始時間と終了時間移動について*/		

	var tempDate = document.cosmos.d1.value;   	
	
	if(ckdateformat(tempDate)){  
		if( ckdateValue(tempDate) == false){
			document.cosmos.d1.focus();
			return false;
		}    
	} else {   
		alert("日付フォーマットが不正です！"); 
		document.cosmos.d1.focus();
		return false;
	}
		
	if(analyze_s_e_check() == false){
		return false;
	}
	
	//開始時間値を取得
	var s = parseInt(document.cosmos.s.value,10);
	//終了時間値を取得
	var e = parseInt(document.cosmos.e.value,10);
	//日付値を取得
	var d1 = document.cosmos.d1.value;
	
	if(change_index == 1){/* １時間が間として　小さくになる*/
		if(e > 0){
			if(s > 0){
				document.cosmos.s.value = s - 1;
				document.cosmos.e.value = e - 1;		
			}else{
				document.cosmos.s.value = 23;
				document.cosmos.e.value = e - 1;
				document.cosmos.d1.value = DateAdd("d",-1,d1,1);			
			}	
		}else if( s > 0){
			document.cosmos.s.value = s - 1;	
			document.cosmos.e.value = 23	
		}else{
			document.cosmos.s.value = 23
			document.cosmos.e.value = 23
			document.cosmos.d1.value = DateAdd("d",-1,d1,1);
		} 	
	}else if(change_index == 2){/* １時間が間として　大きくになる*/
		if(s < 23){
			if(e < 23 ){
				document.cosmos.s.value = s + 1;
				document.cosmos.e.value = e + 1;		
			}else{
				document.cosmos.s.value = s + 1;		
				document.cosmos.e.value = 0;
			}	
		}else if(e < 23 ){
			document.cosmos.s.value = 0;
			document.cosmos.e.value = e + 1;	
			document.cosmos.d1.value = DateAdd("d",1,d1,1);	
		}else{
			document.cosmos.s.value = 0;
			document.cosmos.e.value = 0;	
			document.cosmos.d1.value = DateAdd("d",1,d1,1);	
		} 
	}else if(change_index ==3 ){/* 開始時間と終了時間の差が間として　小さくになる*/
		var i = 0;
		if(s > e){
			i = 24 - s +	e;
		}else if(s == e){
			i = 24;
		}else{
			i = e - s ;
		}
		if(e > i-1){
			if(s > i-1){			 
				document.cosmos.s.value = s - i;
				document.cosmos.e.value = e - i;		
			}
			else{ 
				document.cosmos.s.value = 24 + ( s - i );
				document.cosmos.e.value = e - i;
				document.cosmos.d1.value = DateAdd("d",-1,d1,1);
			}	
		}else if(s > i-1){ 
			document.cosmos.s.value -= i;	
			document.cosmos.e.value = 24 + ( e - i );			
		}else{ 
			document.cosmos.s.value = 24 + ( s - i );
			document.cosmos.e.value = 24 + ( e - i );
			document.cosmos.d1.value = DateAdd("d",-1,d1,1);			
		}		
	}else{/* 開始時間と終了時間の差が間として　多きくになる*/
		var i = 0;
		if(s > e){
			i = 24 - s +	e;
		}else if(s == e){
			i = 24;
		}
		else{
			i = e - s ;
		}	
		if(s < (24 - i )){ 
			if(e < (24 - i ) ){
				document.cosmos.s.value = s + i;
				document.cosmos.e.value = e + i;		
			}else{ 
				document.cosmos.s.value = s + i;		
				document.cosmos.e.value = e + i -24;
			}	
		}else if(e < (24 - i )){ 
			document.cosmos.s.value = s + i - 24;	
			document.cosmos.e.value = e + i ;
			document.cosmos.d1.value = DateAdd("d",1,d1,1);
		}
		else{ 
			document.cosmos.s.value = s + i -24;
			document.cosmos.e.value = e + i -24;	
			document.cosmos.d1.value = DateAdd("d",1,d1,1);
		} 	
	}
}

//**************************************************************
//関数名	：analyze_s_e_check(..)
//機能		：分析画面開始時間と終了時間のチェック
//引数		：なし
//戻り値	：true　　　開始時間と終了時間のフォマットが正しい場合
//			：false  開始時間或いは終了時間のフォマットが不正の場合
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function analyze_s_e_check(){/* 分析日付けチェック*/
	var starttime = document.cosmos.s.value;/*開始時間*/
	var endtime   = document.cosmos.e.value;/*終了時間*/
	if(starttime == null || starttime == ""){
		alert("開始時間を入力してください !");
		document.cosmos.s.focus();
		return false;
	}else if(endtime == null || endtime == ""){
		alert("終了時間を入力してください!");
		document.cosmos.e.focus();
		return false;
	}
	var myReg = /^([0-9]|0[0-9]|[1][0-9]|[2][0-3])$/;	/* タイムチェック*/
	if( starttime.match(myReg)== null){ 
		alert("もう一度開始時間を入力してください！０から２３まで！"); 
		document.cosmos.s.focus();
		return false;
	}else if ( endtime.match(myReg)== null)
	{ 
		alert("もう一度終了時間を入力してください！０から２３まで！"); 
		document.cosmos.e.focus();
		return false;
	}
	return true; 	
}

//**************************************************************
//関数名	：
//機能		：
//引数		：
//戻り値	：
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function TimeCom( dateValue ){/* 分析　*/

	newCom = new Date( dateValue );
	this.year = newCom.getFullYear();
	this.month = newCom.getMonth()+1;
	this.day = newCom.getDate();
	this.hour = newCom.getHours();
	this.minute = newCom.getMinutes();
	this.second = newCom.getSeconds();
	this.msecond = newCom.getMilliseconds();
	this.week = newCom.getDay();
}

//**************************************************************
//関数名	：DateAdd(...)
//機能		：
//引数		：interval
//　　　　　:num
//　　　　　:dateValue
//戻り値	：
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function DateAdd(interval, num, dateValue,flag){/* 分析　日付　チェンジ　*/

	var inparDate;   
	inparDate = dateValue.split("/");   
	inparY = inparDate[0];     //年   
	inparY = parseInt(inparY,10);   
	inparM = inparDate[1];     //月   
	inparM = parseInt(inparM,10);   
	inparD = inparDate[2];     //日
	inparD = parseInt(inparD,10); 
	
	var newCom = new TimeCom(dateValue);
	
	switch(String(interval).toLowerCase())
	{
		case "y": case "year": newCom.year += num; break;
		case "n": case "month": newCom.month += num; break;
		case "d": case "day": newCom.day += num; break;
		case "h": case "hour": newCom.hour += num; break;
		case "m": case "minute": newCom.minute += num; break;
		case "s": case "second": newCom.second += num; break;
		case "ms": case "msecond": newCom.msecond += num; break;
		case "w": case "week": newCom.day += num*7; break;
		default: return("invalid");
	}
	var now = newCom.year+"/"+newCom.month+"/"+newCom.day+" "+newCom.hour+":"+newCom.minute+":"+newCom.second;
	var date = new Date(now); 
	var year = date.getFullYear();
	var month = parseInt(date.getMonth(),10)+1;
	var day = date.getDate();	
	if(month < 10){
		month = "0"+month;
	}
	if(day < 10){
		day = "0"+day;
	}
	var dayofw = date.getDay();
	switch(dayofw){
		case 0:dayofw='（日）';break;
		case 1:dayofw='（月）';break;
		case 2:dayofw='（火）';break;
		case 3:dayofw='（水）';break;
		case 4:dayofw='（木）';break;
		case 5:dayofw='（金）';break;
		case 6:dayofw='（土）';break;
		default:dayofw='';break;
	}
	if(flag == 1){
		document.cosmos.y1.value=year;
		document.cosmos.m1.value=month;
		document.cosmos.dd1.value=day;
		document.getElementById("dayofw1").innerHTML = dayofw;
		return year+"/"+month+"/"+day;
	}else if(flag == 2){
		document.cosmos.y2.value=year;
		document.cosmos.m2.value=month;
		document.cosmos.dd2.value=day;	
		document.getElementById("dayofw2").innerHTML = dayofw;
		return year+"/"+month+"/"+day;
	}else if(flag == 3){//weekly
		return day;
	}else if(flag == 4){//monthly
		document.cosmos.y1.value=year;
		document.cosmos.m1.value=month;	
		return year+"/"+month+"/"+day;
	}else if(flag == 5){//monthly
		document.cosmos.y2.value=year;
		document.cosmos.m2.value=month;
		return year+"/"+month+"/"+day;
	}else{
		return year+"/"+month+"/"+day;
	}
	
}
function DateJumptToNoW(flag){
	var newCom = new TimeCom(new Date());
	var now = newCom.year+"/"+newCom.month+"/"+newCom.day+" "+newCom.hour+":"+newCom.minute+":"+newCom.second;
	var date = new Date(now); 
	var year = date.getFullYear();
	var month = parseInt(date.getMonth(),10)+1;
	var day = date.getDate();	
	if(month < 10){
		month = "0"+month;
	}
	if(day < 10){
		day = "0"+day;
	}
	if(flag == 1){
		return year+'/'+month+'/'+day;
	}else if(flag == 2){
		var box = document.getElementById('boxdayofweek1');
		document.cosmos.y1.value= year;
		document.cosmos.m1.value= month;
		document.cosmos.d1.value= year+'/'+month+'/'+day;
		box.selectedIndex=((date.getDay()-1) == -1 ? 6 : (date.getDay()-1));
	}else{
		document.cosmos.y1.value= year;
		document.cosmos.m1.value= month;
		document.cosmos.dd1.value= day;
		document.cosmos.d1.value= year+'/'+month+'/'+day;
		var dayofw = date.getDay();
		switch(dayofw){
			case 0:dayofw='（日）';break;
			case 1:dayofw='（月）';break;
			case 2:dayofw='（火）';break;
			case 3:dayofw='（水）';break;
			case 4:dayofw='（木）';break;
			case 5:dayofw='（金）';break;
			case 6:dayofw='（土）';break;
			default:dayofw='';break;
		}
		document.getElementById("dayofw1").innerHTML = dayofw;
	}
}
function DateJumpt(name){
	switch(name)
	{
		case "yearly": 
				var value=DateJumptToNoW(1);
				var arr = value.split("/");
				document.getElementById("y1").value=arr[0];
			 	document.getElementById("d1").value=arr[0];
				break;
		case "monthly": 
					var value=DateJumptToNoW(1);
			 		var arr = value.split("/");
			 		document.getElementById("y1").value=arr[0];
			 		document.getElementById("m1").value=arr[1];
			 		document.cosmos.d1.value=arr[0]+"/"+arr[1]+"/01";
				break;
		case "day":
				 if(submit_check('daily',false) == true){
					 if(num == 0){
					 	document.cosmos.d1.value =  DateJumptToNoW(); 
					 }else if(num == -1){
					 	document.cosmos.d2.value = DateAdd('d',-1, DateJumptToNoW()); 
					 }				 
				 }	 
			 	break;
		case "weekly":  
				
					 	var mydate = new Date( DateJumptToNoW(1) );
					 	var dayofweek = mydate.getDay();
					 	var j=0;
					 	var value=DateJumptToNoW(1);

					 	if(dayofweek == 0){
					 		j=6;
					 	}else{
					 		j=dayofweek-1;
					 	}
						for(var i=0; i < j; i++){
							value = DateAdd('d',-1,value);
						}
				 		document.cosmos.d1.value=value;
				 		var arr = value.split("/");
				 		document.getElementById("y1").value=arr[0];
				 		document.getElementById("m1").value=arr[1];

						
						var weekname1 = document.getElementById('weekname1');
						resetoptions(weekname1,value);
						
						var ii = 0;
						var vv = value;
						var jj = 0;
						var mydatett = new Date( arr[0]+'/'+ arr[1]+'/01');
					 	var dayofweektt = mydatett.getDay();
					 	if(dayofweektt != 1){
					 		jj = 1;
					 	}
					 	for(var ss=0;ss<6;ss++){
							if(value.split("/")[1] == vv.split("/")[1]){
								for(var i=0; i < 7; i++){
									vv = DateAdd('d',-1,vv);
								}
								if(value.split("/")[1] == vv.split("/")[1]){
									ii++;
								}
							}
						}
						
						weekname1.selectedIndex= ii+jj;
				 
							
				break;
		default: ;
	}
}
function DateMove(name,num,number){
	switch(name)
	{	
		case "olddata":
				if(olddata(false) == true){
					 	document.cosmos.dt3.value = parseInt(document.cosmos.dt3.value,10)
					 							 + parseInt(num,10) ; 				
				}
				break;
		case "yearly":
				if(yearly_submit_check(false) == true){
					 if(number == 1){
					 	if(num == 1){
					 		if(parseInt(document.cosmos.d1.value,10) < 2030){
					 			document.cosmos.d1.value = parseInt(document.cosmos.d1.value,10)
					 							 + parseInt(num,10) ; 	
					 			document.cosmos.y1.value=document.cosmos.d1.value;	 
					 		}else{
					 			alert('1970年から2030年の間で選択してください！');
					 		}

					 	}else if(num == -1){
					 		if(parseInt(document.cosmos.d1.value,10) > 1970){
					 			document.cosmos.d1.value = parseInt(document.cosmos.d1.value,10)
					 							 + parseInt(num,10) ; 	
					 			document.cosmos.y1.value=document.cosmos.d1.value;	 
					 		}else{
					 			alert('1970年から2030年の間で選択してください！');
					 		}
					 	}else{
					 		document.cosmos.d1.value = parseInt(document.cosmos.d1.value,10)
					 							 + parseInt(num,10) ; 	
					 		document.cosmos.y1.value=document.cosmos.d1.value;	
					 	}

					 }else if(number == 2){
					 	if(num == 1){
					 		if(parseInt(document.cosmos.d2.value,10) < 2030){
						 		document.cosmos.d2.value = parseInt(document.cosmos.d2.value,10)
						 							 + parseInt(num,10) ; 
						 		document.cosmos.y2.value=document.cosmos.d2.value; 
					 		}else{
					 			alert('1970年から2030年の間で選択してください！');
					 		}

					 	}else if(num == -1){
					 		if(parseInt(document.cosmos.d2.value,10) > 1970){
						 		document.cosmos.d2.value = parseInt(document.cosmos.d2.value,10)
						 							 + parseInt(num,10) ; 
						 		document.cosmos.y2.value=document.cosmos.d2.value;
					 		}else{
					 			alert('1970年から2030年の間で選択してください！');
					 		}
					 	}else{
						 	document.cosmos.d2.value = parseInt(document.cosmos.d2.value,10)
						 							 + parseInt(num,10) ; 
						 	document.cosmos.y2.value=document.cosmos.d2.value;
					 	}

					 }				 
				 }
				break;
		case "dayofweek":  
				if(dayofweek_submit_check(false) == true){
					 if(number == 1){
					 	document.cosmos.yy1.value = parseInt(document.cosmos.yy1.value,10)
					 							 + parseInt(num,10) ;	 
					 	document.getElementById("yyt1").innerHTML = document.cosmos.yy1.value;
					 }else if(number == 2){
					 	document.cosmos.yy2.value = parseInt(document.cosmos.yy2.value,10)
					 							 + parseInt(num,10) ; 
					 	document.getElementById("yyt2").innerHTML =document.cosmos.yy2.value;
					 }					 
				 }					
				break;
		case "monthly": 
				 if(monthly_submit_check(false) == true){
					 if(number == 1){
					 	document.cosmos.d1.value = DateAdd('n',num,document.cosmos.d1.value,4); 		 
					 }else if(number == 2){
					 	document.cosmos.d2.value = DateAdd('n',num,document.cosmos.d2.value,5); 
					 }				 
				 }			
				break;
		case "day":
				 if(daily_submit_check(false) == true){
					 if(number == 1){
					 	document.cosmos.d1.value = DateAdd('d',num,document.cosmos.d1.value,1);
					 }else if(number == 2){
					 	document.cosmos.d2.value = DateAdd('d',num,document.cosmos.d2.value,2); 
					 }				 
				 }else {
				 	return false;
				 }
				break;
		case "weekly":
				 if(weekly_submit_check(false) == true){
					 if(number == 1){
					 	if(num == 1){
					 		var dv= DateAdd('w',num,document.cosmos.d1.value); 
					 	}else if(num == -1){
							var dv=document.cosmos.d1.value;
					 		for(var i=1;i <= 7;i++){
					 			dv = DateAdd('d',-1,dv);
					 		}
					 	}
				 		document.cosmos.d1.value=dv;
				 		var arr = dv.split("/");
				 		document.getElementById("y1").value=arr[0];
				 		document.getElementById("m1").value=arr[1];
				 		
				 		//document.getElementById("dayofw1").innerHTML = arr[2];
						//document.getElementById("dayofw3").innerHTML = DateAdd('d',6, dv,3);
						
						var weekname1 = document.getElementById('weekname1');
						resetoptions(weekname1,dv);
						
						var ii = 0;
						var vv = dv;
						var jj = 0;
						var mydatett = new Date( arr[0]+'/'+ arr[1]+'/01');
					 	var dayofweektt = mydatett.getDay();
					 	if(dayofweektt != 1){
					 		jj = 1;
					 	}
					 	for(var ss=0;ss<6;ss++){
							if(dv.split("/")[1] == vv.split("/")[1]){
								for(var i=0; i < 7; i++){
									vv = DateAdd('d',-1,vv);
								}
								if(dv.split("/")[1] == vv.split("/")[1]){
									ii++;
								}
							}
						}
						
						weekname1.selectedIndex= ii+jj;
					 }else if(number == 2){
					 	//document.cosmos.d2.value = DateAdd('w',num,document.cosmos.d2.value);
				 		//var dv= DateAdd('w',num,document.cosmos.d2.value); 
						if(num == 1){
					 		var dv= DateAdd('w',num,document.cosmos.d2.value); 
					 	}else if(num == -1){
							var dv=document.cosmos.d2.value;
					 		for(var i=1;i <= 7;i++){
					 			dv = DateAdd('d',-1,dv);
					 		}
					 	}
				 		document.cosmos.d2.value=dv;
				 		var arr = dv.split("/");
				 		document.getElementById("y2").value=arr[0];
				 		document.getElementById("m2").value=arr[1];
				 		
				 		var weekname2 = document.getElementById('weekname2');
						resetoptions(weekname2,dv);
						
						var ii = 0;
						var vv = dv;
						var jj = 0;
						var mydatett = new Date( arr[0]+'/'+ arr[1]+'/01');
					 	var dayofweektt = mydatett.getDay();
					 	if(dayofweektt != 1){
					 		jj = 1;
					 	}
					 	for(var ss=0;ss<6;ss++){
							if(dv.split("/")[1] == vv.split("/")[1]){
								for(var i=0; i < 7; i++){
									vv = DateAdd('d',-1,vv);
								}
								if(dv.split("/")[1] == vv.split("/")[1]){
									ii++;
								}
							}
						}
						
						weekname2.selectedIndex= ii+jj;
					 }				 
				 }
				break;
		default: ;
	}
}
function resetoptions(obj,dt){
 
 	for (var i = 0; i < obj.options.length; i++){
		obj.options[i] = null;
	}
 	var mydate = new Date( dt.split("/")[0]+'/'+dt.split("/")[1]+'/01' );
 	var dayofweek = mydate.getDay();
 	var j=0;
 	var value=dt.split("/")[0] + '/'+ dt.split("/")[1] + '/01';

 	if(dayofweek == 0){
 		j=6;
 	}else{
 		j=dayofweek-1;
 	}
	for(var i=0; i < j; i++){
		value = DateAdd('d',-1,value);
	}
	obj.options[0]= new Option(parseInt(value.split("/")[2],10)+'~'+parseInt(DateAdd('d',6,value).split("/")[2],10)+'日',0);
	
	for(var m=1; m<=6;m++){
		value = DateAdd('d',7,value);
		if( dt.split("/")[1] == value.split("/")[1]){
			obj.options[m]= new Option(parseInt(value.split("/")[2],10)+'~'+parseInt(DateAdd('d',6,value).split("/")[2],10)+'日',m);
		}
	}
}
//**************************************************************
//関数名	：analyze_submit_check()
//機能		：submit前のチェック(日付フォマットチェックと日付値チェック)
//引数		：なし
//戻り値	：false :不正がある
//       true  :チェック通り
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function analyze_submit_check(issubmit){/* 分析　*/

	if(analyze_s_e_check()){
		if (daily_submit_check(issubmit)) {	
			return true;
		}
	}
	return false;
}

//**************************************************************
//関数名	：ckdateformat(..)
//機能		：日付のフォマットチェック
//引数		：inpar 日付　(2007/01/01)或いは(2007/1/1)
//戻り値	：true  : 日付フォマットが正しい
//       false :　日付フォマットが正しくない
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function   ckdateformat(inpar){// 日付フォーマットチェック       

	var reg;   
	reg=/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/;   
	var r=inpar.match(reg);
	
	if(r==null){   
		return   false;    
	} else {   
		return   true;   
	}   
}

//**************************************************************
//関数名	：ckdateValue(..)
//機能		：閏年チェックと毎月の日数チェック
//引数		：inpar 日付　(2007/01/01)或いは(2007/1/1)
//戻り値	：true   :日付値が正しい
//       false  :日付値が正しくない
//画面		：分析
//作者		： wang
//日付		：2007/11/15
//**************************************************************
function   ckdateValue(inpar){// 日付値チェック     

	var inparDate;   
	inparDate=inpar.split("/");   
	inparY=inparDate[0];     //年   
	inparY=parseInt(inparY,10);   
	inparM=inparDate[1];  //月  
	inparM=parseInt(inparM,10);   
	inparD=inparDate[2];     //日
	inparD=parseInt(inparD,10);   
	
	switch   (inparM){   
		case   2:{   //閏年かどうかチェック   				         
			if ((inparY%400==0)||((inparY%4==0)&&(inparY%100!=0))) {
				if ((inparD>0)&&(inparD<=29))	{
					return true;   
				}else{
					alert("入力した日が正しくないです！"); 
					return   false;
				}
				
			}else if ((inparD>0)&&(inparD<=28)) {
				return true;
			}else {   
				alert("入力した日が正しくないです！");   
				return   false;   
			}   
			break;
		}
		case   1:
		case   3:
		case   5:
		case   7:
		case   8:
		case   10:
		case   12:{
			if ((inparD>0)   &&   (inparD<32)) return true;
				else{
					alert("入力した日が正しくないです！！");
					return   false;
				}
			break;
		}
		case   4:
		case   6:
		case   9:
		case   11:{
			if ((inparD>0)&&(inparD<31)){
				return   true;
			}else {
				alert("入力した日が正しくないです！！");
				return   false;
			}
			break;
		}
		default:{
			alert("入力した月が正しくないです！");
			return   false;
		}
	}
}

function checkVlaue(checkname){
	if(checkname.checked==true){
		checkname.value=1;
		document.cosmos.submit();
	}
	else if(checkname.checked==false){
		checkname.value=0;
		document.cosmos.submit();
	}
}

function login_check(){
	if(document.login.uid.value == "" || document.login.password.value == "") {
		alert("ユーザIDとパスワードを入力してください");
	}else{
		document.login.submit();	
	}
}

function jumptodailybbs(mode,page) {
	f = document.cosmos;
	p = getscriptname(page);
	if (submit_check(p, false)) {
		f.mode.value=mode;
		f.tid.value=5;
		f.form.value='officesetting';
		f.action = 'officesetting.php?tab_flag=1&tid=5';
		f.submit();
	}
}

//**************************************************************
//関数名	：checkDays7(..)
//機能		：
//引数		：
//戻り値	：
//画面		：曜日,7日,月間最大最小
//作者		： liye
//日付		：2007/11/15
//**************************************************************
function checkDays7(checknamec,hiddenname){
	if(checknamec.checked==true){				
		hiddenname.value=1;
	}
	else { 	
		hiddenname.value=0;
	}
//		document.cosmos.submit();
}

//**************************************************************
//関数名	：moveOverDiv()
//機能		：カレンダを使う前にこの関数を使う
//日付		：2007/11/15
//**************************************************************
function moveOverDiv(){
	document.all.overDiv.style.top = '-1000px';
}

function getcontractmenu(form){
	form.fupdate.value = 0;
	form.action = 'officesetting.php';
	form.submit();
	
}




//**************************************************************
//関数名	：status_search(..)
//機能		：結果報告 　確認button 日付チェック
//**************************************************************
function status_search(form){
	var dt=document.cosmos.dt.value;
	if (!(isvaliddate(dt) && isvaliddatescope(dt))) {
		alert('日付フォーマットが不正です！');
		document.cosmos.dt.focus();
		return;
	}
	form.submit();
}
//**************************************************************
//関数名	：status_update(..)
//機能		：結果報告 　登録button データチェック
//**************************************************************
function status_update(form){
	var dt=document.cosmos.dt.value;
	if (!(isvaliddate(dt) && isvaliddatescope(dt))) {
		alert('日付フォーマットが不正です！');
		document.cosmos.dt.focus();
		return;
	}
	for(var i = 1;i<=12;i++){
		var elem = document.getElementsByName("m"+i)[0];
		if(isNaN(elem.value)){ 
			alert(i+'月分の基本値が半角数字です！');
			elem.focus();
			return ;
			break;
		}	
	}
	form.on.value = 1;
	form.submit();
}

//**************************************************************
//関数名	：plan_search(..)
//機能		：実施計画画面　確認button 日付チェック
//**************************************************************
function plan_search(form){
	var dt=document.cosmos.dt.value;
	if (!(isvaliddate(dt) && isvaliddatescope(dt))) {
		alert('日付フォーマットが不正です！');
		document.cosmos.dt.focus();
		return;
	}
	form.submit();
}

//**************************************************************
//関数名	：plan_update(..)
//機能		：実施計画画面　登録button データチェック
//**************************************************************
function plan_update(form){

	for(var i = 1;i<=12;i++){
		var base = document.getElementsByName("base["+i+"]")[0];
		var y1 = document.getElementsByName("y1["+i+"]")[0];
		var y2 = document.getElementsByName("y2["+i+"]")[0];
		var y3 = document.getElementsByName("y3["+i+"]")[0];
		var y4 = document.getElementsByName("y4["+i+"]")[0];
		var y5 = document.getElementsByName("y5["+i+"]")[0];
		var y6 = document.getElementsByName("y6["+i+"]")[0];

		if(isNaN(y1.value)){ 
			alert('1年目'+i+'月分の値が半角数字です！');
			y1.focus();
			return ;
			break;
		}
		if(isNaN(y2.value)){ 
			alert('2年目'+i+'月分の値が半角数字です！');
			y2.focus();
			return ;
			break;
		}
		if(isNaN(y3.value)){ 
			alert('3年目'+i+'月分の値が半角数字です！');
			y3.focus();
			return ;
			break;
		}
		if(isNaN(y4.value)){ 
			alert('4年目'+i+'月分の基本値が半角数字です！');
			y4.focus();
			return ;
			break;
		}	
		if(isNaN(y5.value)){ 
			alert('5年目'+i+'月分の値が半角数字です！');
			y5.focus();
			return ;
			break;
		}	
		if(isNaN(y6.value)){ 
			alert('6年目'+i+'月分の値が半角数字です！');
			y6.focus();
			return ;
			break;
		}	
	}
	form.on.value = 1;
	form.submit();
}
//**************************************************************
//関数名	：actualuse_search(..)
//機能		：過去実績入力　確認button 日付チェック
//**************************************************************
function actualuse_search(form){
	var dt3=form.dt3.value+"/01/01";
	if (!(isvaliddate(dt3) && isvaliddatescope(dt3))) {
		alert('日付フォーマットが不正です！');
		document.cosmos.dt3.focus();
		return;
	}
	form.submit();
}

//**************************************************************
//関数名	：actualuse_update(..)
//機能		：過去実績入力　登録button データチェック
//**************************************************************
function actualuse_update(form){
	var dt3=form.dt3.value+"/01/01";
	if (!(isvaliddate(dt3) && isvaliddatescope(dt3))) {
		alert('日付フォーマットが不正です！');
		form.dt3.focus();
		return;
	}
	for(var i = 1;i<=12;i++){
		var m = document.getElementsByName("m["+i+"]")[0];
		if(isNaN(m.value)){ 
			alert(i+'月分の基本値が半角数字です！');
			m.focus();
			return ;
			break;
		}
	}
	form.on.value = 1;
	form.submit();
}
//**************************************************************
//関数名	：popup_submit_check(..)
//機能		：popup チェック
//作者		：李孜博
//**************************************************************
function popup_submit_check(page, issubmit) {
	switch(page)
	{
		case 'analyze': return popup_analyze_submit_check(issubmit);
			break;
		case 'daily': return popup_daily_submit_check(issubmit);
			break;
		case 'weekly': return popup_weekly_submit_check(issubmit);
			break;
		case 'monthly': return popup_monthly_submit_check(issubmit);
			break;
		case 'dayofweek': return popup_dayofweek_submit_check(issubmit);
			break;
		case 'yearly': return popup_yearly_submit_check(issubmit);
			break;
		case 'mailsend': return popup_mailsend_check(issubmit);
			break;
		default : return false;
	}
}

//**************************************************************
//関数名	：popup_monthly_submit_check(..)
//機能		：popup 月間チェック
//**************************************************************
function popup_monthly_submit_check(issubmit) {
	return popup_daily_submit_check(issubmit);
}

//**************************************************************
//関数名	：popup_monthly_submit_check(..)
//機能		：popup 週間チェック
//**************************************************************
function popup_weekly_submit_check(issubmit) {
	return popup_daily_submit_check(issubmit);
}

//**************************************************************
//関数名	：popup_monthly_submit_check(..)
//機能		：popup 曜日チェック
//**************************************************************
function popup_dayofweek_submit_check(issubmit) {
	return popup_daily_submit_check(issubmit);
}

//**************************************************************
//関数名	：popup_monthly_submit_check(..)
//機能		：popup 一日チェック
//**************************************************************
function popup_daily_submit_check(issubmit) {
	var f = parent.document.cosmos;
	var d1 = trim(f.d1.value);
	var d2 = trim(f.d2.value);
	var error = false;
	var msg = '';
	if (!(isvaliddate(d1) && isvaliddatescope(d1))) {
		msg += '計測データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d1;
		}
	}
	if (!(isvaliddate(d2) && isvaliddatescope(d2))) {
		msg += '比較データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d2;
		}
	}
	if(!error){
		f.d1.value = d1;
		f.d2.value = d2;
		return true
	} else {
		alert(msg);
		return false;
	}
}

//**************************************************************
//関数名	：popup_yearly_submit_check(..)
//機能		：popup 年間チェック
//**************************************************************
function popup_yearly_submit_check(issubmit) {
	var f = parent.document.cosmos;
	var d1 = trim(f.d1.value);
	var d2 = trim(f.d2.value);
	var d1full = d1 + '/01/01';
	var d2full = d2 + '/01/01';
	var error = false;
	var msg = '';
	if (!(isvaliddate(d1full) && isvaliddatescope(d1full))) {
		msg += '計測データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d1;
		}
	}
	if (!(isvaliddate(d2full) && isvaliddatescope(d2full))) {
		msg += '比較データの日付フォーマットが不正です！\n';
		if (!error) {
			error = f.d2;
		}
	}
	if(!error){
		f.d1.value = d1;
		f.d2.value = d2;
		return true
	} else {
		alert(msg);
		return false
	}
}

//**************************************************************
//関数名	：popup_analyze_s_e_check(..)
//機能		：popup 分析開始時間と終了時間チェック
//**************************************************************
function popup_analyze_s_e_check(){/* 分析日付けチェック*/
	var starttime = parent.document.cosmos.s.value;/*開始時間*/
	var endtime   = parent.document.cosmos.e.value;/*終了時間*/
	if(starttime == null || starttime == ""){
		alert("開始時間を入力ください !");
		parent.document.cosmos.s.focus();
		return false;
	}else if(endtime == null || endtime == ""){
		alert("終了時間を入力ください!");
		parent.document.cosmos.e.focus();
		return false;
	}
	var myReg = /^([0-9]|0[0-9]|[1][0-9]|[2][0-3])$/;	/* タイムチェック*/
	if( starttime.match(myReg)== null){ 
		alert("もう一度開始時間を入力してください！０から２３まで！"); 
		parent.document.cosmos.s.focus();
		return false;
	}else if ( endtime.match(myReg)== null)
	{ 
		alert("もう一度終了時間を入力してください！０から２３まで！"); 
		parent.document.cosmos.e.focus();
		return false;
	}
	return true; 	
}

//**************************************************************
//関数名	：popup_analyze_submit_check(..)
//機能		：popup 分析チェック
//**************************************************************
function popup_analyze_submit_check(issubmit){/* 分析　*/
	if (popup_daily_submit_check(issubmit) && popup_analyze_s_e_check()) {
		return true;
	}
	return false;
}
function calendar1_show(){	
	calendar_data_p = parseInt(calendar_data_p,10) + 1;
	calendar_show_p = calendar_data_p % 2;
	document.cosmos.calendar_show_p.value = calendar_show_p;
	if(calendar_show_p == 1){
		document.cosmos.mycalendar.value="非表示";
	}else{
		document.cosmos.mycalendar.value="カレンダー";
	}
}

function dayofweek_detail_cal_show(ce){	
	calendar_data_p = parseInt(calendar_data_p,10) + 1;
	calendar_show_p = calendar_data_p % 2;
	document.cosmos.calendar_show_p.value = calendar_show_p;
	if(calendar_show_p == 1){
		dayofweekdetail_cal1.style.display='inline';
		if(ce == 1){
			dayofweekdetail_cal2.style.display='inline';
		}
		document.cosmos.mycalendar.value="非表示";
	}else{
		dayofweekdetail_cal1.style.display='none';
		if(ce == 1){
			dayofweekdetail_cal2.style.display='none';
		}
		document.cosmos.mycalendar.value="カレンダー";
	}
}

function sheetshow(sheetindex,tempbt,divname){
	if(sheetindex != null){
		sheetindex.value = (parseInt(sheetindex.value,10) + 1) % 2;
		if(sheetindex.value == 1){
			divname.style.display='inline';
			tempbt.value='温度グラフ非表示';
		}else{
			divname.style.display='none';
			tempbt.value='温度グラフ表示';
		}
	}
}
function highshow(ce){
	//var hight1 = document.getElementById('heigh1'); 
	if(calendar_show_p == 1){
		hight1.style.display='inline';
		if(ce == 1){
			hight2.style.display='inline';
		}
	}else{
		hight1.style.display='none';
		if(ce == 1){
			hight2.style.display='none';
		}
	}
}
function detailhighshow(ce){
	if(ce == 1){
		if(calendar_show_p == 1){
			hight1.style.display='inline';
			
		}else{
			hight1.style.display='none';
		}
	}
}
function newdata(value){
	document.cosmos.newdata_flag.value=value;
}
function mover(month){

	if(mouseover_flag==1 && month_flag != month){
		document.getElementById(''+month).className='waku';
	}
}
function nover(month){

	if(mouseover_flag1==1 && month_flag1 != month){
		document.getElementById(''+month).className='waku';
	}
}
function mdown(month,mm,index){
	dowcal(mm,index);
	if(document.getElementById(''+ month_flag)!=null){
		document.getElementById(''+ month_flag).className='waku_out';
	}
	mouseover_flag=0;
	month_flag=month;
	document.getElementById('' + month).className='waku_blue';
	submit_check(document.cosmos.form.value,true);
}
function ndown(month,mn,index){
	dowcal(mn,index);
	if(document.getElementById(''+ month_flag1)!=null){
		document.getElementById(''+ month_flag1).className='waku_out';
	}
	mouseover_flag1=0;
	month_flag1=month;
	document.getElementById('' + month).className='waku_blue';
	submit_check(document.cosmos.form.value,true);
}
function mout(month){
	if(mouseover_flag==1 && month_flag != month){
		document.getElementById(''+ month).className='waku_out';
	}
	mouseover_flag=1;
}
function nout(month){
	if(mouseover_flag1==1 && month_flag1 != month){
		document.getElementById(''+ month).className='waku_out';
	}
	mouseover_flag1=1;
}
//**************
//dayofweekcalendar
//**************
function dowcal(month,index){
	var d1='';
	var d2='';
	if(index == 1){
		if(month_flag == 'mm1' || month_flag == 'mm2' || month_flag == 'mm3'){
			if(month == '01' || month == '02' || month == '03'){
				d1 = document.cosmos.yy1.value+'/'+month+'/01';
				document.cosmos.y1.value=document.cosmos.yy1.value;
			}else{
				d1 = (parseInt(document.cosmos.yy1.value,10)-1)+'/'+month+'/01';
				document.cosmos.yy1.value=parseInt(document.cosmos.yy1.value,10)-1;
				document.getElementById("yyt1").innerHTML = document.cosmos.yy1.value;
				document.cosmos.y1.value=document.cosmos.yy1.value;
				
			}
		}else{
			if(month == '01' || month == '02' || month == '03'){
				d1 = (parseInt(document.cosmos.yy1.value,10)+1)+'/'+month+'/01';
				document.cosmos.yy1.value=parseInt(document.cosmos.yy1.value,10)+1;
				document.getElementById("yyt1").innerHTML = document.cosmos.yy1.value
				document.cosmos.y1.value=document.cosmos.yy1.value;
			}else{
				d1 = document.cosmos.yy1.value+'/'+month+'/01';
				document.cosmos.y1.value=document.cosmos.yy1.value;
			}
		}
		document.cosmos.d1.value=d1;
		document.cosmos.m1.value=month;
	}else if(index == 2){
		if(month_flag1 == 'mn1' || month_flag1 == 'mn2' || month_flag1 == 'mn3'){
			if(month == '01' || month == '02' || month == '03'){
				d2 = document.cosmos.yy2.value+'/'+month+'/01';
				document.cosmos.y2.value=document.cosmos.yy2.value;
			}else{
				d2 = (parseInt(document.cosmos.yy2.value,10)-1)+'/'+month+'/01';
				document.cosmos.yy2.value=parseInt(document.cosmos.yy2.value,10)-1;
				document.getElementById("yyt2").innerHTML = document.cosmos.yy2.value;
				document.cosmos.y2.value=document.cosmos.yy2.value;
				
			}
		}else{
			if(month == '01' || month == '02' || month == '03'){
				d2 = (parseInt(document.cosmos.yy2.value,10)+1)+'/'+month+'/01';
				document.cosmos.yy2.value=parseInt(document.cosmos.yy2.value,10)+1;
				document.getElementById("yyt2").innerHTML = document.cosmos.yy2.value
				document.cosmos.y2.value=document.cosmos.yy2.value;
			}else{
				d2 = document.cosmos.yy2.value+'/'+month+'/01';
				document.cosmos.y2.value=document.cosmos.yy2.value;
			}
		}
		document.cosmos.d2.value=d2;
		document.cosmos.m2.value=month;
	}
	
}
//**************************************************************
//関数名	：bulletin_board_check(..)
//機能	：掲示板履歴データをチェック
//作者	：那宇峰
//**************************************************************
function bulletin_board_check(issubmit) {

	var f = document.cosmos;
	var y1 = trim(f.y1.value);
	var m1 = trim(f.m1.value);
	var day1 = trim(f.day1.value);
	var y2 = trim(f.y2.value);
	var m2 = trim(f.m2.value);
	var day2 = trim(f.day2.value);
	if(m1.length == 1 ){
		m1 = "0" + m1;
	}
	if(m2.length == 1 ){
		m2 = "0" + m2;
	}
	if(day1.length == 1 ){
		day1 = "0" + day1;
	}
	if(day2.length == 1 ){
		day2 = "0" + day2;
	}
	var d1 = y1 + "/" + m1 + "/" + day1;
	var d2 = y2 + "/" + m2 + "/" + day2;
	var error = false;
	var msg = '';
	if (!(isvaliddate(d1) && isvaliddatescope(d1))) {
		msg += '日付フォーマットが不正です！\n';
		if (!error) {
			error = f.day1;
		}
	}
	if (!(isvaliddate(d2) && isvaliddatescope(d2))) {
		msg += '日付フォーマットが不正です！\n';
		if (!error) {
			error = f.day2;
		}
	}
	if(parseInt(y1,10) > parseInt(y2,10)){
		alert('掲示板履歴の年フォーマットが不正です！\n');
		f.y2.focus();
		return false;
	}
	else if(parseInt(y1,10) == parseInt(y2,10)){
		if(parseInt(m1,10) > parseInt(m2,10)){
			alert('掲示板履歴の月フォーマットが不正です！\n');
			f.m2.focus();
			return false;
		}
		else if(parseInt(m1,10) == parseInt(m2,10)){
			if(parseInt(day1,10) > parseInt(day2,10)){
				alert('掲示板履歴の日フォーマットが不正です！\n');
				f.day2.focus();
				return false;
			}
		}
	}
	if(!error){
		f.d1.value = d1;
		f.d2.value = d2;
		if (issubmit) f.submit();
		return true
	} else {
		alert(msg);
		error.focus();
		return false;
	}
}
//**************************************************************
//関数名 ：csv_download_dayofweekdetaildata(..)
//機能　　： データダウンロード
//引数　　：なし
//戻り値  ：なし  
//画面　　：曜日比較分析表
//作者　　：那　宇峰
//日付　　：2008/11/20
//**************************************************************
function csv_download_dayofweekdetaildata(page,unitname) {
	f = document.cosmos;
	if (submit_check(page,false)) {
		displayflag = 0;
		f.mode.value=page;
		f.action = "csvoutput.php?unitname=" + unitname;
		f.submit();
	}
}

function popupelecadd(channelno,year){
	c = '\'elecadd.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&channelno=' + channelno;
	c += '&year=' + year;
	c += '\'';
	s = '<iframe src=' + c + ' width=300 height=500/>';
	
	return overlib(s, CAPTION, '過去使用量の登録 ',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, LEFT);
	
}
function elecaddyear(year){
	alert(year);
	var year1=year+5;
	if(document.popup.dt.value <= year ||document.popup.dt.value >=year1){
		alert('日付は'+year+'から'+year1+'まで');
	}else{
		document.popup.dt.value=parseInt(document.popup.dt.value,10)-1;
	}
}

function popupkakodataadd(type,data_show_flag,year){
	c = '\'kakousedadd.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&type=' + type;
	c += '&data_show_flag=' + data_show_flag;
	c += '&year=' + year;
	c += '\'';

	s = '<iframe src=' + c + ' width=300 height=450/>';
	
	return overlib(s, CAPTION, '過去使用量の登録 ',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, ABOVE);
	
}
//値入力選択gbl 新規 2008/12/24
function popupValueSelect(width,height){
	//alert("gbl nihao ");
	c = '\'valueselect.php?';
	c += '&sid=0'; //+ document.cosmos.form.value;
	//alert(c);
	c += '&kid=1';// + document.cosmos.id.value;
	c += '&tid=1';// + document.cosmos.tid.value;
	c += '&cn_cd=1';// + document.cosmos.cn_cd.value;
	c += '\'';
	s = '<iframe src=' + c + ' width= ' + width + ' height= ' + height + ' />';

	return overlib(s, CAPTION, '値入力選択',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY,BGCOLOR, '#000099',FIXX, 575,BELOW);
}

	
//gbl add 2008/12/25
function sheetdisp1(radioname,divname){
	if(radioname.id == "valueInput1"){
		mokuhyo1.style.display='inline';
		mokuhyo2.style.display='none';
		document.getElementById("radioSelected").value = 1;
		//alert(radioname.id + " " + radioname.value);
	}
	if(radioname.id == "valueInput2"){
		mokuhyo2.style.display='inline';
		mokuhyo1.style.display='none';
		document.getElementById("radioSelected").value = 2;
		//alert(radioname.id + " " + radioname.value);
	}
}

function updateDataSubmit(form){
//	document.getElementById("updateFlag").value = 1;
//	formName.submit();
//	alert("gbl");
//	window.parent.document.forms["cosmos"].action = 'progress.php?' + '&updateFlag=1';
//	window.parent.document.forms["cosmos"].submit();
	form.updateFlag.value = 1;
	form.submit();
}

function mailvaluecheck(checknamec,hiddenname){

	if(checknamec.checked==true){				
		hiddenname.value=1;
	}
	else { 	
		hiddenname.value=0;
	}
}
function popupcoefficient(channelno){
	c = '\'coefficientset.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&channelno=' + channelno;
	c += '\'';
	s = '<iframe src=' + c + ' width=400 height=350/>';
	
	return overlib(s, CAPTION, 'パルス変換比設定 ',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, LEFT);
	
}
function eleccompany(channelno){
	c = '\'eleccompanyset.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&channelno=' + channelno;
	c += '\'';
	s = '<iframe src=' + c + ' width=900 height=450/>';
	
	return overlib(s, CAPTION, '契約種別設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, LEFT);
	
}
function coefficientdis(){

}
//**************************************************************
//関数名	：officesetingsubmit(..)
//機能		：事業所設定 　formatチェック
//**************************************************************
function officesetingsubmit1(){
	var ctl = trim(document.popup.dc_ct_ratio_l.value);
	var ctr = trim(document.popup.dc_ct_ratio_r.value);
	var vtl = trim(document.popup.dc_vt_ratio_l.value);
	var vtr = trim(document.popup.dc_vt_ratio_r.value);
	var pulsel = trim(document.popup.dc_pulse_conv_rate_l.value);
	var pulser = trim(document.popup.dc_pulse_conv_rate_r.value);
	if(isNaN(ctl)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_ct_ratio_l.focus();
		return ;
	}
	if(isNaN(ctr) || ctr==0){ 
		alert('半角数字を入力してください！');
		document.popup.dc_ct_ratio_r.focus();
		return ;
	}
	if(isNaN(vtl)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_vt_ratio_l.focus();
		return ;
	}
	if(isNaN(vtr) || vtr==0){ 
		alert('半角数字を入力してください！');
		document.popup.dc_vt_ratio_r.focus();
		return ;
	}
	if(isNaN(pulser) || pulser==0){ 
		alert('半角数字を入力してください！');
		document.popup.dc_pulse_conv_rate_r.focus();
		return ;
	}
	if(isNaN(pulsel)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_pulse_conv_rate_l.focus();
		return ;
	}
	document.popup.dc_conv_rate.value = ( ctl / ctr ) * ( vtl / vtr ) * ( pulsel / pulser );
}
function coefficient_submit(){
	var ctl = trim(document.popup.dc_ct_ratio_l.value);
	var ctr = trim(document.popup.dc_ct_ratio_r.value);
	var vtl = trim(document.popup.dc_vt_ratio_l.value);
	var vtr = trim(document.popup.dc_vt_ratio_r.value);
	var pulsel = trim(document.popup.dc_pulse_conv_rate_l.value);
	var pulser = trim(document.popup.dc_pulse_conv_rate_r.value);
	var conv_rate = trim(document.popup.dc_conv_rate.value);
	if(isNaN(ctl)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_ct_ratio_l.focus();
		return ;
	}
	if(isNaN(ctr)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_ct_ratio_r.focus();
		return ;
	}
	if(isNaN(vtl)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_vt_ratio_l.focus();
		return ;
	}
	if(isNaN(vtr) ){ 
		alert('半角数字を入力してください！');
		document.popup.dc_vt_ratio_r.focus();
		return ;
	}
	if(isNaN(pulser)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_pulse_conv_rate_r.focus();
		return ;
	}
	if(isNaN(conv_rate)){ 
		alert('半角数字を入力してください！');
		document.popup.dc_conv_rate.focus();
		return ;
	}
	
	document.popup.update_flag.value=1;
	document.popup.submit();
}
function kakoadd(){
	if(isNaN(document.popup.v4.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v4.focus();
		return ;
	}
	if(isNaN(document.popup.v5.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v5.focus();
		return ;
	}
	if(isNaN(document.popup.v6.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v6.focus();
		return ;
	}
	if(isNaN(document.popup.v7.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v7.focus();
		return ;
	}
	if(isNaN(document.popup.v8.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v8.focus();
		return ;
	}
	if(isNaN(document.popup.v9.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v9.focus();
		return ;
	}
	if(isNaN(document.popup.v10.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v10.focus();
		return ;
	}
	if(isNaN(document.popup.v11.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v11.focus();
		return ;
	}
	if(isNaN(document.popup.v12.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v12.focus();
		return ;
	}
	if(isNaN(document.popup.v1.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v1.focus();
		return ;
	}
	if(isNaN(document.popup.v2.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v2.focus();
		return ;
	}
	if(isNaN(document.popup.v3.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v3.focus();
		return ;
	}
	document.popup.update_flag.value=1;
	document.popup.submit();
}

//**************************************************************
//関数名 ：kako_used_login(..)
//機能　　： check out
//引数　　：なし
//戻り値  ：なし  
//画面　　：結果報告（電力会社の値）
//作者　　：那　宇峰
//日付　　：2009/01/16
//**************************************************************
function kako_used_login(){
	if(isNaN(document.popup.v4.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v4.focus();
		return ;
	}
	if(isNaN(document.popup.v5.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v5.focus();
		return ;
	}
	if(isNaN(document.popup.v6.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v6.focus();
		return ;
	}
	if(isNaN(document.popup.v7.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v7.focus();
		return ;
	}
	if(isNaN(document.popup.v8.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v8.focus();
		return ;
	}
	if(isNaN(document.popup.v9.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v9.focus();
		return ;
	}
	if(isNaN(document.popup.v10.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v10.focus();
		return ;
	}
	if(isNaN(document.popup.v11.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v11.focus();
		return ;
	}
	if(isNaN(document.popup.v12.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v12.focus();
		return ;
	}
	if(isNaN(document.popup.v1.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v1.focus();
		return ;
	}
	if(isNaN(document.popup.v2.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v2.focus();
		return ;
	}
	if(isNaN(document.popup.v3.value)){ 
		alert('半角数字を入力してください！');
		document.popup.v3.focus();
		return ;
	}
	document.popup.update_flag.value=1;
	document.popup.submit();
}

function editpopupchannel_submit(form){
	if(isNaN(form.coefficient.value)){ 
		alert('半角数字を入力してください！');
		form.coefficient.focus();
		return ;
	}
	if(isNaN(form.powerfactor.value)){ 
		alert('半角数字を入力してください！');
		form.powerfactor.focus();
		return ;
	}
	if(isNaN(form.co2param.value)){ 
		alert('半角数字を入力してください！');
		form.co2param.focus();
		return ;
	}
	if(isNaN(form.oilparam.value)){ 
		alert('半角数字を入力してください！');
		form.oilparam.focus();
		return ;
	}
	form.update_flag.value=1;
	form.submit();
}

function eleccompany_submit(form){
	if(isNaN(form.mc_power_factor.value)){ 
		alert('半角数字を入力してください！');
		form.mc_power_factor.focus();
		return ;
	}
	if(isNaN(form.mc_contract_watt.value)){ 
		alert('半角数字を入力してください！');
		form.mc_contract_watt.focus();
		return ;
	}

	if(isNaN(form.co2param.value)){ 
		alert('半角数字を入力してください！');
		form.co2param.focus();
		return ;
	}
	if(isNaN(form.oilparam.value)){ 
		alert('半角数字を入力してください！');
		form.oilparam.focus();
		return ;
	}
	document.popup.update_flag.value=1;
	document.popup.submit();
}
//**************************************************************
//関数名 ：officesetting_jump(..)
//機能　　： check out
//引数　　：なし
//戻り値  ：なし  
//画面　　：掲示板履歴
//作者　　：那　宇峰
//日付　　：2009/01/16
//**************************************************************
function officesetting_jump(pages){
	if(isNaN(document.cosmos.cuurentpage.value)){ 
		alert('半角数字を入力してください！');
		document.cosmos.cuurentpage.focus();
		return ;
	}
	if(parseInt(document.cosmos.cuurentpage.value,10) > parseInt(pages,10)){
		document.cosmos.cuurentpage.value = parseInt(pages,10);
//		document.cosmos.cuurentpage.focus();
//		return ;
	}
	document.cosmos.submit();
}
//**************************************************************
//関数名 ：alarmhistory_jump(..)
//機能　　： check out
//引数　　：なし
//戻り値  ：なし  
//画面　　：初期設定のシステム活用集計の通報履歴
//作者　　：那　宇峰
//日付　　：2009/01/16
//**************************************************************
function alarmhistory_jump(pages){
	if(isNaN(document.cosmos.cuurentpage.value)){ 
		alert('半角数字を入力してください！');
		document.cosmos.cuurentpage.focus();
		return ;
	}
	if(parseInt(document.cosmos.cuurentpage.value,10) > parseInt(pages,10)){
		document.cosmos.cuurentpage.value = parseInt(pages,10);
	}
	document.cosmos.submit();
}

//gbl add 2008/12/25
function valueselectSubmit(formName){
	
	var radioSelect= document.getElementById("radioSelected").value; 
	
	//document.getElementById("dataInsert").value = 1;
	var v='';
	if(radioSelect == 2){//!= null
		var yearValue1 = document.getElementById("yearValue1").value 
		if(yearValue1 != "" || yearValue1.value != null ){
			v += '&yearValue1=' + (0-document.getElementById("yearValue1").value); 
		}
		var yearValue2 = document.getElementById("yearValue2").value 
		if(yearValue2 != "" || yearValue2 != null){
			v += '&yearValue2=' + (0-document.getElementById("yearValue2").value);
		}
		var yearValue3 = document.getElementById("yearValue3").value 
		if(yearValue3 != "" || yearValue3 != null){
			v += '&yearValue3=' + (0-document.getElementById("yearValue3").value);
		}
		var yearValue4 = document.getElementById("yearValue4").value 
		if(yearValue4 != "" || yearValue4 != null){
			v += '&yearValue4=' + (0-document.getElementById("yearValue4").value);
		}
		var yearValue5 = document.getElementById("yearValue5").value 
		if(yearValue5 != "" || yearValue5 != null){
			v += '&yearValue5=' + (0-document.getElementById("yearValue5").value);
		}
	}
	if(radioSelect == 1){
		var yearValue21 = document.getElementById("yearValue21").value 
		if(yearValue21 != "" || yearValue21.value != null ){
			v += '&yearValue21=' + document.getElementById("yearValue21").value; 
		}
		var yearValue22 = document.getElementById("yearValue22").value 
		if(yearValue22 != "" || yearValue22 != null){
			v += '&yearValue22=' + document.getElementById("yearValue22").value;
		}
		var yearValue23 = document.getElementById("yearValue23").value 
		if(yearValue23 != "" || yearValue23 != null){
			v += '&yearValue23=' + document.getElementById("yearValue23").value;
		}
		var yearValue24 = document.getElementById("yearValue24").value 
		if(yearValue24 != "" || yearValue24 != null){
			v += '&yearValue24=' + document.getElementById("yearValue24").value;
		}
		var yearValue25 = document.getElementById("yearValue25").value 
		if(yearValue25 != "" || yearValue25 != null){
			v += '&yearValue25=' + document.getElementById("yearValue25").value;
		}
	}
	v += '&radioSelected=' + radioSelect;//
	v += '&dataInsert=1';
	//alert(v);
//	formName.action = 'progress.php?' + v;
//	formName.submit();
//	window.parent.document.forms["cosmos"].action = "{$sid}.php?param_co2={$co2}{foreach from = $days key = k item = v}&n{$k}={$v}{/foreach}";
//	window.parent.document.forms["cosmos"].submit();
	window.parent.document.forms["cosmos"].action = 'report.php?' + v;
	window.parent.document.forms["cosmos"].submit();
}
//**************************************************************
//関数名 ：Bill_information_setting(..)
//画面　　：初期設定の施設情報の「施設情報設定」
//作者　　：那　宇峰
//日付　　：2009/01/28
//**************************************************************
function Bill_information_setting(channelno){
	c = '\'billinfo.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	//c += '&channelno=' + channelno;
	c += '\'';
	s = '<iframe src=' + c + ' width=510 height=350/>';

	return overlib(s, CAPTION, '施設情報設定',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, LEFT);
	
}
//**************************************************************
//関数名 ：contract_information_setting(..)
//画面　　：初期設定の施設情報の「各社情報入力」
//作者　　：那　宇峰
//日付　　：2009/01/28
//**************************************************************
function contract_information_setting(channelno){

	var popup_update_flag=1;
	if(channelno == 'insert'){
		popup_update_flag = 0;
	}
	c = '\'contractinfo.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&popup_update_flag=' + popup_update_flag;
	c += '&channelno=' + channelno;
	c += '\'';
	s = '<iframe src=' + c + ' width=300 height=250/>';
	
	return overlib(s, CAPTION, '各社情報入力',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, LEFT);
	
}
//**************************************************************
//関数名 ：Bill_information_submit(..)
//機能　　： check out
//画面　　：初期設定の施設情報の「施設情報設定」
//作者　　：那　宇峰
//日付　　：2009/01/29
//**************************************************************
function Bill_information_submit(form){
	if(isNaN(form.area.value)){ 
		alert('数字を入力してください！');
		form.area.focus();
		return ;
	}
	document.popup.update_flag.value=1;
	document.popup.submit();
}

function popup_account(id,customerid,manager_right_flag){
	var flag = 0;
	if(manager_right_flag == '1'){
		flag = 1;
	}
	if(id.length > 0){
		s0 = 'useraccount.php?id=' + id;
		s0 += '&sid=' + document.cosmos.form.value;
		s0 += '&manager_right_flag=' + flag;
		s0 += '&customerid=' + customerid;
		s = '<iframe src=';
		s += '\'' + s0 + '\' ';
		s += 'width=380 height=270/>';

		return overlib(s, CAPTION, 'アカウント「' + id + '」の編集', STICKY, LEFT);
	}
	else {
		s0 = 'useraccount.php?customerid=' + customerid;
		s0 += '&manager_right_flag=' + flag;
		s0 += '&sid=' + document.cosmos.form.value;
		s = '<iframe src=';
		s += '\'' + s0 + '\' ';
		s += 'width=380 height=270/>';
		return overlib(s, CAPTION, 'アカウント追加', STICKY, LEFT);
	}
}
function useraccount_submit(){
	if(trim(document.customer.mailaddress.value).length > 0){
		emailReg = /^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!emailReg.test(trim(document.customer.mailaddress.value))) {
			alert('メールアドレスが不正です！');
			document.customer.mailaddress.focus();
			return false;
		}
	}
	if(document.customer.uid.value==''){
		alert('ログインIDを入力してください！');
		document.customer.uid.focus();
		return false;
	}
	if(document.customer.passwd1.value==''){
		alert('パスワードを入力してください！');
		document.customer.passwd1.focus();
		return false;
	}
	if(document.customer.passwd2.value==''){
		alert('パスワードの確認を入力してください！');
		document.customer.passwd2.focus();
		return false;
	}
	if(document.customer.passwd1.value != document.customer.passwd2.value){
		alert('パスワードがあわないです。もう一度パスワードの確認を入力してください！');
		document.customer.passwd2.focus();
		return false;
	}
	
	document.customer.data_update_flag.value=1;
	document.customer.submit();
}
//**************************************************************
//関数名 ：officesetting_submit(..)
//機能　　： check out
//画面　　：初期設定のデマンド通報設定の「更新」
//作者　　：那　宇峰
//日付　　：2009/02/02
//**************************************************************
function officesetting_submit(form){

	if(isNaN(form.alarmsetvalue.value)){ 
		alert('数字を入力してください！');
		form.alarmsetvalue.focus();
		return ;
	}
	if(form.alarmsetvalue.value >= 1){ 

	}else{
		alert('年間メール通報設定は1kW以上の値を入力してください！');
		form.alarmsetvalue.focus();
		return ;
	}
	for(var i = 0;i<=35;i++){
		var alarm = document.getElementsByName("alarm["+i+"]")[0];
		if(isNaN(alarm.value)){ 
			alert('数字を入力してください！');
			alarm.focus();
			return ;
		}
	}
	document.cosmos.update_flag.value=1;
	document.cosmos.submit();
}

function bbs_update_setting(dt_k,mode_k){
	c = '\'bbsupdate.php ? ';
	c += 'sid=' + document.cosmos.form.value;
	c += '&cn_cd=' + document.cosmos.cn_cd.value;
	c += '&mode_k=' + mode_k;
	c += '&dt_k=' + dt_k;
	c += '\'';
	s = '<iframe src=' + c + ' width=590 height=330/>';

	return overlib(s, CAPTION, '編集',CLOSECLICK,CLOSETEXT, '閉じる',CLOSECOLOR, 'white',STICKY, LEFT);
	
}

function kejibann_delete(dt,mode){
	
	if(confirm("このデータを削除しますか？") == 0){
		return;
	}
	document.cosmos.delete_k_dt.value=dt;
	document.cosmos.delete_k_flag.value=mode;
	document.cosmos.submit();
}

	
function remember_setting(){
	if(document.all.remember.checked){
		SetCookie(document.all.uid.value,document.all.password.value);
	}else{
		DelCookie();
	}
}
function GetCookie (name) 
{ 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = window.document.cookie.length; 
	var i = 0; 
	while (i < clen) 
	{ 
	var j = i + alen; 
	if (window.document.cookie.substring(i, j) == arg) return getCookieVal (j); 
	i = window.document.cookie.indexOf(" ", i) + 1; 
	if (i == 0)
	break; 
	} 
	return null;
}
function getCookieVal (offset)
{ 
	var endstr = window.document.cookie.indexOf (";", offset); 
	if (endstr == -1)
	endstr = window.document.cookie.length; 
	return unescape(window.document.cookie.substring(offset, endstr));
}
function SetCookie (name, value)
{ 
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (30*24*60*60*1000));
	window.document.cookie = name + "=" + escape (value) + "; expires=" + exp.toGMTString();
}

function DeleteCookie (name)
{
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 30*24*60*60*1000);
	var cval = GetCookie (name); 
	window.document.cookie = name + "=" +cval + "; expires=" + exp.toGMTString();
}

function DelCookie()
{
	DeleteCookie(document.all.uid.value);
}

function showpassword()
{
	var p=GetCookie(document.all.uid.value);
	if(p!=null){
		document.all.password.value= p;
		document.all.remember.checked=true;
	}
}	
function bbsshow(sheetindex,tempbt,divname){
	if(sheetindex != null){
		sheetindex.value = (parseInt(sheetindex.value,10) + 1) % 2;
		if(sheetindex.value == 1){
			divname.style.display='inline';
			tempbt.value='非表示';
		}else{
			divname.style.display='none';
			tempbt.value='表示';
		}
	}
}

function bbs_text_show(){
	
	if(document.cosmos.mes_show.value == 0) {
                  //   alert(document.cosmos.bbs_old_mes.value );
		if(document.cosmos.bbs_old_mes.value == 'bbs_default'){
		   document.cosmos.bbs_old_mes.value = document.cosmos.customermemo.value;
		}            
	//alert(document.cosmos.bbs_old_mes.value );  
	}    
       if(document.cosmos.customermemo.value == document.cosmos.bbs_old_mes.value){
		if(document.cosmos.customermemo.value != '' ) {
		document.cosmos.bbs_hidden_text.value=document.cosmos.customermemo.value;
		document.cosmos.customermemo.value='';
		}
	document.cosmos.mes_show.value=parseInt(document.cosmos.mes_show.value,10)+1;
	}	

	//}
	
}


