//-----------------------------------------------------------------------------
// Servlet ２重送信防止チェック
//-----------------------------------------------------------------------------
// Usage 1.:２重送信チェック( JavaScript のみで制御 )
//          
// Usage 2.:２重送信チェック( JavaScript ＋ Cookie で制御 )
// 
//-----------------------------------------------------------------------------
// Exceptions:
//   
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// DubleSend Count Up
//-----------------------------------------------------------------------------
function DubleSend_Count()
{
	DoubleSend = DoubleSend + 1;
	return true;
}
//-----------------------------------------------------------------------------
// DubleSend_Check
//-----------------------------------------------------------------------------
function DubleSend_Check()
{
	if ( DoubleSend > 0 ) {
		return false;
	}
	else if ( getCookie("DupFlg") == "Valid" ) {
		if ( navigator.platform == "Win32" ) {
			alert("　処理中です。もうしばらくお待ち下さい。　");
		}
		return false;
	}
	else {
		DubleSend_Count();
		setCookie("DupFlg","Valid");
		DoubleSend = 0;
		return true;
	}
}
//-----------------------------------------------------------------------------
// Create a value for the cookie
//-----------------------------------------------------------------------------
function setCookie(name,value,domain,path)
{
        document.cookie=name+"="+escape(value)+";path="+path+";domain="+domain;
}
function setCookie(name,value)
{
        document.cookie=name+"="+escape(value)+";expires="+"Fri, 01 Jan 3000 18:56:35 GMT"+";path=/";
}
//-----------------------------------------------------------------------------
// Get the value for the cookie
//-----------------------------------------------------------------------------
function getCookie(name)
{
        var dc=document.cookie;
        var cname=name+"=";
        var clen=dc.length;
        var cbegin=0;
        while(cbegin < clen)
        {
                var vbegin=cbegin+cname.length;
                if (dc.substring(cbegin,vbegin) == cname)
                {
                        var vend=dc.indexOf(";",vbegin);
                        if (vend == -1)
                                vend = clen;
                        return unescape(dc.substring(vbegin,vend));
                }
                cbegin=dc.indexOf(" ",cbegin) + 1;
                if (cbegin == 0) break;
        }
        return null;
}
//-----------------------------------------------------------------------------
// Delete the cookie 
//-----------------------------------------------------------------------------
function deleteCookie(name)
{
                if (getCookie(name) != null)
			document.cookie=name+"="+null+";expires="+"Fri, 03 Jan 1997 12:00:00 GMT"+";path=/";
}

