<?php
	include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
	include $_SERVER['DOCUMENT_ROOT'].'/common/auth_chk.php';

	$mode="Step1";

//	$s_cd_sale = $_SESSION['s_cd_sale'];
	$s_cd_car = $_SESSION['s_cd_car'];
//	echo $s_cd_car;
	$s_nm_name = $_SESSION['s_nm_name'];
	$s_ds_type = $_SESSION['s_ds_type'];	//$_SESSION['s_ds_type']= "C0"
	$s_car_update_ing = $_SESSION['s_car_update_ing'];

	$s_ds_area_user = $_SESSION['s_ds_area_user'];

	$ds_cate = $_REQUEST[ds_cate];
	if(!$ds_cate) $ds_cate='A0';

	$ds_model_cate= $ds_cate;

	if($s_cd_car !="" || $s_cd_car != null){

		$sql ="SELECT *
			FROM car_master mst
			WHERE  cd_car='$s_cd_car' AND ds_delind='N'";
/*
		$sql ="SELECT *
			FROM car_master mst
				inner join sale_master s
				on (
					mst.cd_car = s.cd_car
					AND mst.ds_delind='N'
					AND s.cd_sale = '$s_cd_sale'
				) ";
*/

		$col=mysql_fetch_array(mysql_query($sql));

		if (!empty($col[cd_car])){

			$cd_car = $col[cd_car];
			$cd_brand  = $col[cd_brand];
			$cd_category  = $col[cd_category];
			$cd_model  = $col[cd_model];
			$cd_model_sub  = $col[cd_model_sub];
			$cd_grade  =$col[cd_grade];
			$car_report  =$col[car_report];
			$ds_type  = $col[ds_type];
			$ds_year  =$col[ds_year];
			$nm_mileage  = $col[nm_mileage];
			$ds_driving_system  = $col[ds_driving_system];
			$ds_transmission  = $col[ds_transmission];
			$ds_oil  = $col[ds_oil];
			$nm_gearbox  = $col[nm_gearbox];
			$ds_accident  = $col[ds_accident];
			$nm_cont_accident  = $col[nm_cont_accident];
			$nm_regdate  = $col[nm_regdate];
			$ds_sales  = $col[ds_sales];
			$nm_btitle  = $col[nm_btitle];
			$nm_stitle  = $col[nm_stitle];
			$nm_ltitle  = $col[nm_ltitle];
			$nm_cont  = $col[nm_cont];
			$ds_open  = $col[ds_open];
			$ds_status  = $col[ds_status];
			$ds_logo  = $col[ds_logo];
			$nm_price  = $col[nm_price];
			$nm_name  =$col[nm_name];
			$nm_color = $col[nm_color];
			$nm_incolor= $col[nm_incolor];
			$nm_cc = $col[nm_cc];
			$nm_number = $col[nm_number];
			$ds_trade = $col[ds_trade];
			$nm_regdate_yyyy  = $col[nm_regdate_yyyy];
			$nm_regdate_mm  = $col[nm_regdate_mm];
			$nm_regdate_dd  = $col[nm_regdate_dd];
			$nm_guide  = $col[nm_guide];
			$ds_main  = $col[ds_main];
			$ds_cate = $col[ds_cate];

			$nm_chk_178_q1  = $col[nm_chk_178_q1];
			$nm_chk_178_q2  = $col[nm_chk_178_q2];
			$nm_chk_178_q3  = $col[nm_chk_178_q3];
			$nm_chk_178_q4  = $col[nm_chk_178_q4];
			$nm_chk_178_q5  = $col[nm_chk_178_q5];
			$nm_chk_178_q6  = $col[nm_chk_178_q6];
			$nm_chk_178_q7  = $col[nm_chk_178_q7];
			$nm_chk_178_q8  = $col[nm_chk_178_q8];
			$nm_chk_178_q9  = $col[nm_chk_178_q9];
			$nm_chk_178_q10  = $col[nm_chk_178_q10];
			$nm_chk_178_q11  = $col[nm_chk_178_q11];
			$nm_chk_178_q12  = $col[nm_chk_178_q12];
			$nm_chk_178_q13  = $col[nm_chk_178_q13];

			$nm_chk_carno  = $col[nm_chk_carno];
			$nm_chk_cnt  = $col[nm_chk_cnt];
			$nm_chk_s1 = $col[nm_chk_s1];
			$nm_chk_s2 = $col[nm_chk_s2];
			$nm_chk_s3 = $col[nm_chk_s3];
			$nm_chk_s4 = $col[nm_chk_s4];
			$nm_chk_advisor = $col[nm_chk_advisor];
			$nm_chk_date = $col[nm_chk_date];
			$nm_chk_p1 = $col[nm_chk_p1];
			$nm_chk_p2 = $col[nm_chk_p2];
			$nm_chk_p3 = $col[nm_chk_p3];
			$nm_file_chk = $col[nm_file_chk];
			$nm_act_chgno = $col[nm_act_chgno];
			$nm_act_chgnm = $col[nm_act_chgnm];
			$nm_act_s1 = $col[nm_act_s1];
			$nm_act_s2 = $col[nm_act_s2];
			$nm_act_s3 = $col[nm_act_s3];
			$nm_act_s4 = $col[nm_act_s4];
			$nm_act_my = $col[nm_act_my];
			$nm_act_my_amt = $col[nm_act_my_amt];
			$nm_act_other = $col[nm_act_other];
			$nm_act_other_amt = $col[nm_act_other_amt];
			$nm_act_searchdt  = $col[nm_act_searchdt];
			$nm_act_cnt = $col[nm_act_cnt];
			$nm_file_act = $col[nm_file_act];



			//안전 편의사항등등
			$ds_g1_01= $col[ds_g1_01];
			$ds_g1_02= $col[ds_g1_02];
			$ds_g1_03= $col[ds_g1_03];
			$ds_g1_04= $col[ds_g1_04];
			$ds_g1_05= $col[ds_g1_05];
			$ds_g1_06= $col[ds_g1_06];
			$ds_g1_07= $col[ds_g1_07];
			$ds_g1_08= $col[ds_g1_08];
			$ds_g1_09= $col[ds_g1_09];
			$ds_g1_10= $col[ds_g1_10];
			$ds_g1_11= $col[ds_g1_11];
			$ds_g1_12= $col[ds_g1_12];
			$ds_g1_13= $col[ds_g1_13];
			$ds_g1_14= $col[ds_g1_14];
			$ds_g1_15= $col[ds_g1_15];
			//안전
			$ds_g2_01= $col[ds_g2_01];
			$ds_g2_02= $col[ds_g2_02];
			$ds_g2_03= $col[ds_g2_03];
			$ds_g2_04= $col[ds_g2_04];
			$ds_g2_05= $col[ds_g2_05];
			$ds_g2_06= $col[ds_g2_06];
			$ds_g2_07= $col[ds_g2_07];
			$ds_g2_08= $col[ds_g2_08];
			$ds_g2_09= $col[ds_g2_09];
			$ds_g2_10= $col[ds_g2_10];
			$ds_g2_11= $col[ds_g2_11];
			$ds_g2_12= $col[ds_g2_12];
			$ds_g2_13= $col[ds_g2_13];
			$ds_g2_14= $col[ds_g2_14];
			$ds_g2_15= $col[ds_g2_15];
			//편의멀티미디어
			$ds_g3_01= $col[ds_g3_01];
			$ds_g3_02= $col[ds_g3_02];
			$ds_g3_03= $col[ds_g3_03];
			$ds_g3_04= $col[ds_g3_04];
			$ds_g3_05= $col[ds_g3_05];
			$ds_g3_06= $col[ds_g3_06];
			$ds_g3_07= $col[ds_g3_07];
			$ds_g3_08= $col[ds_g3_08];
			$ds_g3_09= $col[ds_g3_09];
			$ds_g3_10= $col[ds_g3_10];
			$ds_g3_11= $col[ds_g3_11];
			$ds_g3_12= $col[ds_g3_12];
			$ds_g3_13= $col[ds_g3_13];
			$ds_g3_14= $col[ds_g3_14];
			$ds_g3_15= $col[ds_g3_15];
			//시트
			$ds_g4_01= $col[ds_g4_01];
			$ds_g4_02= $col[ds_g4_02];
			$ds_g4_03= $col[ds_g4_03];
			$ds_g4_04= $col[ds_g4_04];
			$ds_g4_05= $col[ds_g4_05];
			$ds_g4_06= $col[ds_g4_06];
			$ds_g4_07= $col[ds_g4_07];
			$ds_g4_08= $col[ds_g4_08];
			$ds_g4_09= $col[ds_g4_09];
			$ds_g4_10= $col[ds_g4_10];
			$ds_g4_11= $col[ds_g4_11];
			$ds_g4_12= $col[ds_g4_12];
			$ds_g4_13= $col[ds_g4_13];
			$ds_g4_14= $col[ds_g4_14];
			$ds_g4_15= $col[ds_g4_15];

			$upload_file_report_name = $col[nm_file_report];
			$upload_file_report_back_name = $col[nm_file_report_back];

			$upload_file_main_name = $col[nm_file_main];
			$upload_file_list_name = $col[nm_file_list];

		}else{
			AlertBack("게시물을 가져오지 못하였습니다.");
		}
		$PageNo = $PageNo;
//		$mode = "Update";
	}else{
//		$mode="Add";
	}

	if ($mode=="Add"){
//		$cd_userid = $_SESSION[admin_cd_userid];
	}

	if($ds_open==""){$ds_open="Y";}
	if($cd_category==""){$cd_category="1";}

?>
<? include("../include/inc_top.php") ?>
<? include("../include/inc_header.php") ?>

<section id="wrap">
	<section id="visual" class="visual_sell">
		<h2>내차팔기</h2>
		<p>쉽고 간편한 내차팔기, 견적산출, 최종 매각까지 어떤 수수료도 요구하지 않습니다.</p>
	</section>

	<section id="content">
		<ul class="location">
			<li><a href="/" class="home">홈</a></li>
			<li><span class="depth1">내차팔기</span></li>
			<li><span class="depth2">입찰하기</span></li>
		</ul>

		<h3>차량정보 입력</h3>
<form id="frmForm" name="frmForm" method="post" action="proc.php" enctype="multipart/form-data">
<input type="hidden" name="car_report" id="car_report" value="<?=$car_report?>"/>
<input type="hidden" name="ds_cate" id="ds_cate" value="<?=$ds_cate?>"/>
<input type="hidden" name="cd_car" id="cd_car" value="<?=$cd_car?>"/>
<input type="hidden" name="mode" id="mode" value="<?=$mode?>"/>
<input type="hidden" name="cd_userid" id="cd_userid" value="<?=$cd_userid?>"/>
<input type="hidden" name="PageNo" id="PageNo" value="<?=$PageNo?>"/>
<input type="hidden" name="upload_file_report_name" id="upload_file_report_name" value="<?=$upload_file_report_name?>"/>
<input type="hidden" name="upload_file_report_back_name" id="upload_file_report_back_name" value="<?=$upload_file_report_back_name?>"/>
<input type="hidden" name="upload_file_main_name" id="upload_file_report_name" value="<?=$upload_file_main_name?>"/>
<input type="hidden" name="upload_file_list_name" id="upload_file_list_name" value="<?=$upload_file_list_name?>"/>
<input type="hidden" name="cd_category" id="cd_category" value="<?=$cd_category?>"/>
<!--input type="hidden" name="s_nm_name" id="s_nm_name" value="<?=$s_nm_name?>"/-->
<input type="hidden" name="carinfochkresult" id="carinfochkresult" value="<? if ($s_car_update_ing != "Y"){ ?>N<? }else{ ?>Y<? } ?>"/>
		<table class="tbl_h">
			<colgroup>
				<col width="18%">
				<col width="*">
			</colgroup>
			<tr>
				<th>차량소유주명</th>
				<td>
					<input type="text" name="nm_name" id="nm_name" class="inp_txt"<? if ($s_car_update_ing == "Y"){ ?> value="<?=$nm_name?>"<? }else{ ?> value="<?=$s_nm_name?>"<? } ?><? if ((!empty($nm_number) && $s_ds_type == "C0") || $s_car_update_ing == "Y"){ ?> readonly<? } ?>/>
				</td>
			</tr>
			<tr>
				<th>차량번호</th>
				<td>
					<input type="text" name="nm_number" id="nm_number" class="inp_txt" maxlength="50" value="<?=$nm_number?>">
<? if ($s_car_update_ing != "Y"){ ?>
					<a href="#" class="td_btn" style="margin-left:50px;" id="btnCarInfo">차량번호 확인</a>
<? } ?>
				</td>
			</tr>
			<tr>
				<th>제조사</th>
				<td>
					<select id="cd_brand" name="cd_brand"></select>
				</td>
			</tr>
			<tr>
				<th>모델</th>
				<td>
					<select id="cd_model" name="cd_model"></select>
				</td>
			</tr>
			<tr>
				<th>세부모델</th>
				<td>
					<select id="cd_model_sub" name="cd_model_sub"></select>
				</td>
			</tr>
			<tr>
				<th>등급</th>
				<td>
					<select id="cd_grade" name="cd_grade"></select>				    &nbsp;선택하신 차종과 일치하지 않을 경우 최종 금액이 변경될 수 있습니다. </td>
			</tr>
			<tr>
				<th>연식(최초등록일)</th>
				<td>
					<select name="nm_regdate_yyyy" id="nm_regdate_yyyy" style="width:100px;">
					<?
					for($i=1990; $i<=2020; $i++){
					?>
						<option value="<?=$i?>" <? if($i == $nm_regdate_yyyy){ ?>selected<? } ?>><?=$i?></option>
					<?
					}
					?>
					</select>
					년
					<select name="nm_regdate_mm" id="nm_regdate_mm" style="width:100px;">
					<?
					for($i=1; $i<=12; $i++){
					?>
						<option value="<?=($i<10)?"0".$i:$i?>" <? if($i == $nm_regdate_mm){ ?>selected<? } ?>><?=($i<10)?"0".$i:$i?></option>
					<?
					}
					?>
					</select>
					월
				</td>
			</tr>
			<tr>
				<th>형식연도</th>
				<td>
					<select id="ds_year" name="ds_year"></select>
				</td>
			</tr>
			<tr>
				<th>배기량</th>
				<td>
					<input type="text" name="nm_cc" id="nm_cc" class="inp_txt" maxlength="50" value="<?=$nm_cc?>"> cc
				</td>
			</tr>
			<tr>
				<th>변속기</th>
				<td>
					<select id="ds_transmission" name="ds_transmission">
						<option value="">선택하세요</option>
						<option value="A0" <? if($ds_transmission == "A0"){ ?>selected<? } ?>>A/T</option>
						<option value="B0" <? if($ds_transmission == "B0"){ ?>selected<? } ?>>CVT</option>
						<option value="C0" <? if($ds_transmission == "C0"){ ?>selected<? } ?>>M/T</option>
					</select>
				</td>
			</tr>
			<tr>
				<th>연료</th>
				<td>
					<select id="ds_oil" name="ds_oil">
						<option value="">선택하세요</option>
						<option value="A0" <? if($ds_oil == "A0"){ ?>selected<? } ?>>Diesel</option>
						<option value="B0" <? if($ds_oil == "B0"){ ?>selected<? } ?>>Diesel/Hybrid</option>
						<option value="C0" <? if($ds_oil == "C0"){ ?>selected<? } ?>>Electric</option>
						<option value="D0" <? if($ds_oil == "D0"){ ?>selected<? } ?>>Gasoline</option>
						<option value="E0" <? if($ds_oil == "E0"){ ?>selected<? } ?>>Gasoline/Hybrid</option>
						<option value="F0" <? if($ds_oil == "F0"){ ?>selected<? } ?>>Hydrogen</option>
						<option value="G0" <? if($ds_oil == "G0"){ ?>selected<? } ?>>LPG</option>
						<option value="H0" <? if($ds_oil == "H0"){ ?>selected<? } ?>>LPG/Hybrid</option>
					</select>
				</td>
			</tr>
			<tr>
				<th>색상</th>
				<td>
					<div class="pos">
						<input type="text" name="nm_color" id="nm_color" class="inp_txt" maxlength="50" value="<?=$nm_color?>">
						<!-- color pick -->
						<div class="color_pick_popup">
							<p>기본 색상 선택<em class="txt_red">(1개를 선택해주세요)</em></p>
							<ul>
								<li><em>검정색</em></li>
								<li><em>흰색</em></li>
								<li><em>갈대색</em></li>
								<li><em>청색</em></li>
								<li><em>빨간색</em></li>
								<li><em>자주색</em></li>
								<li><em>검정투톤</em></li>
								<li><em>진주색</em></li>
								<li><em>연금색</em></li>
								<li><em>하늘색</em></li>
								<li><em>주황색</em></li>
								<li><em>보라색</em></li>
								<li><em>쥐색</em></li>
								<li><em>흰색투톤</em></li>
								<li><em>갈색</em></li>
								<li><em>명은색</em></li>
								<li><em>담녹색</em></li>
								<li><em>분홍색</em></li>
								<li><em>은색</em></li>
								<li><em>진주투톤</em></li>
								<li><em>갈색투톤</em></li>
								<li><em>금색</em></li>
								<li><em>녹색</em></li>
								<li><em>노란색</em></li>
								<li><em>은회색</em></li>
								<li><em>은색투톤</em></li>
								<li><em>은하색</em></li>
								<li><em>금색투톤</em></li>
								<li><em>청옥색</em></li>
								<li><em>연두색</em></li>
								<li><em>기타</em></li>
							</ul>
							<div class="close" onclick="closeLayer('color_pick');">레이어팝업 닫기</div>
						</div>
						<!-- // color pick -->
					</div>
				</td>
			</tr>
			<tr>
				<th>주행거리</th>
				<td>
					<input type="text" name="nm_mileage" id="nm_mileage" class="inp_txt" maxlength="50" value="<?=$nm_mileage?>"> km
				</td>
			</tr>
			<tr>
				<th>사고유무</th>
				<td>
					<select id="ds_accident" name="ds_accident"></select>
					<input type="text" name="nm_cont_accident" id="nm_cont_accident" class="inp_txt" maxlength="200" value="<?=$nm_cont_accident?>" placeholder="사고부위를 입력해주세요">
				</td>
			</tr>
			<tr>
				<th>판매희망지역</th>
				<td>
					<select style="width:230px;" name="ds_area_user" id="ds_area_user">
						<option value="">판매지역을 선택하세요</option>
					</select>
				</td>
			</tr>
		</table>
</form>

		<div class="btn_center">
			<a href="#" class="button arr" id="btn_write">다음(옵션선택)</a>
		</div>
    
		<!-- loading -->
		<div id="loading" style="background:none!important;">
    <div class="lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
			<p>차량을 조회중 입니다.</p>
		</div>
		<!-- // loading -->

	</section>
</section>

<style>
/** css loader **/
.lds-roller { display: inline-block; position: relative; width: 80px; height: 80px; margin-bottom:35px;}
.lds-roller div { animation: lds-roller 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; transform-origin: 40px 40px;}
.lds-roller div:after { content: " "; display: block; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #fff; margin: -4px 0 0 -4px;}
.lds-roller div:nth-child(1) { animation-delay: -0.036s;}
.lds-roller div:nth-child(1):after { top: 63px; left: 63px;}
.lds-roller div:nth-child(2) {animation-delay: -0.072s;}
.lds-roller div:nth-child(2):after { top: 68px; left: 56px;}
.lds-roller div:nth-child(3) { animation-delay: -0.108s;}
.lds-roller div:nth-child(3):after { top: 71px; left: 48px;}
.lds-roller div:nth-child(4) { animation-delay: -0.144s;}
.lds-roller div:nth-child(4):after { top: 72px; left: 40px;}
.lds-roller div:nth-child(5) { animation-delay: -0.18s;}
.lds-roller div:nth-child(5):after { top: 71px; left: 32px;}
.lds-roller div:nth-child(6) { animation-delay: -0.216s;}
.lds-roller div:nth-child(6):after { top: 68px; left: 24px;}
.lds-roller div:nth-child(7) { animation-delay: -0.252s;}
.lds-roller div:nth-child(7):after { top: 63px; left: 17px;}
.lds-roller div:nth-child(8) { animation-delay: -0.288s;}
.lds-roller div:nth-child(8):after { top: 56px; left: 12px;}
@keyframes lds-roller {
  0% { transform: rotate(0deg);  }
  100% {transform: rotate(360deg);  }
}

</style>


<script language="javascript" type="text/javascript">

	$(document).ready(function() {

    
		var vISTD_TRANS = null;
		var vFUEL = null;
//		setCodeSelect("listcategory","cd_category", "car_category","cd_category","<?=$cd_category?>","선택하세요","");
		setCodeSelect("listBrandBycate","cd_brand","car_brand","cd_brand",'<?=$cd_brand?>','선택하세요','');
<? if (!empty($cd_model)){ ?>
		setCodeSelect("listModelBybrand","cd_model","car_model","cd_model",'<?=$cd_model?>','선택하세요','<?=$cd_brand?>');
<? } ?>
<? if (!empty($cd_model_sub)){ ?>
		setCodeSelect("listModelSubByModel","cd_model_sub","car_model_sub","cd_model_sub",'<?=$cd_model_sub?>','선택하세요','<?=$cd_model?>');
<? } ?>
<? if (!empty($cd_grade)){ ?>
		setCodeSelect("listGradeByModelSub","cd_grade","car_grade","cd_grade",'<?=$cd_grade?>','선택하세요','<?=$cd_model_sub?>');
<? } ?>
	setCodeSelect("listcode","ds_area_user", "member_master","ds_area","<?=$s_ds_area_user?>","선택하세요","");

//		$("#cd_category").change(function(){
//			setCodeSelect("listBrandBycate","cd_brand","car_brand","cd_brand","",'선택하세요',$(this).val());
//		});

		$("#cd_brand").change(function(){
			setCodeSelect("listModelBybrand","cd_model","car_model","cd_model","",'선택하세요',$(this).val());
		});

		$("#cd_model").change(function(){
			setCodeSelect("listModelSubByModel","cd_model_sub","car_model_sub","cd_model_sub","",'선택하세요',$(this).val());
		});

		$("#cd_model_sub").change(function(){
			setCodeSelect("listGradeByModelSub","cd_grade","car_grade","cd_grade","",'선택하세요',$(this).val());
		});

		setCodeSelect("listcode","ds_year", "car_master","ds_year","<?=$ds_year?>","선택하세요","");
//		setCodeSelect("listcode","ds_transmission", "car_master","ds_transmission","<?=$ds_transmission?>","선택하세요","");
//		setCodeSelect("listcode","ds_oil", "car_master","ds_oil","<?=$ds_oil?>","선택하세요","");
		setCodeSelect("listcode","ds_accident", "car_master","ds_accident","<?=$ds_accident?>","선택하세요","");

<? if ($ds_accident != "A0"){ ?>
//		$("#nm_cont_accident").css({"display":"none"});
<? } ?>

		// #ds_accident
		$("#ds_accident").on("change", function(){
			if($("#ds_accident").val() == "A0"){
//				$("#nm_cont_accident").css({"display":""});
			}else{
//				$("#nm_cont_accident").css({"display":"none"});
			}
		});

		// color pick
		$("input#nm_color").on("click", function(){
			$(this).next().show();
		});

		$(".color_pick_popup li").click(function(){
			var text = $(this).find("em").text();
			$("input#nm_color").val(text);
			$(".color_pick_popup").hide();
		});


		$("#btn_write").bind("click",function(){

			controlObjCarInfo("select",true);	//car_info all object

//nm_number,cd_brand,cd_model,cd_grade,nm_regdate_yyyy,nm_regdate_mm,ds_year,nm_cc,ds_transmission,ds_oil,nm_color,nm_mileage,ds_accident
			if ("<?=$s_cd_car?>" == ""){
			var fieldlist = [["nm_number","차량번호"],["cd_brand","제조사"],["cd_model","모델"],["cd_grade","등급"],["nm_regdate_yyyy","연식(최초등록일)"],["nm_regdate_mm","연식(최초등록일)"],["ds_year","형식연도"],["nm_cc","배기량"],["ds_transmission","변속기"],["ds_oil","연료"],["nm_color","색상"],["nm_mileage","주행거리"],["ds_accident","사고유무"],["ds_area_user","판매희망지역"]] ;
			}else{
			var fieldlist = [["cd_brand","제조사"],["cd_model","모델"],["cd_grade","등급"],["nm_regdate_yyyy","연식(최초등록일)"],["nm_regdate_mm","연식(최초등록일)"],["ds_year","형식연도"],["nm_cc","배기량"],["ds_transmission","변속기"],["ds_oil","연료"],["nm_color","색상"],["nm_mileage","주행거리"],["ds_accident","사고유무"],["ds_area_user","판매희망지역"]] ;
			}

			if (!fnCheckForm(fieldlist)){
				return false;
			}

			if($("#carinfochkresult").val() != "Y"){
				alert("차량번호 확인을 해 주세요.");
				$("#nm_number").focus();
				return false;
			}

			var c = confirm("처리하시겠습니까?");
			if(c){
				$("#frmForm").submit();
			}else{
				return false;
			}
		});

		$("#btnCarInfo").bind("click",function(){

			if($("#nm_name").val() == ""){
				alert("차량소유주명을 입력하세요.");
				$("#nm_name").focus();
				return false;
			}

			if($("#nm_number").val() == ""){
				alert("차량 번호를 입력하세요.");
				$("#nm_number").focus();
				return false;
			}

			//차량정보 가져오기 시 페이지 제어
			lockLayer('loading');

			$("#btnCarInfo").css({"display":"none"});

			$.post("car_info_proc.php", { nm_name: $("#nm_name").val(), nm_number: $("#nm_number").val()},function(data) {
//alert(data);
				var obj = JSON.parse(data);	//JSON형식으로 리턴 받을 때
				var INFO = obj.INFO;

				if(INFO.PROCESS_IMPRTY_RESN_CODE == "000"){	//정상
					var CARINFO = null;
					var GRADE_LIST = null;
						CARINFO = INFO.CARINFO;
						GRADE_LIST = CARINFO.GRADE_LIST;


					setCodeSelect("listBrandBycate","cd_brand","car_brand","cd_brand",CARINFO.CD_BRAND,'선택하세요','');

					setCodeSelect("listModelBybrand","cd_model","car_model","cd_model",CARINFO.CD_MODEL,'선택하세요',CARINFO.CD_BRAND);

					setCodeSelect("listModelSubByModel","cd_model_sub","car_model_sub","cd_model_sub",CARINFO.CD_MODEL_SUB,'선택하세요',CARINFO.CD_MODEL);

					setCodeSelect("listGradeByModelSub","cd_grade","car_grade","cd_grade",'','선택하세요',CARINFO.CD_MODEL_SUB);

					setCodeSelect("listcode","ds_year", "car_master","ds_year",CARINFO.YEAR_TYPE,"선택하세요","");

					$("#nm_regdate_yyyy").val(CARINFO.FIRST_REGIST_DT.substring(0,4));
					$("#nm_regdate_mm").val(CARINFO.FIRST_REGIST_DT.substring(4,6));
					$("#nm_cc").val(CARINFO.ENGINESIZE);
					$("#cd_category").val(CARINFO.CD_CATEGORY);
 /*
					$("#ds_transmission option:contains('"+CARINFO.ISTD_TRANS+"')").attr('selected','selected');

					$("#ds_oil option:contains('" + CARINFO.FUEL + "')").filter(function(i){
						return $(this).text() === CARINFO.FUEL;
					}).attr("selected", true)
*/

					vISTD_TRANS = CARINFO.ISTD_TRANS;
					vFUEL = CARINFO.FUEL;
/*
alert(CARINFO.ISTD_TRANS);
alert(CARINFO.FUEL);
		setCodeSelect("listcode","ds_transmission", "car_master","ds_transmission",CARINFO.ISTD_TRANS,"선택하세요","");
		setCodeSelect("listcode","ds_oil", "car_master","ds_oil",CARINFO.FUEL,"선택하세요","");
*/
/*
					$("#ds_transmission option:contains('" + CARINFO.ISTD_TRANS + "')").filter(function(i){
						return $(this).text() == CARINFO.ISTD_TRANS;
					}).attr("selected", true)

					$("#ds_oil option:contains('" + CARINFO.FUEL + "')").filter(function(i){
						return $(this).text() == CARINFO.FUEL;
					}).attr("selected", true)
*/
//alert(CARINFO.ISTD_TRANS);
//alert(CARINFO.FUEL);
/*
var s_transmission = $('#ds_transmission option').filter(function () { return $(this).html() == CARINFO.ISTD_TRANS; }).val();
var s_oil = $('#ds_oil option').filter(function () { return $(this).html() == CARINFO.FUEL; }).val();
//alert(s_transmission);
alert(s_oil);

					$("#ds_transmission").val(s_transmission);
					$("#ds_oil").val(s_oil);
*/
   $('#ds_transmission option').map(function () {
       if ($(this).text() == CARINFO.ISTD_TRANS) return this;
      }).attr('selected', 'selected');


    $('#ds_oil option').map(function () {
       if ($(this).text() == CARINFO.FUEL) return this;
      }).attr('selected', 'selected');



					controlObjCarInfo("all",false);	//car_info all object

					$("#carinfochkresult").val("Y");

				}else{	// 에러
//					alert("["+INFO.PROCESS_IMPRTY_RESN_CODE+"]"+INFO.PROCESS_IMPRTY_RESN_DTLS);
//					alert("차량 정보 조회에 실패하였습니다.");
					alert("["+INFO.PROCESS_IMPRTY_RESN_CODE+"]"+"차량 정보 조회에 실패하였습니다.");
<? if ($s_ds_type == "A0" && $s_car_update_ing != "Y"){ ?>
					$("#btnCarInfo").css({"display":""});
<? } ?>

					$("#carinfochkresult").val("N");

				}

			//차량정보 가져오기 시 페이지 제어
			unlockLayer('loading');

            });

			return false;

		});

<? if ($s_car_update_ing == "Y"){ ?>
		controlObjCarInfo("all",false);	//car_info all object
<? } ?>

<? if (!empty($nm_number) && $s_ds_type == "C0" && $s_car_update_ing != "Y"){ ?>
		raiseObjClickEvent("btnCarInfo");
//		setCodeSelect("listcode","ds_transmission", "car_master","ds_transmission",vISTD_TRANS,"선택하세요","");
//		setCodeSelect("listcode","ds_oil", "car_master","ds_oil",vFUEL,"선택하세요","");
<? } ?>

	});

	function raiseObjClickEvent(arg){
		$("#"+arg).trigger("click");
	}

	function controlObjCarInfo(arg_type,arg_bool){
		if (arg_bool){
			$("#cd_brand,#cd_model,#cd_model_sub,#ds_year,#ds_transmission,#ds_oil,#nm_regdate_yyyy,#nm_regdate_mm").removeAttr("disabled", "disabled");

			if (arg_type == "all"){
			$("#nm_number").attr('readonly',false);
			$("#nm_cc").attr('readonly',false);
			}

	//		$("#btnCarInfo").css({"display":""});
		}else{
			/*
			$("#cd_brand option[value!="+CARINFO.CD_BRAND+"]").remove();
			$("#cd_model option[value!="+CARINFO.CD_MODEL+"]").remove();
			$("#cd_model_sub option[value!="+CARINFO.CD_MODEL_SUB+"]").remove();

			$("#ds_year option[value!="+CARINFO.YEAR_TYPE+"]").remove();
			$("#ds_transmission option[value!="+CARINFO.ISTD_TRANS+"]").remove();
			$("#ds_oil option[value!="+CARINFO.FUEL+"]").remove();
			*/
			$("#cd_brand,#cd_model,#cd_model_sub,#ds_year,#ds_transmission,#ds_oil,#nm_regdate_yyyy,#nm_regdate_mm").attr("disabled", "disabled");

			$("#nm_number").attr('readonly',true);
			$("#nm_cc").attr('readonly',true);

//			$("#btnCarInfo").css({"display":"none"});
		}
	}

</script>

<? include("../include/inc_footer.php") ?>
<? include("../include/inc_bottom.php") ?>
<?
mysql_close($connect);
?>
