////////////////////////////////////////////////////////////////////////////////
//■グローバル変数
	var objAjax;
//	var objAjax = new AjaxRequest();
	var objAmazon = [];		//
	var objProgress = {};	//進捗ゲージインスタンス
//	var ClickedElement;		//押下されたボタンのelement
var ProductLoad_Manager="0";	//商品データロード管理（暫定的仕様）







////////////////////////////////////////////////////////////////////////////////
//■商品情報の初期読み込み関連
//●window.onload 時にロード開始
	function OnloadAmazonProduct(asin){
		objAmazon["Product"] = [];
		objAmazon["retry_counter"] = 0;
		objAmazon["asinlist"] = asin;

//		objAmazon["ClickedElement"] = {};	//クリックされた「カートに入れる」ボタンを捕まえておく

//		var status_ele = document.getElementById("amazonds_button");
//		status_ele.src = "/img/review_loading.gif";
//alert(AmazonProduct_LoadComplete);
		//amazon の offerリクエスト登録
			var request_url = "/process/method_send_item.php?operate=lookup&asin=" + objAmazon["asinlist"] + "&page=1&option=A";
			objAjax.RequestQueue_Entry(request_url, AmazonProduct_LoadComplete, 1000);
			//objAjax.RequestQueue_Entry(request_url, "AmazonProduct_LoadComplete('amazon');", 1000);

		//new used の offerリクエスト登録
			request_url = "/process/method_send_item.php?operate=lookup&asin=" + objAmazon["asinlist"] + "&page=1&option=RC";
			objAjax.RequestQueue_Entry(request_url, AmazonProduct_LoadComplete, 1000);
			//objAjax.RequestQueue_Entry(request_url, "AmazonProduct_LoadComplete('customer');", 1000);

		//AmazonDS開始 のリクエスト登録
			request_url = "/process/method_send_amazonds.php?operate=start_statistical&asin=" + objAmazon["asinlist"];
			objAjax.RequestQueue_Entry(request_url, AmazonDSOperate_StartComplete, 1);
	}





//●在庫読み込み完了
	AmazonProduct_LoadComplete = function(){
		//●load結果の取得
		var Response = objAjax.body.split("\n");

		//●アクセス完了
		if( Response[0] == "search_complete" ){
			Response.shift();
			//・パラメータ
			var param_list = ["asin","title","image_s","image_m","average_rating",
								"stock_type","price","stock","item_id","shop_name",
								"available","condition_note"];
			for(var index_Response in Response){
				if(Response[index_Response]=="eof"){ break; }
				var ResponseRecord = Response[index_Response].split("/");

				var tmp_obj = {};
				for(var index_ResponseRecord in ResponseRecord){
					tmp_obj[ param_list[index_ResponseRecord] ] = ResponseRecord[index_ResponseRecord];
				}
				tmp_obj.price = tmp_obj.price=="" ? 0 : parseInt(tmp_obj.price);
				tmp_obj.stock = tmp_obj.stock=="" ? 0 : parseInt(tmp_obj.stock);
				tmp_obj["item_id_encoded"] = tmp_obj.item_id;
				tmp_obj.item_id = tmp_obj.item_id.urldecode();
				objAmazon["Product"].push(tmp_obj);
			}
		}
		//●アクセスエラー
		else{
			return false;
		}

		//●price値をキーとして昇順ソート
		objAmazon["Product"].sort( function(a,b){ return (a.price - b.price); } );

		//●集計結果のDOM出力
		for(var index_Product in objAmazon["Product"]){
			var ProductRecord = objAmazon["Product"][index_Product];
			var id_type = ProductRecord["asin"] + "_offer_" + ProductRecord["stock_type"];

			//表示フラグの状態ですでに挿入した情報かどうか判定
			parent_ele = document.getElementById(id_type);
			if( !parent_ele || parent_ele.style.display==""){
				continue;
			}

			if( ProductRecord["stock_type"]=="amazon" || (ProductRecord["stock"] > 0) ){
				//・タイトル名
				var ele = document.getElementById(ProductRecord["asin"] + "_title")
				if( ele ){
					ele.innerHTML = ProductRecord["title"].urldecode();
				}

				//・星
				ele = document.getElementById(ProductRecord["asin"] + "_rating")
				if( ProductRecord["average_rating"] ){
					var average_rating = parseInt(ProductRecord["average_rating"]);
				}else{
					var average_rating = 0;
				}
				if( ele && !ele.hasChildNodes() && (average_rating > 0) ){
					var img_average_ration = document.createElement("img");
					img_average_ration.border = "0";
					img_average_ration.src = "/img/average" + ProductRecord["average_rating"] + ".jpg";
					ele.appendChild(img_average_ration);
				}

				//・価格
				ele = document.getElementById(id_type + "_price")
				if( ele ){
					var price = parseInt(ProductRecord["price"]);
					ele.innerHTML = price.number_format();
				}

				//・在庫数
				ele = document.getElementById(id_type + "_stock");
				if( ele && (ProductRecord["stock"] > 0) ){	//amazonの場合在庫情報が無い
					ele.innerHTML = ProductRecord["stock"];
				}

				//・カートボタンの追加
				ele = document.getElementById(id_type + "_button_rect");
//				if( !ele.hasChildNodes() ){
					var button_ele = document.createElement("input");
					button_ele.id = "cart_add_" + ProductRecord["item_id_encoded"];
					button_ele.type = "image";
					button_ele.src = "/img/cart_into.gif";
					button_ele.value = ProductRecord["item_id_encoded"]
					set_attribute(button_ele, "onclick", 'ClickCartInsert(this); return false;');

					ele.appendChild(button_ele);
//				}
				//・表示フラグON
				parent_ele.style.display = "";
			}
		}


		if( ProductLoad_Manager==0 ){
			objProgress["product"].UpdateGauge(1, 2);
			objProgress["product"].UpdateStatus("Loading...50％");
			ProductLoad_Manager++;
		}else{
			objProgress["product"].UpdateGauge(2, 2);
			objProgress["product"].UpdateStatus("complete");
			ProductLoad_Manager++;
		}
	}


//●DOM更新
	AmazonProduct_UpdateElement = function(product_param){
	}








////////////////////////////////////////////////////////////////////////////////
//■AmazonDS処理関連
//●更新ボタン押下
	//function ClickAmazonDSQuery(ele, asin){
	function ClickAmazonDSQuery(){
	}

//●
	AmazonDSOperate_StartComplete = function(){
		var request_url = "/process/method_send_amazonds.php?operate=continue_statistical";
		objAjax.RequestQueue_Entry(request_url, AmazonDSOperate_ContinueComplete, 1000);

	}

//●
	AmazonDSOperate_ContinueComplete = function(){
		//・load結果 operateの取得
	//	var separate_start = 0;
	//	var separate_end = objAjax.body.indexOf("\n", separate_start);
	//	var next_operate = objAjax.body.substr(separate_start, separate_end-separate_start);
		var Response = objAjax.body.split("\n");
		var next_operate = Response[0];
		Response.shift();

		//・アクセスエラー
		//if( next_operate=="error" ){
		if( !(next_operate=="go conitnue" || next_operate=="end" )){
			//ここで集計終了のDOM出力を行う
			objProgress["amazonds"].UpdateStatus("Load Error...");
		}
		//・集計
		else{
			//load結果
			objAmazon["retry_counter"] = 0;
			current_page = parseInt(Response[0]);
			Response.shift();
			page_max = parseInt(Response[0]);
			Response.shift();

			var echo_string = "";
			var result_counter = 0;
			star_param = Response;

			//集計途中のDOM出力を行う
			var param_list = ["asin", "star_num", "review_max", "param_num", "param_base"
								, "param_recommend", "param_summary", "param_name", "param_content"];
			var param_encode_list = ["param_summary", "param_name", "param_content"]
			var param_int_list = ["star_num", "review_max", "param_num", "param_base", "param_recommend"]
			var param_tmp = {};
			for(result_counter in star_param){
				if( star_param[result_counter].indexOf("/") == -1 ){
					continue;
				}

				star_param_tmp = star_param[result_counter].split("/");
				for(star_param_tmp_index in star_param_tmp){
					param_tmp[ param_list[star_param_tmp_index] ] = star_param_tmp[star_param_tmp_index];
				}
				for(param_int_list_index in param_int_list){
					param_tmp[ param_int_list[param_int_list_index] ] = parseInt(param_tmp[ param_int_list[param_int_list_index] ]);
				}
				for(param_encode_list_index in param_encode_list){
					param_tmp[ param_encode_list[param_encode_list_index] ] = param_tmp[ param_encode_list[param_encode_list_index] ].urldecode();
				}

				//DOM更新
					var ele;
					var gauge_tmp;
					var ratio_tmp;
				//★の投稿総数
					ele = document.getElementById("dss_s" + param_tmp.star_num.toString(10) + "num_" + param_tmp.asin);
					if( ele ){
						ele.innerHTML = "（" + param_tmp.param_num.toString(10) + "）"
					}
				//★レビュー総数割合ゲージ
					ele = document.getElementById("dss_s" + param_tmp.star_num.toString(10) + "review_" + param_tmp.asin);
					if( ele ){
						gauge_tmp = param_tmp.review_max==0 ? 0 : Math.ceil(param_tmp.param_num * 120 / param_tmp.review_max);;
						if( gauge_tmp==0 ){ gauge_tmp = 1; }
						ratio_tmp = param_tmp.review_max==0 ? 0 : Math.ceil(param_tmp.param_num * 100 / param_tmp.review_max);;
						ele.style.width = gauge_tmp.toString(10) + "px";
						ele.alt = ratio_tmp.toString(10) + "％";
					}
				//★参考にした人の総数割合ゲージ
					ele = document.getElementById("dss_s" + param_tmp.star_num.toString(10) + "recommend_" + param_tmp.asin);
					if( ele ){
						gauge_tmp = param_tmp.param_base==0 ? 0 : Math.ceil(param_tmp.param_recommend * 120 / param_tmp.param_base);;
						if( gauge_tmp==0 ){ gauge_tmp = 1; }
						ratio_tmp = param_tmp.param_base==0 ? 0 : Math.ceil(param_tmp.param_recommend * 100 / param_tmp.param_base);;
						ele.style.width = gauge_tmp.toString(10) + "px";
						ele.alt = ratio_tmp.toString(10) + "％";
					}
				//★参考にした人の割合についての詳細数値
					ele = document.getElementById("dss_s" + param_tmp.star_num.toString(10) + "propaty_" + param_tmp.asin);
					if( ele ){
						ele.innerHTML = "（" + param_tmp.param_recommend.toString(10) + "/" + param_tmp.param_base.toString(10) + "）"
					}
				//★参考にした人のレビューの冒頭数文字
					ele = document.getElementById("dss_s" + param_tmp.star_num.toString(10) + "summary_" + param_tmp.asin);
					if( ele && (param_tmp.param_summary != "") ){
					//	ele.title = param_tmp.param_summary + "\n\n" + param_tmp.param_content + "\n\n" + param_tmp.param_name;
						ele.title = param_tmp.param_summary;
						ele.innerHTML = param_tmp.param_summary.substr(0, 10);
						if( param_tmp.param_summary.length > 10 ){
							ele.innerHTML += "...";
						}
					}
			}

			//集計進捗の更新
			//集計途中の場合次のaccessを登録
			if( next_operate=="go conitnue" ){
				var request_url = "/process/method_send_amazonds.php?operate=continue_statistical";
				objAjax.RequestQueue_Entry(request_url, AmazonDSOperate_ContinueComplete, 1000);

				var load_completed_page = current_page;
				if( load_completed_page <= 0 ){ load_completed_page = 0; }
				var progress_ratio = ((page_max==0) ? 0 : Math.floor(load_completed_page * 100 / page_max));

				objProgress["amazonds"].UpdateGauge(load_completed_page, page_max);
				objProgress["amazonds"].UpdateStatus("AmazonDS Loading..." + progress_ratio.toString(10) + "％");
			}
			//集計終了
			else{
				//ここで集計終了のDOM出力を行う
				objProgress["amazonds"].UpdateGauge(1, 1);
				objProgress["amazonds"].UpdateStatus("complete");
			}
		}
	}




////////////////////////////////////////////////////////////////////////////////
//■カート処理関連
//●カートに入れるボタン押下
	function ClickCartInsert(ele){
		for(var index_Product in objAmazon["Product"]){
			if( objAmazon["Product"][index_Product].item_id_encoded == ele.value ){
				var ProductRecord = objAmazon["Product"][index_Product];
				break;
			}
		}

		ele.src = "/img/cart_into_anm.gif";
		var request_target = "/process/method_send_cart.php?operate=add_cart&asin=" + ProductRecord["asin"] + "&title=" + ProductRecord["title"].urlencode() + "&image_s=" + ProductRecord["image_s"] + "&price=" + ProductRecord["price"] + "&item_id=" + ProductRecord["item_id_encoded"];
		objAjax.RequestQueue_Interupt(request_target, CartOperate_AddComplete, 1);
	}

//●カードから削除するボタン押下
	function ClickCartDelete(request_target){
		objAjax.RequestQueue_Interupt(request_target, CartOperate_DecComplete, 1);
	}

//●カート関連のボタン押下
	function ClickCartQuery(ele, mode, url){
		switch(mode){
/*
			case "add":
				ClickedElement = ele;
				ele.src = "/img/cart_into_anm.gif";
				id = objAjax.RequestQueue_Interupt(url, CartOperate_AddComplete, 1);
//				objAmazon["ClickedElement"][id] = ele;
				break;
*/
			case "dec":
				id = objAjax.RequestQueue_Interupt(url, CartOperate_DecComplete, 1);
//				objAmazon["ClickedElement"][id] = ele;
				break;
			default:
				return false;
				break;
		}
	}

//●ajaxのトリガーにオーバーロードする関数
//・カートに追加
	CartOperate_AddComplete = function(){
		//親ブロックを取得しておく
		var div_cart_inside = document.getElementById("cart_inside");

		//エラー時の出力ブロックを取得しておく
		var progress_ele = document.getElementById("review_loading_progress");
		progress_ele.innerHTML = "";

		//load結果の取得
		var separate_start = 0;
		var separate_end = objAjax.body.indexOf("\n", separate_start)
		var asin = objAjax.body.substr(separate_start, separate_end-separate_start);

		if( asin=="error" ){
			progress_ele.innerHTML = "add error...";
		}else{
			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start)
			var title = objAjax.body.substr(separate_start, separate_end-separate_start);

			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start)
			var image_s = objAjax.body.substr(separate_start, separate_end-separate_start);
			if( image_s == "" ){
				image_s = "/img/no_image_s.gif";
			}

			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start)
			var price = objAjax.body.substr(separate_start, separate_end-separate_start);
			price = parseInt(price);

			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start)
			var item_id = objAjax.body.substr(separate_start, separate_end-separate_start);	//生のitem_id
			var item_id_encoded = item_id.urlencode();

			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start)
			var cart_index = objAjax.body.substr(separate_start, separate_end-separate_start);

			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start)
			var cart_index_4d = objAjax.body.substr(separate_start, separate_end-separate_start);
	
			//DOM書き込み
			//カートに入れる処理を行う前の段階で、カートが空だった場合、合計金額とレジへすすむボタンを追加する	
			var attr_of_class = DOCUMENT_IS_IE4 ? "className" : "class";
			if( !div_cart_inside.hasChildNodes() ){
				CreateCartAreaElments();
			}
	
			var InsertItem = {asin:asin, title:title, item_id:item_id, image_s:image_s, num:1, price:price, cart_index:cart_index};
			//同じitem_idを持つelementが存在するなら個数増加
			var add_target = document.getElementById("product_" + item_id_encoded);
			if( add_target ){
				target_input_ele = document.getElementById("product_num_" + item_id_encoded);
				var num_value = target_input_ele.value;
				num_value = parseInt(num_value);
				target_input_ele.value = (num_value + 1).toString(10);
	
				//カート内容管理オブジェクトの個数更新
				for(var CartItem in objCart){
					if( objCart[CartItem].item_id == InsertItem["item_id"] ){
						objCart[CartItem].num++;
					}
				}
			}else{
				//カート内容管理オブジェクトへの挿入
				objCart.push(InsertItem);
				var ele = CreateCartItemElement( InsertItem );
				div_cart_inside.appendChild(ele);
			}

			//合計金額の更新
			UpdateTotalPriceElement();

			//クリック元の画像を元に戻す
			document.getElementById("cart_add_" + item_id_encoded).src = "/img/cart_into.gif";
		}
	}

//・カートから削除
	CartOperate_DecComplete = function(){
		//エラー時の出力ブロックを取得しておく
		var progress_ele = document.getElementById("review_loading_progress");
		progress_ele.innerHTML = "";

		//リクエスト結果の取得
			if( objAjax.body == "" ){ return false; }
	
			var separate_start = 0;
			var separate_end = objAjax.body.indexOf("\n", separate_start)
			var result = objAjax.body.substr(separate_start, separate_end-separate_start);

			if( result=="error" ){
				progress_ele.innerHTML = "delete error...";
			}

			if( result != "item cleared" ){ return false; }

			separate_start = separate_end + 1;
			separate_end = objAjax.body.indexOf("\n", separate_start);
			var item_id = objAjax.body.substr(separate_start, separate_end-separate_start);	//生のitem_id
			if( item_id == "" ){ return false; }

		//・カート内管理配列の更新
			for(var CartItem in objCart){
				if( objCart[CartItem].item_id == item_id ){
					objCart.splice(CartItem, 1);
				}
			}

		//・合計金額の再計算、カート内容管理オブジェクトの更新
			UpdateTotalPriceElement();

		//DOM処理
			//・カート表示部分の削除
			var remove_target = document.getElementById("product_" + item_id.urlencode());
			remove_target.parentNode.removeChild(remove_target);

			//・カートが空になった場合のタグ削除
			var div_cart_inside = document.getElementById("cart_inside");
			if( !div_cart_inside.hasChildNodes() ){
				remove_target = document.getElementById("cart_total_price");
				remove_target.parentNode.removeChild(remove_target);
				remove_target = document.getElementById("register_button_top");
				remove_target.parentNode.removeChild(remove_target);
			}
	}



//●カートのDOM要素を新規作成
	function CreateCartItemElement(CartItem){
		var attr_of_class = DOCUMENT_IS_IE4 ? "className" : "class";
		var div_cart_item = document.createElement("div");
			div_cart_item.id = "product_" + CartItem["item_id"].urlencode();
			div_cart_item.setAttribute(attr_of_class, "cart_item");

			var span_cart_item_title = document.createElement("span");
				span_cart_item_title.setAttribute(attr_of_class, "cart_item_title");
				span_cart_item_title.appendChild( document.createTextNode(CartItem["title"]) );
		div_cart_item.appendChild(span_cart_item_title);

			var div_cart_item_num = document.createElement("div");
				div_cart_item_num.setAttribute(attr_of_class, "cart_item_num");
				var input_product_num = document.createElement("input");
					input_product_num.id = "product_num_" + CartItem["item_id"].urlencode();
					input_product_num.setAttribute(attr_of_class, "product_num_box");
					input_product_num.type = "text";
					input_product_num.name = "product_num[" + CartItem["cart_index"] + "]";
					input_product_num.value = CartItem["num"];
			div_cart_item_num.appendChild(input_product_num);
			div_cart_item_num.appendChild( document.createTextNode("個") );
			div_cart_item_num.appendChild( document.createElement("br") );

				var img_product_clear_button = document.createElement("img");
					img_product_clear_button.setAttribute(attr_of_class, "item_delete_button");
					img_product_clear_button.src = "/img/cart_node_clear.gif";
					img_product_clear_button.alt = "この商品を削除する";
					img_product_clear_button.border = "0";
					var click_hander_resource = "ClickCartDelete('/process/method_send_cart.php?operate=dec_cart&cart_index=" + CartItem["cart_index"] + "&item_id=" + CartItem["item_id"].urlencode() + "');";
					set_attribute(img_product_clear_button, "onclick", click_hander_resource);

/*
				var img_product_clear_button = document.createElement("img");
					img_product_clear_button.setAttribute(attr_of_class, "item_delete_button");
					img_product_clear_button.src = "/img/cart_node_clear.gif";
					img_product_clear_button.alt = "この商品を削除する";
					img_product_clear_button.border = "0";
					var click_hander_resource = "ClickCartQuery(this, 'dec', '/process/method_send_cart.php?operate=dec_cart&cart_index=" + CartItem["cart_index"] + "&item_id=" + CartItem["item_id"] + "');";
					if(DOCUMENT_IS_IE4){
						img_product_clear_button.setAttribute("onclick", new Function(click_hander_resource) );
					}else{
						img_product_clear_button.setAttribute("onclick", click_hander_resource );
					}
*/
			div_cart_item_num.appendChild(img_product_clear_button);
		div_cart_item.appendChild(div_cart_item_num);

			var img_product_image_s = document.createElement("img");
				img_product_image_s.src = CartItem["image_s"];
				img_product_image_s.alt = CartItem["title"];
				img_product_image_s.border = "0";
		div_cart_item.appendChild(img_product_image_s);

			var cart_item_price = document.createElement("div");
				cart_item_price.setAttribute(attr_of_class, "cart_item_price");
				cart_item_price.appendChild( document.createTextNode( "￥" + CartItem["price"].number_format() ) );
		div_cart_item.appendChild(cart_item_price);

		return div_cart_item;
	}

//●合計金額、レジへすすむボタンのDOM追加
function CreateCartAreaElments(){
	var attr_of_class = DOCUMENT_IS_IE4 ? "className" : "class";
	var div_cart_inside = document.getElementById("cart_inside");

	var div_cart_area = document.getElementById("cart_area");
		//合計金額
		var div_cart_total_price = document.createElement("div");
			div_cart_total_price.id = "cart_total_price";
			div_cart_total_price.setAttribute(attr_of_class, "cart_total_price");
			div_cart_total_price.appendChild( document.createTextNode("合計　￥") );

			var span_total_price =  document.createElement("span");
				span_total_price.id = "total_price";
				span_total_price.appendChild( document.createTextNode(TotalPrice.number_format()) );

			div_cart_total_price.appendChild(span_total_price);
	div_cart_area.appendChild(div_cart_total_price);

		//ボタン
		var div_register_button_top = document.createElement("input");
			div_register_button_top.id = "register_button_top";
			div_register_button_top.type = "image";
			div_register_button_top.name = "operate";
			div_register_button_top.src = "/img/cart_buy_all.gif";
			div_register_button_top.value = "account_cart";
			div_register_button_top.alt = "会計する";
	div_cart_area.appendChild(div_register_button_top);
}


//●合計金額出力の更新
function UpdateTotalPriceElement(){
	//合計金額の更新
	TotalPrice = 0;
	for(var CartItem in objCart){
		TotalPrice += objCart[CartItem].price * objCart[CartItem].num;
	}

	var span_total_price = document.getElementById("total_price");
	if( span_total_price ){
		span_total_price.innerHTML = TotalPrice.number_format();
	}
}

























////////////////////////////////////////////////////////////////////////////////
//■carendar関連
//●クラス定義
function ds_calendar(index){ this.initialize(index); }
ds_calendar.prototype = {
	//■コンストラクタ
	initialize: function(index){
		this.id_index = index;

		this.date = new Date();
			this.today_year = this.date.getYear();
			if(this.today_year < 1900){ this.today_year += 1900 }	//クロスブラウザのための補正
			this.today_month = this.date.getMonth() + 1;
			this.today_date = this.date.getDate();
			this.current_year = this.today_year;
			this.current_month = this.today_month;
			this.current_date = this.today_date;

		this.ClickIdOffset = 0;
		this.ClickIdLimit = 0;
	}

	,SetPathInfoPropaty: function(type, year, month, date, genre, keyword){
		this.query_type = type;
		this.query_year = year;
		this.query_month = month;
		this.query_date = date;
		this.query_genre = genre;
		this.query_keyword = keyword;
	}

	//■指定年月日を設定
	//  ※月は 1～12 で指定
	,SetCurrentDate: function(year, month, date){
		//setYear、 setMonth、 setDate、 setHours、 setMinutes、 setSeconds
		this.current_year = year;
		this.current_month = month;
		this.current_date = date;

		this.date.setYear(this.current_year);
		this.date.setMonth(this.current_month - 1);
		this.date.setDate(this.current_date);
	}

	//■設定年月日を取得
	,GetCurrentYear: function(){ return this.current_year; }
	,GetCurrentMonth: function(){ return this.current_month; }
	,GetCurrentDate: function(){ return this.current_date; }


	//■カレンダー出力
	,RefrechCalendar: function(){
		//●現時点の年月日をキャッシュする
	//	var year_cache = this.date.getYear() + 1900;
	//	if(year_cache < 1900){ year_cache += 1900 }
		var month_cache = this.date.getMonth();
		var date_cache = this.date.getDate();


		//●月と年を出力
		var ele = document.getElementsByName( "calendar_month_year" );
		ele[0].innerHTML = this.current_year.toString(10) + " " + (month_cache+1).toString(10);


		//●日付の表を出力
		this.date.setDate(1);
		this.ClickIdOffset = this.date.getDay();
		this.ClickIdLimit = 0;
		var index_start = this.ClickIdOffset + 1; // 月の1日の曜日から document を取得開始
		var index_id = "";
		var date = 0;
		var index_classname = "day_seq";
		var day_of_the_week = 0;

		if( (this.today_year == this.current_year) && (this.today_month == this.current_month) ){
			var today_flag = true;
		}else{
			var today_flag = false;
		}

		var day_seq = document.getElementsByName("day_seq")
		var day_seq_length = day_seq.length;
		for(var index_count = 1; index_count <= day_seq_length; index_count++){
			if( (index_count >= index_start) && this.date.getMonth() == month_cache ){
				date = this.date.getDate();
				day_of_the_week = this.date.getDay();
				day_seq[index_count - 1].innerHTML = date.toString(10);

				if( today_flag && (date == this.current_date) ){
					day_seq[index_count - 1].className += " today";
				}

				this.ClickIdLimit = index_count;
				this.date.setDate(date + 1);
			}else{
				day_seq[index_count - 1].innerHTML = "・";
			}
		}
	}


	//■カレンダー表示年月を変更
	,ClickMoveMonth: function(offset){
		//日付チェック用のタイムスタンプを取得
		//  ※ 2004/12 以降、検索日の翌月まで
		var begin_stamp = (new Date(2004, 11, 1)).getTime();

		var next_month = new Date();
		var month_tmp = next_month.getMonth();
		next_month.setMonth( month_tmp + 2 );
		next_month.setDate( 1 );
		var end_stamp = next_month.getTime();

		//日付移動
		var move_month = this.current_month + offset;
		var move_year = this.current_year;
		if( move_month <= 0 ){
			move_month += 12;
			move_year -= 1;
		}
		if( move_month > 12 ){
			move_month -= 12;
			move_year += 1;
		}
		this.SetCurrentDate(move_year, move_month, this.current_date);
		var move_stamp = this.date.getTime();

		//日付チェックと補正
		if( move_stamp < begin_stamp ){
			this.SetCurrentDate(2004, 12, 2);
		}else if(move_stamp > end_stamp){
			this.SetCurrentDate(this.today_year, this.today_month + 1, this.today_date);
		}

		this.RefrechCalendar();
	}




	//■ページ切り替え
	,ClickMovePage: function(page){
		switch(this.query_type){
			case "b":
				document.search_query.action = "/shop/nds/b/"
													+ page.toString(10) + "/"
													+ this.query_genre + "/"
													+ this.query_keyword;
				var result = true;
				break;

			case "d":
				document.search_query.action = "/shop/nds/d/"
													+ this.query_year + "/"
													+ this.query_month + "/"
													+ this.query_date + "/"
													+ page.toString(10) + "/"
													+ this.query_genre + "/"
													+ this.query_keyword;
				var result = true;
				break;

			default:
				var result = false;
				break;
		}
		return result;
	}

	//■全ソフト検索ボタンの押下
	,ClickButton: function(page){
		var keyword = document.search_query.keyword.value;
		var filter_ele = document.search_query.elements["inc"];
		var filter_bit_field = 0;
		for(var index = 0; index < filter_ele.length; index++){
			if( filter_ele[index].checked ){
				filter_bit_field |= parseInt(filter_ele[index].value.substr(2, 8), 16);
			}
		}
		document.search_query.action = "/shop/nds/b/"
											+ page.toString(10) + "/"
											+ filter_bit_field.toString_unsign(16) + "/"
											+ keyword;
		return true;
	}

	//■カレンダー表示月変更の押下
	,ClickMonth: function(page){
		var keyword = document.search_query.keyword.value;
		var filter_ele = document.search_query.elements["inc"];
		var filter_bit_field = 0;
		for(var index = 0; index < filter_ele.length; index++){
			if( filter_ele[index].checked ){
				filter_bit_field |= parseInt(filter_ele[index].value.substr(2, 8), 16);
			}
		}

		document.search_query.action = "/shop/nds/d/"
											+ this.GetCurrentYear().toString(10) + "/"
											+ this.GetCurrentMonth().toString(10) + "/"
											+ this.GetCurrentDate().toString(10) + "/"
											+ page.toString(10) + "/"
											+ filter_bit_field.toString_unsign(16) + "/"
											+ keyword;
		return true;
	}

	//■カレンダー日付の押下
	,ClickDate: function(id_number, page){
		var target_date = id_number - this.ClickIdOffset;
		if( (target_date < 1) || (target_date >= this.ClickIdLimit)){
			return false;
		}
		this.SetCurrentDate(this.current_year, this.current_month, target_date);

		var keyword = document.search_query.keyword.value;
		var filter_ele = document.search_query.elements["inc"];
		var filter_bit_field = 0;
		for(var index = 0; index < filter_ele.length; index++){
			if( filter_ele[index].checked ){
				filter_bit_field |= parseInt(filter_ele[index].value.substr(2, 8), 16);
			}
		}

		document.search_query.action = "/shop/nds/d/"
											+ this.GetCurrentYear().toString(10) + "/"
											+ this.GetCurrentMonth().toString(10) + "/"
											+ this.GetCurrentDate().toString(10) + "/"
											+ page.toString(10) + "/"
											+ filter_bit_field.toString_unsign(16) + "/"
											+ keyword;
		return true;
	}

	//■閏年判定
	,CheckLeapYear: function(year){
		// 1. 西暦年が4で割り切れる年は閏年
		// 2. ただし、西暦年が100で割り切れる年は平年
		// 3. ただし、西暦年が400で割り切れる年は閏年
			var date_tmp = new Date(year, 2, 0);
			var date = this.date_tmp.getDate();
			if(date == 29){ return true; }
			else{           return false; }
	}

}

