function init_car_kor(selectobj) {
	idx = 0;
	val = 0;
	s = selectobj.options[0].text;
	selectobj.length = 0;
	AddItem(selectobj, -1, s, 0);
	
	while (DB_CAR_CODE[val][0][0] != "") {
		if ( DB_CAR_CODE[val][0][0] < "011" ) {
	      idx = idx + 1;
			AddItem(selectobj, val, DB_CAR[val][0][0], idx);
		}
		val=val+1;
	}
	selectobj.selectedIndex =0;
}

function init_car_for(selectobj) {
	idx = 0;
	val = 0;
	s = selectobj.options[0].text;
	selectobj.length = 0;
	AddItem(selectobj, -1, s, 0);
	
	while (DB_CAR_CODE[val][0][0] != "") {
		if ( DB_CAR_CODE[val][0][0] >= "011" ) {
	      idx = idx + 1;
			AddItem(selectobj, val, DB_CAR[val][0][0], idx);
		}
		val=val+1;
	}
	selectobj.selectedIndex =0;
}

function init_items_japs(ary, selectobj) {
	idx = 0;
	val = 0;
	s = selectobj.options[0].text
	selectobj.length =0;
	AddItem(selectobj,-1,s,0);
	
	while (ary[val][0][0] != "") {
		if ( ary[val][0][0] == "HONDA" || ary[val][0][0] == "ISUZU" || ary[val][0][0] == "MAZDA" || ary[val][0][0] == "MITSUBISHI"
	        || ary[val][0][0] == "TOYOTA" || ary[val][0][0] == "SANYO" || ary[val][0][0] == "NISSAN" || ary[val][0][0] == "LEXUS"
	        || ary[val][0][0] == "SUZUKI" ) {
	      idx = idx + 1;
			AddItem(selectobj, val, ary[val][0][0], idx);
		}
		val=val+1;
	}
	selectobj.selectedIndex =0;
}

function init_items(ary, selectobj) {
	idx = 0;
	val = 0;
	s = selectobj.options[0].text
	selectobj.length =0;
	AddItem(selectobj,-1,s,0);
	
	while (ary[val][0][0] != "") {
		AddItem(selectobj, val, ary[val][0][0], val+1);
		val=val+1;
	}
	selectobj.selectedIndex =0;
}

function init_items_2by2(ary, selectobj) {
	idx = 0;
	val = 0;
	s = selectobj.options[0].text
	selectobj.length = 0;
	AddItem(selectobj,-1,s,0);
	
	while (ary[val][0] != "") {
		AddItem(selectobj, val, ary[val][0], val+1);
		val=val+1;
	}
	selectobj.selectedIndex =0;
}

function init_a_item (ary, ary_code, selectobj) {
	val = 0
	s = selectobj.options[0].text
	selectobj.length =0;
	AddItem(selectobj,-1,s,0);
	if  (ary_code == ary) {
		while (ary[val] != "") {
			AddItem(selectobj, ary_code[val], ary[val],val+1);
			val=val+1;
		}
	} else {
		while (ary[val] != "") {
			AddItem(selectobj, val, ary[val],val+1);
			val=val+1;
		}
	}
	selectobj.selectedIndex =0;
}

function init_number (selectobj, st,ed,step) {
	val = st
	index = 1
	s = selectobj.options[0].text
	selectobj.length =0;

	AddItem(selectobj,-1,s,0);
	if (step < 0) index = ed-st+1
	for (val = st; val <= ed; val ++){
		AddItem(selectobj, val, val,index);
		index+=step;
	}
	selectobj.selectedIndex =0;
}

function init_number_desc (selectobj, ed,st,step) {
	val = st
	index = 1
	s = selectobj.options[0].text
	selectobj.length =0;
	AddItem(selectobj,-1,s,0);
	if  (step < 0) index = ed-st+1
	for  (val = st; val <= ed; val ++) {
		AddItem(selectobj, val, val,index);
		index+=step;
	}
	selectobj.selectedIndex =0;
}

function AddItem(selectobj,val,txt,optindex) {
	NewItem = new Option(txt, val, false, true);
   selectobj.options[optindex]=NewItem;
}

function set_sub_combo_2step (ary, val, subobj) {
	s = subobj.options[0].text
	subobj.length =0;
	AddItem(subobj,-1,s,0);
   if (val >= 0) {
		var idx=1;
		while (ary[val][idx] != "") {
			AddItem(subobj,idx, ary[val][idx],idx);
			idx=idx+1;
		}
	}
	subobj.selectedIndex =0;
}

function set_sub_combo (ary, val, subobj) {
	s = subobj.options[0].text
	subobj.length =0;
	AddItem(subobj,-1,s,0);
   if (val >= 0) {
		var idx=1;
		while (ary[val][idx][0] != "") {
			AddItem(subobj,idx, ary[val][idx][0],idx);
			idx=idx+1;
		}
	}
	subobj.selectedIndex =0;
}

function set_sub_combo2(ary, val, subobj,code_ary) {
	s = subobj.options[0].text;
	subobj.length =0;
	AddItem(subobj,-1,s,0);
   if  (val >= 0) {
		var idx=1;
		while (ary[val][idx] != "") {
			AddItem(subobj,code_ary[val][idx], ary[val][idx],idx);
			idx=idx+1;
		}
	}
	subobj.selectedIndex =0;
}

function set_sub_combo1(ary, val, sub, clsobj) {
	s = clsobj.options[0].text
	clsobj.length =0;
	AddItem(clsobj,-1,s,0);
  	if  (val >= 0 && sub >= 0) {
		var idx=1;
		while (ary[val][sub][idx] != "") {
			AddItem(clsobj,idx, ary[val][sub][idx],idx);
			idx=idx+1;
		}
	}
	clsobj.selectedIndex =0;
}

function set_sub_combo_car (ary, val, subobj, clsobj) {
	s = subobj.options[0].text
	subobj.length =0;
	AddItem(subobj,-1,s,0);

	if (clsobj != null) {
		clsobj.length =0;
		AddItem(clsobj,-1,"ÀüÃ¼",0);
	}
   if (val >= 0) {
		var idx=1;
		while (ary[val][idx][0] != "") {
			AddItem(subobj, idx, ary[val][idx][0],idx);
			idx=idx+1;
		}
	}
	subobj.selectedIndex =0;
}


function select_all_year_fr (val) {
	var today = new Date();
	var js_Year;
	
	if ( today.getYear() < 1900 ) js_Year = today.getYear() + 1900;
	else js_Year = today.getYear();

	s1 = document.search.car_month_fr.options[0].text
	s2 = document.search.car_year_to.options[0].text
  	s3 = document.search.car_month_to.options[0].text
   if  ( val < 0 ) {
		document.search.car_month_fr.length=0;
		document.search.car_year_to.length=0;
		document.search.car_month_to.length=0;
		AddItem(document.search.car_month_fr,0, s1,0);
		AddItem(document.search.car_year_to,0, s2,0);
		AddItem(document.search.car_month_to,0, s3,0);
		document.search.car_month_fr.selectedIndex = 0;
	} else {
	   i = document.search.car_year_to.selectedIndex;
		if ( document.search.car_month_fr.length <= 1 ) {
			init_number (document.search.car_month_fr, 1,12,1)
			init_number (document.search.car_year_to,val,js_Year + 1,-1)
			if ( i > 0 ) init_number (document.search.car_month_to, 1,12,1)
			else AddItem(document.search.car_month_to,0, s3,0);
		} else init_number (document.search.car_year_to,val,js_Year + 1,-1);
		document.search.car_year_to.selectedIndex = i;
	}
}
function select_all_year_fr2 (val) {
	var today = new Date();
	var js_Year;
	
	if ( today.getYear() < 1900 ) js_Year = today.getYear() + 1900;
	else js_Year = today.getYear();

	s1 = document.search.car_month_fr2.options[0].text
	s2 = document.search.car_year_to2.options[0].text
  	s3 = document.search.car_month_to2.options[0].text
   if  ( val < 0 ) {
		document.search.car_month_fr2.length=0;
		document.search.car_year_to2.length=0;
		document.search.car_month_to2.length=0;
		AddItem(document.search.car_month_fr2,0, s1,0);
		AddItem(document.search.car_year_to2,0, s2,0);
		AddItem(document.search.car_month_to2,0, s3,0);
		document.search.car_month_fr2.selectedIndex = 0;
	} else {
	   i = document.search.car_year_to2.selectedIndex;
		if ( document.search.car_month_fr2.length <= 1 ) {
			init_number (document.search.car_month_fr2, 1,12,1)
			init_number (document.search.car_year_to2,val,js_Year + 1,-1)
			if ( i > 0 ) init_number (document.search.car_month_to2, 1,12,1)
			else AddItem(document.search.car_month_to2,0, s3,0);
		} else init_number (document.search.car_year_to2,val,js_Year + 1,-1);
		document.search.car_year_to2.selectedIndex = i;
	}
}
function select_all_year (val) {
	if ( val < 0 ) {
		document.search.car_month_fr.length=0;
		AddItem(document.search.car_month_fr,0, "¼±ÅÃ",0);
		document.search.car_month_fr.selectedIndex = 0;
	} else {
		if ( document.search.car_month_fr.length <= 1 ) {
			init_number (document.search.car_month_fr, 1,12,1)
		}
		document.search.car_month_fr.selectedIndex = 1;
	}
	displayCalendar(1);
}
function select_all_year2 (val) {
	if ( val < 0 ) {
		document.search.car_month_fr2.length=0;
		AddItem(document.search.car_month_fr2,0, "¼±ÅÃ",0);
		document.search.car_month_fr2.selectedIndex = 0;
	} else {
		if ( document.search.car_month_fr2.length <= 1 ) {
			init_number (document.search.car_month_fr2, 1,12,1)
		}
		document.search.car_month_fr2.selectedIndex = 1;
	}
	displayCalendar(3);
}
function select_all_year_to (val) {      
	var temp;
	temp = document.search.car_month_fr.value;
	if ( val < 0 ) {
		document.search.car_year_fr.selectedIndex = 0;
		select_all_year_fr(-1)
	} else {
		if ( temp < 0 ) init_number (document.search.car_month_to, 1,12,1)
		else if ( document.search.car_year_fr.value == val ) init_number (document.search.car_month_to, temp ,12,1)
		else init_number (document.search.car_month_to, 1,12,1)
		document.search.car_month_to.selectedIndex = 1;
	}
}
function select_all_year_to2 (val) {      
	var temp;
	temp = document.search.car_month_fr2.value;
	if ( val < 0 ) {
		document.search.car_year_fr2.selectedIndex = 0;
		select_all_year_fr2(-1)
	} else {
		if ( temp < 0 ) init_number (document.search.car_month_to2, 1,12,1)
		else if ( document.search.car_year_fr2.value == val ) init_number (document.search.car_month_to2, temp ,12,1)
		else init_number (document.search.car_month_to2, 1,12,1)
		document.search.car_month_to2.selectedIndex = 1;
	}
}

function select_year (yrobj, mmobj, val) {
   if  (val < 0) {
		yrobj.selectedIndex = 0;
		AddItem(yrobj,0, "ÀüÃ¼",0);
	} else {
		init_number (mmobj, 1,12,1)
	}
}

function search_index_2_0 (ary, item) {
   i = 0;
   while (ary[i][0] != "") {
  		if (ary[i][0] == item) {
			return i+1;
		}
		i++;
   }
   return 0;
}

function search_index_2_1(ary,item) {
	i= 0;
	while(ary[i][0] != "") {
		j=0;
		while(ary[i][j] != "") {
			if(ary[i][j] == item) return j+1;
			j++;
		}
		i++;
	}
	return 0;
}	

function search_index_2_1parent(ary,item) {
	i= 0;
	while(ary[i][0] != "") {
		j=0;
		while(ary[i][j] != "") {
			if(ary[i][j] == item) return i+1;
			j++;
		}
		i++;
	}
	return 0;
}

function search_index_3_0 (ary, item) {
   i = 0;
   while (ary[i][0][0] != "") {
		if  (ary[i][0][0] == item)  return i+1;
		i++;
   }
   return 0;
}

function search_index_3_01_for (item) {
   i = 0;
   val = 0;
   while ( DB_CAR[i][0][0] != "" ) {
		if ( DB_CAR[i][0][0] == item)  return val;
		if ( DB_CAR_CODE[i][0][0] >= "011" ) {
			val++;
		}
		i++;
   }
   return -1;
}

function search_index_3_01_japs (ary, item) {
   i = 0;
   val = 0;
   while (ary[i][0][0] != "") {
		if  (ary[i][0][0] == item)  return val;
		if ( ary[i][0][0] == "HONDA" || ary[i][0][0] == "ISUZU" || ary[i][0][0] == "MAZDA" || ary[i][0][0] == "MITSUBISHI"
	        || ary[i][0][0] == "TOYOTA" || ary[i][0][0] == "SANYO" || ary[i][0][0] == "NISSAN" || ary[i][0][0] == "LEXUS"
	        || ary[i][0][0] == "SUZUKI" ) {
			val++;
		}
		i++;
   }
   return -1;
}

function search_index_3_01 (ary, item) {
   i = 0;
   while (ary[i][0][0] != "") {
		if  (ary[i][0][0] == item)  return i;
		i++;
   }
   return -1;
}

function search_value_fc( ary, index) {
	i=0;
	while(ary[i][0][0] != "") {
		if(i == index) return ary[i][0][0];
		i++;
	}
	return "";
}

function search_value_md( ary,f_cd, index) {
	i=1;
	while(ary[f_cd][i][0] != "") {
		if(i == index) return ary[f_cd][i][0];
		i++;
	}
	return "";
}

function search_index_3_1 (ary, item, idx) {	
   i = 1;
   while (ary[idx][i][0] != "") {
  		if(ary[idx][i][0] == item){  return i; }
		else i++;
   }
   return 0;
}

function search_index_3_2 (ary, item, idx1, idx2) {	
   i = 1;
   while (ary[idx1][idx2][i] != "") {
  		if(ary[idx1][idx2][i] == item){  return i; }
		else i++;
   }
   return 0;
}

function search_index_1ary (ary, item) {
   i = 0;
   while (ary[i] != "") {
		if (ary[i] == item)  return i;
		i++;
   }
   return 0;
}

function search_index_1ary2111 (ary, item) {
   i = 0;
   while (ary[i] != "") {
		if (ary[i] == item)  return i+1;
		i++;
   }
   return 0;
}

function search_index_option (obj, item) {
	for (i = 0; i < obj.length; i++) {
		if (obj.options[i].text == item) return i;
	}
	return 0;
}

function search_index_option_by_value(obj, item) {
	for (i = 0; i < obj.length; i++) {
		if (obj.options[i].value== item) return i;
	}
	return 0;
}

function OpenZipcode(){
	Window.open("/proc1/SearchZip.jsp","ZipWin","width=480,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

// proc8 function
function dspfctdtMonth() {
	init_number (document.search.fctdtmonth, 1,12,1)
	document.search.fctdtmonth.selectedIndex = 1; 
}

function dspfctdtDay(days) {
	for (i=1 ; i <document.search.fctdtday.length; i++) {
		document.search.fctdtday.options[1]=null;
	}
	
	for (i=1; i<=days; i++) {	
		optionName = new Option(i,i,false,false) ;
		document.search.fctdtday.options[i]=optionName;		
		if (i==1) document.search.fctdtday.options[i].selected = true
	}
}

function dspfctdtCalendar() {       
	var i;
	var now = new Date();
	var nowYear = now.getYear() - 95;
	var nowMonth = now.getMonth();
	var nowDay   = now.getDay();
	var month=document.search.fctdtmonth.selectedIndex ;
//	var year=2001-document.search.fctdtyear.selectedIndex; //comboÀÇ year¿¡ dependant
	var year=document.search.fctdtyear.value; //comboÀÇ year¿¡ dependant
	var days=getDaysInMonth(month,year);
	dspfctdtDay(days);
}

function dsptregreqdtMonth() {
	init_number (document.search.tregreqdtmonth, 1,12,1)
	document.search.tregreqdtmonth.selectedIndex = 1; 
}

function dsptregreqdtDay(days) {
	for (i=1 ; i <document.search.tregreqdtday.length; i++) {
		document.search.tregreqdtday.options[1]=null;
	}
	for (i=1; i<=days; i++) {	
		optionName = new Option(i,i,false,false) ;
		document.search.tregreqdtday.options[i]=optionName;		
		if (i==1) document.search.tregreqdtday.options[i].selected = true
	}
}

function dsptregreqdtCalendar() {       
	var i;
	var now = new Date();
	var nowYear = now.getYear() - 95;
	var nowMonth = now.getMonth();
	var nowDay   = now.getDay();
	var month=document.search.tregreqdtmonth.selectedIndex ;
//	var year=2001-document.search.tregreqdtyear.selectedIndex; //comboÀÇ year¿¡ dependant
	var year=document.search.tregreqdtyear.value; //comboÀÇ year¿¡ dependant
	var days=getDaysInMonth(month,year);
	dsptregreqdtDay(days);
}

function dsptregcomdtMonth() {
	init_number (document.search.tregcomdtmonth, 1,12,1)
	document.search.tregcomdtmonth.selectedIndex = 1; 
}

function dsptregcomdtDay(days) {
	for (i=1 ; i <document.search.tregcomdtday.length; i++) {
		document.search.tregcomdtday.options[1]=null;
	}
	for (i=1; i<=days; i++) {	
		optionName = new Option(i,i,false,false) ;
		document.search.tregcomdtday.options[i]=optionName;		
		if (i==1) document.search.tregcomdtday.options[i].selected = true
	}
}

function dsptregcomdtCalendar() {       
	var i;
	var now = new Date();
	var nowYear = now.getYear() - 95;
	var nowMonth = now.getMonth();
	var nowDay   = now.getDay();
	var month=document.search.tregcomdtmonth.selectedIndex ;
//	var year=2001-document.search.tregcomdtyear.selectedIndex; //comboÀÇ year¿¡ dependant
	var year=document.search.tregcomdtyear.value; //comboÀÇ year¿¡ dependant
	var days=getDaysInMonth(month,year);
	dsptregcomdtDay(days);
}
// proc8 function end

function init_a_item_new (ary, ary_code, selectobj) {
	val = 0
	s = selectobj.options[0].text
	selectobj.length =0;
	AddItem(selectobj,-1,s,0);
	if (ary_code != ary) {
		while (ary[val] != "") {
			AddItem(selectobj, ary_code[val], ary[val],val+1);
			val=val+1;
		}
	} else {
		while (ary[val] != "") {
			AddItem(selectobj, ary_code[val], ary[val],val+1);
			val=val+1;
		}
	}
	selectobj.selectedIndex =0;
}

function top_init() {
	init_items (DB_CAR, document.car_top.manufact);
	}


function top_init_k() {
	init_car_kor (document.car_top.manufact);
	}

function top_init_f() {
	init_car_for (document.car_top.manufact);
	}
function TopCheck() {
            cnt = 0;
            document.car_top.car_idx_manufact.value    = document.car_top.manufact.options[document.car_top.manufact.selectedIndex].value;
            document.car_top.car_idx_model.value        = document.car_top.model.options[document.car_top.model.selectedIndex].value;
            
			if (document.car_top.car_idx_model.value != null && document.car_top.car_idx_model.value > -1)
                document.car_top.car_model.value = DB_CAR[document.car_top.car_idx_manufact.value][document.car_top.car_idx_model.value][0];
            else document.car_top.car_model.value = "";
            if (document.car_top.car_idx_manufact.value != null && document.car_top.car_idx_manufact.value > -1)
                document.car_top.car_manufact.value = DB_CAR[document.car_top.car_idx_manufact.value][0][0];
            else document.car_top.car_manufact.value = "";
            document.car_top.submit();
        }
function setParam2(str){
	var eObj = event.srcElement;
	obj = new Object();
	obj = eval(str);
	if(eObj.value != -1){

		obj.value =  eObj.options[eObj.selectedIndex].text;
	}else{
		obj.value ="";
	}
}

function alram_init() {
	init_items (DB_CAR, document.car_alram.manufact);
	init_a_item (DB_COLOR, DB_COLOR, document.car_alram.car_color);

	}

function top_init2() {
	init_items (DB_CAR, document.car_top.manufact);
	}