/*        クッキーに登録する汎用関数              */
/* 書式 : mySetCookie(クッキー名,値,有効期限日数) */
/* 戻り値 : なし(void)                            */
function mySetCookie(myCookie,myValue,myDay){
   myExp = new Date();
   myExp.setTime(myExp.getTime()+(myDay*24*60*60*1000));
   myItem = "@" + myCookie + "=" + escape(myValue) + ";";
   myExpires = "expires="+myExp.toGMTString();
   document.cookie =  myItem + myExpires;
}

/*        クッキーを取り込む汎用関数              */
/* 書式 : myGetCookie(クッキー名)                 */
/* 戻り値 : 値(string)  null:該当なし             */
function myGetCookie(myCookie){
   myCookie = "@" + myCookie + "=";
   myValue = null;
   myStr = document.cookie + ";" ;
   myOfst = myStr.indexOf(myCookie);
   if (myOfst != -1){
      myStart = myOfst + myCookie.length;
      myEnd   = myStr.indexOf(";" , myStart);
      myValue = unescape(myStr.substring(myStart,myEnd));
   }
   return myValue;
}

myTbl     = new Array("日","月","火","水","木","金","土");
myD       = new Date();

myYear    = myD.getYear();
myYear4   = (myYear < 2000) ? myYear+1900 : myYear;
myMonth   = myD.getMonth() + 1;
myDate    = myD.getDate();
myDay     = myD.getDay();
myHours   = myD.getHours();
myMinutes = myD.getMinutes();
mySeconds = myD.getSeconds();

myMess1   = myYear4 + "年" + myMonth + "月" + myDate + "日";
myMess2   = myTbl[myDay] + "曜日";
myMess3   = myHours + "時" + myMinutes + "分";

// myMess    = myMess1 + " " + myMess2 + " " + myMess3;

myMess    = myMess1 + " " + myMess3;

document.write( myMess );

myCount = eval(myGetCookie("USER_COUNTER"));//カウンター読み込み
if (myCount == null){                    // 初めての訪問
   myCount = 1;                         // 訪問回数→初回
   document.write(" 現在の在庫状況　【3台】");
}

if (myCount >= 2 && myCount <= 5){
document.write(" 現在の在庫状況　【2台】");
}

if (myCount >= 6 && myCount <= 7){
document.write(" 現在の在庫状況　【２台】");
}


if (myCount >= 8){
document.write(" 現在の在庫状況　【１台】");
}


myCount = myCount + 1;                   // カウンター加算
mySetCookie("USER_COUNTER",myCount,365); // カウンター更新
