/* -------------------------------------------------------------------
  出荷日計算・土日祝日お盆ＣＬＥＡＲ　ver
-------------------------------------------------------------------- */

thisDay = new Date();
timeStamp = thisDay.getTime();
myMonth = thisDay.getMonth() + 1;
myDate  = thisDay.getDate();
myHours = thisDay.getHours();
myDay   = thisDay.getDay();
myWeekTbl = new Array("日","月","火","水","木","金","土");

function isHoliday (year, month, date, nday) {
  nofw    = Math.floor((date - 1) / 7) + 1;

/* 2015年は秋分の日が計算では出ないので注意!! */
  shunbun = Math.floor(20.8431+0.242194*(year-1980)-Math.floor((year-1980)/4));
  syubun  = Math.floor(23.2488+0.242194*(year-1980)-Math.floor((year-1980)/4));

/* 2015年は春分の日秋分の日は上記をコメントアウトし下記に日数を入れる */
 // shunbun = ;
 // syubun  = ;

// 元旦は下の年明け休みで設定してください
//  if (month ==  1 && date ==  1)               { return 1; } // 元旦
  if (month ==  1 && nday ==  1 && nofw ==  2) { return 1; } // 成人の日
  if (month ==  2 && date == 11)               { return 1; } // 建国記念の日
  if (month ==  3 && date == shunbun)          { return 1; } // 春分の日
  if (month ==  4 && date == 29)               { return 1; } // みどりの日
  if (month ==  5 && date >=  3 && date <=  5) { return 1; } // 憲法記念日～こどもの日
  if (month ==  7 && nday ==  1 && nofw ==  3) { return 1; } // 海の日
  if (month ==  9 && nday ==  1 && nofw ==  3) { return 1; } // 敬老の日
  if (month ==  9 && date == syubun)           { return 1; } // 秋分の日
  if (month ==  9 && nday ==  2 && nofw ==  3 
                  && date+1 == syubun) { return 1; } // 9月第3火曜の翌日が秋分の日→国民の休日
  if (month == 10 && nday ==  1 && nofw ==  2) { return 1; } // 体育の日
  if (month == 11 && date ==  3)               { return 1; } // 文化の日
  if (month == 11 && date == 23)               { return 1; } // 勤労感謝の日
  if (month == 12 && date == 23)               { return 1; } // 天皇誕生日
  if (nday  ==  0)                             { return 2; } // 日曜
  if (nday  ==  6)                             { return 2; } // 土曜
  /*############################################################################
	monthで月の指定。　例）１月ならば　month == 1
	dateで月の指定。　例）１日ならば　date == 1
　　############################################################################*/

  /*_____________________以下はアスキューの休み設定。変更があれば修正してください_________*/
  
  //if (month ==  2 && date == 11)               { return 1; } // 休日が一日の場合
  if (month ==  8 && date >=  12 && date <= 16){ return 1; } // 盆休みの場合
  if (month ==  12 && date >=  28 && date <= 31){ return 1; } // 年末休み
  if (month ==  1 && date >=  1 && date <= 4){ return 1; } // 年明け休み
    //if ((month ==  12 && date >=  26) &&(month ==  1&&  date <= 4)){ return 1; } // お正月の場合
 //  if (month ==  8 && date >=  13 && date <= 17){ return 1; } // ＧＷの場合
  
  // 行の先頭に「//」をつけるとプログラムに影響することなくコメントが書けます。
  // プログラムに反映させたくないけど消したくないプログラムがあれば利用してください。
  
  /*___________________________________ここまで_________________________________________*/

  return 0;
}

function dispDateW () {
  return dispDate(1);
}

function dispDate1W (h) {
  return dispDate1(h, 1);//●月▼日１２時までに・・・の部分。１２時超えると日付が変わる。
}

function dispDate2W (n, h) {
  return dispDate2(n-1, h, 1);//●月▼日発送・・・の部分。１２時超えると日付が変わる。

}

function dispDate (w) {
  return dateFormat(myMonth,myDate,myDay,w);
}

function dispDate1 (h, w) {
  return dispDate2(0, h, w);
}

function dispDate2 (n, h, w) {
  var i = 0;
  while (i <= n) {
    thisDay.setTime(timeStamp + (1000*60*60*24 * i));
    myYear2  = thisDay.getFullYear();
    myMonth2 = thisDay.getMonth() + 1;
    myDate2  = thisDay.getDate();
    myDay2   = thisDay.getDay();
    if (isHoliday(myYear2,myMonth2,myDate2,myDay2) == 0 && i == 0 && h <= myHours) { n++; }  // 翌日扱い
    if (isHoliday(myYear2,myMonth2,myDate2,myDay2) >= 1){ n++; }  // 休日
    if (isHoliday(myYear2,myMonth2,myDate2,myDay2) == 1 && myDay2 == 0){ n++; }  // 振替休日
    i++;
  }
  return dateFormat(myMonth2,myDate2,myDay2,w);
    
}

function dateFormat (month, date, week, w) {

  if(w == 1) { return month+"月"+date+"日（"+myWeekTbl[week]+"）"; }
  else { return month+"月"+date+"日"; }

}
function sendDayTmp1d(){
	//発送予定日テンプレート
	html = '<div class="hassou" style="margin-bottom:0px;">'
		
	+'<span>ただいまのご注文分は </span>'
	+'<span class="hassoubi">'
			
	+dispDate2W(1,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span> から出荷の予定です。<br /></span>'
	+'<span class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</span>'
	+'</div>';

//書き出し
document.write( html );
}	

function sendDayBoxTmp1d(){
	//発送予定日車画像verテンプレート
	html = '<div class="hassoubox" style="margin-bottom:0px;">'
	+'<div class="boxin">'	
	+'ただいまのご注文分は'
	+'<span class="hassoubi">'
			
	+dispDate2W(1,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'から出荷の予定です。'
	+'</div>'
	+'</div>'
	+'<div class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</div>'

//書き出し
document.write( html );
}	

function sendDayBtnTmp1d(){
	//発送予定日ボタン横テンプレート
	html = '<div class="hassoubtn" style="margin-bottom:0px;">'
		
	+'<div>本日PM2:00までにご注文いただくと</div>'
	+'<span class="hassoubibtn">'
			
	+dispDate2W(1,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span>から出荷の予定です。</span>'
+'</div>';

//書き出し
document.write( html );
}	

function sendDayOverTmp1d(){
	//発送予定日出荷ボタンポップアップテンプレート
	html = '<div class="hassouOver" style="margin-bottom:0px;">'
		
	+'<span class="hassoubiOver">'
			
	+dispDate2W(1,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span></span>'
+'</div>';

//書き出し
document.write( html );
}

function sendDayOverTmp2d(){
	//ギリギリ注文の発送予定
	html = '<span class="girigirihassou-txt">'
		
	+dispDate2W(2,14)//(何営業日後？：何時まで？)
+'</span>';

//書き出し
document.write( html );
}

function sendDayTmp4d(){
	//発送予定日テンプレート
	html = '<div class="hassou" style="margin-bottom:0px;">'
		
	+'<span>ただいまのご注文分は </span>'
	+'<span class="hassoubi">'
			
	+dispDate2W(4,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span> から出荷の予定です。<br /></span>'
	+'<span class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</span>'
	+'</div>';

//書き出し
document.write( html );
}	

function sendDayBoxTmp4d(){
	//発送予定日テンプレート
	html = '<div class="hassoubox" style="margin-bottom:0px;">'
	+'<div class="boxin">'	
	+'ただいまのご注文分は'
	+'<span class="hassoubi">'
			
	+dispDate2W(4,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'から出荷の予定です。'
	+'</div>'
	+'</div>'
	+'<div class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</div>'

//書き出し
document.write( html );
}	

function sendDayBtnTmp4d(){
	//発送予定日テンプレート
	html = '<div class="hassoubtn" style="margin-bottom:0px;">'
		
	+'<div>本日PM2:00までにご注文いただくと</div>'
	+'<span class="hassoubibtn">'
			
	+dispDate2W(4,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span>から出荷の予定です。</span>'
+'</div>';

//書き出し
document.write( html );
}	

function sendDayBoxShtTmp4d(){
	//発送予定日テンプレート
	html = '<div class="hassoubox2" style="margin-bottom:0px;">'
	+'<div class="boxin2" style="line-height:140%">'	
	+'ただいまのご注文分は'
	+'<span class="hassoubi2">'
			
	+dispDate2W(4,14)//(何営業日後？：何時まで？)
	+'</span><br />'
	+'から出荷の予定です。'
	+'</div>'
+'</div>';


//書き出し
document.write( html );
}	

function sendDayOverTmp4d(){
	//発送予定日テンプレート
	html = '<div class="hassouOver" style="margin-bottom:0px;">'
		
	+'<span class="hassoubiOver">'
			
	+dispDate2W(4,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span></span>'
+'</div>';

//書き出し
document.write( html );
}	



function sendDayTmp6d(){
	//発送予定日テンプレート
	html = '<div class="hassou" style="margin-bottom:0px;">'
		
	+'<span>ただいまのご注文分は </span>'
	+'<span class="hassoubi">'
			
	+dispDate2W(6,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span> から出荷の予定です。<br /></span>'
	+'<span class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</span>'
	+'</div>';

//書き出し
document.write( html );
}	

function sendDayBoxTmp6d(){
	//発送予定日車画像verテンプレート
	html = '<div class="hassoubox" style="margin-bottom:0px;">'
	+'<div class="boxin">'	
	+'ただいまのご注文分は'
	+'<span class="hassoubi">'
			
	+dispDate2W(6,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'から出荷の予定です。'
	+'</div>'
	+'</div>'
	+'<div class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</div>'

//書き出し
document.write( html );
}	

function sendDayBtnTmp6d(){
	//発送予定日ボタン横テンプレート
	html = '<div class="hassoubtn" style="margin-bottom:0px;">'
		
	+'<div>本日PM2:00までにご注文いただくと</div>'
	+'<span class="hassoubibtn">'
			
	+dispDate2W(6,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span>から出荷の予定です。</span>'
+'</div>';

//書き出し
document.write( html );
}	

function sendDayOverTmp6d(){
	//発送予定日出荷ボタンポップアップテンプレート
	html = '<div class="hassouOver" style="margin-bottom:0px;">'
		
	+'<span class="hassoubiOver">'
			
	+dispDate2W(6,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span></span>'
+'</div>';

//書き出し
document.write( html );
}	

function sendDayTmp9d(){
	//発送予定日テンプレート
	html = '<div class="hassou" style="margin-bottom:0px;">'
		
	+'<span>ただいまのご注文分は </span>'
	+'<span class="hassoubi">'
			
	+dispDate2W(9,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span> から出荷の予定です。<br /></span>'
	+'<span class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</span>'
	+'</div>';
//書き出し
document.write( html );
}	

function sendDayBoxTmp9d(){
	//発送予定日車画像verテンプレート
	html = '<div class="hassoubox" style="margin-bottom:0px;">'
	+'<div class="boxin">'	
	+'ただいまのご注文分は'
	+'<span class="hassoubi">'
			
	+dispDate2W(9,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'から出荷の予定です。'
	+'</div>'
	+'</div>'
	+'<div class="speedcomment">お急ぎの場合は備考欄かお電話にてご連絡ください。</div>'

//書き出し
document.write( html );
}	

function sendDayBtnTmp9d(){
	//発送予定日ボタン横テンプレート
	html = '<div class="hassoubtn" style="margin-bottom:0px;">'
		
	+'<div>本日PM2:00までにご注文いただくと</div>'
	+'<span class="hassoubibtn">'
			
	+dispDate2W(9,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span>から出荷の予定です。</span>'
+'</div>';

//書き出し
document.write( html );
}	

function sendDayOverTmp9d(){
	//発送予定日出荷ボタンポップアップテンプレート
	html = '<div class="hassouOver" style="margin-bottom:0px;">'
		
	+'<span class="hassoubiOver">'
			
	+dispDate2W(9,14)//(何営業日後？：何時まで？)
	+'</span>'
	+'<span></span>'
+'</div>';

//書き出し
document.write( html );
}	

