
function saveCode(code)
{
    var tmp = getCookie("code");    // クッキーを取得
    // 重複しないように保存する
    if (tmp.indexOf(code) == -1) {
        if(tmp != "") { tmp += ";"; }
        tmp += code;
        setCookie("code", tmp);     // クッキーを保存
    }
}

function getCookie(key)
{
    var tmp1, tmp2, xx1, xx2, xx3;
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}

function setCookie(key, val)
{
    var tmp;
    tmp = key + "=" + escape(val) + "; ";
    var date = new Date();
    date.setTime(date.getTime() + 60*60*1000); // クッキーの保持期間（１時間）
    tmp += "expires=" + date.toGMTString() + ";";
    document.cookie = tmp;
}

function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}

function OpenInfo() {
    window.open("","info","toolbar=yes,location=0,directories=0,status=yes,menubar=0,scrollbars=yes,resizable=yes,copyhistory=0,width=570,height=450")
}
function OpenUser() {
    window.open("","user","toolbar=yes,location=0,directories=0,status=yes,menubar=0,scrollbars=yes,resizable=yes,copyhistory=0,width=570,height=450")
}



/* subWindow Open */

/*****
<script type="text/javascript" src="com/js/popup.js"></script>
javascript:subWin('subWin.html',500,500)
javascript:subWin('subWin.html',500,400,1)
javascript:subWin('subWin.html',500,400,1,'wd')
*****/

function subWin(Address, W, H, Style, Target){
Width = parseInt(W);
Height = parseInt(H);

	//Check Scrollbars
	if(Style==1){
		Style="yes";
		//Check Window Size
		Width += 17;
	}else{
		Style="no";
	}

	//Check Target
	if(Target=="undefined"){
		Target="";
	}

	if(document.getElementsByTagName("base")[0]){
		Address = document.getElementsByTagName("base")[0].href + Address;
	}

	Options = "width="+Width+",height="+Height+",toolbar=no,scrollbars="+Style+",resizable=no,directories=no,menubar=no,status=no,location=no";
	window.open(Address, Target, Options);
}
