 /**
 * SHOPにて使用するjs
 * @author Gportal
 * @date     $Date: $
 * @version  $Revision: $
 *
 */

 // チェックフラグ
 var regchkflg = 0;
 var double = 0;
 var dupchkflg = 0;
 var wantflg = 0;
 var cartflg = 0;

 //レコメンドデータリスト
 var recommendList = new Array();

 // レコメンドフラグ
 var recFlg = false;

 /**
  * 提携先種別
  * G-Coins購入ページ遷移判断用に利用する。
  * undefined,0:アットゲームズ、1:ガンホー
  */
 var allianceType;

 /**
 * （SHOP）
 * M.shimoda：試着履歴を変更する
 * @param num 表示箇所（左から0,1,2,3)
 * @param url 衣装ID
 * @param id Itemid
 *
 */
function dispbuy2(num,url,id)
{
	// 自分の色番号を引く
	id-=clothesColor[num*colorNum];
	// Nowの色番号を加える
	id+=colorNow[num];

	dispbuy(url,id)
}

function  dispbuyEx(num,id)
{
	DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	// 自分の色番号を引く
	id-=clothesColor[num*colorNum];
	// Nowの色番号を加える
	id+=colorNow[num];

	dupchkflg = 0;

	ClothesHaveCheck.checkClothes(buyExCallback,id);

	if(dupchkflg == 0){
		//エラー無し、重複所持OKなら画面遷移
		dispbuy('/tinierme/dispbuy.do',id);
	}
}

function dispbuyEx2(id)
{
	DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	dupchkflg = 0;

	ClothesHaveCheck.checkClothes(buyExCallback,id);

	if(dupchkflg == 0){
		//エラー無し、重複所持OKなら画面遷移
		dispbuy('/tinierme/dispbuy.do',id);
	}
}

function buyExCallback(result)
{
	if(result == 0){
		if(confirm("You already own this item. Are you would like to purchase it anyways?") == false){
			dupchkflg = 1;
		}
	}else if(result == -1){
		alert("Failed to retrieve the item information.");
		dupchkflg = 1;
	}
}
 /**
 * （SHOP）
 * 新着衣装SHOP
 * 並び順の切替のアクションを行う
 *
 */
function menuaction(URL,corner, shelf, offset, limit){
	var id = document.getElementById("menu2").value;
	//alert(id);
	linktoSubmit(URL,corner,shelf,offset,limit,id);
}

/**
 * （SHOP）
 * 禁止文字チェック結果を受け取る
 */
function formcallback(data){
	if(data == true){
		badlanguage = new Array('');
		//alert(getMessage('errors.badlanguage', badlanguage));
		regchkflg = 1;
	}
}

/**
 * （SHOP）
 * 作成衣装のGift時の入力チェックを行う
 */
function makeclothesbuychk(URL, formobj){
	//alert('chk開始');
    DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	var createuserMes = document.getElementById("messageCreator").value;

	var resultnum = 0;					// 結果フラグ

	document.itemlist.bodyCreator.value = document.aform.messageCreator.value;
	// 本文文字列長チェック(512)作成者へのコメント
	resultnum = betweenchk(createuserMes, -1, 1024);
	if(resultnum == -2){
		nick = new Array('本文','512');
		// エラーがあった場合
		//alert("Message入力可能文字数は全角512文字までです");
		alert("The message can only contain a maximum of 1024 characters.");
		return;
	}

	NG.checkBadLanguage(formcallback, createuserMes);

	if(regchkflg == 0){
		// 入力エラーがなければ送信
		tosubmit(URL, formobj);
	}else{
		regchkflg=0;
		//alert("Messageに使用禁止文字列が含まれています");
		alert("The message contains forbidden words.");
	}
}

/**
 * （SHOP）
 * 作成衣装のGift時の入力チェックを行う
 */
function makeclothespresentchk(URL, formobj){
    DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	var nickname = formobj.textfield.value;
	var mes = formobj.message.value;
	var createuserMes = formobj.messageCreator.value;

	var resultnum = 0;					// 結果フラグ
	document.itemlist.bodyCreator.value = document.aform.messageCreator.value;

	// ニックネーム存在チェック
	var result = chkempty(nickname);
	if(result == false) {
		// エラーがあった場合
		alert("You did not fill in the required fields.");
		return;
	}

	// ニックネーム文字列長チェック(32バイト)
	resultnum = betweenchk(nickname, -1, 32);
	if(resultnum == -2){
		// エラーがあった場合
		//alert("To:は全角16文字以下でご入力ください");
		alert("The \"To\" field can only contain a maximum of 32 characters.");
		return;
	}

	// 本文文字列長チェック(512)相手先へのコメント
	resultnum = betweenchk(nickname, -1, 1024);
	if(resultnum == -2){
		nick = new Array('本文','512');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		//alert("Message入力可能文字数は全角512文字までです");
		alert("The message can only contain a maximum of 1024 characters.");
		return;
	}

	// 本文文字列長チェック(512)作成者へのコメント
	resultnum = betweenchk(nickname, -1, 1024);
	if(resultnum == -2){
		nick = new Array('本文','512');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		//alert("Message入力可能文字数は全角512文字までです");
		alert("The message contains forbidden words.");
		return;
	}

	NG.checkBadLanguage(formcallback, mes);

	NG.checkBadLanguage(formcallback, createuserMes);

	if(regchkflg == 0){
		// 入力エラーがなければ送信
		submitpresent(URL);
	}else{
		regchkflg=0;
		//alert("Messageに使用禁止文字列が含まれています");
		alert("The message contains forbidden words.");
	}
}


/**
 * （SHOP）
 * 単品の作成衣装購入時の入力チェックを行う
 */
function itempresentchk(URL, formobj){
    DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	//var nickname = formobj.textfield.value;
	var mes = formobj.message.value;

	var resultnum = 0;					// 結果フラグ

	// 本文文字列長チェック(512)
	resultnum = betweenchk(nickname, -1, 1024);
	if(resultnum == -2){
		nick = new Array('本文','512');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	//alert('禁止チェック');
	NG.checkBadLanguage(formcallback, mes);

	if(regchkflg == 0){
		// 入力エラーがなければ送信
//		alert('送信します');
		tosubmit(URL, formobj);
	}else{
		//alert('regchkflg = ' + regchkflg);
	}
}

/**
 * （SHOP）
 * ItemGift時の入力チェックを行う
 */
function itempresentchk(URL, formobj){
    DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	var nickname = formobj.textfield.value;
	var mes = formobj.textfield2.value;
	var resultnum = 0;					// 結果フラグ

	// ニックネーム存在チェック
	var result = chkempty(nickname);
	if(result == false) {
		nick = new Array('ニックネーム');
		//alert(getMessage('errors.required', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	// ニックネーム文字列長チェック(32バイト)
	resultnum = betweenchk(nickname, -1, 32);
	if(resultnum == -2){
		nick = new Array('ニックネーム','16');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	// 本文文字列長チェック(512)
	resultnum = betweenchk(nickname, -1, 1024);
	if(resultnum == -2){
		nick = new Array('本文','512');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	//alert('禁止チェック');
	NG.checkBadLanguage(formcallback, nickname);

	//alert('禁止チェック');
	NG.checkBadLanguage(formcallback, mes);

	if(regchkflg == 0){
		// 入力エラーがなければ送信
//		alert('送信します');
		tosubmit(URL, formobj);
	}else{
		//alert('regchkflg = ' + regchkflg);
	}
}

/**
 * （SHOP）
 * ガチャガチャGift送信前の入力チェックを行う
 * (message.js)使用
 */
function presentchk(URL, formobj){
	var nickname = formobj.textfield.value;
	var mes = formobj.textfield2.value;
	var resultnum = 0;					// 結果フラグ

	// ニックネーム存在チェック
	var result = chkempty(nickname);
	if(result == false) {
		nick = new Array('ニックネーム');
		//alert(getMessage('errors.required', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	// ニックネーム文字列長チェック(32バイト)
	resultnum = betweenchk(nickname, -1, 32);
	if(resultnum == -2){
		nick = new Array('ニックネーム','16');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	// 本文文字列長チェック(512)
	resultnum = betweenchk(nickname, -1, 1024);
	if(resultnum == -2){
		nick = new Array('本文','512');
		//alert(getMessage('errors.maxlength', nick));
		// エラーがあった場合
		regchkflg = 1;		// エラーフラグをオン
	}

	//alert('禁止チェック');
	NG.checkBadLanguage(formcallback, nickname);

	//alert('禁止チェック');
	NG.checkBadLanguage(formcallback, mes);

	if(regchkflg == 0){
		// 入力エラーがなければ送信
//		alert('送信します');
		tosubmit(URL, formobj);
	}else{
		//alert('regchkflg = ' + regchkflg);
	}
}


 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param URL URL
 * @param corner コーナー区分
 * @param shelf 棚区分
 * @param offset オフセット
 * @param limit 表示限界数
 * @param order 並び替え順フラグ
 *  0: 新しいもの順 1: 古いもの順 2: 安い順 3: 高い順
 */
function linktoSubmit(URL, corner, shelf, page, sortType) {
    document.apage.corner.value = corner;
    document.apage.shelf.value = shelf;
    document.apage.page.value = page;
    document.apage.sortType.value = sortType;
    document.apage.action = URL;
    document.apage.submit();

}

 /**
 * （作成衣装SHOP）
 * 作成者を検索させる
 *
 */
function searchcreator(URL, corner, shelf){
	var createuser = document.getElementById("textfield").value;

	if(createuser == ""){
		return;
	}
	document.searchForm.makeuser.value = createuser;
	document.searchForm.action = URL;
	document.searchForm.submit();
}

 /**
 * （SHOP）
 * 買い物かご一覧を表示する
 * @param URL URL
 * @param corner コーナー区分
 * @param shelf 棚区分
 *
 */
function linkwithSubmit(URL) {
    document.linkform.action = URL;
    document.linkform.submit();
}

 /**
 * （SHOP）
 * アバターの衣装をデフォルトの表示にする
 */
function defaultwear(id,pagename,corner, shelf, page, sortType){
	avatar_cb.location.href = "http://www.tinierme.com/tinierme/getAvatarAccount.do?account_id="+id+"&bgFlg=1";
	EquipInfo.setDefaultWear();
	linktoSubmit(pagename, corner, shelf, page, sortType);
}

 /**
 * （SHOP）
 * アバターの衣装を全て外すの表示にする
 */
function allout(){
	for(i=0;i<13;i++){
		equip_id[i]=0;
	}
	if(distinct == 2){
		equip_id[2]=10121;
		equip_id[5]=10156;
		equip_id[8]=10172;
	}else{
		equip_id[2]=10111;
		equip_id[5]=10146;
		equip_id[8]=10163;
	}
	equip_id[0]=10131;
	avatar_cb.location.href = "http://www.tinierme.com/tinierme/getAvatarClothes.do?face="+equip_id[0]+"&hair="+equip_id[2]+"&top="+equip_id[5]+"&bottom="+equip_id[8];
	EquipInfo.setFormatWear();
}

 /**
 * （SHOP）
 * 欲しいものリストに追加する
 */
function addwishlist(){

}

 /**
 * （SHOP）
 * 投票アクションを実行させる
 *
 */
function voteaction(clothesid){
    Vote.voteaction(voteresult, clothesid);
}

 /**
 * （SHOP）
 * 投票アクションのコールバックを行う
 *
 */
function voteresult(data){
	if(data == true) {
		alert('Your vote has been submitted.');
	}else{
		alert('You have already voted. Please vote again next week.');
	}
}

 /**
 * 買い物かごに衣装を加える
 * @param id 商品のID
 * @param name 商品名
 * @param price Price
 * @param imageUrl 画像URL
 * @param creatorNickname 作成者なければ空文字('')
 * @param corner コーナー区分または(ゲームID= gameid)
 * @param shelf  棚区分
 * @param color 色なければ空文字('')
 * @param category 衣装カテゴリなければ空文字('')
 *
 */
function addcartlistclothes(id,num){
	DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)


	// 自分の色番号を引く
	id-=clothesColor[num*colorNum];
	// Nowの色番号を加える
	id+=colorNow[num];

	cartflg = 0;

	//衣装を所持しているかチェックを行う
	ClothesHaveCheck.checkClothes(callback4,id);

    if(cartflg == 0){
    	ChangeRecommend(id, 2);
    	Cart.addcart(callback, id, 0);
    }else{
    	if(confirm("You already own this item. Are you would like to purchase it anyways?") == true){
    		ChangeRecommend(id, 2);
    		Cart.addcart(callback, id, 0);
    	}
    }

}

function addcartlistclothes2(id){
	DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)


	cartflg = 0;

	//衣装を所持しているかチェックを行う
	ClothesHaveCheck.checkClothes(callback4,id);

    if(cartflg == 0){
    	Cart.addcart(callback, id, 0);
    }else{
    	if(confirm("You already own this item. Are you would like to purchase it anyways?") == true){
    		Cart.addcart(callback, id, 0);
    	}
    }

}

function callback4(rtnData){
	if(rtnData == 0){
		cartflg = 1;
	}
}

 /**
 * 買い物かごに家具を加える
 * @param id 商品のID
 * @param name 商品名
 * @param price Price
 * @param imageUrl 画像URL
 */
function addcartlistfurniture(id){
    Cart.addcart(callback, id, 1);
}

 /**
 * 買い物かごにItemを加える
 * @param id 商品のID
 * @param name 商品名
 * @param price Price
 * @param imageUrl 画像URL
 * @param gameid ゲームID
 */
function addcartlistitem(id){
    Cart.addcart(callback, id, 2);
}

 /**
 * 買い物かごに加えた結果を判定する
 * @param backdata 結果(0:成功 -1:同じものは追加できません(衣装) -2:失敗 1:買い物かごがいっぱい)
 * 結果(0:正常 -1:追加できない（すでにもっている） -3:買い物かごがいっぱい -4:追加できない（既に所持している衣装）)
 */
function callback(backdata){
	if(backdata == 0){
		//alert("買い物かごに入れました");
		alert("The item has been added in your Shopping Cart.");
	}else if(backdata == -1){
		//alert("既に買い物かごに入っています");
		alert("This item is already in your Shopping Cart.");
	}else if(backdata == -3){
		//alert("買い物かごががいっぱいです");
		alert("Your Shopping Cart is full.");
	}else{
		//alert("追加に失敗しました");
		alert("Failed to add in your Shopping Cart.");
	}
}

 /**
 * 買い物かごから指定のIDをもつItemを削除する
 * @param itemid ItemID
 * @param name   Itemの分類名(clothes, furniture, item)
 *
 */
function removelist(itemid, name){
    document.itemlist.itemid = itemid;
    document.itemlist.listname = name;

    document.itemlist.submit();
}

 /**
 * Gift画面用の
 * Item情報をセットする
 *
 */
function itemput(accountid, itemid, itemname, category, color, createuser, price, shopimgurl){
    document.itemlist.itemid.value = itemid;
	document.itemlist.itemname.value =itemname;
	document.itemlist.category.value = category;
	document.itemlist.color.value = color;
	document.itemlist.createuser.value = createuser;
	document.itemlist.price.value = price;
	document.itemlist.shopimgurl.value = shopimgurl;
    return;
}


 /**
 * 試着衣装にItemを加える
 * @param URL Item画像URL
 * @param itemid ItemID
 * @param itemname Item
 * @param category カテゴリ名
 * @param price Price
 * @param createuser 作成者
 *
 */
function addwearlist(URL, itemid, itemname, category, price, createuser, category_id, account_id){
    document.itemlist.itemid = itemid;
    document.itemlist.itemname = itemname;
    document.itemlist.category = category;
    document.itemlist.price = price;
    document.itemlist.createuser = createuser;

    document.itemlist.action = URL;
    //document.itemlist.submit();
    location.href=URL+paramset(itemid, itemname, category, category_id, account_id);
}

function paramset(itemid, itemname, category, account_id){
    var param = "";

    // 文字列生成
    /*
     * ?hand=4&body=2&hand=3…の形に直す
     * 引数引渡しが疑問
     */
    param = "?";
    param = param + category + "=" + category_id + "&";

    return param;
}

function LoadEquipAbatar(){
	var result;
	var str = new Array("face=","&hair=","&accef=","&acceh=","&top=","&coat=","&back=","&bottom=","&accen=","&bg=","&shoe=","&fg=");

	result="face=0";
	for(i=1;i<12;i++){
		if(equip_id[i]!=0){
			result = result+str[i]+equip_id[i];
		}
	}
}

function reqdelete() {

}

function OpenWinBuyAndPresent(URL,name)
{
	//return window.open(URL, name,'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=600');
	location.href = URL;
}


function OpenWin(URL)
{
	window.open(URL,"gacha",'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=700');
}

 /**
 * フォームを送信する
 * @param URL URL
 * @param obj フォームオブジェクト
 *
 */
function tosubmit(URL, obj)
{
	if(regchkflg == 0 && double == 0){
		// 入力エラーがない場合
	    obj.action = URL;
	    double = 1;
		obj.submit();
	}else{
		// 入力エラーがある
	}
}

 /**
 * フレンド紹介を表示する
 * @param URL URL
 * @param obj フォームオブジェクト
 *
 */
function toFreindView(URL, obj){
	var param = 'friend';

	window.open(URL, param, 'resizable=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=500,height=600');
	}

 /**
 * タイムカウントを行う
 * @param URL URL
 * @param obj フォームオブジェクト
 *
 */
function timeout(URL, count, obj) {
    setTimeout(tosubmit(URL, obj), count);
}

function pettyChange(price){
	PChange.addPettyCoin(price);
}

 /**
 * （アカウント管理）
 * Modalダイアログの時ウィンドウをClose
 * @param inputvalue 親ウィンドウに返す値
 *
 */
    function winclose(inputvalue){
        returnValue = inputvalue;
        self.window.close();
    }

function jump_otherpage( aPageNum, aIndex ) {
	var obj = document.getElementById( "pageNumber" );
	var obj1 = document.getElementById( "actionName" );

    obj1.value = "LIST";
	obj.value = aPageNum - 1;
	document.eventForm.submit();
}

 /**
 * （SHOP）
 * M.shimoda：試着履歴の初期表示
 *
 */
function firstHistry()
{
	var sichaku = getCookieCommon("sichaku");
	if (sichaku == "") {
		return;
	} else {
		setEquipInfoHTML(sichaku);
	}
	ChangeHistory();
	refreshEquipAbatar();
	heightLine();
}

//着せ替え⇒ログアウト⇒ログイン⇒着せ替え対応
function setEquipInfoHTML(sichaku) {
	var sichakuArr = sichaku.split("&");
	if(sichaku.indexOf('\t') != -1){
		sichakuArr = sichaku.split("\t");
	}
	var rirekiArr;

	for (i=0;i<sichakuArr.length;i++) {
		rirekiArr = sichakuArr[i].split(",");
		if (rirekiArr[0] != "") {
			// rirekiArr[0]がID
			if(equip_id[rirekiArr[4]] != rirekiArr[0]){
				equip_id[rirekiArr[4]] = rirekiArr[0];
			}
		}
	}
}

 /**
 * （SHOP）
 * M.shimoda：試着履歴を変更する
 * @param num 色番号
 * @param color 色数
 * @param id 衣装ID
 * @param name 衣装名
 * @param url 衣装url
 * @param price Price
 * @param made 製作者名
 * @param equip 衣装装着箇所
 *
 */
function changeClothesRoom(id, name, price, made, equip, fileName, price_type_name)
{
	//ChangeRecommend(id, 1);
	ChangeEquipAbatar(id, equip);
	if (setSichaku(id, made, name, price, equip ,fileName, price_type_name)) {
		ChangeHistory();
	}
	//heightLine();
}

function ChangeHistory()
{
	var elem;
	var str;

// 現在どこまで格納されているかチェック
	var sichaku = getCookieCommon("sichaku");
	var sichakuArr = sichaku.split("&");
	if(sichaku.indexOf('\t') != -1){
		sichakuArr = sichaku.split("\t");
	}
	var sichakuFlg = 0;

	for (i = 0; i < sichakuArr.length; i++) {
		if (sichakuArr[i] != ",,,,,") {
			// Cookieに試着情報がある場合
			sichakuFlg = 1;
			break;
		}
	}

	if (sichakuFlg == 0) {
		// 試着履歴なし
		document.getElementById("sichaku0").style.visibility ="visible";
		document.getElementById("sichaku").style.visibility ="hidden";
	} else {
		document.getElementById("sichaku0").style.visibility ="hidden";
		document.getElementById("sichaku").style.visibility ="visible";
	}

	for (i = 0; i < sichakuArr.length; i++) {
		ShowRireki(i, sichakuArr[i]);
	}
}

/* レコメンド情報書き換え */
function ChangeRecommend(id, ptn)
{
	//if(ptn == 1) {
	//	document.getElementById('recomender').src = location.protocol + "//recommend.kbmj.com/scores/addscore/?score[id]=" + id;
	//} else {
	//	document.getElementById('recomender').src = location.protocol + "//recommend.kbmj.com/item/addrate/?score[id]=" + id;
	//}
//		alert(document.getElementById('recomender').src);
}

 /**
 * （SHOP）
 * M.shimoda：試着履歴を表示する
 * @param num 表示する箇所（equip）
 * @param rireki 履歴データ（,区切りで順にid, made, name, price, equip ,fileName）
 *
 */
function ShowRireki(num,rireki)
{
	var rirekiArr = rireki.split(",");

	if (rirekiArr[0] == "") {
		// IDが入っていない
		document.getElementById('try'+num).src = "http://img.tinierme.com/img/spacer.gif";
		document.getElementById('try'+num).title = "";
	} else {
		// 画像を表示
		document.getElementById('try'+num).src = "http://img.tinierme.com/"+rirekiArr[5];
		document.getElementById('try'+num).title = rirekiArr[2];
	}
}

 /**
 * （SHOP）
 * M.shimoda：装備状態の変更
 * @param id 衣装ID
 * @param equip 装備箇所
 *
 */
function ChangeEquipAbatar(id, equip){
	// 同じ衣装を装着していた場合は衣装を外す
	if(equip_id[equip]==id){
		if(equip!=0){
			EquipInfo.setEquipInfo(0,equip);
			equip_id[equip]=0;
		}
	}else{
		EquipInfo.setEquipInfo(id,equip);
		equip_id[equip]=id;
	}
	refreshEquipAbatar();
}
function refreshEquipAbatar() {

	var result;
	var str = new Array("face=","&hat=","&hair=","&accef=","&acceh=","&top=","&coat=","&back=","&bottom=","&accen=","&bg=","&shoe=","&fg=");

	result="face="+equip_id[0];
	for(i=1;i<13;i++){
		if(equip_id[i]!=0){
			result = result+str[i]+equip_id[i];
		}
	}
	avatar_cb.location.href = "http://www.tinierme.com/tinierme/getAvatarClothes.do?mode=fitting&"+result;
//	document.getElementById('avatar_cb').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="110" height="160" id="avatar" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value=http://image2.tinierme.com/avatar.swf?"' + result + '" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" /><embed src=http://image2.tinierme.com/avatar.swf?"' + result + '" menu="false" quality="high" bgcolor="#ffffff" width="110" height="160" name="avatar" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
}


/* 調整（削除）js */
 /**
 * 欲しいものリストに加える
 * @param accountid アカウントID
 * @param itemid ItemID
 * @param category カテゴリ名
 *
 */
function addwantlist(itemid, categoryname){
	DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	wantflg = 0;

	if(categoryname == 1){
		ClothesHaveCheck.checkClothes(callback3,itemid);
	}

    if(wantflg == 0){
    	Want.addwant(callback2,itemid, categoryname);
    }else{
    	if(confirm("You already own this item. Are you would like to purchase it anyways?") == true){
    		Want.addwant(callback2,itemid, categoryname);
    	}
    }
}

function addwantlist2(id,num,categoryname){
	DWREngine.setTimeout(1000);		// DWR実行タイムアウト
    DWREngine.setAsync(false);		// 同期的に実行(false で同期)

	// 自分の色番号を引く
	id-=clothesColor[num*colorNum];
	// Nowの色番号を加える
	id+=colorNow[num];

	wantflg = 0;

	if(categoryname == 1){
		ClothesHaveCheck.checkClothes(callback3,id);
	}

    if(wantflg == 0){
    	Want.addwant(callback2,id, categoryname);
    }else{
    	if(confirm("You already own this item. Are you would like to purchase it anyways?") == true){
    		Want.addwant(callback2,id, categoryname);
    	}
    }
	ChangeMainFrameHeight();
}

 /**
 * 欲しいものリストに加えた結果を判定する
 * @param backdata 結果(0:成功 -3:その他エラー)
 *
 */
function callback2(backdata){
	if(backdata == 0){
		//alert("欲しいものリストに追加しました");
		alert("The item has been added to your Wish List.");
	}else if(backdata == -3){
		//alert("欲しいものリストに追加失敗しました");
		alert("Failed to add the item to your Wish List.");
	}
}

function callback3(back){
	if(back == 0){
		wantflg = 1;
	}
}

 /**
 * 購入画面へ遷移する
 *
 */
function dispbuy(URL,itemid){
    document.itemlist.itemid.value = itemid;
	document.itemlist.action = URL;
	//win = OpenWinBuyAndPresent('','buy');
	//document.itemlist.target = 'buy';
	document.itemlist.submit();
	/*if(win){
		win.focus();
	}*/
}

/**
* Gift画面へ遷移する
**/
function dispPresent(itemid) {
	if(itemid != 10386994 && itemid != 10387006) {
	    document.itemlist.itemid.value = itemid;
		document.itemlist.action = "/tinierme/disppresent.do";
		//win = OpenWinBuyAndPresent('','present');
		//document.itemlist.target = 'present';
		document.itemlist.submit();
		/*if(win){
			win.focus();
		}*/
	} else {
		//alert('福袋はGiftできません。');
		alert('A Lucky Bag cannot be sent as a Gift.');
	}
}

/**
 * Gift画面の内容をサブミットする
 * @param URL
 * @param destNickname
 * @param message
 */
function submitpresent(URL) {
	document.itemlist.nickname.value  = document.aform.textfield.value;
	document.itemlist.body.value = document.aform.message.value;
	document.itemlist.action = URL;

	DWREngine.setTimeout(1000);
	DWREngine.setAsync(false);


	if(double != 0){
		return;
	}
	double = 1;

	if(document.aform.textfield.value == ""){
		alert("You did not fill in the required fields.");
		double = 0;
		return;
	}

// ニックネームは禁止文字チェックを行わない
//	NG.checkBadLanguage(cbBadLang,document.aform.textfield.value);
//	if(kinsiFlg == true){
//		alert(document.aform.textfield.value+"は使用禁止文字列です");
//		double = 0;
//		return;
//	}

	NG.checkBadLanguage(cbBadLang,document.aform.message.value);
	if(kinsiFlg == true){
		//alert("Messageに使用禁止文字列が含まれています");
		alert("The message contains forbidden words.");
		double = 0;
		return;
	}


	if(betweenchk(document.aform.textfield.value, -1, 16)){
		//alert("To:は全角16文字以下でご入力ください");
		alert("The \"To\" field can only contain a maximum of 32 characters.");
		double = 0;
		return;
	}

	if(betweenchk(document.aform.message.value, -1, 512)){
		//alert("Message入力可能文字数は全角512文字までです");
		alert("The message can only contain a maximum of 1024 characters.");
		double = 0;
		return;
	}

	NickNameCheck.isNickName(cbNickName,document.aform.textfield.value);
}

function cbNickName(ret)
{
	if(ret==true){
		ClothesHaveCheck.checkClothesFriend(cbHaveClothes,document.itemlist.nickname.value,document.itemlist.itemid.value);
	}else{
		//alert("存在しないニックネームです");
		alert("That Nickname does not exist.");
		double = 0;
		return;
	}
}

function cbHaveClothes(result)
{
	if(result == 0){
		if(confirm("You already own this item. Are you would like to purchase it anyways?") == false){
			double = 0;
			return;
		}
	}else if(result == -1){
		//alert("衣装情報の取得に失敗しました");
		alert("Failed to retrieve the item information.");
		double = 0;
		return;
	}
	double = 1;
	document.itemlist.submit();
}

function noLogin()
{
	//alert("ログインして下さい");
	alert("Please log in.");
}

function cbBadLang(result)
{
	kinsiFlg=result;
}

/**
 * G-Coins購入ボタン押下時のログイン判定を行う
 */
function GcoinLoginChk(){
	DWREngine.setTimeout(1000);		// DWRタイムアウト時間設定
	DWREngine.setAsync(true);		// 非同期的に実行(trueで非同期)

	// ログインされているかチェック
	isLogin.checkLogin(loginchkcallback);
}

/**
 * ログイン判定結果を受け取る
 */
function loginchkcallback(result){
	if(result == true){
		// G-Coins購入画面をポップアップする
		if( allianceType == 1 ){
			window.open('http://www.gungho.jp/selfytown/gcoin.html', 'G-Coins購入');
		} else {
			window.open('https://www.tinierme.com/tinierme/html/charges/account3.html', 'G-Coins購入');
		}
	} else {
		//alert('ログインして下さい。');
		alert('Please log in.');
	}
}

/**
 * レコメンドデータ表示処理
 * @param num 表示位置番号
 * @param color 色番号
 * @param id 衣装ID
 * @param colorFlg 色選択ありかなしかのフラグ
 *
 */
function dispRecommend(num, color, id, cName, colorFlg) {

	if(!recFlg) {
		recFlg = true;
		// 初期文言を非表示
		document.all('recHead1').style.display = "none";
		// 選択商品名を表示
		document.all('recHead2').style.display = "block";
		// 衣装名の削除
		elem = document.getElementById('itemName');
		if(elem.lastChild != null) {
			elem.removeChild(elem.lastChild);
		}

		if(colorFlg) {
			// 自分の色番号を引く
			id-=clothesColor[num*color];
			// Nowの色番号を加える
			id+=colorNow[num];
			if(colorNow[num] == 1) {
				colorStr = "黒";
			} else if(colorNow[num] == 2) {
				colorStr = "赤";
			} else if(colorNow[num] == 3) {
				colorStr = "青";
			} else if(colorNow[num] == 4) {
				colorStr = "黄";
			} else if(colorNow[num] == 5) {
				colorStr = "緑";
			} else {
				colorStr = "白";
			}
			str = document.createTextNode(cName + '・' + colorStr);
		} else {
			str = document.createTextNode(cName);
		}

		// 衣装名の表示
		elem.appendChild(str);

		// レコメンドデータ取得・表示
		getRecommendData(id);
		for(i=0; i<4; i++) {
			if(document.getElementsByName('cloth' + i)[0] != null) {
				document.getElementsByName('cloth' + i)[0].style.borderStyle = "";
				document.getElementsByName('cloth' + i)[0].style.borderColor = "";
				document.getElementsByName('cloth' + i)[0].style.borderWidth = "";
				document.getElementsByName('clothspan' + i)[0].style.borderColor = "#eeeeee";
			} else {
				break;
			}
		}
		document.getElementsByName('cloth' + num)[0].style.borderStyle = "solid";
		document.getElementsByName('cloth' + num)[0].style.borderColor = "#ff9900";
		document.getElementsByName('cloth' + num)[0].style.borderWidth = "1px";
		document.getElementsByName('clothspan' + num)[0].style.borderColor = "#ff9900";
	}
}

/**
 * レコメンドデータ取得
 */
function getRecommendData(clothesId) {

	//DWREngine.setTimeout(1000);
	//DWREngine.setAsync(false);

	// レコメンド情報取得先URI
	//uri = "/recommend/similarity/?id[]=" + clothesId + "&count=4";

	// DWRでレコメンドXMLを取得する
	//GetRecommendXml.getRecommendXml(callBackGetRecommendData, 'recommend.kbmj.com', 80, uri, 'http://www.tinierme.com/tinierme/top.html');
}


/**
 * レコメンドXML取得DWRコールバック関数
 */
function callBackGetRecommendData(result) {

	// XMLを読み込む
	var obXML = new ActiveXObject('microsoft.XMLDOM');
	obXML.async = false;
	obXML.loadXML(result);
	var Rnode = obXML.documentElement;

	// レコメンド衣装数
	var clothesNum = Rnode.childNodes.length;

	// 衣装ID配列を生成
	var clothesIdArray = new Array(clothesNum);
	if(Rnode.hasChildNodes()) {
		for(i=0; i < clothesNum; i++) {
			clothesIdArray[i] = Rnode.childNodes.item(i).childNodes.item(0).text;
		}
		GetRecommendClothesData.getRecommendClothesData(callBackGetRecommendClothesData, clothesIdArray);
	} else {
		for(i=0;i<recommendList.length;i++){
			// 画像の削除
			document.getElementById('rec'+i).src = "http://img.tinierme.com/img/spacer.gif"

			// 衣装名削除
			elem = document.getElementById('rec'+i+'1');
			elem.removeChild(elem.lastChild);

			// 製作者の削除
			elem = document.getElementById('rec'+i+'2');
			if(elem.lastChild != null) {
				elem.removeChild(elem.lastChild);
			} else {
			}
			document.all('rec'+i+'2').style.display = "none";

			// 販売中の衣装の場合
			if(document.all('recFinish'+i).style.display == "none") {
				// 購入する｜Gift の非表示
				document.all('rec'+i+'3').style.display = "none";
				document.all('rec'+i+'4').href = "";
				document.all('rec'+i+'5').href = "";

				// Priceの削除
				elem = document.getElementById('rec'+i+'6');
				elem.removeChild(elem.lastChild);

				// 買い物かご、欲しいものリストに追加 の非表示
				document.all('rec'+i+'7').style.display = "none";
				document.all('rec'+i+'8').href = "";
				document.all('rec'+i+'9').href = "";
			} else {
				// 販売終了文言の非表示
				document.all('recFinish'+i).style.display = "none";
			}
		}
		recommendList = new Array();
		recFlg = false;
	}
}

/**
 * レコメンド衣装データ取得DWRコールバック関数
 * @param dataList レコメンドデータリスト
 *
 */
function callBackGetRecommendClothesData(dataList) {
	for(i=0;i<recommendList.length;i++){
		// 画像の削除
		document.getElementById('rec'+i).src = "http://img.tinierme.com/img/spacer.gif"

		// 衣装名削除
		elem = document.getElementById('rec'+i+'1');
		elem.removeChild(elem.lastChild);

		// 製作者の削除
		elem = document.getElementById('rec'+i+'2');
		if(elem.lastChild != null) {
			elem.removeChild(elem.lastChild);
		}
		document.all('rec'+i+'2').style.display = "none";
		// 販売中の衣装の場合
		if(document.all('recFinish'+i).style.display == "none") {
			// 購入する｜Gift の非表示
			document.all('rec'+i+'3').style.display = "none";
			document.all('rec'+i+'4').href = "";
			document.all('rec'+i+'5').href = "";

			// Priceの削除
			elem = document.getElementById('rec'+i+'6');
			elem.removeChild(elem.lastChild);

			// 買い物かご、欲しいものリストに追加 の非表示
			document.all('rec'+i+'7').style.display = "none";
			document.all('rec'+i+'8').href = "";
			document.all('rec'+i+'9').href = "";
		} else {
			// 販売終了文言の非表示
			document.all('recFinish'+i).style.display = "none";
		}
	}
	for(j=0;j<dataList.length;j++){
		ShowRecommend(j, dataList[j]);
	}
	recommendList = dataList;
	recFlg = false;
}

 /**
 * （SHOP）
 * レコメンドを表示する
 * @param num 表示する箇所（0～4）
 *
 */
function ShowRecommend(num, data)
{
	var cornerName = new Array("face","hat","hair","accef","acceh","top","coat","back","bottom","accen","bg","shoe","fg");

	document.getElementById('rec'+num+'0').href = "javascript:ChangeEquipAbatar("+data.clothesId+","+ data.equipPartsId +")";
	// 画像を表示
	document.getElementById('rec'+num).src = "http://img.tinierme.com/shop/clothes/"+cornerName[data.equipPartsId]+"/"+data.shopImageUrl;

	// 衣装名の表示
	elem = document.getElementById('rec'+num+'1');
	str = document.createTextNode(data.clothesName);
	elem.appendChild(str);

	// 製作者 の表示
	if(data.createUser != "GCREST"){
		elem = document.getElementById('rec'+num+'2');
		str = document.createTextNode("製作者："+data.createUser);
		elem.appendChild(str);
	    document.all('rec'+num+'2').style.display = "block";
	}
	// 販売中の場合
	if(data.shopSalesFlg == 1) {
		// 購入する｜Gift の表示
		document.all('rec'+num+'3').style.display = "block";
		if(distinct){
			document.all('rec'+num+'4').href = "javascript:dispbuyEx2("+data.clothesId+")";
			document.all('rec'+num+'5').href = "javascript:dispPresent("+data.clothesId+")";
		}else{
			document.all('rec'+num+'4').href = "javascript:noLogin()";
			document.all('rec'+num+'5').href = "javascript:noLogin()";
		}

		// Priceの表示
		elem = document.getElementById('rec'+num+'6');
		str = document.createTextNode("Price："+data.price+" "+data.price_type_name);
		elem.appendChild(str);


		// 買い物かご、欲しいものリストに追加 の表示
		document.all('rec'+num+'7').style.display = "block";
		if(distinct){
			document.all('rec'+num+'8').href = "javascript:addcartlistclothes2("+data.clothesId+")";
			document.all('rec'+num+'9').href = "javascript:addwantlist("+data.clothesId+",1)";
		}else{
			document.all('rec'+num+'8').href = "javascript:noLogin()";
			document.all('rec'+num+'9').href = "javascript:noLogin()";
		}
	// 販売終了の場合
	}else if(data.shopSalesFlg == 0) {
		document.all('recFinish'+num).style.display = "block";
	}
}


 /**
 * （SHOP）
 * 新着衣装SHOP
 * 並び順の切替のアクションを行う
 *
 */
function clothMenuactionCategory(){
	clothLinktoSubmitCategoryMenu(nowCorner, nowShelf)
}

 /**
 * （SHOP）
 * 新着衣装SHOP(ソート)
 * 並び順の切替のアクションを行う
 *
 */
function clothMenuactionCategorySort(){
	nowPage=1;
	var category = document.getElementById("menu1").value;
	var sortType = document.getElementById("menu2").value;
	var findStr = document.getElementById('inputFindStr').value;
	var allianceType = document.getElementById('allianceType').value;
	if (clothesPageFlg == 0) {
		ShopData.getNewClothesList(cbClothesList, nowCorner, nowShelf, 1, sortType, category, findStr, allianceType);
	} else {
		ShopData.getClothesList(cbClothesList, nowCorner, nowShelf, 1, sortType, category, findStr, allianceType);
	}
}


function clothChangeNextPage(page) {
	if (nowPage + page < 1 || nowPage + page > maxPage) {
		return;
	}
	var category = document.getElementById("menu1").value;
	var sortType = document.getElementById("menu2").value;
	var findStr = document.getElementById('inputFindStr').value;
	var allianceType = document.getElementById('allianceType').value;
	nowPage = parseInt(nowPage+page);
	document.getElementById('menuPage').value = nowPage;
	if (clothesPageFlg == 0) {
		ShopData.getNewClothesList(cbClothesList, nowCorner, nowShelf, nowPage, sortType, category, findStr, allianceType);
	} else {
		ShopData.getClothesList(cbClothesList, nowCorner, nowShelf, nowPage, sortType, category, findStr, allianceType);
	}
}

 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param corner コーナー区分
 * @param shelf 棚区分
 * @param page ページ
 * @param category Category
 *
 */
function clothLinktoSubmitCategory() {
	nowPage=parseInt(document.form2.menuPage.value);
	var category = document.getElementById("menu1").value;
	var sortType = document.getElementById("menu2").value;
	var findStr = document.getElementById('inputFindStr').value;
	var allianceType = document.getElementById('allianceType').value;
	if (clothesPageFlg == 0) {
		ShopData.getNewClothesList(cbClothesList, nowCorner, nowShelf, nowPage, sortType, category, findStr, allianceType);
	} else {
		if(isNaN(nowPage)){ nowPage = 0; }
		ShopData.getClothesList(cbClothesList, nowCorner, nowShelf, nowPage, sortType, category, findStr, allianceType);
	}
}

 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param corner コーナー区分
 * @param shelf 棚区分
 *
 */
function clothLinktoSubmitCategoryMenu(corner, shelf) {
	nowPage = 1;
	nowCorner=corner;
	nowShelf=shelf;
	var category = document.getElementById("menu1").value;
	var sortType = document.getElementById("menu2").value;
	document.getElementById('inputFindStr').value = "";
	var allianceType = document.getElementById('allianceType').value;
	if (clothesPageFlg == 0) {
		ShopData.getNewClothesList(cbClothesList, corner, shelf, 1, sortType, category, "", allianceType);
	} else {
		ShopData.getClothesList(cbClothesList, corner, shelf, 1, sortType, category, "", allianceType);
	}

/*
以下、グーグルアナリティクス　ビーコン射出
*/
		if( (nowCorner == 0) && (nowShelf == 0) )
		{
		pageTracker._trackPageview('/clothShop/inner');
		//alert(' Shirts/Blouses');
		}
		if( (nowCorner == 0) && (nowShelf == 1) )
		{
		pageTracker._trackPageview('/clothShop/jacketCoat');
		//alert('ジャケコート');
		}
		if( (nowCorner == 4) && (nowShelf == 0) )
		{
		pageTracker._trackPageview('/clothShop/bandanna');
		//alert('バンダナ');
		}
		if( (nowCorner == 4) && (nowShelf == 2) )
		{
		pageTracker._trackPageview('/clothShop/glasses');
		//alert('グラス');
		}
		if( (nowCorner == 4) && (nowShelf == 5) )
		{
		pageTracker._trackPageview('/clothShop/necklace');
		//alert('ネックレス');
		}
		if( (nowCorner == 4) && (nowShelf == 3) )
		{
		pageTracker._trackPageview('/clothShop/hands');
		//alert('手系');
		}
		if( (nowCorner == 4) && (nowShelf == 6) )
		{
		pageTracker._trackPageview('/clothShop/shoes');
		//alert('靴');
		}
		if( (nowCorner == 4) && (nowShelf == 4) )
		{
		pageTracker._trackPageview('/clothShop/theBack');
		//alert('Footwear');
		}
		if( (nowCorner == 1) && (nowShelf == 0) )
		{
		pageTracker._trackPageview('/clothShop/pantsSkirt');
		//alert(' Trousers/Skirts');
		}
		if( (nowCorner == 2) && (nowShelf == 0) )
		{
		pageTracker._trackPageview('/clothShop/hairStyle');
		//alert('髪型');
		}
		if( (nowCorner == 3) && (nowShelf == 0) )
		{
		pageTracker._trackPageview('/clothShop/faceStyle');
		//alert(' Facial features');
		}

}

function cbClothesList(result) {

	if (result != null) {
		maxPage=result.pageNum;
		var itemList = result.itemGroups;
		var div = 1;
		var recoFlg = false;//recommend

		var subMenuList = document.getElementById('subMenuList');
		if (result.clothesCorner == 0) {
			div=3;
		} else if (result.clothesCorner == 1) {
			div=3;
		} else if (result.clothesCorner == 2) {
			div=6;
		}

		var itemArea = document.getElementById('itemArea');

		for(var i=0;i<8;i++){

			var li = document.getElementById('item_group_'+i);
//			if(!li || li == null){
//				alert('li');
//				li = document.createElement('li');
//				li.id = 'item_group_'+i;
//				li.className = 'heightLine-1';
//				li.style.height = '278px';
//				li.style.display = 'none';
//				itemArea.appendChild(li);
//			}else{
				li.style.display ='none';
//			}

			var elemName = document.getElementById('itemName'+i);
//			if(elemName == null){
//				elemName = document.createElement('span');
//				elemName.id = 'itemName'+i;
//				li.appendChild(elemName);
//			}
			if(elemName.lastChild != null) {
				elemName.removeChild(elemName.lastChild);
			}

			var elemPrice = document.getElementById('itemPrice'+i);
//			if(elemPrice == null){
//				elemPrice = document.createElement('span');
//				elemPrice.id = 'itemPrice'+i;
//				li.appendChild(elemPrice);
//			}
			if(elemPrice.childNodes.length > 0) {
				for(j=0;j<elemPrice.childNodes.length;j++){
					elemPrice.removeChild(elemPrice.childNodes[j]);
				}
			}
			var elemColor = document.getElementById('clothColorSelector'+i);
//			if(elemColor == null){
//				elemColor = document.createElement('p');
//				elemColor.id = 'clothColorSelector'+i;
//				elemColor.className = 'clothColors';
//				li.appendChild(elemColor);
//			}
			while(1) {
				if(elemColor.lastChild != null) {
					elemColor.removeChild(elemColor.lastChild);
				} else {
					break;
				}
			}
//			var elemClothImg = document.getElementById('itemMainImg'+i);
//			if(elemClothImg == null){
//				elemClothImg = document.createElement('img');
//				elemClothImg.id = 'itemMainImg'+i;
//				li.appendChild(elemClothImg);
//			}
			var elem = document.getElementById('cloth'+i);
//			if(elem == null){
//				elem = document.createElement('img');
//				elem.id = 'cloth'+i;
//				var span = document.createElement('span');
//				span.id = 'clothspan'+i;
//				span.appendChild(elem);
//				li.appendChild(span);
//			}

			if(i < itemList.length){
				var itemGroup = itemList[i];

				elem.style.visibility = 'visible';
				var itemDetail = document.getElementById('itemDetailList'+i);
//				if(itemDetail == null){
//					itemDetail = document.createElement('ul');
//					li.appendChild(itemDetail);
//				}
				itemDetail.className = 'shopItemCtrlBtn';
				itemDetail.style.visibility='visible';

				var itemBtns = document.getElementById('itemDetailListBtnTry'+i);
//				if(itemBtns == null){
//					itemBtns = document.createElement('ul');
//					li.appendChild(itemBtns);
//				}
				itemBtns.style.visibility='visible';

				elem.src = "http://img.tinierme.com/"+itemGroup.colorList[0].clothesUrl;
				elem.alt = itemGroup.clothesName;
				elem.title = itemGroup.clothesName;

				// cloth name
				var strName = document.createTextNode(itemGroup.clothesName);
				elemName.appendChild(strName);

				// price
				if(itemGroup.price_type == '0'){
					elemPrice.innerHTML = itemGroup.display_price;
				}else{
					elemPrice.innerHTML = '<b>'+itemGroup.display_price+'</b>';
				}

				// color selector
                var colorList = itemGroup.colorList;

                if(colorList.length > 1){
                	elemColor.innerHTML = '<img src="http://img.tinierme.com/common/img/renewal/shop/selfy/shop_selfy_color_txt.gif" alt="color:" />';

                	var colors = '';

                    for(var j=0;j<colorList.length;j++){

                    	var colorInfo = colorList[j];

    					var str = "ChangeClothesColor(" + i + "," + colorInfo.clothesId
    					+ ",'" + itemGroup.escapedName + "'," + itemGroup.price + ",'"
    					+ itemGroup.createUser + "'," + itemGroup.equipPartsId + ",'"
    					+ colorInfo.clothesUrl + "'," + colorInfo.color + ")";

    					colors += '<img src="http://img.tinierme.com/shop/img/bt_color_'
    						+colorInfo.color + '.png" onClick="' + str + '" class="colorImg"/>';
                    }
                    elemColor.innerHTML += '<span>'+colors+'</span>';
                    //elemColor.style.display = 'block';
                }else{
                	//elemColor.style.display = 'none';
                	elemColor.innerHTML = '';
                }

                // try on
                var elemClothImg = document.getElementById('itemMainImg'+i);
				elemClothImg.href='javascript:changeClothesRoom('
					+ itemGroup.colorList[0].clothesId + ',"'
					+ itemGroup.escapedName + '",'
					+ itemGroup.price + ',"'
					+ itemGroup.createUser + '",'
					+ itemGroup.equipPartsId + ',"'
					+ itemGroup.colorList[0].clothesUrl + '","'
					+ itemGroup.price_type_name +'")';

				// recommend
				// document.getElementById('cloth'+i/div).onclick = new Function("clothDispRecommendCategory(" + i/div + "," + clothesList[i].color + "," + clothesList[i].clothesId + ",'" + clothesList[i].clothesName + "'," + recoFlg + ")");

				if (distinct) {
					// ログインしている場合は購入・Gift・買い物かご・欲しいものリストの処理を変更
					var buy = document.getElementById('kounyuu'+i);
//					if(buy == null){
//						buy = document.createElement('a');
//						buy.id = 'kounyuu'+i;
//					}
					buy.href = 'javascript:dispbuyEx2(' + itemGroup.colorList[0].clothesId + ')';
					var gift = document.getElementById('present'+i);
//					if(gift == null){
//						gift = document.createElement('a');
//						gift.id = 'present'+i;
//					}
					gift.href = 'javascript:dispPresent(' + itemGroup.colorList[0].clothesId + ')';
					var basket = document.getElementById('kago'+i);
//					if(basket == null){
//						basket = document.createElement('a');
//						basket.id = 'kago'+i;
//					}
					basket.href = 'javascript:addcartlistclothes2(' + itemGroup.colorList[0].clothesId + ')';
					var wish = document.getElementById('addWant'+i);
//					if(wish == null){
//						wish = document.createElement('a');
//						wish.id = 'addWant'+i;
//					}
					wish.href = 'javascript:addwantlist(' + itemGroup.colorList[0].clothesId + ', 1)';
				}
				li.style.display ='block';
			}
		}
/*
		for (i=0;i<8*div;i++) {
			// エレメント削除
			var elem = document.getElementById('cloth'+i/div);

			var elemName = document.getElementById('itemName'+i/div);
			if(elemName.lastChild != null) {
				elemName.removeChild(elemName.lastChild);
			}

			var elemPrice = document.getElementById('itemPrice'+i/div);
			if(elemPrice.childNodes.length > 0) {

				for(j=0;j<elemPrice.childNodes.length;j++){
					elemPrice.removeChild(elemPrice.childNodes[j]);
				}
			}
			var elemColor = document.getElementById('clothColorSelector'+i/div);
			while(1) {
				if(elemColor.lastChild != null) {
					elemColor.removeChild(elemColor.lastChild);
				} else {
					break;
				}
			}
			var elemClothImg = document.getElementById('itemMainImg'+i/div);
			if (i<clothesList.length) {
				// 衣装がある場合はエレメント追加
				elem.style.visibility="visible";
				document.getElementById('itemDetailList'+i/div).style.visibility="visible";
				document.getElementById('itemDetailListBtnTry'+i/div).style.visibility='visible';
				elem.src = "http://img.tinierme.com/"+clothesList[i].clothesUrl;
				elem.alt = clothesList[i].clothesName;
				elem.title = clothesList[i].clothesName;

				var strName = document.createTextNode(clothesList[i].clothesName);
				// 衣装名の表示
				elemName.appendChild(strName);

				//var strPrice = document.createTextNode("Price："+clothesList[i].display_price);
				// Priceの表示
				//elemPrice.appendChild(strPrice);
                elemPrice.innerHTML = clothesList[i].display_price;

				// 色の表示
				if (result.clothesCorner == 0 || result.clothesCorner == 1) {
					elemColor.innerHTML = '<img src="http://img.tinierme.com/shop/img/shop_colorSelect_title1.gif" alt="color:" width="33" height="10" /> ';
					for (j=0;j<3;j++) {
						var str = "ChangeClothesColor(" + i/div + "," + + clothesList[i+j].clothesId + ",'" + clothesList[i+j].escapedName + "'," + clothesList[i+j].price + ",'" + clothesList[i+j].createUser + "'," + clothesList[i+j].equipPartsId + ",'" + clothesList[i+j].clothesUrl + "'," + clothesList[i+j].color + ")";
						elemColor.innerHTML += '<img src="http://img.tinierme.com/shop/img/bt_color_' +clothesList[i+j].color + '.png" onClick="' + str + '" class="colorSelectorImg" /> ';
					}
					recoFlg=true;
				} else if (result.clothesCorner == 2) {
					elemColor.innerHTML = '<img src="http://img.tinierme.com/shop/img/shop_colorSelect_title1.gif" alt="color:" width="33" height="10" /> ';
					for (j=0;j<6;j++) {
						var str = "ChangeClothesColor(" + i/div + "," + + clothesList[i+j].clothesId + ",'" + clothesList[i+j].escapedName + "'," + clothesList[i+j].price + ",'" + clothesList[i+j].createUser + "'," + clothesList[i+j].equipPartsId + ",'" + clothesList[i+j].clothesUrl + "'," + clothesList[i+j].color + ")";
						elemColor.innerHTML += '<img src="http://img.tinierme.com/shop/img/bt_color_' +clothesList[i+j].color + '.png" onClick="' + str +'" class="colorSelectorImg" /> ';
					}
					recoFlg=true;
				}
				elemClothImg.href='javascript:changeClothesRoom(' + clothesList[i].clothesId + ',"' + clothesList[i].escapedName + '",' + clothesList[i].price + ',"' + clothesList[i].createUser + '",' + clothesList[i].equipPartsId + ',"' + clothesList[i].clothesUrl + '","'+ clothesList[i].price_type_name +'")';

				// osususme document.getElementById('cloth'+i/div).onclick = new Function("clothDispRecommendCategory(" + i/div + "," + clothesList[i].color + "," + clothesList[i].clothesId + ",'" + clothesList[i].clothesName + "'," + recoFlg + ")");
				if (distinct) {
					// ログインしている場合は購入・Gift・買い物かご・欲しいものリストの処理を変更
					document.getElementById('kounyuu'+i/div).href = 'javascript:dispbuyEx2(' + clothesList[i].clothesId + ')';
					document.getElementById('present'+i/div).href = 'javascript:dispPresent(' + clothesList[i].clothesId + ')';
					document.getElementById('kago'+i/div).href = 'javascript:addcartlistclothes2(' + clothesList[i].clothesId + ')';
					document.getElementById('addWant'+i/div).href = 'javascript:addwantlist(' + clothesList[i].clothesId + ', 1)';
				}

			} else {
				document.getElementById('itemDetailList'+i/div).style.visibility="hidden";
				document.getElementById('itemDetailListBtnTry'+i/div).style.visibility='hidden';
				elem.src = "http://img.tinierme.com/img/spacer.gif";
				elem.alt = "";
				elem.title = "";
				elemClothImg.href = "javascript:void(0);";
				document.getElementById('cloth'+i/div).onclick = new Function("void(0);");
				document.getElementById('cloth'+i/div).style.visibility="hidden";
			}

			if (result.clothesCorner == 0 || result.clothesCorner == 1) {
				i+=2;
			} else if (result.clothesCorner == 2) {
				i+=5;
			}
		}
		*/
		// total count
		var elemNum = document.getElementById('itenNum');
		elemNum.removeChild(elemNum.lastChild);
		elemNum.appendChild(document.createTextNode("There are " + result.clothesNum + " Items."));

		// ページ切り替え部分変更
		var elemSel = document.getElementById('menuPage');
		while(1) {
			if(elemSel.lastChild != null) {
				elemSel.removeChild(elemSel.lastChild);
			} else {
				break;
			}
		}
		for(i=1;i<=result.pageNum;i++){
			var opt = document.createElement('option');
			opt.setAttribute("value", i);
			if (i == nowPage) {
				opt.setAttribute("selected", "selected");
			}
			var str = document.createTextNode("Page "+ i + " of " + (result.pageNum));
			opt.appendChild(str);
			elemSel.appendChild(opt);
		}
	}
}

 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param URL URL
 * @param corner コーナー区分
 * @param shelf 棚区分
 * @param page ページ
 * @param sortType 並び替え順フラグ
 *  0: 新しいもの順 1: 古いもの順 2: 安い順 3: 高い順
 * @param category Category
 *
 */
function clothFindItemSubmit() {

	var str = document.getElementById('inputFindStr').value;

	if(str == "" || str == null){
		alert("Please enter a keyword to search for");
		return;
	} else {
		clothLinktoSubmitCategory();
		try{pageTracker._trackPageview('/clothShop/btnSearch');}catch(e){}
	}
}

 /**
 * （SHOP）
 * 新着衣装SHOP
 * 並び順の切替のアクションを行う
 *
 */
function menuactionCategory(URL,corner, shelf, page, sortType, category){
	var id = document.getElementById("menu1").value;
	linktoSubmitCategoryMenu(URL, corner, shelf, page, sortType, id);
}

 /**
 * （SHOP）
 * 新着衣装SHOP(ソート)
 * 並び順の切替のアクションを行う
 *
 */
function menuactionCategorySort(URL,corner, shelf, page, sortType, category){
	var id = document.getElementById("menu2").value;
	linktoSubmitCategory(URL, corner, shelf, page, id, category);
}

 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param URL URL
 * @param corner コーナー区分
 * @param shelf 棚区分
 * @param page ページ
 * @param sortType 並び替え順フラグ
 *  0: 新しいもの順 1: 古いもの順 2: 安い順 3: 高い順
 * @param category Category
 *
 */
function linktoSubmitCategory(URL, corner, shelf, page, sortType, category) {
	document.apage.corner.value = corner;
	document.apage.shelf.value = shelf;
	document.apage.page.value = page;
	document.apage.sortType.value = sortType;
	if(category == null){
		document.apage.category.value = 0;
	} else {
		document.apage.category.value = category;
	}
	document.apage.findStr.value = document.getElementById('inputFindStr').value;
	document.apage.action = URL;
	document.apage.submit();
}

 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param URL URL
 * @param corner コーナー区分
 * @param shelf 棚区分
 * @param page ページ
 * @param sortType 並び替え順フラグ
 *  0: 新しいもの順 1: 古いもの順 2: 安い順 3: 高い順
 * @param category Category
 *
 */
function linktoSubmitCategoryMenu(URL, corner, shelf, page, sortType, category) {
	document.apage.corner.value = corner;
	document.apage.shelf.value = shelf;
	document.apage.page.value = page;
	document.apage.sortType.value = sortType;
	if(category == null){
		document.apage.category.value = 0;
	} else {
		document.apage.category.value = category;
	}
	document.apage.findStr.value = "";
	document.apage.action = URL;
	document.apage.submit();
}

 /**
 * （SHOP）
 * 指定されたURLへサブミットを実行する
 * @param URL URL
 * @param corner コーナー区分
 * @param shelf 棚区分
 * @param page ページ
 * @param sortType 並び替え順フラグ
 *  0: 新しいもの順 1: 古いもの順 2: 安い順 3: 高い順
 * @param category Category
 *
 */
function findItemSubmit(URL, corner, shelf, page, sortType, category) {

	var str = document.getElementById('inputFindStr').value;

	if(str == "" || str == null){
		alert("Please enter a keyword in the search field.");
		return;
	} else {
		linktoSubmitCategory(URL, corner, shelf, page, sortType, category);
	}
}

 /**
 * （SHOP）
 * アバターの衣装をデフォルトの表示にする
 */
function clothDefaultwearCategory(id){
	avatar_cb.location.href = "http://www.tinierme.com/tinierme/getAvatarAccount.do?account_id="+id+"&bgFlg=1";
	EquipInfo.setDefaultWear();
	clothLinktoSubmitCategory();
}

 /**
 * （SHOP）
 * アバターの衣装をデフォルトの表示にする
 */
function defaultwearCategory(id,corner, shelf, page, sortType, category){
	avatar_cb.location.href = "http://www.tinierme.com/tinierme/getAvatarAccount.do?account_id="+id+"&bgFlg=1";
	EquipInfo.setDefaultWear();
	linktoSubmitCategory(corner, shelf, page, sortType, category);
}

/**
 * レコメンドデータ表示処理
 * @param num 表示位置番号
 * @param color 色番号
 * @param id 衣装ID
 * @param colorFlg 色選択ありかなしかのフラグ
 *
 */
function dispRecommendCategory(num, color, id, cName, colorFlg) {

	if(!recFlg) {
		recFlg = true;
		// 初期文言を非表示
		document.all('recHead1').style.display = "none";
		// 選択商品名を表示
		document.all('recHead2').style.display = "block";
		// 衣装名の削除
		elem = document.getElementById('itemName');
		if(elem.lastChild != null) {
			elem.removeChild(elem.lastChild);
		}

		if(colorFlg) {
			// 自分の色番号を引く
			id-=clothesColor[num*color];
			// Nowの色番号を加える
			id+=colorNow[num];
			if(colorNow[num] == 1) {
				colorStr = "黒";
			} else if(colorNow[num] == 2) {
				colorStr = "赤";
			} else if(colorNow[num] == 3) {
				colorStr = "青";
			} else if(colorNow[num] == 4) {
				colorStr = "黄";
			} else if(colorNow[num] == 5) {
				colorStr = "緑";
			} else {
				colorStr = "白";
			}
			str = document.createTextNode(cName + '・' + colorStr);
		} else {
			str = document.createTextNode(cName);
		}

		// 衣装名の表示
		elem.appendChild(str);

		// レコメンドデータ取得・表示
		getRecommendData(id);
		for(i=0; i<8; i++) {
			if(document.getElementsByName('cloth' + i)[0] != null) {
				document.getElementsByName('cloth' + i)[0].style.borderStyle = "";
				document.getElementsByName('cloth' + i)[0].style.borderColor = "";
				document.getElementsByName('cloth' + i)[0].style.borderWidth = "";
				document.getElementsByName('clothspan' + i)[0].style.borderColor = "#eeeeee";
			} else {
				break;
			}
		}
		document.getElementsByName('cloth' + num)[0].style.borderStyle = "solid";
		document.getElementsByName('cloth' + num)[0].style.borderColor = "#ff9900";
		document.getElementsByName('cloth' + num)[0].style.borderWidth = "1px";
		document.getElementsByName('clothspan' + num)[0].style.borderColor = "#ff9900";
	}
}
function clothDispRecommendCategory(num, color, id, cName, colorFlg) {

//	var colorStr;
//	if(!recFlg) {
//		recFlg = true;
//		// 初期文言を非表示
//		document.all('recHead1').style.display = "none";
//		// 選択商品名を表示
//		document.all('recHead2').style.display = "block";
//		// 衣装名の削除
//		elem = document.getElementById('itemName');
//		if(elem.lastChild != null) {
//			elem.removeChild(elem.lastChild);
//		}
//
//		if(colorFlg) {
//			if(color == 1) {
//				colorStr = "黒";
//			} else if(color == 2) {
//				colorStr = "赤";
//			} else if(color == 3) {
//				colorStr = "青";
//			} else if(color == 4) {
//				colorStr = "黄";
//			} else if(color == 5) {
//				colorStr = "緑";
//			} else {
//				colorStr = "白";
//			}
//			str = document.createTextNode(cName + '・' + colorStr);
//		} else {
//			str = document.createTextNode(cName);
//		}
//
//		// 衣装名の表示
//		elem.appendChild(str);
//
//		// レコメンドデータ取得・表示
//		getRecommendData(id);
//		for(i=0; i<8; i++) {
//			if(document.getElementsByName('cloth' + i)[0] != null) {
//				document.getElementsByName('cloth' + i)[0].style.borderStyle = "";
//				document.getElementsByName('cloth' + i)[0].style.borderColor = "";
//				document.getElementsByName('cloth' + i)[0].style.borderWidth = "";
//				document.getElementsByName('clothspan' + i)[0].style.borderColor = "#eeeeee";
//			} else {
//				break;
//			}
//		}
//		document.getElementsByName('cloth' + num)[0].style.borderStyle = "solid";
//		document.getElementsByName('cloth' + num)[0].style.borderColor = "#ff9900";
//		document.getElementsByName('cloth' + num)[0].style.borderWidth = "1px";
//		document.getElementsByName('clothspan' + num)[0].style.borderColor = "#ff9900";
//	}
//	heightLine();
}

/**
 * 試着履歴をCookieに登録
 * @param id 衣装ID
 * @param made 製作者名
 * @param name 衣装名
 * @param price Price
 * @param equip 装着箇所番号
 * @param fileName 画像URL
 *
 */
function setSichaku(id, made, name, price, equip ,fileName, price_type_name) {
	// Cookieに既に入っているデータを取得
	var val = getCookieCommon("sichaku");
	var addData = id+","+made+","+name+","+price+","+equip+","+fileName+","+price_type_name;
	var sichakuArr;

	// 最初の一回目はCookieにデータがない
	if (val == "") {
		sichakuArr = new Array(12);
		for(i = 0; i < 12; i++) {
			if (i == equip) {
				sichakuArr[i] = addData;
			} else {
				sichakuArr[i] = ",,,,,";
			}
		}
	} else {
		// Cookieにデータが入っている場合
		sichakuArr = val.split("&");

		if(sichakuArr.length == 12){

			var dataArray = sichakuArr[equip].split(",");

			if(dataArray.length == 6 || dataArray.length == 7){

				if (dataArray[0] == id) {
					// IDが同じ(試着中)場合は衣装を外す
					sichakuArr[equip] = ",,,,,";
				} else {
					sichakuArr[equip] = addData;
				}
			}
		}else if(val.indexOf('\t') == -1 && sichakuArr.length > 0){

			sichakuArr = new Array(12);
			for(i = 0; i < 12; i++) {
				sichakuArr[i] = ",,,,,";
			}
			// 試着データを格納
			sichakuArr[equip] = addData;

		}else if(val.indexOf('\t') != -1){

			sichakuArr = val.split("\t");

			if(sichakuArr.length == 12){

				var dataArray = sichakuArr[equip].split(",");

				if(dataArray.length == 6 || dataArray.length == 7){

					if (dataArray[0] == id) {
						// IDが同じ(試着中)場合は衣装を外す
						sichakuArr[equip] = ",,,,,";
					} else {
						sichakuArr[equip] = addData;
					}
				}
			}
		}
	}
	val = sichakuArr.join("\t");
	setCookieCommon("sichaku", val);
	return true;
}

/**
 * 試着衣装を買い物かごに投入する
**/
function addTryOnClothes() {
	DWREngine.setTimeout(1000);		// DWRタイムアウト時間設定
	DWREngine.setAsync(false);		// 非同期的に実行(trueで非同期)
	var val = getCookieCommon("sichaku");
	var sichakuArr = val.split("&");
	if(sichakuArr.length != 12){
		sichakuArr = val.split("\t");
	}
	var sendData = null;

	for (i = 0; i < 12; i++) {
		var dataArray = sichakuArr[i].split(",");
		if (dataArray[0] != "") {
			// データが入っていればリストに追加
			if (sendData != null) {
				sendData = sendData + "," + dataArray[0];
			} else {
				sendData = dataArray[0];
			}
		}
	}
	var array = sendData.split(",");
	Cart.addListCart(cbAddListCart, sendData.split(","), 0);
}

function cbAddListCart(result) {
	if (result == 0) {
		document.location.href = "/tinierme/baglistview.do";
	} else {
		alert("An error has occurred.");
	}
}

var loginFlg = false;
/**
 * ログイン判定を行う
 */
function loginChk(){
	DWREngine.setTimeout(1000);		// DWRタイムアウト時間設定
	DWREngine.setAsync(false);		// 非同期的に実行(trueで非同期)

	// ログインされているかチェック
	isLogin.checkLogin(loginChkCallback);
	return loginFlg;
}

/**
 * ログイン判定結果を受け取る
 */
function loginChkCallback(result){
	loginFlg = result;
}