﻿
var current_o2;
var current_o3;
var off_o3;
var Y_optionOnOffFlg="on";
function Y_confirmOption(ID)
{
	Y_initLists();

	if(!checkList(current_o,ID)){

		if(typeof(fixed_g)!="undefined"){
			var rslt = tryOn(ID,fixed_g,fixed_bc,fixed_ic);
			if(rslt!=true) return rslt;
		}

		if(fixed_g!=current_g || fixed_bc!=current_bc || fixed_ic!=current_ic){
			var rslt = tryOn(ID,current_g,current_bc,current_ic);
			if(rslt!=true) return rslt;
		}
	}else{

		if(typeof(fixed_g)!="undefined"){
			var rslt = tryOff(ID,fixed_g,fixed_bc,fixed_ic);
			if(rslt!=true) return rslt;
		}

		if(fixed_g!=current_g || fixed_bc!=current_bc || fixed_ic!=current_ic){
			var rslt = tryOff(ID,current_g,current_bc,current_ic);
			if(rslt!=true) return rslt;
		}
	}

	if(checkList(current_o,ID)){
		Y_optionOff(ID);
		Y_optionOnOffFlg="off";
	}else{
		Y_optionOn(ID);
		Y_optionOnOffFlg="on";
	}
	preOff_o = off_o;
	//preOff_ic = off_ic;
	Y_recoveryLists();
	return true;
	//-------------------------------------------------
	
	
	function tryOn(ID,gID,bcID,icID){

		if(!checkList(gData[gID]["oA"],ID)) return "grade";
		

		if(typeof(bcData[bcID]["oNA"][gID])!="undefined"){
			if(checkList(bcData[bcID]["oNA"][gID],ID)) return "color";
		}
		
		
		if(typeof(io_oLimit[gID])!="undefined" && typeof(io_oLimit[gID][ID])!="undefined"){
			for(i=0;i<io_oLimit[gID][ID].length;i++){
				if(checkList(current_io,io_oLimit[gID][ID][i])){
					return "interior";
				}
			}
		}
		
		
		if(typeof(oLimit[gID])!="undefined" && typeof(oLimit[gID][ID])!="undefined"){
			var flg = o_i_checkLimit(oLimit[gID][ID]);
			if(!flg){
				Y_getLimit_o(ID,gID);
				return "limit";
			}
		}
		
		
		if(typeof(oGLimit[gID])!="undefined" && typeof(oGLimit[gID][ID])!="undefined"){
			var flg = o_i_g_checkLimit(oGLimit[gID][ID]);
			if(!flg){
				Y_getLimit_og(ID,gID);
				return "limit2";
			}
		}
		
		return true;
	}
	
	function tryOff(ID,gID,bcID,icID){
	
		if(typeof(io_oOn[gID])!="undefined"){
			for(i in io_oOn[gID]){
				if(checkList(current_io,i)){
					for(j=0;j<io_oOn[gID][i].length;j++){
						if(io_oOn[gID][i][j]==ID){
							return "io_oOn";
						}
					}
				}
			}
		}
		return true;
	}
}

function Y_initLists()
{
	off_o = new Array();
	preOff_o = new Array();
	current_o2 = copyArray(current_o);
}
function Y_recoveryLists()
{
	current_o3 = copyArray(current_o);
	current_o = copyArray(current_o2);
	off_o3 = copyArray(off_o);
}


var current_io2;
var current_io3;
var off_io3;

function Y_confirm_I_Option(ID)
{
	Y_i_initLists();
	
	if(!checkList(current_io,ID)){
		
		if(typeof(fixed_g)!="undefined"){
			var rslt = tryOn(ID,fixed_g,fixed_bc,fixed_ic);
			if(rslt!=true) return rslt;
		}
		
		if(fixed_g!=current_g || fixed_bc!=current_bc || fixed_ic!=current_ic){
			var rslt = tryOn(ID,current_g,current_bc,current_ic);
			if(rslt!=true) return rslt;
		}
	}
	
	if(checkList(current_io,ID)){
		Y_i_optionOff(ID);
	}else{
		Y_i_optionOn(ID);
		if(typeof(io_oOn[current_g])!="undefined"&&typeof(io_oOn[current_g][ID])!="undefined"){
			for(i=0;i<io_oOn[current_g][ID].length;i++){
				Y_optionOn(io_oOn[current_g][ID][i]);
			}
		}
	}
	preOff_o = off_o;
	preOff_io = off_io;
//	preOff_ic = off_ic;
	if(typeof(io_oOn[current_g])!="undefined"){
		preOn_o = io_oOn[current_g][ID];
	}
	Y_i_recoveryLists();
	return true;
	
	
	//-------------------------------------------------
	function tryOn(ID,gID,bcID,icID){
		
		if(!checkList(icData[icID]["sIo"],ID)) return "interior";
		
		
		if(typeof(ioLimit[gID])!="undefined" && typeof(ioLimit[gID][ID])!="undefined"){
			var flg = i_checkLimit(ioLimit[gID][ID]);
			if(!flg){
				Y_getLimit_io(ID,gID);
				return "limit";
			}
		}
		return true;
	}
}

function Y_i_initLists()
{
	off_o = new Array();
	preOff_o = new Array();
	current_o2 = copyArray(current_o);
	off_io = new Array();
	preOff_io = new Array();
	current_io2 = copyArray(current_io);
	preOn_o = new Array();
}
function Y_i_recoveryLists()
{
	current_o3 = copyArray(current_o);
	current_o = copyArray(current_o2);
	off_o3 = copyArray(off_o);
	current_io3 = copyArray(current_io);
	current_io = copyArray(current_io2);
	off_io3 = copyArray(off_io);
}


var str3d;
var flg_limitCheck = true;
var Y_typeFlg = "grade";

function Y_callStatus(type,ID)
{
	Y_typeFlg = type;
	resetData();
	switch(type){
		case "grade"://------------------------------------
			if(ID==current_g){
				return false;
			}
			
			off_g = current_g;
			current_g = ID;
			
			defOptions = gData[ID]["oDef"];
			
			Alist_bc = gData[ID]["cA"];
			Y_checkA_bc();
			
			checkInterior();
			
			checkInteriorOption();
			
			checkOption();
			
			on_o = null;
			break;
		case "color":
			if(!checkList(Alist_bc,ID)){return false;}
			if(ID==current_bc) return;
			off_bc = current_bc;
			current_bc = ID;
			
			checkInterior();
			
			checkInteriorOption();
			
			checkOption();
			
			on_o = null;
			break;
		case "interior"://---------------------------------
			if(!checkList(Alist_ic,ID)){return false;}
			if(ID==current_ic) return;
			off_ic = current_ic;
			current_ic = ID;
			
			Y_change_ic(ID);
			
			checkInteriorOption();
			
			on_o = null;
			break;
		case "option"://-----------------------------------
			current_o = copyArray(current_o3);
			off_o = copyArray(off_o3);
			//---------------------------------
			if(Y_page=="web"){
				fixed_o = copyArray(current_o);
			}
			//---------------------------------
			on_o = ID;
			break;
		case "ioption"://----------------------------------
			if(checkList(current_io,ID)==true)return;
			
			current_o = copyArray(current_o3);
			off_o = copyArray(off_o3);
			
			current_io = copyArray(current_io3);
			off_io = copyArray(off_io3);
			
			//---------------------------------
			if(Y_page=="web"){
				fixed_o = copyArray(current_o);
				fixed_io = copyArray(current_io);
			}
			//---------------------------------
			on_o = null;//
			break;
	}
	
	
	
	str3d = current_g+"&"+current_bc+"&"+current_ic+"&"+current_o.toString();
	Y_entryData();//
	
	return true;
	
	function resetData(){
		off_bc = "";
		off_ic = "";
		off_o = new Array();
		off_io = new Array();
		limitList = new Array();
	}
	function checkInterior(){//
		var newList = Y_getList_ic(current_bc,current_g);
		if(Alist_ic.toString()!=newList.toString()){
			Alist_ic = newList;
			Y_checkA_ic();
		}
	}
	function checkOption(){
		var newList = Y_getList_o(current_bc,current_g);
		if(Alist_o.toString()!=newList.toString()){
			Alist_o = newList;
			flg_limitCheck = false;
			Y_checkA_o();
			flg_limitCheck = true;
		}
		Y_checkLimit_o();
	}
	function checkiOption(){
		var newList = Y_getList_io(current_bc,current_g);
		if(Alist_io.toString()!=newList.toString()){
			Alist_io = newList;
			flg_limitCheck = false;
			Y_checkA_io();
			flg_limitCheck = true;
		}
		Y_checkLimit_io();
		Y_checkLimit_io_o();
		Y_checkLimit_o();
	}
	/////////////
	function checkInteriorOption(){
		var newList = icData[current_ic]["sIo"];
		
		
		var newList2=new Array();
		for(i=0; i<gData[current_g]["ioA"].length;i++){
			if(checkList2(newList,gData[current_g]["ioA"][i])){
				newList2.push(gData[current_g]["ioA"][i]);
			}
		}
		if(Alist_io.toString()!=newList2.toString()){
		
			
		
		if(gData[current_g]["ioA"].length==0){//alert("old")
			Alist_io = newList;//old
			flg_limitCheck = false;//old
			Y_checkA_io();//old
			for(j=0;j<icData[current_ic]["dIo"].length;j++){//old
				Y_i_optionOn(icData[current_ic]["dIo"][j]);//old
			}//old
		}else{
			Alist_io = Y_Alist_io_Gcheck();
		}
		
			flg_limitCheck = false;
			Y_checkA_io();
			for(j=0;j<icData[current_ic]["dIo"].length;j++){
				//new
				if(!checkList3(Alist_io,icData[current_ic]["dIo"][j]))continue;
				if(checkList2(Alist_io,checkList3(Alist_io,icData[current_ic]["dIo"][j]))){
					Y_i_optionOn(icData[current_ic]["dIo"][j]);
				}else{
					Y_i_optionOn(Alist_io[0]);
				}
				//new
				
				
			}
			flg_limitCheck = true;
		}
		Y_checkLimit_io();
		Y_checkLimit_io_o();
		Y_checkLimit_o();
		
	}
	////////////////////
	
}
function Y3d_callStatus()//////////////////////////////////////////////////////////
{
	if(Y_applet){
		if(typeof(Y_group)=="object"){
			if(Y_currentEquipInfo==str3d) return;
			Y_3dMain(str3d);
		}
	}
}
function Y_entryData()
{
	fixed_g = current_g;
	fixed_bc = current_bc;
	fixed_ic = current_ic;
	fixed_io = copyArray(current_io);
	fixed_o = copyArray(current_o);
	Y_costCalculate();
	entryData('sim');

}

function Y_loadCartData()
{
	if(typeof(fixed_g)=='undefined'||fixed_g==''){
		fixed_g = current_g;
		fixed_bc = current_bc;
		fixed_ic = current_ic;
		fixed_io = copyArray(current_io);
		fixed_o = copyArray(current_o);
	}
	else{
		current_g = fixed_g;
		current_bc = fixed_bc;
		current_ic = fixed_ic;

	}
	Y_costCalculate();
	entryData('sim');
}

//get limit data
function Y_getLimit_o(ID,gID)
{
	limitList = oLimit[gID][ID].list;
	limitType = oLimit[gID][ID].type;
}
function Y_getLimit_og(ID,gID)
{
	og_limitList = oGLimit[gID][ID].list;
	og_limitType = oGLimit[gID][ID].type;
}
function Y_getLimit_io(ID,gID)
{
	io_limitList = ioLimit[gID][ID].list;
	io_limitType = ioLimit[gID][ID].type;
}

///////////////////////////////////////////////////////////////////////////////////////
function Y_getList_ic(cID,gID)
{
	if(typeof(bcData[cID]["iNA"][gID])=="undefined"){
		var intList = gData[gID]["iA"];
	}else{
		var intList = new Array();
		for(var x=0;x<gData[gID]["iA"].length;x++){
			if(checkList(bcData[cID]["iNA"][gID],gData[gID]["iA"][x])) continue;
			intList.push(gData[gID]["iA"][x]);
		}
	}
	return intList;
}

function Y_getList_o(cID,gID)
{
	if(typeof(bcData[cID]["oNA"][gID])=="undefined"){
		var opList = gData[gID]["oA"];
	}else{
		var opList = new Array();
		for(var x=0;x<gData[gID]["oA"].length;x++){
			if(checkList(bcData[cID]["oNA"][gID],gData[gID]["oA"][x])) continue;
			opList.push(gData[gID]["oA"][x]);
		}
	}
	return opList;
}
function Y_getList_io(cID,gID)
{
	if(typeof(bcData[cID]["oNA"][gID])=="undefined"){
		var opList = gData[gID]["oA"];
	}else{
		var opList = new Array();
		for(var x=0;x<gData[gID]["oA"].length;x++){
			if(checkList(bcData[cID]["oNA"][gID],gData[gID]["oA"][x])) continue;
			opList.push(gData[gID]["oA"][x]);
		}
	}
	return opList;
}

function Y_checkA_bc()
{
	if(!checkList(gData[current_g]["cA"],current_bc)){
		off_bc = current_bc;
		current_bc = gData[current_g]["cDef"];
	}
}

function Y_checkA_ic()
{
	if(!checkList(Alist_ic,current_ic)){
		Y_change_ic(Y_getA_ic());
	}
}
function Y_getA_ic()
{
	if(typeof(iLimit[current_g])=="undefined") return Alist_ic[0];
	for(var x=0;x<Alist_ic.length;x++){
		if(typeof(iLimit[current_g][Alist_ic[x]])=="undefined"){
			return Alist_ic[x];
		}else{
			if(checkLimit(iLimit[current_g][Alist_ic[x]])){
				return Alist_ic[x];
			}
		}
	}
	if(debug_flg){
		
	}
}


function Y_checkA_o()
{
	var targetList = current_o;
	for(var i=0;i<targetList.length;i++){
		if(!checkList(Alist_o,targetList[i])){
			Y_optionOff(targetList[i]);
		}
	}
}

function Y_checkA_io()
{
	var targetList = current_io;
	for(var i=0;i<targetList.length;i++){
		if(!checkList(Alist_io,targetList[i])){
			Y_i_optionOff(targetList[i]);
		}
	}
	
}
// interior ******************************************************
function Y_change_ic(ID)
{
	off_ic = current_ic;
	current_ic = ID;
	Y_checkLimit_io();
}

// i_option*********************************************************
function Y_i_optionOff(ID)
{
	if(!checkList(current_io,ID)) return;
	off_io.push(ID);
	current_io = deleteArray(current_io,ID);
	
	if(flg_limitCheck){
		Y_checkLimit_io();
		Y_checkLimit_o();
	}
}
function Y_i_optionOn(ID)
{
	
	if(checkList(current_io,ID)) return;
	current_io.push(ID);
	Y_CheckComp(ID);
	if(flg_limitCheck){
		Y_checkLimit_io();
		Y_checkLimit_io_o();
		Y_checkLimit_o();
	}
}
// option*********************************************************
function Y_optionOff(ID)
{
	if(!checkList(current_o,ID)) return;
	off_o.push(ID);
	current_o = deleteArray(current_o,ID);
	if(flg_limitCheck){
		Y_checkLimit_o();
	}
}
function Y_optionOn(ID)
{
	if(checkList(current_o,ID)) return;
	current_o.push(ID);
	Y_CheckComp(ID);
	if(flg_limitCheck) Y_checkLimit_o();
	if(oData[ID]["intID"]!=""){
		Y_change_ic(oData[ID]["intID"]);
	}
}
/////////////////////////////////////////////////////////////////////
function Y_Alist_io_Gcheck()
{
	var Alist_io_data = new Array();

	for(a=0;a<icData[current_ic]["sIo"].length;a++){
		if(checkList2(gData[current_g]["ioA"],icData[current_ic]["sIo"][a])){
			Alist_io_data.push(icData[current_ic]["sIo"][a]);
		}
		
	}
	return Alist_io_data;
}
//////////////////////////////////////////////////////////////////
//comp
function Y_CheckComp(ID)
{
	if(typeof(oData[ID])!="undefined"){
		var idx = getIndex(oData[ID]["compGID"]);
		if(idx>-1){
			for(var i=0;i<oData[ID]["compOID"][idx].length;i++){
				if(checkList(current_o,oData[ID]["compOID"][idx][i])){
					Y_optionOff(oData[ID]["compOID"][idx][i]);
				}
			}
		}
	}
	if(typeof(ioData[ID])!="undefined"){
		var idx = getIndex(ioData[ID]["compGID"]);
		if(idx>-1){
			for(var i=0;i<ioData[ID]["compOID"][idx].length;i++){
				if(checkList(current_io,ioData[ID]["compOID"][idx][i])){
					Y_i_optionOff(ioData[ID]["compOID"][idx][i]);
				}
			}
		}
	}

	function getIndex(list){
		for(var x=0;x<list.length;x++){
			for(var y=0;y<list[x].length;y++){
				if(list[x][y]==current_g) return x;
			}
		}
		return -1;
	}
}

//limit
function Y_checkLimit_io()
{
	//i_option×i_option--------------------
	if(typeof(ioLimit[current_g])!="undefined"){
		for(var x in ioLimit[current_g]){
			var flg = i_checkLimit(ioLimit[current_g][x]);
			if(!flg){
				if(checkList(current_io,x)){
					Y_i_optionOff(x);
				}
			}
		}
	}
}

function Y_checkLimit_io_o(){
	//i_option×option--------------------
	if(typeof(io_oLimit[current_g])!="undefined"){
		for(x in io_oLimit[current_g]){
			for(var a=0;a<io_oLimit[current_g][x].length;a++){
				if(checkList(current_io,io_oLimit[current_g][x][a])){
					Y_optionOff(x);
				}
			}
		}
	}
}
function Y_checkLimit_o()
{
	//option×option--------------------
	if(typeof(oLimit[current_g])!="undefined"){
		for(var x in oLimit[current_g]){
			var flg = o_i_checkLimit(oLimit[current_g][x]);
			if(!flg){
				if(checkList(current_o,x)){
					Y_optionOff(x);
				}
				if(checkList(current_io,x)){
					Y_optionOff(x);
				}
			}
		}
	}
	if(typeof(oGLimit[current_g])!="undefined"){
		for(var x in oGLimit[current_g]){
			var flg = o_i_g_checkLimit(oGLimit[current_g][x]);
			if(!flg){
				if(checkList(current_o,x)){
					Y_optionOff(x);
				}
			}
		}
	}
}
function checkLimit(obj){
	for(var y=0;y<obj.list.length;y++){
		if(obj.type==checkList(current_o,obj.list[y])) return true;
	}
	return false;
}
function i_checkLimit(obj){
	for(var y=0;y<obj.list.length;y++){
		if(obj.type==checkList(current_io,obj.list[y])) return true;
	}
	return false;
}
function o_i_checkLimit(obj){
	for(var y=0;y<obj.list.length;y++){
		if(obj.type==checkList(current_o,obj.list[y])) return true;
		if(obj.type==checkList(current_io,obj.list[y])) return true;
	}
	return false;
}
function o_i_g_checkLimit(obj){
	var aaaa = new Array();
	var bbbb = new Array();
	for(var i=0;i<obj.list.length;i++){
		aaaa[i] = new Array();
		for(var j=0;j<obj.list[i].length;j++){
			aaaa[i][j] = checkList(current_o,obj.list[i][j]);
			for(var k in ioData){
				if(obj.list[i][j]!=k){
					aaaa[i][j] = checkList(current_o,obj.list[i][j]);
				}else{
					aaaa[i][j] = checkList(current_io,obj.list[i][j]);
				}
			}
			
		}
		bbbb[i] = checkList4(aaaa[i],obj.type);
		if(obj.type==checkList(bbbb,obj.type)){
			return true;
		}
	}
	return false;
}

// library ********************************************************
function checkList4(list,val)
{
	var aa=true;
	for(var x=0;x<list.length;x++){
		if(val!=list[x]) aa=false;
	}
	return aa;
}
function checkList(list,val)
{
	for(var x=0;x<list.length;x++){
		if(val==list[x]) return true;
	}
	return false;
}
function checkList2(list,val)
{
	
	for(var x=0;x<list.length;x++){
		if(val==list[x]) return true;
	}
	return false;
}
function checkList3(list,val)
{
	
	for(var x=0;x<list.length;x++){
		if(val==list[x]) return val;
	}
	return false;
}
function deleteArray(list,val)
{
	var dummyArray = new Array();
	for(var x=0;x<list.length;x++){
		if(list[x]==val) continue;
		dummyArray[dummyArray.length] = list[x];
	}
	return dummyArray;
}
function copyArray(obj)
{
	var dummyArray = new Array();
	for(var x=0;x<obj.length;x++){
		dummyArray.push(obj[x]);
	}
	return dummyArray;
}
var sortTarget;
function sortRule(a,b)
{
	return window[sortTarget][a]["order"] - window[sortTarget][b]["order"];
}


////////////////////////////////////////////////////////////////
function Y_costCalculate(){
	Y_estMop = new Array();
	Y_estDop = new Array();
	Y_estMopIn = new Array();
	Y_estDopIn = new Array();
	Y_est_I_Mop = new Array();
	Y_est_I_Dop = new Array();
	Y_est_I_MopIn = new Array();
	Y_est_I_DopIn = new Array();
	if(typeof(fixed_g)=="undefined"){
		Y_estGrade = Y_estGradeIn = 0;
		Y_estColor = Y_estColorIn = 0;
		Y_estInterior = Y_estInteriorIn = 0;
		Y_estFinisher = Y_estFinisherIn = 0;
	}else{
	//grade
		Y_estGrade = gData[fixed_g]["costTL"];
		Y_estGradeIn = gData[fixed_g]["costTI"];
		
	//bcolor
		//
		if(typeof(bcData[fixed_bc]["cost"])!="undefined"){
			Y_estColor = bcData[fixed_bc]["cost"].costTL;
			Y_estColorIn = bcData[fixed_bc]["cost"].costTI;
			
		//
		}else{
			for(var i=0;i<bcData[fixed_bc]["costSP"].length;i++){
				if(!checkList(bcData[fixed_bc]["costSP"][i].gID,fixed_g)) continue;
				Y_estColor = bcData[fixed_bc]["costSP"][i].costTL;
				Y_estColorIn = bcData[fixed_bc]["costSP"][i].costTI;
				break;
			}
			
		}
		
	//icolor
		//
		if(typeof(icData[fixed_ic]["cost"])!="undefined"){
			Y_estInterior = icData[fixed_ic]["cost"].costTL;
			Y_estInteriorIn = icData[fixed_ic]["cost"].costTI;
			
		//
		}else{
			for(var i=0;i<icData[fixed_ic]["costSP"].length;i++){
				if(!checkList((icData[fixed_ic]["costSP"].gID=="")?icData[fixed_ic]["costSP"][i].cID:icData[fixed_ic]["costSP"][i].gID,(icData[fixed_ic]["costSP"].gID=="")?fixed_bc:fixed_g)) continue;
				Y_estInterior = icData[fixed_ic]["costSP"][i].costTL;
				Y_estInteriorIn = icData[fixed_ic]["costSP"].costTI;
				break;
			}
			
		}
		
	//option
	
		for(var j=0;j<fixed_o.length;j++){
			//
			if(typeof(oData[fixed_o[j]]["cost"])!="undefined"){
				if(oData[fixed_o[j]]["MD"]=="M"){
					Y_estMop[fixed_o[j]] = oData[fixed_o[j]]["cost"].costTL;
					Y_estMopIn[fixed_o[j]] = oData[fixed_o[j]]["cost"].costTI;
				}else{
					Y_estDop[fixed_o[j]] = oData[fixed_o[j]]["cost"].costTL;
					Y_estDopIn[fixed_o[j]] = oData[fixed_o[j]]["cost"].costTI;
				}
				
			//
			}else{
				for(var i=0;i<oData[fixed_o[j]]["costSP"].length;i++){
					if(!checkList((oData[fixed_o[j]]["costSP"][i].gID=="")?oData[fixed_o[j]]["costSP"][i].cID:oData[fixed_o[j]]["costSP"][i].gID,(oData[fixed_o[j]]["costSP"][i].gID=="")?fixed_bc:fixed_g)) continue;
					if(oData[fixed_o[j]]["MD"]=="M"){
						Y_estMop[fixed_o[j]] = oData[fixed_o[j]]["costSP"][i].costTL;
						Y_estMopIn[fixed_o[j]] = oData[fixed_o[j]]["costSP"][i].costTI;
					}else{
						Y_estDop[fixed_o[j]] = oData[fixed_o[j]]["costSP"][i].costTL;
						Y_estDopIn[fixed_o[j]] = oData[fixed_o[j]]["costSP"][i].costTI;
					}
					break;
				}
				
			}
		}
		
	//option
	if(typeof(fixed_io)!='undefined'){
		for(var j=0;j<fixed_io.length;j++){
			//
			if(fixed_io[j]==undefined){
				}else{
			if(typeof(ioData[fixed_io[j]]["cost"])!="undefined"){
				if(ioData[fixed_io[j]]["MD"]=="M"){
					Y_est_I_Mop[fixed_io[j]] = ioData[fixed_io[j]]["cost"].costTL;
					Y_est_I_MopIn[fixed_io[j]] = ioData[fixed_io[j]]["cost"].costTI;
				}else{
					Y_est_I_Dop[fixed_io[j]] = ioData[fixed_io[j]]["cost"].costTL;
					Y_est_I_DopIn[fixed_io[j]] = ioData[fixed_io[j]]["cost"].costTI;
				}
				
			//
			}else{
				for(var i=0;i<ioData[fixed_io[j]]["costSP"].length;i++){
					if(!checkList((ioData[fixed_io[j]]["costSP"][i].gID=="")?ioData[fixed_io[j]]["costSP"][i].cID:ioData[fixed_io[j]]["costSP"][i].gID,(ioData[fixed_io[j]]["costSP"][i].gID=="")?fixed_bc:fixed_g)) continue;
					if(ioData[fixed_io[j]]["MD"]=="M"){
						Y_est_I_Mop[fixed_io[j]] = ioData[fixed_io[j]]["costSP"][i].costTL;
						Y_est_I_MopIn[fixed_io[j]] = ioData[fixed_io[j]]["costSP"][i].costTI;
					}else{
						Y_est_I_Dop[fixed_io[j]] = ioData[fixed_io[j]]["costSP"][i].costTL;
						Y_est_I_DopIn[fixed_io[j]] = ioData[fixed_io[j]]["costSP"][i].costTI;
					}
					break;
				}
				
			}
			}
		}
		
	}
	}
		var str = "";
		str += "grade:"+Y_estGrade+"\n";
		str += "gradeIN:"+Y_estGradeIn+"\n";
		str += "bodycolor:"+Y_estColor+"\n";
		str += "bodycolorIN:"+Y_estColorIn+"\n";
		str += "interiorcolor:"+Y_estInterior+"\n";
		str += "interiorcolorIN:"+Y_estInteriorIn+"\n";
		str += "Y_estFinisher:"+Y_estFinisher+"\n";
		str += "Y_estFinisherIn:"+Y_estFinisherIn+"\n";
		for(var i in Y_estMop){
			str += "MOP("+i+"):"+Y_estMop[i]+"\n";
			str += "MOPIN("+i+"):"+Y_estMopIn[i]+"\n";
		}
		for(var i in Y_estDop){
			str += "DOP("+i+"):"+Y_estDop[i]+"\n";
			str += "DOPIN("+i+"):"+Y_estDopIn[i]+"\n";
		}
		for(var i in Y_est_I_Mop){
			str += "MOP("+i+"):"+Y_est_I_Mop[i]+"\n";
			str += "MOPIN("+i+"):"+Y_est_I_MopIn[i]+"\n";
		}
		for(var i in Y_est_I_Dop){
			str += "DOP("+i+"):"+Y_est_I_Dop[i]+"\n";
			str += "DOPIN("+i+"):"+Y_est_I_DopIn[i]+"\n";
		}
		//document.form1.areaOutput.value = str;
		
}

function getOpPrice(id){
	var op_price="";
	if(op_price==''){
		
		if(typeof(oData[id])!="undefined"){
			if(typeof(oData[id]["cost"])!="undefined"){
				if(typeof(oData[id])!='undefined'){
					op_price=oData[id]['cost'].costTI;
				}
			}else{
				for(var i=0;i<oData[id]["costSP"].length;i++){
					var aa = (oData[id]['costSP'][i].gID=='')?oData[id]['costSP'][i].cID:oData[id]['costSP'][i].gID;
					var bb = (oData[id]['costSP'][i].gID=="")?current_bc:current_g;
					if(!checkList(aa,bb)) continue;
					op_price=oData[id]['costSP'][i].costTI;
				}
			}
		}////
		if(typeof(ioData[id])!="undefined"){
			if(typeof(ioData[id]["cost"])!="undefined"){
				if(typeof(ioData[id])!='undefined'){
					op_price=ioData[id]['cost'].costTI;
				}
			}else{
				for(var i=0;i<ioData[id]["costSP"].length;i++){
					var aa = (ioData[id]['costSP'][i].gID=='')?ioData[id]['costSP'][i].cID:ioData[id]['costSP'][i].gID;
					var bb = (ioData[id]['costSP'][i].gID=="")?current_bc:current_g;
					if(!checkList(aa,bb)) continue;
					op_price=ioData[id]['costSP'][i].costTI;
				}
			}
		}
	}
	return op_price;
}

function entryData(){
	if(!flg_firstLoad && load_3d_flg){
		Y3d_callStatus();
	}
}