// JavaScript Document
var siteInfo = "e-frontier/shade/0001";
var design   = new Object();
var bodyInfo = new Object();

design.obj1 = {
					'ttl'  : 'hikutei',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj2 = {
					'ttl'  : 'robo',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj3 = {
					'ttl'  : 'T-AirShip',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj4 = {
					'ttl'  : 'T-AirShip2',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj5 = {
					'ttl'  : 'T-BIKE',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj6 = {
					'ttl'  : 'T-BIKE2',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj7 = {
					'ttl'  : 'T-FACE',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj8 = {
					'ttl'  : 'T-KING1',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj9 = {
					'ttl'  : 'T-Sword',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
				
design.obj21 = {
					'ttl'  : 'flay3',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj22 = {
					'ttl'  : 'girl1-2',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj23 = {
					'ttl'  : 'girl2',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj24 = {
					'ttl'  : 'rakkyo',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj25 = {
					'ttl'  : 'xmas',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj26 = {
					'ttl'  : 'OMP1',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj27 = {
					'ttl'  : 'OMP2',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj28 = {
					'ttl'  : 'OMP3',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};
design.obj29 = {
					'ttl'  : 'OMP4',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};

design.obj31 = {
					'ttl'  : 'sofa2',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};

design.obj32 = {
					'ttl'  : 'arm',
					'info' : '<p>半袖Tシャツ</p>'
						+ '<ul>'
						+ '	<li>カラー：ホワイト</li>'
						+ '	<li>価格：2940円(税込)</li>'
						+ '</ul>',
					'stat'  : {'color' : '3321','multiblend' : '1'}
				};

bodyInfo = {
				'1386' : {
					'info'  : '[表]ポリエステル&nbsp;100%<br />[裏]コットン&nbsp;100%',
					'price' : 2800,
					'color' : {
							'2677' : 'default'
						}
					},
				'1397' : {
					'info'  : '6.2オンス&nbsp;綿100%<br />(ライトブルー,ライトイエローのみ5.6オンス&nbsp;綿100%)',
					'price' : 2000,
					'color' : {
							'2711' : 'ナチュラル',
							'2712' : 'ホワイト',
							'2713' : 'ライトベージュ',
							'2714' : 'アッシュ',
							'2715' : 'ライトグレー',
							'2716' : 'ライトイエロー',
							'2717' : 'ライトピンク',
							'2718' : 'ライトブルー'
						}
					},
				'1413' : {
					'info'  : '5.6oz&nbsp;17/1天竺カード&nbsp;綿100％<br />',
					'price' : 2500,
					'color' : {
							'2786' : 'レッドxホワイト',
							'2787' : 'パープルxホワイト',
							'2788' : 'ﾛｲﾔﾙﾌﾞﾙｰxホワイト',
							'2789' : 'ネイビーxホワイト',
							'2790' : 'グリーンxホワイト',
							'2791' : 'ブラックxホワイト'
						}
					},
				'1508' : {
					'info'  : '陶器&nbsp;15オンス<br />',
					'price' : 1600,
					'color' : {
							'2997' : 'default'
						}
					},
				'1487' : {
					'info'  : '素材&nbsp;紙<br />',
					'price' : 600,
					'color' : {
							'2960' : 'default'
						}
					},
				'1488' : {
					'info'  : '素材&nbsp;紙<br />',
					'price' : 600,
					'color' : {
							'2961' : 'default'
						}
					},
				'1448' : {
					'info'  : '5.9oz&nbsp;綿100％<br />',
					'price' : 2000,
					'color' : {
							'2895' : 'ホワイト',
							'2896' : 'ライトイエロー',
							'2897' : 'ライトピンク',
							'2898' : 'ライトブルー'
						}
					},
				'1441' : {
					'info'  : '5.9oz&nbsp;綿100％<br />',
					'price' : 2300,
					'color' : {
							'2869' : 'ホワイト',
							'2870' : 'ライトイエロー',
							'2871' : 'ライトピンク',
							'2868' : 'ライトブルー'
						}
					},
				'1445' : {
					'info'  : '5.9oz&nbsp;綿100％<br />',
					'price' : 2300,
					'color' : {
							'2888' : 'ホワイト',
							'2889' : 'ライトピンク',
							'2887' : 'ライトブルー'
						}
					},
				'1452' : {
					'info'  : '5.9oz&nbsp;28/-フライス&nbsp;綿100％<br />',
					'price' : 2000,
					'color' : {
							'2913' : 'ホワイト',
							'2912' : 'ライトブルー'
						}
					},
				'1465' : {
					'info'  : 'ポリエステル100%&nbsp;マイクロファイバータオル<br />',
					'price' : 2000,
					'color' : {
							'2938' : 'default'
						}
					},
				'1459' : {
					'info'  : '綿100％&nbsp;縦360mm×横370mm×マチ110mm<br />',
					'price' : 1500,
					'color' : {
							'2931' : 'default'
						}
					},
				'1802' : {
					'info'  : 'コットン100%（無漂白）※生地薄タイプ<br />',
					'price' : 953,
					'color' : {
							'4300' : 'default'
						}
					}
			};

function changeDesign(n) {
	document.getElementById('design_ttl').innerHTML = design[n].ttl;
	document.getElementById('picture').src = 'images/picture_' + n + '.jpg';
	document.getElementById('picture').alt = design[n].ttl;
//	document.getElementById('product_image').src = 'images/product_' + n + '.jpg';
//	document.getElementById('product_info').innerHTML = design[n].info + "<br />";

	//Cart Botton
	element = document.getElementById("product_cart");
	element.innerHTML = "";
	newElement = document.createElement("img");
	element.insertBefore(newElement,null);
	newElement.setAttribute("src", "images/cart_btn.gif");
	if(document.documentElement.getAttribute("style") == document.documentElement.style){
		newElement.setAttribute("onclick", new Function("sendCart();"));
	} else {
		newElement.setAttribute("onclick", "sendCart();");
	}
	newElement.style.cursor = "pointer";

	for(i in design){
		document.getElementById('p_' + i).style.visibility = 'hidden';
	}
	document.getElementById('p_' + n).style.visibility = 'visible';

	//API Status
	document.setForm.color_id.value = design[n].stat.color;
	document.setForm.filename.value = n;
	document.setForm.multiblend_flag.value = design[n].stat.multiblend;

	selectBody();
}

function selectBody(){
	bodyid = document.selectForm.select_body.options[document.selectForm.select_body.selectedIndex].value;
	document.setForm.body_id.value = bodyid;
	document.getElementById('product_memo').innerHTML = bodyInfo[bodyid].info;

	document.selectForm.select_color.length = 0;
	document.selectForm.select_color.disabled = false;
	count = 0;
	for(i in bodyInfo[bodyid].color){
		if(count == 0){
			document.setForm.color_id.value = i;
		}
		document.selectForm.select_color.options[count] = new Option(bodyInfo[bodyid].color[i], i); 
		if(bodyInfo[bodyid].color[i] == "default"){
			document.selectForm.select_color.disabled = true;
		}
		count++;
	}

	document.getElementById('product_price').innerHTML = Math.floor(bodyInfo[bodyid].price * 1.05);
	document.setForm.price.value = bodyInfo[bodyid].price;

	sendAPIData();
}

function selectColor(){
	colorid = document.selectForm.select_color.options[document.selectForm.select_color.selectedIndex].value;
	document.setForm.color_id.value = colorid;

	sendAPIData();
}

// API Request
function sendAPIData(){
	var sendAPIString;
	sendAPIString = "/system/api/request2xml_lv1.php?";
	for(element = 0; element < document.setForm.elements.length; element++){
		sendAPIString += "&OP_" + document.setForm.elements[element].name + "=" + document.setForm.elements[element].value;
	}
	sendAPIString += "&OP_siteInfo=" + siteInfo;
	sendAPIString += "&dt=" + setTmpdate();
//document.getElementById("test").innerHTML = sendAPIString;
	httpObj = createXMLHttpRequest(sendRequestXML);
	if (httpObj) {
		httpObj.open("GET",sendAPIString,true);
		httpObj.send(null);
	}
}

function createXMLHttpRequest(cbFunc) {
	var XMLhttpObject = null;
	try{
		XMLhttpObject = new XMLHttpRequest();
	}catch(e){
		try{
			XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				return null;
			}
		}
	}
	if (XMLhttpObject) XMLhttpObject.onreadystatechange = cbFunc;
	return XMLhttpObject;
}

function setTmpdate(){
	var now = new Date();
	var dt = "";
	yy = now.getYear();
	mm = now.getMonth() + 1;
	dd = now.getDate();
	hh = now.getHours();
	ms = now.getMinutes();
	ss = now.getSeconds();
	if (yy < 2000) { yy += 1900; }
	if (mm < 10) { mm = "0" + mm; }
	if (dd < 10) { dd = "0" + dd; }
	if (hh < 10) { hh = "0" + hh; }
	if (ms < 10) { ms = "0" + ms; }
	if (ss < 10) { ms = "0" + ss; }
	dt = yy+mm+dd+hh+ms+ss;
	return dt;
}

function sendRequestXML() {
	if ((httpObj.readyState == 4)&& httpObj.responseText){
		LineAry = httpObj.responseText.split("\n");
		for(i=0;i<(LineAry.length - 1);i++){
			layoutData = LineAry[i].split("\t");
			if(layoutData[0] != "ERROR"){
				document.getElementById("product_image").src = layoutData[1]
				document.cartForm.cartAddr.value = layoutData[0];
			} else {
				alert(layoutData[1]);
			}
		}
		document.getElementById("loading").style.display = "none";
	}else{
		document.getElementById("loading").style.display = "block";
	}
}

function sendCart(){
		location.href = document.cartForm.cartAddr.value;
}
