if (!window.encodeURIComponent)
    encodeURIComponent = escape;
if (!window.decodeURIComponent)
    decodeURIComponent = unescape;

if (!Date.prototype.toUTCString)
    Date.prototype.toUTCString = Date.prototype.toGMTString;

Date.prototype.toExpireString = function(maxAge) {
    this.setTime(this.getTime() + maxAge*1000);
    return this.toUTCString();
};

function getCookie(key) {
    var value = new RegExp("(^|[,;]\\s*)" + key + "=\"?([^\",;\\s]+)").exec(document.cookie);
    return value ? decodeURIComponent(value[2]) : "";
}

function setCookie(key, value, maxAge) {
    document.cookie = key + "=\"" + encodeURIComponent(value)
                      + "\"; version=1; path=/; max-age=" + maxAge
                      + "; expires=\"" + new Date().toExpireString(maxAge) + '"';
}

function delnoin(no){
	document.Del.delno.value = no;
	document.Del.del.focus();
}

// クッキーで規約を読んだ人はもう表示しないでおｋ機能
function read_ok(obj) {
	if (obj.checked) {
		setCookie("skip_kiyaku","True",30*24*60*60);
	} else {
		setCookie("skip_kiyaku","",0);
	}
	return false;
}

// document.write('<div id="termPanel" style="display:none;position:absolute;width:400px;width:50%; left:25%; top:250px;padding:5px;border:1px solid #433;background:#E8E8E8;">'
// +'<h3>利用規約でしょ</h3>'
// +'<p>あいうえ<font color="red">お</font></p>'
// +'<ul><li>リスト1</li><li>リスト2</li></ul>'
// +'<p align="center"><input type="button" value="OK" onclick="termBtnClk(true)"> <input type="button" value="キャンセル" onclick="termBtnClk(false)"></p></div>');


// 「'」書くときは「\'」　「\」書くときは「\\」
// ヒアドキュメントみたいなの出来たら凄い楽なのにね ってこういう時に強く思う




function upload() {
	// クッキー食べてる人はそのまんまsubmit
	if(getCookie('skip_kiyaku')){
		document.Form.submit(); // Add 0:18
		return true;
	}
	if(arguments.length){//規約のOKボタン
		document.getElementById('uploading').style.display = 'block';
		setCookie("passwd", document.Form.pass.value, 30*24*60*60);
		if(!document.Form.mode){
			var hdnInput = document.createElement("input");
			hdnInput.type = "hidden";
			hdnInput.name = "mode";
			hdnInput.value = "javascript";
			document.Form.appendChild(hdnInput);
		}
		document.Form.submit(); // Add 0:18
		return true;
	}else{//アップロードフォームの送信ボタンから

		if (document.getElementById('uploading').style.display != 'block'){
			document.getElementById('termPanel').style.display = 'block';
		}
		return false;
	}
}

function termBtnClk(ok) {
	document.getElementById('termPanel').style.display = 'none';
	if(ok){//OKボタン
		upload(true);
	}else{//キャンセルボタン
		
	}
}


onload = function(e) {
    var passwd = getCookie("passwd"), i;
    document.Form.pass.value = passwd;
    document.Del.delpass.value = passwd;
}


