/*------------------------------------
// クッキーから値を読み込む関数
------------------------------------*/
function getCookie()
{
    keyname = "BLAWEBSSO";  //注：Cookieを利用しない場合、keyname = "NNNNNNNNNNN";
    tmp = document.cookie + ";";
    index1 = tmp.indexOf(keyname, 0);
    if (index1 != -1)
    {
        tmp = tmp.substring(index1, tmp.length);
        index2 = tmp.indexOf("=", 0) + 1;
        index3 = tmp.indexOf(";", index2);
        return(unescape(tmp.substring(index2, index3)));
    }
    return("");
}

/*------------------------------------
// クッキーから値を読み込む関数U
------------------------------------*/
function getCookieByName(keyname)
{
    tmp = document.cookie + ";";
    index1 = tmp.indexOf(keyname, 0);
    if (index1 != -1)
    {
        tmp = tmp.substring(index1, tmp.length);
        index2 = tmp.indexOf("=", 0) + 1;
        index3 = tmp.indexOf(";", index2);
        return(unescape(tmp.substring(index2, index3)));
    }
    return("");
}

/*------------------------------------
// クッキーに値を書き込む関数
------------------------------------*/
function setCookie(val)
{
    keyname = "BLAWEBSSO";  //注：Cookieを利用しない場合、keyname = "NNNNNNNNNNN";
    var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (1 * 24 * 60 * 60 * 1000)); //1 days from now 
    tmp = keyname + "=" + escape(val);
    //tmp += "; expires=" + expdate.toGMTString();
    tmp += "; path=/";
    document.cookie = tmp;
}

/*------------------------------------
// クッキーに値を書き込む関数U
------------------------------------*/
function setCookieByName(keyname, val)
{
    var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (90 * 86400 * 1000)); //90 days from now 
    tmp = keyname + "=" + escape(val);
    tmp += "; expires=" + expdate.toGMTString();
    tmp += "; path=/";
    document.cookie = tmp;
}

/*------------------------------------
// クッキーに値をクリア関数U
------------------------------------*/
function clearCookie()
{
    var strCookie = document.cookie;
    var arrCookie = strCookie.split(";");
    var i;
    var expires = new Date();
    expires.setYear(expires.getYear()-1);
    for(i=0; i<arrCookie.length; i++)
    {
        document.cookie = arrCookie[i].split("=")[0]+"=;expires=" + expires.toGMTString()+"; path=/";
    }
}

function doWindowLogOff()
{
    clearCookie();
    alert("認証情報をクリアしました。");
    //location.replace("/blabo/HomeLogin.stm");
	window.top.location = "/blabo/HomeLogin.stm";
} 

function doWindowCloseOff()
{
    clearCookie();
    window.close();
} 

function OpenLoginWindow()
{
    newWName = "ログイン画面";
    SubW=window.open("/blabo/FFLogin.stm", newWName,       "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=1,width=325,height=220");
    SubW.opener=self;
}

//WebLink and WriteLog
function DoWebLink(strUserCD, strEJrnCD, strURL)
{
    document.listform.usercd.value = strUserCD;
    document.listform.ejrncd.value = strEJrnCD;
    document.listform.url.value = strURL;
    document.listform.target="_blank";
    document.listform.action = "Eweblink.exe";
    document.listform.submit();
}

//WebLink and WriteLog2
function DoWebLink2(strUserCD, strMagCD, strEJrnCD, strURL)
{
    document.listform.usercd.value = strUserCD;
    document.listform.MagCD.value = strMagCD;
    document.listform.ejrncd.value = strEJrnCD;
    document.listform.url.value = strURL;
    document.listform.target="_blank";
    document.listform.action = "Eweblink.exe";
    document.listform.submit();
}

//IsYearCheck
function IsYearCheck(strdate) {
   if (strdate == "" || strdate == " " || strdate == "  " || strdate == "   " || strdate == "    ")
   {
       return true;
   }
   if (isNaN(strdate) == true || strdate.length != 4 || strdate < 1900 || strdate > 2500)
   {
       return false;
   }
   return true;
}

//IsMonthCheck
function IsMonthCheck(strdate) {
   if (strdate == "" || strdate == " " || strdate == "  ")
   {
       return true;
   }
   if (isNaN(strdate) == true || strdate < 1 || strdate > 12)
   {
       return false;
   }

   return true;
}

//IsDayCheck
function IsDayCheck(strdate) {
   if (strdate == "" || strdate == " " || strdate == "  ")
   {
       return true;
   }
   if (isNaN(strdate) == true || strdate < 1 || strdate > 31)
   {
       return false;
   }
   return true;
}

function getInfo(strAct, strTitle)
{
    varUSERID = getCookie();
    document.FormLink.target = "_top";
    document.FormLink.usercd.value = varUSERID;
    if(document.FormLink.usercd.value != "")
       document.FormLink.CookieON.value = '1';
    if(strTitle == "TitleList")
       document.FormLink.blacolumnlist.value = getCookieByName("BLAMAGLIST");
    else if(strTitle == "NewBook")
       document.FormLink.blacolumnlist.value = getCookieByName("NEWBOOKLIST");
    else if(strTitle == "NewMag")
       document.FormLink.blacolumnlist.value = getCookieByName("NEWMAGLIST");
    document.FormLink.action = strAct;
    document.FormLink.TitleList.value = strTitle;
    document.FormLink.Entrance.value = strTitle;
    document.FormLink.SearchBM.value = strTitle;
    document.FormLink.submit();
}

function getInfoSelf(strAct, strTitle)
{
    varUSERID = getCookie();
    document.FormLink.usercd.value = varUSERID;
    if(document.FormLink.usercd.value != "")
       document.FormLink.CookieON.value = '1';
    if(strTitle == "TitleList")
       document.FormLink.blacolumnlist.value = getCookieByName("BLAMAGLIST");
    else if(strTitle == "NewBook")
       document.FormLink.blacolumnlist.value = getCookieByName("NEWBOOKLIST");
    else if(strTitle == "NewMag")
       document.FormLink.blacolumnlist.value = getCookieByName("NEWMAGLIST");
    document.FormLink.action = strAct;
    document.FormLink.TitleList.value = strTitle;
    document.FormLink.Entrance.value = strTitle;
    document.FormLink.SearchBM.value = strTitle;
    document.FormLink.submit();
}
//** Script file end**//