/*
* E&Y Collection
* Require:
*  jquery.js
*
**************************************/

var currentData;
var orderData;
var sendStatus;

// init
$(document).ready(function(){
	$("ul.categoryIndex img").click(getData);
});


// function getData (for COLLECTION)
function getData(){
	$.getJSON(entryUrl[$("ul.categoryIndex img").index(this)], null, showPanel);
}

// function showPanel (for COLLECTION)
function showPanel(data){
	currentData = data;
	
	for (i=1; i<=data.imageNum; i++) {
		var mainImg = new Image();
		mainImg.src = "/collection/img/col_img_" + data.id + "_0" + i + ".jpg";
	}
	
	var panel = document.createElement("div");
	panel.id = "collectionPanel";

	var title = document.createElement("h2");
	var titleImg = document.createElement("img");
	titleImg.src = "/collection/img/col_ttl_" + data.id + ".gif";
	titleImg.alt = data.title + ", " + data.designer + ", " + data.year;
	title.appendChild(titleImg);
	
	var mainImagePanel = document.createElement("div");
	mainImagePanel.className = "mainImage";
	var mainImage = document.createElement("img");
	mainImage.src = "/collection/img/col_img_" + data.id + "_01.jpg";
	mainImage.alt = "";
	mainImage.width = "950";
	mainImage.height = "470";
	mainImagePanel.appendChild(mainImage);
	
	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "closeBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);
	var funcListElement2 = document.createElement("li");
	var descImage = document.createElement("img");
	descImage.id = "descriptionBtn"
	descImage.className = "hover";
	descImage.src = "/shared/img/btn_description_01.gif";
	descImage.width = "73";
	descImage.height = "10";
	descImage.alt = "Description";
	funcListElement2.appendChild(descImage);
	funcList.appendChild(funcListElement2);
	var funcListElement3 = document.createElement("li");
	var downloadImage = document.createElement("img");
	downloadImage.id = "downloadBtn";
	downloadImage.className = "hover";
	downloadImage.src = "/shared/img/btn_download_01.gif";
	downloadImage.width = "64";
	downloadImage.height = "10";
	downloadImage.alt = "Download";
	funcListElement3.appendChild(downloadImage);
	funcList.appendChild(funcListElement3);
	
	$.getJSON("/collection/order/order" + currentData.id + ".js", null, function(){
		var funcListElement4 = document.createElement("li");
		var orderImage = document.createElement("img");
		orderImage.id = "orderBtn";
		orderImage.className = "hover";
		orderImage.src = "/shared/img/btn_order_01.gif";
		orderImage.width = "37";
		orderImage.height = "10";
		orderImage.alt = "Order";
		funcListElement4.appendChild(orderImage);
		funcList.appendChild(funcListElement4);
		$("img#orderBtn").click(getOrderData);
		$.lm.hover.init();
	});
	
	var thumbList = document.createElement("ul");
	thumbList.className = "thumbUL";
	for (i=1; i<=data.imageNum; i++) {
		var thumbListElement = document.createElement("li");
		var thumbImage = document.createElement("img");
		thumbImage.className = "hover";
		if (i==1) {
			thumbImage.className = "stay";
		}
		thumbImage.src = "/collection/img/col_btn_" + data.id + "_0" + i + ".gif";
		thumbImage.width = "30";
		thumbImage.height = "20";
		thumbListElement.appendChild(thumbImage);
		thumbList.appendChild(thumbListElement);
	}
	panel.appendChild(title);
	panel.appendChild(mainImagePanel);
	panel.appendChild(funcList);
	panel.appendChild(thumbList);
	$("div#body").append(panel);
	$("div#collectionPanel").show("slow");
	$("img#closeBtn").click(hidePanel);
	$("img#descriptionBtn").click(showDescPanel);
	$("img#downloadBtn").click(showDlPanel);
	$("ul.thumbUL img.hover").click(changeImage);
	$.lm.hover.init();
}

// function hidePanel (for COLLECTION)
function hidePanel(){
	$("div#collectionPanel").hide("slow", function(){
		$("div#collectionPanel").remove();
	});
}

// function showDescPanel (for COLLECTION)
function showDescPanel(){
	for (i=1; i<=currentData.descNum; i++) {
		var mainImg = new Image();
		mainImg.src = "/collection/img/col_des_" + currentData.id + "_0" + i + ".jpg";
	}
	
	var panel = document.createElement("div");
	panel.id = "descriptionPanel";

	var mainImagePanel = document.createElement("div");
	mainImagePanel.className = "mainDescImage";
	var mainImage = document.createElement("img");
	mainImage.src = "/collection/img/col_des_" + currentData.id + "_01.jpg";
	mainImage.alt = "";
	mainImage.width = "950";
	mainImage.height = "470";
	mainImagePanel.appendChild(mainImage);
	
	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "descCloseBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);

	var thumbList = document.createElement("ul");
	thumbList.className = "descThumbUL";
	for (i=1; i<=currentData.descNum; i++) {
		var thumbListElement = document.createElement("li");
		var thumbImage = document.createElement("img");
		thumbImage.className = "hover";
		if (i==1) {
			thumbImage.className = "stay";
		}
		thumbImage.src = "/collection/img/col_des_btn_" + currentData.id + "_0" + i + ".gif";
		thumbImage.width = "30";
		thumbImage.height = "20";
		thumbListElement.appendChild(thumbImage);
		thumbList.appendChild(thumbListElement);
	}

	panel.appendChild(mainImagePanel);
	panel.appendChild(funcList);
	panel.appendChild(thumbList);
	$("div#body").append(panel);
	$("div#descriptionPanel").show("slow");
	$("img#descCloseBtn").click(hideDescPanel);
	$("ul.descThumbUL img.hover").click(descChangeImage);
	$.lm.hover.init();
}

// function hideDescPanel (for COLLECTION)
function hideDescPanel(){
	$("div#descriptionPanel").hide("slow", function(){
		$("div#descriptionPanel").remove();
	});
}

// function descChangeImage (for COLLECTION)
function descChangeImage(evt) {
	var fileName = $(this).attr("src").replace("_btn", "");
	fileName = fileName.replace("_o", "");
	fileName = fileName.replace(".gif", ".jpg");
	$("div.mainDescImage").fadeOut("slow", function(){
		$("div.mainDescImage img").attr("src", fileName);
		$("div.mainDescImage").fadeIn("slow");
	});
	$("ul.descThumbUL img").removeClass("stay");
	$("ul.descThumbUL img").addClass("hover");
	$(this).removeClass("hover");
	$(this).addClass("stay");
	$(this)	
		.unbind('mouseover')
		.unbind('mouseout')
		.unbind('focus')
		.unbind('blur')
		.unbind('click');
	$(this).attr("src", $(this).attr("src").replace("_o", ""));
	$("ul.descThumbUL img.hover").click(descChangeImage);
	$.lm.hover.init();
}

// function showDlPanel (for COLLECTION)
function showDlPanel(){
	var panel = document.createElement("div");
	panel.id = "downloadPanel";

	var mainPanel = document.createElement("div");
	mainPanel.id = "mainPanel";
	var mainImagePanel = document.createElement("div");
	mainImagePanel.className = "mainDlImage";
	var mainImage = document.createElement("img");
	mainImage.src = "/collection/img/col_dld_" + currentData.id + ".jpg";
	mainImage.alt = "";
	mainImagePanel.appendChild(mainImage);
	mainPanel.appendChild(mainImage);
	
	var dlLinkPanel = document.createElement("div");
	dlLinkPanel.id = "linkPanel";
	var dlLinkElem = document.createElement("a");
	dlLinkElem.href = "/collection/zip/" + currentData.zip;
	var dlLinkImage = document.createElement("img");
	dlLinkImage.src = "/collection/img/col_dld_txt_" + currentData.id + ".gif";
	dlLinkImage.className = "hover";
	dlLinkImage.alt = currentData.zip;
	dlLinkElem.appendChild(dlLinkImage);
	dlLinkPanel.appendChild(dlLinkElem);
	mainPanel.appendChild(dlLinkPanel);
	
	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "dlCloseBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);

	panel.appendChild(mainPanel);
	panel.appendChild(funcList);
	$("div#body").append(panel);
	$("div#downloadPanel").show("slow");
	$("img#dlCloseBtn").click(hideDlPanel);
	$.lm.hover.init();
}

// function hideDlPanel (for COLLECTION)
function hideDlPanel(){
	$("div#downloadPanel").hide("slow", function(){
		$("div#downloadPanel").remove();
	});
}

// function getOrderData (for COLLECTION)
function getOrderData(){
	$.getJSON("/collection/order/order" + currentData.id + ".js", null, showOrderPanel);
}

// function showOrderPanel (for COLLECTION)
function showOrderPanel(data){
	orderData = data;
	
	var panel = document.createElement("div");
	panel.id = "orderPanel";

	var innerPanel = document.createElement("div");
	innerPanel.id = "innerPanel";
	
	var textImagePanel = document.createElement("div");
	textImagePanel.className = "orderText";
	var textImage = document.createElement("img");
	textImage.src = "/collection/img/order/col_ord_txt_" + currentData.id + ".gif";
	textImage.alt = orderData.text;
	textImagePanel.appendChild(textImage);
	innerPanel.appendChild(textImagePanel);

	var selectPanel = document.createElement("div");
	selectPanel.className = "orderBlock";
	var itemID = 1;
	for (i in orderData.items){
		var selectItem = document.createElement("div");
		selectItem.className = "orderItem";
		var itemThumb = document.createElement("div");
		itemThumb.className = "thumb";
		var itemThumbImage = document.createElement("img");
		var itemThumbNum = itemID > 9 ? itemID : "0" + itemID;
		itemThumbImage.src = "/collection/img/order/col_ord_img_" + currentData.id + "_" + itemThumbNum + ".gif";
		itemThumbImage.alt = orderData.items[i].name;
		itemThumb.appendChild(itemThumbImage);
		selectItem.appendChild(itemThumb);
		
		var checkList = document.createElement("ul");
		checkList.className = "checkList";
		checkList.id = i;
		var listID = 1;
		for (j in orderData.items[i].subitems) {
			var listItem = document.createElement("li");
			var listImage = document.createElement("img");
			listImage.id = j;
			var listNum = listID > 9 ? listID : "0" + listID;
			listImage.src = "/collection/img/order/col_ord_che_" + currentData.id + "_" + itemThumbNum + "_" + listNum + ".gif";
			listImage.className = "clickable";
			listImage.alt = orderData.items[i].subitems[j].name + ":&yen;" + orderData.items[i].subitems[j].price + "(In tax)";
			listItem.appendChild(listImage);
			checkList.appendChild(listItem);
			listID++;
		}
		selectItem.appendChild(checkList);
		selectPanel.appendChild(selectItem);
		itemID++;
	}
	innerPanel.appendChild(selectPanel);
	
	var fabricBlock = document.createElement("div");
	fabricBlock.className = "fabricBlock";
	if(orderData.fabric){
		var fabricTitle = document.createElement("div");
		fabricTitle.className = "fabricTitle";
		var fabricTitleImage = document.createElement("img");
		fabricTitleImage.src = "/shared/img/order_text_01.gif";
		fabricTitleImage.alt = "FABRIC SAMPLE";
		fabricTitle.appendChild(fabricTitleImage);
		fabricBlock.appendChild(fabricTitle);
		var fabricList = document.createElement("ul");
		for(k in orderData.fabric){
			var fabricListElem = document.createElement("li");
			var fabricImage = document.createElement("img");
			switch(orderData.fabric[k]){
				case 1:
					fabricImage.src = "/shared/img/btn_fabric_01.gif";
					fabricImage.id = "fabric1";
					fabricImage.alt = "A TYPE-NS";
					break;
				case 2:
					fabricImage.src = "/shared/img/btn_fabric_02.gif";
					fabricImage.id = "fabric2";
					fabricImage.alt = "A TYPE-SU";
					break;
				case 3:
					fabricImage.src = "/shared/img/btn_fabric_03.gif";
					fabricImage.id = "fabric3";
					fabricImage.alt = "VINYL LEATHER A TYPE-LG";
					break;
				case 4:
					fabricImage.src = "/shared/img/btn_fabric_04.gif";
					fabricImage.id = "fabric4";
					fabricImage.alt = "B TYPE-CL";
					break;
				case 5:
					fabricImage.src = "/shared/img/btn_fabric_05.gif";
					fabricImage.id = "fabric5";
					fabricImage.alt = "B TYPE-FK";
					break;
				case 6:
					fabricImage.src = "/shared/img/btn_fabric_06.gif";
					fabricImage.id = "fabric6";
					fabricImage.alt = "C TYPE-EC";
					break;
				case 7:
					fabricImage.src = "/shared/img/btn_fabric_07.gif";
					fabricImage.id = "fabric7";
					fabricImage.alt = "D TYPE-NV";
					break;
				case 8:
					fabricImage.src = "/shared/img/btn_fabric_08.gif";
					fabricImage.id = "fabric8";
					fabricImage.alt = "D TYPE-EP";
					break;
			}
			fabricImage.className = "fabricBtn";
			fabricImage.className = "hover";
			fabricListElem.appendChild(fabricImage);
			fabricList.appendChild(fabricListElem);
		}
		fabricBlock.appendChild(fabricList);
	}
	innerPanel.appendChild(fabricBlock);
	
	var attentionBlock = document.createElement("div");
	attentionBlock.className = "attentionBlock";
	var attentionCol1 = document.createElement("div");
	attentionCol1.className = "col1";
	var attentionTitle = document.createElement("div");
	attentionTitle.className = "attentionTitle";
	var attentionTitleImage = document.createElement("img");
	attentionTitleImage.src = "/shared/img/order_text_02.gif";
	attentionTitleImage.alt = "ATTENTION";
	attentionTitle.appendChild(attentionTitleImage);
	attentionCol1.appendChild(attentionTitle);
	if(orderData.attention){
		var attention = document.createElement("div");
		attention.className = "attentionText";
		attentionImage = document.createElement("img");
		attentionImage.src = "/collection/img/order/col_ord_att_" + currentData.id + ".gif";
		attentionImage.alt = orderData.attention;
		attention.appendChild(attentionImage);
		attentionCol1.appendChild(attention);
	}
	attentionBlock.appendChild(attentionCol1);
	var attentionCol2 = document.createElement("div");
	attentionCol2.className = "col2";
	var nextImage = document.createElement("img");
	nextImage.src = "/collection/img/order/btn_next_01.gif";
	nextImage.className = "hover";
	nextImage.id = "showOrderSum";
	attentionCol2.appendChild(nextImage);
	attentionBlock.appendChild(attentionCol2);
	innerPanel.appendChild(attentionBlock);
	panel.appendChild(innerPanel);
	
	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "orderCloseBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);
	var funcListElement2 = document.createElement("li");
	var descImage = document.createElement("img");
	descImage.id = "descriptionBtn2"
	descImage.className = "hover";
	descImage.src = "/shared/img/btn_description_01.gif";
	descImage.width = "73";
	descImage.height = "10";
	descImage.alt = "Description";
	funcListElement2.appendChild(descImage);
	funcList.appendChild(funcListElement2);
	var funcListElement3 = document.createElement("li");
	var csImage = document.createElement("img");
	csImage.id = "csBtn";
	csImage.className = "hover";
	csImage.src = "/shared/img/btn_cs_01.gif";
	csImage.width = "110";
	csImage.height = "10";
	csImage.alt = "Customer Service";
	funcListElement3.appendChild(csImage);
	funcList.appendChild(funcListElement3);
	panel.appendChild(funcList);

	var funcList2 = document.createElement("ul");
	funcList2.className = "funcUL2";
	var funcList2Element1 = document.createElement("li");
	var lawImage = document.createElement("img");
	lawImage.id = "lawBtn";
	lawImage.className = "hover";
	lawImage.src = "/shared/img/btn_law_01.gif";
	lawImage.width = "44";
	lawImage.height = "10";
	lawImage.alt = "通販法規";
	funcList2Element1.appendChild(lawImage);
	funcList2.appendChild(funcList2Element1);
	panel.appendChild(funcList2);

	$("div#body").append(panel);
	$("div.orderItem").addClassFLtoDiv(4);
	$("ul.checkList li img").click(checkItem);
	$("img#orderCloseBtn").click(hideOrderPanel);
	$("img#descriptionBtn2").click(showDescPanel);
	$("img#csBtn").click(showCSPanel);
	$("img#lawBtn").click(showLawPanel);
	$("div.fabricBlock ul li img").click(showFabric);
	$("img#showOrderSum").click(showOrderSum);
	$("div#orderPanel").show("slow");
	$.lm.hover.init();
}

function checkItem(evt){
	if(evt.target.src.indexOf("_c.gif") > 0){
		orderData.items[evt.target.parentNode.parentNode.id].subitems[evt.target.id].num = 0;
		evt.target.src = evt.target.src.replace(/^(.+)_c(\.[a-z]+)$/, "$1$2");
	} else {
		orderData.items[evt.target.parentNode.parentNode.id].subitems[evt.target.id].num = 1;
		evt.target.src = evt.target.src.replace(/^(.+)(\.[a-z]+)$/, "$1_c$2");
	}
}

// function hideOrderPanel (for COLLECTION)
function hideOrderPanel(){
	$("div#orderPanel").hide("slow", function(){
		$("div#orderPanel").remove();
	});
}

// function showCSPanel (for COLLECTION)
function showCSPanel(evt){
	var panel = document.createElement("div");
	panel.id = "csPanel";

	var mainPanel = document.createElement("div");
	mainPanel.className = "csInnerPanel";

	mainPanel.innerHTML = "<h1><img src='/collection/img/order/cus_h1_01.gif' alt='カスタマーサービス' /></h1>\
<h2><img src='/collection/img/order/cus_h2_01.gif' alt='ご注文方法' /></h2>\
<p><img src='/collection/img/order/cus_text_01_01.gif' alt='ご注文の際はオーダーページよりご希望の商品を選び、お客様情報をご記入の上、送信ください。ご注文内容を確認後、配送料金を含めた最終金額をご連絡致しますので、ご確認の上、お支払い手続きをお願いいたします。' /></p>\
<h2><img src='/collection/img/order/cus_h2_02.gif' alt='お支払方法' /></h2>\
<p><img src='/collection/img/order/cus_text_02_01.gif' alt='ご注文から商品発送までの間に、銀行振込にて承ります。ご入金確認後に商品を発送させていただきます。クレジットカードでのお支払いの場合は、お電話での受付となります。注文フォーム送信後、お電話にて手続きをお願いいたします。' /></p>\
<h2><img src='/collection/img/order/cus_h2_03.gif' alt='お振込先' /></h2>\
<p><img src='/collection/img/order/cus_text_03_01.gif' alt='銀行名 : 三菱東京UFJ銀行 / 表参道支店 口座番号 : 普通 1766563 口座名称 : 株式会社E&amp;Y' /></p>\
<h2><img src='/collection/img/order/cus_h2_04.gif' alt='配送について' /></h2>\
<p><img src='/collection/img/order/cus_text_04_01.gif' alt='商品は全て全国への配送を行っております。送料は別途ご負担いただきます。なお、原則として商品のお届けは玄関でのお引き渡しとなりますので、開梱設置をご希望の方はご相談下さい。納期については在庫状況によって異なりますので随時お問い合わせ下さい。' /></p>\
<h2><img src='/collection/img/order/cus_h2_05.gif' alt='返品・交換' /></h2>\
<p><img src='/collection/img/order/cus_text_05_01.gif' alt='商品が到着しましたら商品をご点検ください。万一破損等がある場合には納入日から7日以内にご連絡ください。ご連絡いただいたものにつきましては無償修理・交換の対象とさせていただきます。この期間以降のクレームに関しましてはお受けいたしかねますのでご了承下さい。' /></p>\
<h2><img src='/collection/img/order/cus_h2_06.gif' alt='保証' /></h2>\
<p><img src='/collection/img/order/cus_text_06_01.gif' alt='商品の保証期間はお買い上げ日（納入日）より1年間です。この期間中製品上の欠陥により発生した破損等に関しましては無償にて補修させていただきます。補修不可能品につきましては交換もしくは同等品とお取り換えいたします。その他に関しましては実費にて補修をお受けいたします。以下に起因する損傷に関して、当社は責任を負いかねます。● 直射日光、冷暖房機ほか電気製品の熱などによる変形、変色。● 納品後の移動、輸送により生じた破損、故障。● その他不適切な取り扱い、不注意により生じた破損、故障。' /></p>\
<h2><img src='/collection/img/order/cus_h2_07.gif' alt='おことわり' /></h2>\
<p class='last'><img src='/collection/img/order/cus_text_07_01.gif' alt='● 画像の色や質感において実物と多少異なる場合がございます。● 商品の仕様、デザインを改良のため止むを得ず予告なしで一部変更する場合がありますので予めご了承下さい。● 本価格は2008年7月現在の税込み価格です。本価格は予告なく変更される場合がありますので、ご注文時に必ずご確認下さい。● 表示サイズは製品により多少の誤差が生じることがございます。● ご注文後の仕様変更、他商品への変更、キャンセルは原則としてお受けいたしかねますのでご了承ください。' /></p>";

	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "csCloseBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);

	panel.appendChild(mainPanel);
	panel.appendChild(funcList);
	$("div#body").append(panel);
	$("div#csPanel").show("slow");
	$("img#csCloseBtn").click(hideCSPanel);
	$.lm.hover.init();
}

// function hideCSPanel (for COLLECTION)
function hideCSPanel(){
	$("div#csPanel").hide("slow", function(){
		$("div#csPanel").remove();
	});
}

// function showLawPanel (for COLLECTION)
function showLawPanel(evt){
	var panel = document.createElement("div");
	panel.id = "lawPanel";

	var mainPanel = document.createElement("div");
	mainPanel.className = "lawInnerPanel";

	mainPanel.innerHTML = "<h1><img src='/collection/img/order/law_h1_01.gif' alt='通信販売の法規【訪問販売法】に基づく表示' /></h1>\
<p><img src='/collection/img/order/law_text_01.gif' alt='販売業者:株式会社E&amp;Y 運営統括責任者:代表取締役 松澤 剛 所在地:〒153-0041東京都目黒区駒場1-32-17 UNS Bldg 電話番号:03-3481-5518' /></p>\
<h2><img src='/collection/img/order/law_h2_01.gif' alt='商品代金以外の必要料金' /></h2>\
<p><img src='/collection/img/order/law_text_01_01.gif' alt='1. 商品は本体価格の表記です。（　）は税込表記となります。詳しくは各商品ページをご覧ください。2. 送料は地域・大きさによって異なります。3. 銀行振込による決済をご希望時の振込手数料はお客様のご負担となります。また、上記は国内での販売の場合、適用となります。' /></p>\
<h2><img src='/collection/img/order/law_h2_02.gif' alt='申込の有効期限' /></h2>\
<p><img src='/collection/img/order/law_text_02_01.gif' alt='受注後7日間' /></p>\
<h2><img src='/collection/img/order/law_h2_03.gif' alt='交換・返品' /></h2>\
<p><img src='/collection/img/order/law_text_03_01.gif' alt='お客様のご都合による交換、返品はお受けできません。もし商品の破損や汚損、ご注文と異なる商品が届いた場合には商品到着後７日以内にご連絡ください。すみやかに対応させていただきます。' /></p>\
<h2><img src='/collection/img/order/law_h2_04.gif' alt='商品の内容' /></h2>\
<p><img src='/collection/img/order/law_text_04_01.gif' alt='各商品ページをご覧ください。' /></p>\
<h2><img src='/collection/img/order/law_h2_05.gif' alt='申込方法' /></h2>\
<p><img src='/collection/img/order/law_text_05_01.gif' alt='各商品のオーダーフォームにお客様の名前、住所、お届け先等を入力してください。' /></p>\
<h2><img src='/collection/img/order/law_h2_06.gif' alt='問い合わせ方法' /></h2>\
<p><img src='/collection/img/order/law_text_06_01.gif' alt='Email又は電話、Fax' /></p>\
<h2><img src='/collection/img/order/law_h2_07.gif' alt='販売数量' /></h2>\
<p><img src='/collection/img/order/law_text_07_01.gif' alt='1点から' /></p>\
<h2><img src='/collection/img/order/law_h2_08.gif' alt='引き渡し時期' /></h2>\
<p><img src='/collection/img/order/law_text_08_01.gif' alt='受注時にご連絡となります。' /></p>\
<h2><img src='/collection/img/order/law_h2_09.gif' alt='お支払い方法' /></h2>\
<p><img src='/collection/img/order/law_text_09_01.gif' alt='注文の内容を確認後、指定の口座にお振込ください。お振込がない場合は、自動的に注文はキャンセルとなりますのでご了承ください。また、お電話でのクレジットカードによるお支払いがご利用いただけます。' /></p>\
<h2><img src='/collection/img/order/law_h2_10.gif' alt='お支払い期限' /></h2>\
<p><img src='/collection/img/order/law_text_10_01.gif' alt='7日間' /></p>\
<h2><img src='/collection/img/order/law_h2_11.gif' alt='返品期限' /></h2>\
<p><img src='/collection/img/order/law_text_11_01.gif' alt='商品到着後7日以内（商品使用後の返品は、ご遠慮願います。）' /></p>\
<h2><img src='/collection/img/order/law_h2_12.gif' alt='返品送料' /></h2>\
<p><img src='/collection/img/order/law_text_12_01.gif' alt='商品の破損や汚損、ご注文と異なる商品が届いた場合、当社負担とさせていただきます。' /></p>";

	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "lawCloseBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);

	panel.appendChild(mainPanel);
	panel.appendChild(funcList);
	$("div#body").append(panel);
	$("div#lawPanel").show("slow");
	$("img#lawCloseBtn").click(hideLawPanel);
	$.lm.hover.init();
}

// function hideLawPanel (for COLLECTION)
function hideLawPanel(){
	$("div#lawPanel").hide("slow", function(){
		$("div#lawPanel").remove();
	});
}

// function showFabric
function showFabric(evt){
	var fabricID = evt.target.id.replace("fabric", "");

	var panel = document.createElement("div");
	panel.id = "fabricPanel";

	var mainImagePanel = document.createElement("div");
	mainImagePanel.className = "mainImage";
	var mainImage = document.createElement("img");
	mainImage.src = "/collection/img/order/col_ord_fab_" + currentData.id + "_0" + fabricID + ".jpg";
	mainImage.alt = "";
	mainImage.width = "950";
	mainImage.height = "470";
	mainImagePanel.appendChild(mainImage);
	
	var funcList = document.createElement("ul");
	funcList.className = "funcUL";
	var funcListElement1 = document.createElement("li");
	var closeImage = document.createElement("img");
	closeImage.id = "fabricCloseBtn";
	closeImage.className = "hover";
	closeImage.src = "/shared/img/btn_close_01.gif";
	closeImage.width = "35";
	closeImage.height = "10";
	closeImage.alt = "Close";
	funcListElement1.appendChild(closeImage);
	funcList.appendChild(funcListElement1);

	panel.appendChild(mainImagePanel);
	panel.appendChild(funcList);
	$("div#body").append(panel);
	$("div#fabricPanel").show("slow");
	$("img#fabricCloseBtn").click(hideFabricPanel);
	$("ul.fabricThumbUL img.hover").click(changeImage);
	$.lm.hover.init();
}

// function hideFabricPanel (for COLLECTION)
function hideFabricPanel(){
	$("div#fabricPanel").hide("slow", function(){
		$("div#fabricPanel").remove();
	});
}

// function showOrderSum (for COLLECTION)
function showOrderSum(){
	$("div#innerPanel").fadeOut("slow", function(){
		$("div#innerPanel").empty();
		
		var totalPrice = 0;
		var orderTable = "<div class='orderTableBlock'><table class='orderTable'><tr><th><img src='/collection/img/order/order_text_01.gif' alt='Item' /></th><th class='price'><img src='/collection/img/order/order_text_02.gif' alt='Unit Price(In tax)' /></th><th class='quantity'><img src='/collection/img/order/order_text_03.gif' alt='Quantity' /></th><th class='price'><img src='/collection/img/order/order_text_04.gif' alt='Price(In tax)' /></th></tr><tbody>";
		for(i in orderData.items){
			for(j in orderData.items[i].subitems){
				if(orderData.items[i].subitems[j].num > 0){
					orderTable += "<tr><td>" + orderData.items[i].name + " - " + orderData.items[i].subitems[j].name + "</td><td class='price'>&yen;" + formatPrice(orderData.items[i].subitems[j].price) + "</td><td class='quantity'><input name='" + j + "' id='" + j + "' type='text' value='" + orderData.items[i].subitems[j].num + "' /></td><td id='" + j + "total' class='price'>&yen;" + formatPrice(orderData.items[i].subitems[j].price * orderData.items[i].subitems[j].num) + "</td></tr>";
					totalPrice += orderData.items[i].subitems[j].price * orderData.items[i].subitems[j].num;
				}
			}
		}
		orderTable += "</tbody></table></div>";
		$("div#innerPanel").append(orderTable);
		
		var totalTable = "<table class='totalTable'><tr><th><img src='/collection/img/order/order_text_05.gif' alt='Total Price(In tax)' /></th><td>&yen;" + formatPrice(totalPrice) + "</td></tr></table>";
		$("div#innerPanel").append(totalTable);
		
		var navigationBlock = "<div class='orderNav'><div class='col1'><img id='backBtn1' class='hover' src='/collection/img/order/btn_back_01.gif' alt='Back' /></div><div class='col2'><img id='nextBtn2' class='hover' src='/collection/img/order/btn_next_01.gif' alt='Next' /></div>"
		$("div#innerPanel").append(navigationBlock);
		$("table.orderTable input").change(changeItemQuantity);
		$("img#backBtn1").click(backOrderPanel);
		$("img#nextBtn2").click(showOrderForm);
		$("div#innerPanel").fadeIn("slow");
		$.lm.hover.init();
	});
}

// function changeItemQuantity (for COLLECTION)
function changeItemQuantity(evt){
	var parentID = evt.target.id.substr(0, 6);
	if(isNaN(evt.target.value)){
		orderData.items[parentID].subitems[evt.target.id].num = 0;
	} else {
		orderData.items[parentID].subitems[evt.target.id].num = evt.target.value;
	}
	var priceID = "#" + evt.target.id + "total";
	$(priceID).html("&yen;" + formatPrice(orderData.items[parentID].subitems[evt.target.id].num * orderData.items[parentID].subitems[evt.target.id].price));
	var totalPrice = 0;
	for(i in orderData.items){
		for(j in orderData.items[i].subitems){
			if(orderData.items[i].subitems[j].num > 0){
				totalPrice += orderData.items[i].subitems[j].price * orderData.items[i].subitems[j].num;
			}
		}
	}
	$("table.totalTable td").html("&yen;" + formatPrice(totalPrice));
}

// function backOrderPanel (for COLLECTION)
function backOrderPanel(evt){
	$("div#innerPanel").fadeOut("slow", function(){
		$("div#innerPanel").empty();

		var textImagePanel = document.createElement("div");
		textImagePanel.className = "orderText";
		var textImage = document.createElement("img");
		textImage.src = "/collection/img/order/col_ord_txt_" + currentData.id + ".gif";
		textImage.alt = orderData.text;
		textImagePanel.appendChild(textImage);
		$("div#innerPanel").append(textImagePanel);

		var selectPanel = document.createElement("div");
		selectPanel.className = "orderBlock";
		var itemID = 1;
		for (i in orderData.items){
			var selectItem = document.createElement("div");
			selectItem.className = "orderItem";
			var itemThumb = document.createElement("div");
			itemThumb.className = "thumb";
			var itemThumbImage = document.createElement("img");
			var itemThumbNum = itemID > 9 ? itemID : "0" + itemID;
			itemThumbImage.src = "/collection/img/order/col_ord_img_" + currentData.id + "_" + itemThumbNum + ".gif";
			itemThumbImage.alt = orderData.items[i].name;
			itemThumb.appendChild(itemThumbImage);
			selectItem.appendChild(itemThumb);
			
			var checkList = document.createElement("ul");
			checkList.className = "checkList";
			checkList.id = i;
			var listID = 1;
			for (j in orderData.items[i].subitems) {
				var listItem = document.createElement("li");
				var listImage = document.createElement("img");
				listImage.id = j;
				var listNum = listID > 9 ? listID : "0" + listID;
				if(orderData.items[i].subitems[j].num > 0){
					listImage.src = "/collection/img/order/col_ord_che_" + currentData.id + "_" + itemThumbNum + "_" + listNum + "_c.gif";
					orderData.items[i].subitems[j].num = 1;
				} else {
					listImage.src = "/collection/img/order/col_ord_che_" + currentData.id + "_" + itemThumbNum + "_" + listNum + ".gif";
				}
				listImage.className = "clickable";
				listImage.alt = orderData.items[i].subitems[j].name + ":&yen;" + orderData.items[i].subitems[j].price + "(In tax)";
				listItem.appendChild(listImage);
				checkList.appendChild(listItem);
				listID++;
			}
			selectItem.appendChild(checkList);
			itemID++;
			selectPanel.appendChild(selectItem);
		}
		$("div#innerPanel").append(selectPanel);

		var fabricBlock = document.createElement("div");
		fabricBlock.className = "fabricBlock";
		if(orderData.fabric){
			var fabricTitle = document.createElement("div");
			fabricTitle.className = "fabricTitle";
			var fabricTitleImage = document.createElement("img");
			fabricTitleImage.src = "/shared/img/order_text_01.gif";
			fabricTitleImage.alt = "FABRIC SAMPLE";
			fabricTitle.appendChild(fabricTitleImage);
			fabricBlock.appendChild(fabricTitle);
			var fabricList = document.createElement("ul");
			for(k in orderData.fabric){
				var fabricListElem = document.createElement("li");
				var fabricImage = document.createElement("img");
				switch(orderData.fabric[k]){
					case 1:
						fabricImage.src = "/shared/img/btn_fabric_01.gif";
						fabricImage.id = "fabric1";
						fabricImage.alt = "A TYPE-NS";
						break;
					case 2:
						fabricImage.src = "/shared/img/btn_fabric_02.gif";
						fabricImage.id = "fabric2";
						fabricImage.alt = "A TYPE-SU";
						break;
					case 3:
						fabricImage.src = "/shared/img/btn_fabric_03.gif";
						fabricImage.id = "fabric3";
						fabricImage.alt = "VINYL LEATHER A TYPE-LG";
						break;
					case 4:
						fabricImage.src = "/shared/img/btn_fabric_04.gif";
						fabricImage.id = "fabric4";
						fabricImage.alt = "B TYPE-CL";
						break;
					case 5:
						fabricImage.src = "/shared/img/btn_fabric_05.gif";
						fabricImage.id = "fabric5";
						fabricImage.alt = "B TYPE-FK";
						break;
					case 6:
						fabricImage.src = "/shared/img/btn_fabric_06.gif";
						fabricImage.id = "fabric6";
						fabricImage.alt = "C TYPE-EC";
						break;
					case 7:
						fabricImage.src = "/shared/img/btn_fabric_07.gif";
						fabricImage.id = "fabric7";
						fabricImage.alt = "D TYPE-NV";
						break;
					case 8:
						fabricImage.src = "/shared/img/btn_fabric_08.gif";
						fabricImage.id = "fabric8";
						fabricImage.alt = "D TYPE-EP";
						break;
				}
				fabricImage.className = "fabricBtn";
				fabricImage.className = "hover";
				fabricListElem.appendChild(fabricImage);
				fabricList.appendChild(fabricListElem);
			}
			fabricBlock.appendChild(fabricList);
		}
		$("div#innerPanel").append(fabricBlock);
		
		var attentionBlock = document.createElement("div");
		attentionBlock.className = "attentionBlock";
		var attentionCol1 = document.createElement("div");
		attentionCol1.className = "col1";
		var attentionTitle = document.createElement("div");
		attentionTitle.className = "attentionTitle";
		var attentionTitleImage = document.createElement("img");
		attentionTitleImage.src = "/shared/img/order_text_02.gif";
		attentionTitleImage.alt = "ATTENTION";
		attentionTitle.appendChild(attentionTitleImage);
		attentionCol1.appendChild(attentionTitle);
		if(orderData.attention){
			var attention = document.createElement("div");
			attention.className = "attentionText";
			attentionImage = document.createElement("img");
			attentionImage.src = "/collection/img/order/col_ord_att_" + currentData.id + ".gif";
			attentionImage.alt = orderData.attention;
			attention.appendChild(attentionImage);
			attentionCol1.appendChild(attention);
		}
		attentionBlock.appendChild(attentionCol1);
		var attentionCol2 = document.createElement("div");
		attentionCol2.className = "col2";
		var nextImage = document.createElement("img");
		nextImage.src = "/collection/img/order/btn_next_01.gif";
		nextImage.className = "hover";
		nextImage.id = "showOrderSum";
		attentionCol2.appendChild(nextImage);
		attentionBlock.appendChild(attentionCol2);
		$("div#innerPanel").append(attentionBlock);

		$("div.orderItem").addClassFLtoDiv(4);
		$("ul.checkList li img").click(checkItem);
		$("img#orderCloseBtn").click(hideOrderPanel);
		$("img#descriptionBtn2").click(showDescPanel);
		$("div.fabricBlock ul li img").click(showFabric);
		$("img#showOrderSum").click(showOrderSum);

		$("div#innerPanel").fadeIn("slow");
		$.lm.hover.init();
	});
}

// function showOrderForm (for COLLECTION)
function showOrderForm(){
	$("div#innerPanel").fadeOut("slow", function(){
		$("div#innerPanel").empty();
		
		var orderFormBlock = "<div class='orderFormBlock'><div class='col1'></div><div class='col2'></div><div class='col3'></div></div>";
		$("div#innerPanel").append(orderFormBlock);
		
		var totalPrice = 0;
		var orderTable = "<div class='orderTableBlock'><table class='orderTable2'><tr><th><img src='/collection/img/order/order_text_01.gif' alt='Item' /></th><th class='quantity'><img src='/collection/img/order/order_text_03.gif' alt='Quantity' /></th></tr><tbody>";
		for(i in orderData.items){
			for(j in orderData.items[i].subitems){
				if(orderData.items[i].subitems[j].num > 0){
					orderTable += "<tr><td>" + orderData.items[i].name + " - " + orderData.items[i].subitems[j].name + "</td><td class='quantity'>" + orderData.items[i].subitems[j].num + "</td></tr>";
					totalPrice += orderData.items[i].subitems[j].price * orderData.items[i].subitems[j].num;
				}
			}
		}
		orderTable += "</tbody></table></div>";
		$("div.orderFormBlock div.col1").append(orderTable);
		
		var totalTable = "<table class='totalTable'><tr><th><img src='/collection/img/order/order_text_05.gif' alt='Total Price(In tax)' /></th><td>&yen;" + formatPrice(totalPrice) + "</td></tr></table>";
		$("div.orderFormBlock div.col1").append(totalTable);

		var form1 = "<p class='label'><label for='name'><img src='/collection/img/order/order_text_06.gif' alt='ご発送先名' width='52' height='11' /></label></p>\
		<p class='form'><input name='name' id='name' type='text' /></p>\
		<p class='label'><label for='zip'><img src='/collection/img/order/order_text_07.gif' alt='郵便番号' width='44' height='11' /></label></p>\
		<p class='form'><input name='zip' id='zip' type='text' /></p>\
		<p class='label'><label for='address'><img src='/collection/img/order/order_text_08.gif' alt='ご発送先住所' width='64' height='11' /></label></p>\
		<p class='form'><input name='address' id='address' type='text' /></p>\
		<p class='label'><label for='phone'><img src='/collection/img/order/order_text_09.gif' alt='ご発送先電話番号' width='86' height='11' /></label></p>\
		<p class='form'><input name='phone' id='phone' type='text' /></p>\
		<p class='label'><label for='fax'><img src='/collection/img/order/order_text_10.gif' alt='ファックス' width='47' height='10' /></label></p>\
		<p class='form'><input name='fax' id='fax' type='text' /></p>\
		<p class='label'><label for='email'><img src='/collection/img/order/order_text_11.gif' alt='Email' width='34' height='10' /></label></p>\
		<p class='form'><input name='email' id='email' type='text' /></p>\
		<input type='hidden' name='category' id='category' value='ja' />";
		$("div.orderFormBlock div.col2").html(form1);
		
		var form2 = "	<p class='label'><img src='/collection/img/order/order_text_12.gif' alt='優先して希望されるご連絡方法' width='146' height='11' /><input class='check' type='hidden' name='check1' id='check1' value='false' /><input class='check' type='hidden' name='check2' id='check2' value='false' /><input class='check' type='hidden' name='check3' id='check3' value='false' /></p><ul class='form'><li><img id='check1Btn' src='/collection/img/order/order_check_01.gif' alt='Email' width='49' height='10' class='check' /></li><li><img id='check2Btn' src='/collection/img/order/order_check_02.gif' alt='電話' width='37' height='10' class='check' /></li><li><img id='check3Btn' src='/collection/img/order/order_check_03.gif' alt='ファックス' width='62' height='10' class='check' /></li></ul><p class='label'><label for='comment'><img src='/collection/img/order/order_text_13.gif' alt='ご質問・ご要望等' width='80' height='11' /></label></p><p class='form'><textarea name='comment' id='comment' cols='40' rows='20'></textarea></p>";
		$("div.orderFormBlock div.col3").html(form2);

		var navigationBlock = "<div class='orderNav'><div class='col1'><img id='backBtn2' class='hover' src='/collection/img/order/btn_back_01.gif' alt='Back' /></div><div class='col2'><img id='orderBtn2' class='hover' src='/collection/img/order/btn_order_01.gif' alt='Order' /></div>"
		$("div#innerPanel").append(navigationBlock);
		
		$("img#backBtn2").click(showOrderSum);
		$("div#innerPanel").fadeIn("slow");
		$("img#orderBtn2").click(postData);
		$("img.check").click(toggleCheck);
		$.lm.hover.init();
	});
}

// function postData (for COLLECTION)
function postData(){
	var data = {};
	var count = 0;
	var totalPrice = 0;
	data.product = currentData.title;
	data.order = "";
	for(i in orderData.items){
		for(j in orderData.items[i].subitems){
			if(orderData.items[i].subitems[j].num > 0){
				data.order += orderData.items[i].name + " - " + orderData.items[i].subitems[j].name + " ￥" + orderData.items[i].subitems[j].price + "×" + orderData.items[i].subitems[j].num + "\r\n";
				totalPrice += orderData.items[i].subitems[j].price * orderData.items[i].subitems[j].num;
				count++;
			}
		}
	}
	data.totalprice = totalPrice;
	data.category = $("input#category").val();
	data.name = $("input#name").val();
	data.zip = $("input#zip").val();
	data.address = $("input#address").val();
	data.email = $("input#email").val();
	data.phone = $("input#phone").val();
	data.fax = $("input#fax").val();
	data.check1 = $("input#check1").val();
	data.check2 = $("input#check2").val();
	data.check3 = $("input#check3").val();
	data.comment = $("textarea#comment").val();
	$.post("/collection/order/order.php", data, showResult, "text");
}

// function showResult (for CONTACT)
function showResult(data){
	sendStatus = data;
	
	$("img#orderBtn2").unbind("click").unbind("mouseover").unbind("mouseout").unbind("focus").unbind("blur").attr("src", "/collection/img/order/btn_order_01_o.gif");
	var message;

	if(data == 1){
		message = "ご依頼をお受け致しました。<br />後日担当者よりご連絡させて頂きます。<br />ありがとうございました。";
	} else if(data == 2){
		message = "「氏名」をご入力ください。";
	} else if(data == 3){
		message = "「フリガナ」をご入力ください。";
	} else if(data == 4){
		message = "「EMAIL」をご入力ください。";
	} else if(data == 5){
		message = "E-mailアドレスの形式が正しくありません。<br />正しいE-mailアドレスをご入力ください。";
	} else if(data == 6){
		message = "「ご用件」をご入力ください。";
	} else if(data == 7){
		message = "「御社名」をご入力ください。";
	} else if(data == 8){
		message = "「TEL」をご入力ください。";
	} else if(data == 9){
		message = "「ご担当」をご入力ください。";
	} else if(data == 10){
		message = "商品が選択されていません。<br />商品をお選びください。";
	} else if(data == 11){
		message = "「ご発送先名」をご入力ください。";
	} else if(data == 12){
		message = "「郵便番号」をご入力ください。";
	} else if(data == 13){
		message = "「ご発送先住所」をご入力ください。";
	} else if(data == 14){
		message = "「ご発送先電話番号」をご入力ください。";
	} else if(data == 15){
		message = "「優先して希望されるご連絡方法」を選択してください。";
	} else {
		message = "エラーが発生しました。<br />申し訳ございませんが、<a href='mailto:info@eandy.com'>Info</a>までご連絡ください。";
	}
	
	var resultPanel = document.createElement("div");
	resultPanel.id = "resultPanel";
	var resultMessage = document.createElement("p");
	resultMessage.innerHTML = message;
	resultPanel.appendChild(resultMessage);
	$("div#body").append(resultPanel);
	$("div#resultPanel").fadeIn("slow", function(){
		hideTimer = setTimeout("hideResult()", 3000);
	});
}

// function hideResult (for COLLECTION)
function hideResult(){
	$("div#resultPanel").fadeOut("slow", function(){
		$("div#resultPanel").remove();
		$("img#orderBtn2").attr("src", "/collection/img/order/btn_order_01.gif");
		$.lm.hover.init();
		$("img#orderBtn2").click(postData);
		if(sendStatus == 1){
			location.href = "/collection/";
		}
	});
}
