// JavaScript Document

var AreaNUM = 0//地域ごとのファイル名の配列の数字で使用する変数のデフォルト値


/*地域ごとのファイル名配列作成*/
//1番目がクッキーなしの場合に表示されるデフォルトページとなります
ThisWeekDir = new Array("kanto_thisweek","hokkaido_thisweek", "tohoku_thisweek", "kanto_thisweek", "koshinetsu_hokuriku_thisweek", "tokai_thisweek", "kinki_thisweek", "chugoku_thisweek" ,"shikoku_thisweek","kyusyu_thisweek");
NextWeekDir = new Array("kanto_nextweek","hokkaido_nextweek", "tohoku_nextweek", "kanto_nextweek", "koshinetsu_hokuriku_nextweek", "tokai_nextweek", "kinki_nextweek", "chugoku_nextweek" ,"shikoku_nextweek","kyusyu_nextweek");


/* Cookie への書き出し
     引数 value : データの値（地域毎のファイル名の配列で使用する数字※0～9まで）*/
function SetCookie(value) {
     var str = "Area" + "=" + escape(value) + ";";					// 書き出す値１ : key=value
     var dt = new Date();                                  // 現在の日時
     dt.setDate(dt.getDate() + 365);                 			  // days日後の日時
     str += "expires=" + dt.toGMTString() + ";"; 						// 書き出す値２ : 有効期限
     document.cookie = str+";path=/;";                                 // Cookie に書き出し
}


/* Cookie の読み込み
     引数 key : 求める値のキー
     戻り値　 : 値（ない時は空文字""）*/
function ReadCookie(key) {
     var sCookie = document.cookie;    // Cookie文字列
     var aData = sCookie.split(";");       // ";"で区切って"キー=値"の配列にする
     var oExp = new RegExp(" ", "g");   // すべての半角スペースを表す正規表現
     key = key.replace(oExp, "");          // 引数keyから半角スペースを除去

     var i = 0;
     while (aData[i]) {                           /* 語句ごとの処理 : マッチする要素を探す */
          var aWord = aData[i].split("=");                         // さらに"="で区切る
          aWord[0] = aWord[0].replace(oExp, "");              // 半角スペース除去
          if (key == aWord[0]) return unescape(aWord[1]); // マッチしたら値を返す
          if (++i >= aData.length) break;                          // 要素数を超えたら抜ける
     }
     return 0;                                   // 見つからない時は空文字を返す
}

AreaNUM = ReadCookie("Area");



function ThisWeek(){
	if(AreaNUM == 0){	//クッキーの値がない場合
		document.write("<li><a href=\"/sej/html/products/area/" + ThisWeekDir[0] + "/index.html\">今週の新商品</a></li>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
	}
	else if(typeof AreaNUM == "undefined"){
		document.write("<li><a href=\"/sej/html/products/area/" + ThisWeekDir[0] + "/index.html\">今週の新商品</a></li>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
	}

	else{
		document.write("<li><a href=\"/sej/html/products/area/" + ThisWeekDir[AreaNUM] + "/index.html\">今週の新商品</a></li>");
	}
}



//来週のリンクを生成する
function NextWeek(){
	if(AreaNUM == 0){
		document.write("<li><a href=\"/sej/html/products/area/" + NextWeekDir[0] + "/index.html\">来週の新商品</a></li>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
	}
	else if(typeof AreaNUM == "undefined"){
		document.write("<li><a href=\"/sej/html/products/area/" + NextWeekDir[0] + "/index.html\">来週の新商品</a></li>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
	}
	else{
		document.write("<li><a href=\"/sej/html/products/area/" + NextWeekDir[AreaNUM] + "/index.html\">来週の新商品</a></li>");
	}
}


/*2011.04.01 トップページ右サイドの画像リンク用 今週の新商品*/

function RE_ThisWeek(){
	if(AreaNUM == 0){	//クッキーの値がない場合
		document.write("<a href=\"/sej/html/products/area/" + ThisWeekDir[0] + "\" onclick=\"javascript:_gaq.push(['_trackEvent\', 'index', 'RightSide_click', '今週の新商品']);\"><img height=\"100\" width=\"190\" border=\"0\" alt=\"今週の新商品\" src=\"/mngdbps/_template_/_user_/_SITE_/localhost/_res/images/top/bt_newproducts_2.jpg\"></a>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
	}
	else if(typeof AreaNUM == "undefined"){
		document.write("<a href=\"/sej/html/products/area/" + ThisWeekDir[0] + "\" onclick=\"javascript:_gaq.push(['_trackEvent\', 'index', 'RightSide_click', '今週の新商品']);\"><img height=\"100\" width=\"190\" border=\"0\" alt=\"今週の新商品\" src=\"/mngdbps/_template_/_user_/_SITE_/localhost/_res/images/top/bt_newproducts_2.jpg\"></a>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
	}

	else{
		document.write("<a href=\"/sej/html/products/area/" + ThisWeekDir[AreaNUM] + "\" onclick=\"javascript:_gaq.push(['_trackEvent\', 'index', 'RightSide_click', '今週の新商品']);\"><img height=\"100\" width=\"190\" border=\"0\" alt=\"今週の新商品\" src=\"/mngdbps/_template_/_user_/_SITE_/localhost/_res/images/top/bt_newproducts_2.jpg\"></a>");
	}
}



/*2011.09.22 スマートフォントップ用のリンク生成*/

function SP_ThisWeek(){
	if(AreaNUM == 0){	//クッキーの値がない場合
		document.write("<a href=\"/sej/html/products/area/" + ThisWeekDir[0] + "\"><img src=\"/mngdbps/_template_/_user_/_SITE_/localhost/_res/sp/img/secondbnr_02.png\" class=\"left\"></a>");
	}
	else if(typeof AreaNUM == "undefined"){//クッキーの値が未定義の場合
		document.write("<a href=\"/sej/html/products/area/" + ThisWeekDir[0] + "\"><img src=\"/mngdbps/_template_/_user_/_SITE_/localhost/_res/sp/img/secondbnr_02.png\" class=\"left\"></a>");
	}

	else{//クッキーが保存されている場合
		document.write("<a href=\"/sej/html/products/area/" + ThisWeekDir[AreaNUM] + "\"><img src=\"/mngdbps/_template_/_user_/_SITE_/localhost/_res/sp/img/secondbnr_02.png\" class=\"left\"></a>");
	}
}

/*
-----確認用の関数----- 
function chkfnc(){
		document.write("<li><a href=\"/sej/html/products/area/" + NextWeekDir[AreaNUM] + "/index.html\">"+AreaNUM+"</a></li>");	//クッキーの値がなければデフォルトページへのリンクを書き出す
}
*/




