function checkDate() {

	var str = document.frm.fromdate.value;
	var str2 = document.frm.todate.value;
	var errcnt = 0; 

	if (str !="") {

	  // 書式の確認
		if( !str.match( /^\d{4}\/\d{2}\/\d{2}$/ ) ) {
				errcnt += 1;
		}
	var vYear  = str.substr( 0, 4 ) - 0;
	var vMonth = str.substr( 5, 2 ) - 1;
	var vDay   = str.substr( 8, 2 ) - 0;

	// 年月日の値の確認
	if( 0 <= vMonth && vMonth <= 11 && 1 <= vDay && vDay <= 31 ) {
		var vDate = new Date( vYear, vMonth, vDay );
			if( !isNaN( vDate ) && vDate.getFullYear() == vYear 
				&& vDate.getMonth() == vMonth 
				&& vDate.getDate() == vDay ) {
					//OK
			} else {
				errcnt += 1;
			}} else {
				errcnt += 1;
			} 
	}
	else{
		//空欄はOK
	}


	if (str2 !="") {
	  // 書式の確認       
		if( !str2.match( /^\d{4}\/\d{2}\/\d{2}$/ ) ) {
				errcnt += 1;
		}
		var vYear  = str2.substr( 0, 4 ) - 0;
		var vMonth = str2.substr( 5, 2 ) - 1;
		var vDay   = str2.substr( 8, 2 ) - 0;

		// 年月日の値の確認
		if( 0 <= vMonth && vMonth <= 11 && 1 <= vDay && vDay <= 31 ) {
			var vDate = new Date( vYear, vMonth, vDay );
				if( !isNaN( vDate ) && vDate.getFullYear() == vYear 
					&& vDate.getMonth() == vMonth 
					&& vDate.getDate() == vDay ) {
					//OK
				} else {
					errcnt += 1;
				}} else {
					errcnt += 1;
				} 
	}
	else{
		//空欄はOK
	}

		//エラーの判定
		if(errcnt > 0 ){
			alert("年月を正しく入力して下さい");
			return false;
		}
				return true;
}

function InPass(list_id , mode , modeid){
	ret = window.prompt("パスワードを入力して下さい","");
	if (ret == null)
	{
		return;	
	}
	else
	{
		if(mode=="1"){
	 		location.href="PriceList.aspx?list_id=" + list_id + "&pass=" + ret +"&mode=" + modeid;
			return;
		}
		if(mode=="2")
		{
	 		window.open("Operation.aspx?list_id=" + list_id + "&pass=" + ret + "&mode=" + modeid);
			return;
		}

	}
}

function ArrowEdit(){
	return confirm("実行します。よろしいですか？");
}

function SelOpeRadio(selID){

	switch (selID)
	{
		case 1:
			
		case 2:

		case 3:

		case 4:

	}
}


//選択中のフォルダ・タイプを保存する
function SetSelFolder(type,folder,obj,istree,name,parent)
{
	if (type == null) type = "1";
	if (folder == null) folder = "";

	if ($("atree_" + parent))
	{
		var txt = "";
		if ($("atree_" + parent).textContent != null) {
			txt = $("atree_" + parent).textContent;
		} else {
			txt = $("atree_" + parent).innerText;
		}
		$("selParentName").Value = txt;

	}
	else
	{
		$("selParentName").Value = "";
	}

	$("seltype").Value = type;
	$("selfolder").Value = folder;
	$("selName").Value = name;


	//ツリー選択時
	if (istree != null)
	{
		$("sellist").Value="";	//リストをクリア
		$("isNinsyo").Value="";	//認証有無をクリア
		$("isSakujo").Value="";	//削除判定をクリア	
	}

	//メッセージセット
	setMessage(type, 'mypagelistmessage');

	if (obj != null) SetSelObject(obj,istree);

}

//選択中のリスト・タイプ・認証有無を保存する
function SetSelList(type,list,obj,list_id,isNinsyo,isSakujo)
{
	if (type == null) type = "0";
	if (list == null) list = "";
	if (isNinsyo == null) isNinsyo = "";
	if (isSakujo == null) isSakujo = "";

	$("seltype").Value = type;
	$("sellist").Value = list;
	$("selID").Value = list_id;
	$("isNinsyo").Value = isNinsyo;
	$("isSakujo").Value = isSakujo;

	if (obj != null) SetSelObject(obj);
}

//選択中のラインを目立たせる
var selMyLine = null;
function SetSelObject(obj, istree)
{
	if (selMyLine == obj) return;

	var i = 0;

	var arrtd = obj.childNodes;

	if (istree == null)
	{
		for (i = 0; i < arrtd.length; i++)
		{
			if (arrtd[i].style != null)	arrtd[i].style.background = "#FFFF99";
			if (arrtd[i].style != null)	arrtd[i].style.fontWeight = "bold";
			if (arrtd[i].style != null)	arrtd[i].style.fontSize = "9pt";
		}
	}
	if (selMyLine != null)
	{
		arrtd = selMyLine.childNodes;
		for (i = 0; i < arrtd.length; i++)
		{
			if (arrtd[i].style != null)	arrtd[i].style.background = "#FFFFFF";
			if (arrtd[i].style != null)	arrtd[i].style.fontWeight = "normal";
			if (arrtd[i].style != null)	arrtd[i].style.fontSize = "8pt";
		}
	}
	selMyLine = obj;
}

//選択している年月でリンクする
function LinkPriceList(list_id, isNinsyo)
{
	var ninsyo = "";
	if (isNinsyo != null && isNinsyo != "")
	{
		ninsyo = prompt("認証キーを入力","");
		if (ninsyo == "" || ninsyo == null) return;
	}

	if (document.forms[0].name == "mypageform")
	{
		var year = $("year").value;
		var month = $("month").value;
		var seltype = ""
		if ($("seltype") != null) seltype = $("seltype").Value;
		$("mypageform").action="PriceList.aspx?list_id=" + list_id + "&h_year=" + year + "&h_month=" + month + "&ninsyo=" + ninsyo + "&pass=" + ninsyo + "&type=" + seltype + "&mypagemain=true";
		$("mypageform").submit();
	}
	else
	{
		document.forms[0].list_id.value=list_id;
		var year = $("year").value;
		var month = $("month").value;
		var seltype = ""
		var year2 = ""
		var month2 = ""
		if ($("year2") != null) year2 = $("year2").value;
		if ($("month2") != null) month2 = $("month2").value;
		if ($("seltype") != null) seltype = $("seltype").Value;
		
		document.forms[0].action="PriceList.aspx?year=" + year + "&month=" + month + "&year2=" + year2 + "&month2=" + month2 + "&pass=" + ninsyo + "&type=" + seltype + "&pricelist=true";
		document.forms[0].submit();		
	}

}

//コマンド実行
function DoCommand(command)
{
	if (command == null || command == "")
	{
		alert("操作が実行出来ません");
		return;
	}

	var listid = $("sellist").Value;
	var folderid = $("selfolder").Value;
	var type = $("seltype").Value;
	var url = "command.aspx";
	var param = "?command=" + command + "&type=" + type;
	var isNinsyo = $("isNinsyo").Value;
	var isSakujo = $("isSakujo").Value;
	var size = "";
	var pass = "";

	//処理チェック
	switch (command)
	{
		case 2:		//フォルダ名変更
		case 3:    	//フォルダ削除
			if (folderid == null || folderid == "" || type != "3")
			{
				alert("グループフォルダを選択してください");
				return;
			}
			param += "&folder_id=" + folderid;
        	break;
		case 4:    	//リストコピー
			if (listid == null || listid == "")
			{
				alert("リストを選択してください");
				return;
			}
			param += "&list_id=" + listid;
			if (isNinsyo == "true")
			{
				pass = prompt("認証パスワードを入力してください","");
				if (pass == "" || pass == null) return;
				param += "&isStart=true&pass=" + pass;
			}
			break;
		case 5:   	//リスト名変更
			url = "listedit.aspx";
		case 7:		//公開
		case 8:		//送信
			if (listid == null || listid == "")
			{
				alert("リストを選択してください");
				return;
			}
			else if (listid == null || listid == "" || (type != "1" && type != "3"))
			{
				alert("ユーザーフォルダまたは自グループのリストのみ選択可能です");
				return;
			}
			param += "&list_id=" + listid;
			break;
		case 6:    	//リスト削除
			if (listid == null || listid == "")
			{
				alert("リストを選択してください");
				return;
			}
			if (type == "10")
			{
				alert("共有リストは削除できません");
				return;
			}
			if ((type == "5" || type == "6") && (isSakujo == "" || isSakujo == null))
			{
				alert("このリストを削除する権限がありません");
				return;
			}
			param += "&list_id=" + listid;
			break;
		case 9:		//ダウンロード
			if (listid == null || listid == "")
			{
				alert("リストを選択してください");
				return;
			}
			if (type == "5" || type == "6" || type == "7")
			{
				alert("ユーザーフォルダ・グループフォルダ・共有フォルダ以下のリストのみダウンロード可能です。");
				return;
			}
			if (confirm("OKを押した時点で当月DL数に加算されます。再度ダウンロードを行う場合は”ダウンロード履歴”をご利用下さい。"))
			{
				var frm = $("mypageform");
				frm.action = "menu.aspx";
				frm.action += "?list_id=" + listid + "&cmdDL.x=true&type=" + type;
				if (isNinsyo == "true")
				{
					pass = prompt("認証パスワードを入力してください","");
					if (pass == "" || pass == null) return;
					frm.action += "&isStart=true&pass=" + pass;					
				}
				frm.submit();
			}
			return;
			break;
		case 10:	//過去ダウンロード
			if (confirm("ダウンロードを実行します。"))
			{
				var frm = $("mypageform");
				frm.action = "menu.aspx";
				frm.action += "?cmdPrevDL.x=true";
				frm.submit();
			}
			return;
			break;
		case 11:   //共有確定
			url = "result.aspx";
			break;
		case 12:   //共有申請受信
			url = "approval.aspx";
			break;
		case 13:   //共有申請送信
			url = "request.aspx";
			break;
	}

	//サイズ決定
	switch (command)
	{
		case 1:
			size = "width=600, height=150";
			break;
		case 2:
			size = "width=500, height=150";
			break;
		case 3:
			size = "width=500, height=150";
			break;
		case 4:
			size = "width=800, height=500, resizable=yes";
			break;
		case 5:
			size = "width=1000, height=600, scrollbars=yes, resizable=yes";
			break;
		case 6:
			size = "width=500, height=150";
			break;
		case 7:
			size = "width=800, height=400";
			break;
		case 8:
			size = "width=800, height=400";
			break;
		case 11:
			size = "width=1000, height=700";
			break;
		case 12:
			size = "width=1000, height=600";
			break;
		case 13:
			size = "width=800, height=400";
			break;
	}

	window.open(url + param, null, size);
}

//マイページのセルに文言をセット
function setMessage(mode, id)
{

//alert(mode)
	if (document.getElementById(id) == null) return;
	switch (mode)
	{
		//個人・グループ
		case 0:
		case 1:
		case 2:
		case 3:
			document.getElementById(id).innerHTML="選択行のリストに対して編集、送信、ダウンロードが出来ます。リスト名をクリックすると価格表が表示されます。";
			break;

		//公開
		case 4:
		case 5:
		case 6:
			document.getElementById(id).innerHTML="選択行のリストに対して編集(コピー・削除)をしてください。";
			break;

		//受信
		case 7:
			document.getElementById(id).innerHTML="選択行のリストに対して編集(移動・削除)をしてください。";
			break;

		//共有
		case 8:
		case 9:
		case 10:
			document.getElementById(id).innerHTML="選択行のリストに対して編集、ダウンロードが出来ます。リスト名をクリックすると価格表が表示されます。";
			break;
	}
}
