document.write('<sc'+'ript src="/scripts/jsr_class.js"></sc'+'ript>');
var popupStyle = [
	'width=650',
	'height=600',
	'status=no',
	'scrollbars=yes',
	'directories=no',
	'menubar=no',
	'resizable=yes',
	'toolbar=no',
	].join(',');

function showItem(itemId){
	var path = location.pathname;
	var tokens = path.split('/');
	var win = window.open('/' + tokens[1] + '/ItemPopup.htm?itemId=' + itemId, 'popup',popupStyle);
	win.focus();
}

var popupStyle2 = [
	'width=800',
	'height=600',
	'status=no',
	'scrollbars=yes',
	'directories=no',
	'menubar=no',
	'resizable=yes',
	'toolbar=no',
	].join(',');

function openWindow(url, name){
	var win = window.open(url, name, popupStyle2);
	win.focus();
}

function intoCart4(itemNo, count, uri){
	var path = location.pathname;
	var tokens = path.split('/');
	count = count || 1;
	uri = uri || '';

	location.href = '/' + tokens[1] + '/Cart.htm?item=' + itemNo + '&count=' + count + '&uri=' + encodeURIComponent(uri);
}

function intoCartSkincare(itemNo, count, uri, catalogId){
	count = count || 1;
	uri = uri || '';
	if(catalogId){
		location.href = '/skincare/Cart.htm?item=' + itemNo + '&count=' + count + '&catalogId=' + catalogId + '&uri=' + encodeURIComponent('/skincare/CartList.htm');
	} else {
		location.href = '/skincare/Cart.htm?item=' + itemNo + '&count=' + count + '&uri=' + encodeURIComponent('/skincare/CartList.htm');
	}
}

function intoCart(itemNo, count){
	var form = document.cart;
	form.item.value = itemNo;
	form.count.value = count || 1;
	form.uri.value = location.protocol + "//" + location.host + "/life/CartList.htm";
	form.submit();
}

function intoCart2(itemNo){
	var form = document["item_" + itemNo];
	intoCart(itemNo, form.count.value);
}

function intoCartSkincare2(itemNo){
	var form = document["item_" + itemNo];
	var count;
	var form2 = document.cart;
	var catalogId;
	var uri;

	if(form.count.value){
		count = form.count.value;
	}else{
		count = form.count[form.count.selectedIndex].text;
	}
	
	if(form2.catalogId.value){
		catalogId = form2.catalogId.value;
	}
	if(form2.uri.value){
		uri = form2.uri.value;
	}

	intoCartSkincare(itemNo, count, uri, catalogId);
}

function intoCart3(itemNo){
	var form = document["item_" + itemNo];
	intoCart(form.options[form.options.selectedIndex].value, form.count.value);
}

function intoCart_Teiki(itemNo){
	var form = document["item_" + itemNo];
	checkedId = 0;
	for(var i = 0; i < form.options.length; i++){
		if(form.options[i].checked == true){
			checkedId = i;
		}
	}
	intoCart(form.options[checkedId].value, form.count.value);
}

function deleteItem(itemNo){
	var form = document.cartList;
	flag = false;
	form.deleteItemNo.value = itemNo;
	form.submit();
}

function windowOnLoad(){
	for(var i = 0; i < document.forms.length; i++){
		document.forms[i].__flag = true;
		document.forms[i].onsubmit = function(){
			if(this.__flag){
				this.__flag = false;
				return true;
			}
			
			return false;
		};
	}
};

var addressFlg = 0;

var oJsr;

function getAddress(obj, flg){
	addressFlg = flg;
  	if(obj){
		value = obj.value;
		Zip = value.replace('-', '');
		if( !isNaN(Zip) ){
	
			if(Zip.length == 7){
				var dir  = Zip.substr(0,1);
				var file = Zip.substr(1,4);
				var key  = Zip.substr(5,2);
				try{
					oJsr = new JSONscriptRequest("/zip/" + dir + "/" + file + ".json?callback=loadZip");
					oJsr.buildScriptTag();
					oJsr.addScriptTag();
				}
				catch(e){
					alert(e  + "指定された郵便番号に該当するデータは存在しません。 ");
				}
			}
		} else {
			alert("指定された郵便番号に該当するデータは存在しません。 ");
		}
	}
}

function loadZip(data){
	if(addressFlg == 1){
		value = document.getElementById("zip").value;
	} else {
		value = document.getElementById("officeZip").value;
	}
	Zip = value.replace('-', '');
	if( !isNaN(Zip) ){
		if(Zip.length == 7){
			var key  = Zip.substr(5,2);
			try{
				var pref;
				var address1;
				var address2;
				if(addressFlg == 1){
					pref = document.getElementById('prefecture');
					address1 = document.getElementById('address1');
					address2 = document.getElementById('address2');
				} else {
					pref = document.getElementById('officePrefecture');
					address1 = document.getElementById('officeAddress1');
					address2 = document.getElementById('officeAddress2');
				}
					
				for(var i = 0; i < pref.options.length; i++){
					if(pref.options[i].value == data[key][0]){
						pref.options[i].selected = true;
						break;
					}
				}
				address1.value = data[key][1];
				address2.value = data[key][2];
				if(oJsr){
					oJsr.removeScriptTag();
				}
			}
			catch(e){
//				alert("指定された郵便番号に該当するデータは存在しません。 ");
			}
		}
	} else {
//		alert("指定された郵便番号に該当するデータは存在しません。 ");
	}
}