//
//http通信を行う関数
//
function GetItemStock(){
	var	odrno	=	document.getElementById("order").value;
	var	lurl	=	"/getitemstock_ecv/"+odrno+"/";
	xotree2 = new XML.ObjTree();
	httpObjects = xotree2.parseHTTP(lurl, {method:'get'}, stock_display);
	return false;
}
//表示関数
function stock_display(tree,httpObject){
}


//
// 商品がセレクトボックスで選択された場合在庫表示と
// 選択可能個数を修正する。
//
function setOrderNo(){
	var amount = document.getElementById("amount").value;
	var size   = document.getElementById("size").value;
	var taste  = document.getElementById("taste").value;
	var kind   = document.getElementById("kind").value;
	var color  = document.getElementById("color").value;
	
	var curindex	=	""+color+size+taste+kind+amount;

	// 連想配列と同じキーなら注文番号が存在する
	document.getElementById("order").value = "";
	var count		=	0;
	var oderno_local	=	"";
	for(var key in orderno_list){
		if(key == curindex){
			oderno_local	=	orderno_list[curindex];
			document.getElementById("order").value = oderno_local;
			
			obj = document.getElementById("main_image");
			if(obj){
				obj.src = orderno_list[curindex+"_img1"];
				obj.alt = orderno_list[curindex+"_alt1"];
			}
			obj = document.getElementById("main_image_see");
			if(obj){
				obj.href = orderno_list[curindex+"_img1"];
			}
			obj = document.getElementById("main_image_txt");
			if(obj){
				obj.href = orderno_list[curindex+"_img1"];
			}
			obj = document.getElementById("main_image_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img1"];
			}
			
			// for themnail images
			obj = document.getElementById("them_image1");
			if(obj){
				obj.src = orderno_list[curindex+"_img1"];
				obj.alt = orderno_list[curindex+"_alt1"];
			}
			obj = document.getElementById("them_image1_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img1"];
			}
			
			obj = document.getElementById("them_image2");
			if(obj){
				obj.src = orderno_list[curindex+"_img2"];
				obj.alt = orderno_list[curindex+"_alt2"];
			}
			obj = document.getElementById("them_image2_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img2"];
			}
			
			obj = document.getElementById("them_image3");
			if(obj){
				obj.src = orderno_list[curindex+"_img3"];
				obj.alt = orderno_list[curindex+"_alt3"];
			}
			obj = document.getElementById("them_image3_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img3"];
			}
			
			obj = document.getElementById("them_image4");
			if(obj){
				obj.src = orderno_list[curindex+"_img4"];
				obj.alt = orderno_list[curindex+"_alt4"];
			}
			obj = document.getElementById("them_image4_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img4"];
			}
			
			obj = document.getElementById("them_image5");
			if(obj){
				obj.src = orderno_list[curindex+"_img5"];
				obj.alt = orderno_list[curindex+"_alt5"];
			}
			obj = document.getElementById("them_image5_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img5"];
			}
			
			obj = document.getElementById("them_image6");
			if(obj){
				obj.src = orderno_list[curindex+"_img6"];
				obj.alt = orderno_list[curindex+"_alt6"];
			}
			obj = document.getElementById("them_image6_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img6"];
			}
			
			obj = document.getElementById("them_image7");
			if(obj){
				obj.src = orderno_list[curindex+"_img7"];
				obj.alt = orderno_list[curindex+"_alt7"];
			}
			obj = document.getElementById("them_image7_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img7"];
			}
			
			obj = document.getElementById("them_image8");
			if(obj){
				obj.src = orderno_list[curindex+"_img8"];
				obj.alt = orderno_list[curindex+"_alt8"];
			}
			obj = document.getElementById("them_image8_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img8"];
			}
			
			obj = document.getElementById("them_image9");
			if(obj){
				obj.src = orderno_list[curindex+"_img9"];
				obj.alt = orderno_list[curindex+"_alt9"];
			}
			obj = document.getElementById("them_image9_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img9"];
			}
			
			obj = document.getElementById("them_image10");
			if(obj){
				obj.src = orderno_list[curindex+"_img10"];
				obj.alt = orderno_list[curindex+"_alt10"];
			}
			obj = document.getElementById("them_image10_rel");
			if(obj){
				obj.href = orderno_list[curindex+"_img10"];
			}
			break;
		}
	}
	var disp	=	orderstock_list[oderno_local];
	stock_obj = document.getElementById("stock");
	if(stock_obj){
		if(disp == undefined){
			stock_obj.innerHTML = "：×";
		} else {
			stock_obj.innerHTML = "："+disp;
		}
	}

	if( order_disp_pulldown == "1" ) {
		// 商品個数のプルダウンも最大個数に変更
		var maxnum	=	ordermax_list[oderno_local];
		var select1	=	document.getElementById('unit');
		if( select1 != null ) {
			select1.options.length	=	0;
			var i		=	0;
			if( maxnum == 0 || disp == undefined ){
				maxnum = 0;
				if( document.getElementById("buy") != null ){
					document.getElementById("buy").src = '/bc/images/shop/disable_cart.gif';
					document.getElementById("buy").disabled = true;
				}
				for(i=0; i<= maxnum; i++){
					select1.options[i]  	=	new Option(i+"　",i);
				}
			} else {
				if( document.getElementById("buy") != null ){
					document.getElementById("buy").disabled = false;
					if( reserve_flg == "1" ){ 
						document.getElementById("buy").src = '/bc/images/shop/reserve_item.gif';
					} else {
						document.getElementById("buy").src = '/bc/images/shop/button02.gif';
					}
				}
				for(i=1; i<= maxnum; i++){
					select1.options[i-1]  	=	new Option(i+"　",i);
				}
			}
		}
	} else {
		var maxnum	=	ordermax_list[oderno_local];
		if( document.getElementById("buy") != null ){
			if( maxnum == 0 || disp == undefined ){
				document.getElementById("buy").src = '/bc/images/shop/disable_cart.gif';
				document.getElementById("buy").disabled = true;
			} else {
				if( reserve_flg == "1" ){ 
					document.getElementById("buy").src = '/bc/images/shop/reserve_item.gif';
				} else {
					document.getElementById("buy").src = '/bc/images/shop/button02.gif';
				}
				document.getElementById("buy").disabled = false;
			}
		}
	}
}


function about_wrapping() {
	var Win   = navigator.userAgent.indexOf('Win')     != -1;
	var Mac   = navigator.userAgent.indexOf('Mac')     != -1;
	var X11   = navigator.userAgent.indexOf('X11')     != -1;
	var Moz   = navigator.userAgent.indexOf('Gecko')   != -1;
	var Fir   = navigator.userAgent.indexOf('Firefox') != -1;
	var Opera = !!window.opera;

	var parent;
	var popup;
	var popup_flg = 0;
	var color;
	var today;
	var base_year;
	var base_month;
	var base_day;

	var option;

	// ウィンドウサイズ設定
	var width  = 600;
	var height = 500;

	// calendar用OS別サイズ微調整
	if (Fir) {
		width  += 60;
		height += 65;
	}
	else if (Moz) {
		width  += 25;
		height += 30;
	}
	else if (Mac) {
		width  += 8;
		height += 22;
	}
	else if (X11) {
		width  += 5;
		height += 65;
	}
	else if (Opera) {
		width  += 5;
		height += 65;
	}

	// 表示位置設定
	var pos_x = 100;
	var pos_y = 20;

	// 表示位置調整
	if (document.all) {
		pos_x = window.event.screenX + 30;
		pos_y = window.event.screenY - 100;
    } else if (document.layers || document.getElementById) {
		pos_x += window.screenX;
		pos_y += window.screenY;
    }
	option  = "left="         + pos_x;
	option += ",screenX="     + pos_x;
	option += ",top="         + pos_y;
	option += ",screenY="     + pos_y;
	option += ",innerWidth="  + width;
	option += ",width="       + width;
	option += ",innerHeight=" + height;
	option += ",height="      + height;
	option += ",toolbar=0";
	option += ",location=0";
	option += ",directories=0";
	option += ",status=0";
	option += ",menubar=0";
	option += ",scrollbars=1";
	option += ",resizable=1";

	return window.open('/bc/images/shopping/wrapping_sample.jpg', 'wrapping', option);	
}
