// Please, No Korean Comment !!!!
// Please, No Korean Comment !!!!
// Please, No Korean Comment !!!!
// Please, No Korean Comment !!!!



function setOrgCity( depArea, orgCityCode, arrArea, destCityCode, selectedRegion, svc_gubun, today, only_online, selectCityName, isView)
{
	var spl_city = "";

	if (selectedRegion == null || selectedRegion == '') {
		emptySelect(orgCityCode);
                orgCityCode.options[0] = new Option(eval("KOR")[0].classname, eval("KOR")[0].classcode);
		depArea.selectedIndex = 0;
		return;
	} 
	else { spl_city = selectedRegion;}
	
	for (var i=0, j=0; i< eval(spl_city).length; i++) {
		var ClassCode = eval(spl_city)[i].classcode;
		var ClassName = eval(spl_city)[i].classname;
		
		var tmp_path = location.href;
		if(tmp_path.indexOf('www.koreanair.com')!=-1 || tmp_path.indexOf('cyb.koreanair.com/iKalApp')!=-1){
		} else {
			if (svc_gubun == 'RSV' && ClassCode == 'MWX') continue;		
		}

		if (svc_gubun == 'RSV' && eval(spl_city)[i].svcRSV == '0') continue;
		else if (svc_gubun == 'SCH' && eval(spl_city)[i].svcSCH == '0') continue;
		else if (svc_gubun == 'FLT' && eval(spl_city)[i].svcFLT == '0') continue;
		else if (svc_gubun == 'FAR' && eval(spl_city)[i].svcFAR == '0')	continue;		
		if (today < eval(spl_city)[i].eff_from && today > eval(spl_city)[i].eff_to)	continue;
		if (only_online == 'true' && eval(spl_city)[i].svcLevel < '500') continue;
		if (svc_gubun == 'RSV' && eval(spl_city)[i].svcDEP == '0') continue;
		orgCityCode.options[j] = new Option(ClassName, ClassCode);
		j++;
	}

	orgCityCode.length = j;
	
	orgCityCode.selectedIndex = 0;
	if (arrArea != null && arrArea != ''){
		arrArea.selectedIndex = 0;
	}
	if (destCityCode != null && destCityCode != ''){
		emptySelect(destCityCode);
		destCityCode.options[0] = new Option(eval("KOR")[0].classname, eval("KOR")[0].classcode);
	//	destCityCode.selectedIndex = 0;
	}
}


function setDestCity(arrArea, destCityCode ,selectedRegion, svc_gubun, today, only_online, rst_orgCityCode){
	
	var spl_city = "";

	if (selectedRegion == null || selectedRegion == '') {
		emptySelect(destCityCode);
		arrArea.selectedIndex = 0;
		return;
	}
	else { 
	  spl_city = selectedRegion;}
	
	for (var i=0, j=0; i< eval(spl_city).length; i++) {

		var ClassCode = eval(spl_city)[i].classcode;
		var ClassName = eval(spl_city)[i].classname;
		var far_rst_depCode = eval(spl_city)[i].far_rst_depCode;

		if (svc_gubun == 'RSV' && eval(spl_city)[i].svcRSV == '0'){
			continue;
		} else if (svc_gubun == 'SCH' && eval(spl_city)[i].svcSCH == '0'){
			continue;
		} else if (svc_gubun == 'FLT' && eval(spl_city)[i].svcFLT == '0'){
			continue;
		} else if (svc_gubun == 'FAR' && eval(spl_city)[i].svcFAR == '0'){
			continue;
		}
		
		if (today < eval(spl_city)[i].eff_from && today > eval(spl_city)[i].eff_to){
			continue;
		}
		
		if (only_online == 'true' && eval(spl_city)[i].svcLevel < '500') {
			continue;
		}

		if (rst_orgCityCode != null && (far_rst_depCode =='' || (far_rst_depCode.indexOf(rst_orgCityCode) == -1 ))) {
			continue;
		}
		
		destCityCode.options[j] = new Option(ClassName, ClassCode);
		j++;
	}

	destCityCode.length = j;
	
	destCityCode.selectedIndex = 0;
	
}

function setArrArea(orgCityCode,arrArea, destCityCode){
	emptySelect(arrArea);
	var k = 1;
	arrArea.options[0] = new Option( eval(REGION[0]).classname ,eval(REGION[0]).classcode);
	for (var r=0; r<REGION.length; r++) {
		var regionCode = eval(REGION[r]).classcode;
		var regionName = eval(REGION[r]).classname;
		for (var i=0; regionCode!='' && i<eval(regionCode).length; i++) {
			far_rst_depCode = eval(regionCode)[i].far_rst_depCode;
			if (far_rst_depCode!='' && (far_rst_depCode.indexOf(orgCityCode.options[orgCityCode.selectedIndex].value) > -1 )) {
				arrArea.options[k++] = new Option( regionName ,regionCode);
				arrArea.length = k;
				break;
			}
		}
	}

	arrArea.selectedIndex = 0;
	emptySelect(destCityCode);
	destCityCode.options[0] = new Option(eval("KOR")[0].classname, eval("KOR")[0].classcode);
	destCityCode.selectedIndex = 0;
	
}

function emptySelect(col) {
	if (col.length > 0) {
		for (i=col.length-1; i>=0; i--) {
			col.remove(i);
		}
	}
}

function setRegionIntEtc(region, defaultRegion, cityCode, defaultCity, svc_gubun, today, only_online, exceptRegion)
{
	setRegion(region, defaultRegion, cityCode, null, svc_gubun, today, only_online, exceptRegion);
	setOrgCity(region, cityCode, '', '', defaultRegion, svc_gubun, today, only_online, '', "TRUE");
	if (defaultCity != null)
	{
		for( i = 0; i <  cityCode.length; i ++)
		{
			if ( cityCode[i].value == defaultCity)  
				cityCode.selectedIndex = i;
		}
	}
}


function setRegion(region, defaultRegion, cityCode, defaultCity, svc_gubun, today, only_online, exceptRegion)
{
	emptySelect(region);
	
	for (var i=0, j=0; i< REGION.length; i++) {
		var ClassCode = REGION[i].classcode;
		var ClassName = REGION[i].classname;

		if (exceptRegion == ClassCode)	continue;
		
		if (svc_gubun == 'RSV' && REGION[i].svcRSV == '0'){
			continue;
		} else if (svc_gubun == 'SCH' && REGION[i].svcSCH == '0'){
			continue;
		} else if (svc_gubun == 'FLT' && REGION[i].svcFLT == '0'){
			continue;
		} else if (svc_gubun == 'FAR' && REGION[i].svcFAR == '0'){
			continue;
		}

		region.options[j] = new Option(ClassName, ClassCode);
		j++;
	}

	if (defaultRegion != null){
		for( i = 0; i <  region.length; i ++){
			if ( region[i].value == defaultRegion)  region.selectedIndex = i;
		}
	}

	if (defaultCity != null)
	{
		setOrgCity( region, cityCode, '', '', defaultRegion, svc_gubun, today, only_online)
		for( i = 0; i <  cityCode.length; i ++){
			if ( cityCode[i].value == defaultCity)  cityCode.selectedIndex = i;
		}
	}	
}

function setRegion2(region, defaultRegion, cityCode, defaultCity, svc_gubun, today, only_online, exceptRegion)
{
	emptySelect(region);
	
	for (var i=0, j=0; i< REGION.length; i++) {
		var ClassCode = REGION[i].classcode;
		var ClassName = REGION[i].classname;

		if (exceptRegion == ClassCode)	continue;
		
		if (svc_gubun == 'RSV' && REGION[i].svcRSV == '0'){
			continue;
		} else if (svc_gubun == 'SCH' && REGION[i].svcSCH == '0'){
			continue;
		} else if (svc_gubun == 'FLT' && REGION[i].svcFLT == '0'){
			continue;
		} else if (svc_gubun == 'FAR' && REGION[i].svcFAR == '0'){
			continue;
		}

		region.options[j] = new Option(ClassName, ClassCode);
		j++;
	}

	if (defaultRegion != null){
		for( i = 0; i <  region.length; i ++){
			if ( region[i].value == defaultRegion)  region.selectedIndex = i;
		}
	}

	if (defaultCity != null)
	{
		setDestCity( region, cityCode, defaultRegion, svc_gubun, today, only_online)
		for( i = 0; i <  cityCode.length; i ++){
			if ( cityCode[i].value == defaultCity)  cityCode.selectedIndex = i;
		}
	}	
}

function removeRegion_KOR(){
//	setOrgCity(document.form_Single.depArea, document.form_Single.orgCityCode, document.form_Single.arrArea, document.form_Single.destCityCode, document.form_Single.depArea.value, 'RSV', '20051015', 'true');
	if (document.fareschedule.B_REG_ID.value == 'KOR'){
		for( i = 0; i <  document.fareschedule.E_REG_ID.length; i ++){
			if ( document.fareschedule.E_REG_ID[i].value == 'KOR'){
				document.fareschedule.E_REG_ID.remove(i);
				i --;
			}
		}
	}
}

// selectRegion.js

function setCity(region, defaultRegion, cityCode, defaultCity, svc_gubun, today, only_online, isView, exceptRegion)
{
	var i = 0;
	if (defaultCity != null)
	{
		setOrgCity( region, cityCode, '', '', defaultRegion, svc_gubun, today, only_online, '', isView);
		for( i = 0; i <  cityCode.length; i ++){
			if ( cityCode[i].value == defaultCity)  cityCode.selectedIndex = i;
		}
	}	
}

	
// Please, No Korean Comment !!!!
// Please, No Korean Comment !!!!
// Please, No Korean Comment !!!!
// Please, No Korean Comment !!!!