
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 (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_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_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_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 (ary, item) 
{
   i = 0;
   while (ary[i][0][0] != "")
   {
		if  (ary[i][0][0] == item)  return i;
		i++;
   }
   return -1;
}

function search_index_3_1 (ary, item, idx) 
{
   i = 0;
   
   while (ary[idx][i][0] != "")
   {
   		if  (ary[idx][i][0] == item)  return i;
		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
